Skip to content
Conduit

mcp server

MCP-basic

aswego123/MCP-basiccommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

This project does not publish an install method we can turn into a config. Follow the README instead.

README

synced Oct 24, 2026

MCP Server Langchain Project

A demonstration project showcasing the integration of Model Context Protocol (MCP) servers with Langchain and LangGraph for creating AI agents that can interact with custom tools.

Project Overview

This project demonstrates how to:

  • Create MCP servers with custom tools (Math and Weather services)
  • Connect multiple MCP servers to a Langchain client
  • Use LangGraph to create reactive agents that can utilize MCP tools
  • Integrate with different LLM providers (Groq, Gemini)

Project Structure

MCPSERVERLangchain-main/
├── server/
│   ├── mathserver.py      # MCP server with math operations
│   └── weather.py         # MCP server with weather information
├── client/
│   └── client.py          # Langchain client connecting to MCP servers
├── main.py                # Main entry point
├── pyproject.toml         # Project dependencies
├── requirements.txt       # Python requirements
└── README.md             # This file

Features

MCP Servers

  1. Math Server (server/mathserver.py)

    • Provides mathematical operations
    • Tools: add(a, b) and multiple(a, b)
    • Transport: stdio
  2. Weather Server (server/weather.py)

    • Provides weather information
    • Tools: get_weather(location)
    • Transport: streamable-http

Client

The client (client/client.py) demonstrates:

  • Multi-server MCP client setup
  • Integration with LangGraph reactive agents
  • Tool invocation through natural language queries

Prerequisites

  • Python 3.13 or higher
  • API keys for LLM providers (Groq, Gemini)

Installation

  1. Clone the repository:
git clone <repository-url>
cd MCPSERVERLangchain-main
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root with your API keys:
GROQ_API_KEY=your_groq_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here

Usage

Running the MCP Servers

  1. Start the Weather Server (in one terminal):
cd server
python weather.py
  1. Start the Math Server (in another terminal):
cd server
python mathserver.py

Running the Client

  1. Run the client (in a third terminal):
cd client
python client.py

The client will:

  • Connect to both MCP servers
  • Create a reactive agent using the specified LLM
  • Execute example queries for math and weather operations

Configuration

Environment Variables

  • GROQ_API_KEY: Your Groq API key for LLM access
  • GEMINI_API_KEY: Your Gemini API key for LLM access

Server Configuration

  • Math Server: Uses stdio transport for direct communication
  • Weather Server: Uses streamable-http transport on localhost:8000

Client Configuration

The client is configured to connect to:

  • Math server via stdio transport
  • Weather server via HTTP transport at http://localhost:8000/mcp

Example Queries

The client demonstrates these example queries:

  1. Math Query: "what's (3 + 5) x 12?"
  2. Weather Query: "what is the weather in California?"

Dependencies

  • langchain-groq: Groq LLM integration
  • langchain-mcp-adapters: MCP adapters for Langchain
  • langgraph: Reactive agent framework
  • mcp: Model Context Protocol implementation
  • python-dotenv: Environment variable management

Troubleshooting

  1. Port Conflicts: Ensure port 8000 is available for the weather server
  2. API Keys: Verify your API keys are correctly set in the .env file
  3. Python Version: Ensure you're using Python 3.13 or higher
  4. Dependencies: Run pip install -r requirements.txt if you encounter import errors

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

This project is licensed under the terms specified in the LICENSE file.

↑↓ navigate openesc close