Langgraph-MCP Client for Postgresql Example
About
LangGraph implementation interacting with a PostgreSQL MCP Server
Details
- Author
- BrianCusack
- GitHub stars
- 3
- Downloads
- 453
- Categories
- Other
Jump to
- Connects to a PostgreSQL database via an MCP server.
- Uses langchain_mcp_adapters.tools.load_mcp_tools to create MCP tools.
- Employs LangGraph's create_react_agent for fast agent templating.
- Outputs the agent’s stream to a file.
- Accepts user queries via command line.
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Langgraph-MCP Client for Postgresql ExampleCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Clone the repository, create a .env file with database credentials (DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME), install the UV package globally, and build the MCP Postgres Docker image. Then run uv sync followed by uv run queryagent to start the query agent, optionally passing a natural language query as an argument (e.g., uv run queryagent "Who holds the most funds in their account?").
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"langgraph-mcp client for postgresql example": {
"LangGraph-MCP-Client": {
"command": "uv",
"args": [
"sync"
]
}
}
}
}
McpServers
{
"LangGraph-MCP-Client": {
"command": "uv",
"args": [
"sync"
]
}
}
Langgraph-MCP Client for Postgresql Example
This repository demonstrates a very low level example of how to interact with an MCP server as a docker image, connected to a PostgreSQL database for LangGraph agents.
model context protocol
>MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
---
Prerequisites
Before you begin, ensure you have the following installed on your system:
- Docker
- PostgreSQL Database - running and populated
- MCP Servers
---
Flow and tools
- We use a postgresql database that the Postgresl MCP Server is aware of through the config -from langchain_mcp_adapters.tools import load_mcp_tools creates the mcp tool
- create_react_agent is a fast agent templater
- we output the stream to file
Project Setup Instructions
1. Clone the Repository
Clone this repository to your local machine:git clone https://github.com/your-repo/Langchain-MCP.git
cd Langgraph-mcp-client directory
2. Create a .env File
Create a .env file in the root of the repository with the following variables:
DB_HOST=<your-database-host>
DB_PORT=<your-database-port>
DB_USER=<your-database-username>
DB_PASSWORD=<your-database-password>
DB_NAME=<your-database-name>
Replace the placeholders with your actual database and MCP server connection details.
3. Install UV Package
Install the UV package globally if you haven't already:---
MCP Server Setup
1. Clone the repo MCP Servers to a separate directory
2. Run - docker build -t mcp/postgres -f src/postgres/Dockerfile . to build and tag the image
Usage Instructions
1. Sync the UV Package
Run the following command to sync the UV package:uv sync
This command ensures that the UV package installs the package correctly.
2. Run the Query Agent
Start the query agent using the following command:
uv run queryagent
This will prompt for the user query
Alt - with query (Banking database)
uv run queryagent "Who holds the most funds in thier account?"
---
TODO:
- Output formating - Multi agentTroubleshooting
- Database Connection: Verify the .env file contains the correct database credentials.
- UV Package Errors: Ensure the UV CLI is installed globally and the uv sync command completes without errors.
---
Contributing
Feel free to open issues or submit pull requests to improve this repository.
---
License
This project is licensed under the MIT License. See the LICENSE file for details.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



