Cover image
Try Now
2025-03-19

Langgraph实现与PostgreSQL MCP服务器进行交互

3 years

Works with Finder

1

Github Watches

1

Github Forks

1

Github Stars

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:


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:

Astral uv


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 agent

Troubleshooting

  • 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.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

    Reviews

    3 (1)
    Avatar
    user_3h3vKBem
    2025-04-17

    LangGraph-MCP-Client by BrianCusack is a fantastic tool for managing and visualizing language data. It offers a user-friendly interface and robust features that make data manipulation tasks intuitive and efficient. Highly recommend for anyone working with multilingual projects! Check it out [here](https://github.com/BrianCusack/LangGraph-MCP-Client).