-
Notifications
You must be signed in to change notification settings - Fork 2.2k
mcp-agent-for-postgres #3182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mcp-agent-for-postgres #3182
Conversation
Summary of ChangesHello @Vrajesh-Babu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a new sample agent designed to facilitate the integration of PostgreSQL databases with the Model Context Protocol (MCP). It provides a robust reference implementation for developers, showcasing how to securely manage database credentials, deploy the MCP server with minimal setup using Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a valuable sample agent for integrating with PostgreSQL databases using the Model Context Protocol (MCP). The code is well-structured and the accompanying README provides clear setup instructions. My review focuses on improving the robustness, security, and reliability of the sample. I've suggested adding an explicit check for the database connection string to prevent runtime errors, lowering the model's temperature for more predictable and accurate SQL generation, and adding a security warning to the README regarding the use of 'unrestricted' access mode. I also pointed out a minor code cleanup by removing an unused import.
b1694bd to
a61d7f2
Compare
|
Hi, Thank you for the PR! can you fix these failing test |
143ffb2 to
c91944e
Compare
46db38d to
f3b3846
Compare
f3b3846 to
9c11dc8
Compare
9c11dc8 to
8d7b428
Compare
…tgreSQL databases using the Model Context Protocol (MCP) ## What's Added - **PostgreSQL MCP Agent** ([mcp_postgres_agent/agent.py](cci:7://file:///Users/admin/git%20repos/adk-python/contributing/samples/mcp_postgres_agent/agent.py:0:0-0:0)): A fully functional agent that connects to PostgreSQL databases via the `postgres-mcp` MCP server - **Comprehensive README** ([mcp_postgres_agent/README.md](cci:7://file:///Users/admin/git%20repos/adk-python/contributing/samples/mcp_postgres_agent/README.md:0:0-0:0)): Documentation with setup instructions, configuration details, and example queries - **Environment Configuration**: Support for secure credential management via `.env` files ## Key Features - **MCP Integration**: Demonstrates proper use of `MCPToolset` with `StdioConnectionParams` - **Zero Installation**: Uses `uvx` to run the MCP server without manual installation - **Secure Credentials**: Database connection strings passed via environment variables - **Production-Ready**: Uses Gemini 2.0 Flash with unrestricted access mode for full database operations ## Technical Details - **Model**: Gemini 2.0 Flash - **MCP Server**: `postgres-mcp` (via `uvx`) - **Connection**: StdioConnectionParams with 60-second timeout - **Environment Variable**: Maps `POSTGRES_CONNECTION_STRING` to `DATABASE_URI` ## Testing The agent has been tested with: - PostgreSQL database connections (local and remote) - Schema inspection queries - Data querying operations - Table listing and management ## Example Queries Users can interact with the agent using natural language queries like: - "What tables are in the database?" - "Show me the schema for the users table" - "Query the first 10 rows from the products table" This sample serves as a reference implementation for developers looking to integrate PostgreSQL databases with ADK agents using MCP. COPYBARA_INTEGRATE_REVIEW=#3182 from Vrajesh-Babu:postgres-mcp f3b3846 PiperOrigin-RevId: 822865931
|
Thank you for your PR just merged this! |

Add PostgreSQL MCP Agent Sample
This PR adds a new sample agent that demonstrates how to integrate PostgreSQL databases using the Model Context Protocol (MCP).
What's Added
postgres-mcpMCP server.envfilesKey Features
MCPToolsetwithStdioConnectionParamsuvxto run the MCP server without manual installationTechnical Details
postgres-mcp(viauvx)POSTGRES_CONNECTION_STRINGtoDATABASE_URITesting
The agent has been tested with:
Example Queries
Users can interact with the agent using natural language queries like:
This sample serves as a reference implementation for developers looking to integrate PostgreSQL databases with ADK agents using MCP.