Langchain_with_MCP

MCP.Pizza Chef: Paul60209

Langchain_with_MCP is a client application combining the Langchain framework and Chainlit UI to build an AI chatbot that interacts with multiple MCP tool servers. It uses the Model Context Protocol (MCP) for standardized communication with external tools like weather queries, database queries, and PowerPoint translation. This client enables seamless integration and orchestration of diverse MCP servers, facilitating multi-tool AI workflows with real-time context and interaction.

Use This MCP client To

Integrate Langchain agents with MCP tool servers Build chatbots that query weather data via MCP Execute SQL database queries through MCP servers Translate PowerPoint slides using MCP translation tools Manage multi-tool AI workflows with Chainlit UI Experiment with MCP client-server communication Simplify launching and managing MCP client and servers

README

Langchain with MCP Integrated Application

1. Project Scope

This project primarily combines the Langchain framework, Chainlit user interface, and the Model Context Protocol (MCP) to build an AI application capable of utilizing external tools.

  • Core Components:
    • A client application (app.py) based on Chainlit and Langchain Agent.
    • Three independently running MCP Tool Servers (MCP_Servers/):
      • Weather Query (weather_server.py)
      • Database Query (sql_query_server.py)
      • PowerPoint Translation (ppt_translator_server.py)
    • Startup and Management Scripts (run.py, run_server.py, run_client.py) to simplify the launch process.
  • Communication Protocol: Uses MCP (Model Context Protocol) as the standardized communication method between the client and tool servers (via SSE transport).
  • Goal: To provide a foundational platform for understanding and experimenting with the MCP Client-Server architecture, Langchain Agent and Tool interaction, and Chainlit UI integration.

2. Quick Start

2.1. Environment Setup

  1. Python Version: Ensure you have Python 3.10 or higher installed.
  2. Install Dependencies: Open a terminal in the project root directory and run the following command to install all necessary Python packages:
    pip install -r requirements.txt
  3. Set Environment Variables (Important):
    • Find the .env_example file in the project root directory.
    • Copy it and rename the copy to .env.
    • Edit the .env file and fill in your own API keys and database settings:
      • OPENAI_API_KEY: Your OpenAI API key (used for PPT translation).
      • OPENWEATHER_API_KEY: Your OpenWeatherMap API key (used for weather query).
      • CLEARDB_DATABASE_URL: Your MySQL database connection URL, format: mysql://user:password@host:port/dbname (used for database query).
      • USER_AGENT: (Optional, might be needed by OpenWeather) Set a User-Agent string.

2.2. Start MCP Servers

Using the Launcher

Langchain_with_MCP FAQ

How does Langchain_with_MCP communicate with MCP tool servers?
It uses the Model Context Protocol (MCP) over Server-Sent Events (SSE) for real-time, standardized communication.
What external tools does Langchain_with_MCP support?
It supports weather queries, SQL database queries, and PowerPoint translation via dedicated MCP servers.
Can I extend Langchain_with_MCP with additional MCP servers?
Yes, the client is designed to integrate with multiple MCP tool servers easily.
What frameworks does Langchain_with_MCP use?
It combines Langchain for agent logic, Chainlit for UI, and MCP for protocol communication.
How do I start the Langchain_with_MCP client and servers?
Use the provided startup scripts like run.py, run_server.py, and run_client.py to launch components.
Is Langchain_with_MCP compatible with multiple LLM providers?
Yes, it can work with OpenAI, Anthropic Claude, and Google Gemini models through Langchain.
What transport protocol does Langchain_with_MCP use for MCP communication?
It uses Server-Sent Events (SSE) for efficient, real-time data streaming.
How does Langchain_with_MCP help in AI application development?
It provides a foundational platform to experiment with multi-tool AI workflows using MCP and Langchain.