LangChain Agent MCP Server

LangChain Agent MCP Server

Exposes LangChain agent capabilities through the Model Context Protocol, enabling multi-step reasoning tasks with ReAct pattern execution via a production-ready FastAPI service deployed on Google Cloud Run.

Category
Visit Server

README

LangChain Agent MCP Server

A production-ready MCP server exposing LangChain agent capabilities through the Model Context Protocol, deployed on Google Cloud Run.

GitHub Stars GitHub Forks License

๐Ÿš€ Overview

This is a standalone backend service that wraps a LangChain agent as a single, high-level MCP Tool. The server is built with FastAPI and deployed on Google Cloud Run, providing a scalable, production-ready solution for exposing AI agent capabilities to any MCP-compliant client.

Live Service: https://langchain-agent-mcp-server-554655392699.us-central1.run.app

โœจ Features

  • โœ… MCP Compliance - Full Model Context Protocol support
  • โœ… LangChain Agent - Multi-step reasoning with ReAct pattern
  • โœ… Google Cloud Run - Scalable, serverless deployment
  • โœ… Tool Support - Extensible framework for custom tools
  • โœ… Production Ready - Error handling, logging, and monitoring
  • โœ… Docker Support - Containerized for easy deployment

๐Ÿ—๏ธ Architecture

Component Technology Purpose
Backend Framework FastAPI High-performance, asynchronous web server
Agent Framework LangChain Multi-step reasoning and tool execution
Deployment Google Cloud Run Serverless, auto-scaling hosting
Containerization Docker Consistent deployment environment
Protocol Model Context Protocol (MCP) Standardized tool and context sharing

๐Ÿ› ๏ธ Quick Start

Prerequisites

  • Python 3.11+
  • OpenAI API key
  • Google Cloud account (for Cloud Run deployment)
  • Docker (optional, for local testing)

Local Development

  1. Clone the repository:

    git clone https://github.com/mcpmessenger/LangchainMCP.git
    cd LangchainMCP
    
  2. Install dependencies:

    # Windows
    py -m pip install -r requirements.txt
    
    # Linux/Mac
    pip install -r requirements.txt
    
  3. Set up environment variables: Create a .env file:

    OPENAI_API_KEY=your-openai-api-key-here
    OPENAI_MODEL=gpt-4o-mini
    PORT=8000
    
  4. Run the server:

    # Windows
    py run_server.py
    
    # Linux/Mac
    python run_server.py
    
  5. Test the endpoints:

    • Health: http://localhost:8000/health
    • Manifest: http://localhost:8000/mcp/manifest
    • API Docs: http://localhost:8000/docs

โ˜๏ธ Google Cloud Run Deployment

The server is designed for deployment on Google Cloud Run. See our comprehensive deployment guides:

Quick Deploy

# Windows PowerShell
.\deploy-cloud-run.ps1 -ProjectId "your-project-id" -Region "us-central1"

# Linux/Mac
./deploy-cloud-run.sh your-project-id us-central1

Current Deployment

  • Service URL: https://langchain-agent-mcp-server-554655392699.us-central1.run.app
  • Project: slashmcp
  • Region: us-central1
  • Status: โœ… Live and operational

๐Ÿ“ก API Endpoints

MCP Endpoints

Get Manifest

GET /mcp/manifest

Returns the MCP manifest declaring available tools.

Response:

{
  "name": "langchain-agent-mcp-server",
  "version": "1.0.0",
  "tools": [
    {
      "name": "agent_executor",
      "description": "Execute a complex, multi-step reasoning task...",
      "inputSchema": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "description": "The user's query or task"
          }
        },
        "required": ["query"]
      }
    }
  ]
}

Invoke Tool

POST /mcp/invoke
Content-Type: application/json

{
  "tool": "agent_executor",
  "arguments": {
    "query": "What is the capital of France?"
  }
}

Response:

{
  "content": [
    {
      "type": "text",
      "text": "The capital of France is Paris."
    }
  ],
  "isError": false
}

Other Endpoints

  • GET / - Server information
  • GET /health - Health check
  • GET /docs - Interactive API documentation (Swagger UI)

๐Ÿ”ง Configuration

Environment Variables

Variable Description Default Required
OPENAI_API_KEY OpenAI API key - โœ… Yes
OPENAI_MODEL OpenAI model to use gpt-4o-mini No
PORT Server port 8000 No
API_KEY Optional API key for authentication - No
MAX_ITERATIONS Maximum agent iterations 10 No
VERBOSE Enable verbose logging false No

๐Ÿ“š Documentation

๐Ÿ“– Full Documentation Site - Complete documentation with examples (GitHub Pages)

Quick Links:

Build Docs Locally:

# Windows
.\build-docs.ps1 serve

# Linux/Mac
./build-docs.sh serve

Additional Guides:

๐Ÿงช Testing

# Test health endpoint
Invoke-WebRequest -Uri "https://langchain-agent-mcp-server-554655392699.us-central1.run.app/health"

# Test agent invocation
$body = @{
    tool = "agent_executor"
    arguments = @{
        query = "What is 2+2?"
    }
} | ConvertTo-Json

Invoke-WebRequest -Uri "https://langchain-agent-mcp-server-554655392699.us-central1.run.app/mcp/invoke" `
    -Method POST `
    -ContentType "application/json" `
    -Body $body

๐Ÿ—๏ธ Project Structure

.
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI application with MCP endpoints
โ”‚   โ”œโ”€โ”€ agent.py             # LangChain agent definition and tools
โ”‚   โ”œโ”€โ”€ mcp_manifest.json    # MCP manifest configuration
โ”‚   โ””โ”€โ”€ start.sh             # Cloud Run startup script
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_mcp_endpoints.py # Test suite
โ”œโ”€โ”€ Dockerfile               # Container configuration
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ deploy-cloud-run.ps1     # Windows deployment script
โ”œโ”€โ”€ deploy-cloud-run.sh      # Linux/Mac deployment script
โ””โ”€โ”€ cloudbuild.yaml          # Cloud Build configuration

๐Ÿš€ Deployment Options

Google Cloud Run (Recommended)

  • Scalable - Auto-scales based on traffic
  • Serverless - Pay only for what you use
  • Managed - No infrastructure to manage
  • Fast - Low latency with global CDN

See DEPLOY_CLOUD_RUN_WINDOWS.md for detailed instructions.

Docker (Local/Other Platforms)

docker build -t langchain-agent-mcp-server .
docker run -p 8000:8000 -e OPENAI_API_KEY=your-key langchain-agent-mcp-server

๐Ÿ“Š Performance

  • P95 Latency: < 5 seconds for standard 3-step ReAct chains
  • Scalability: Horizontal scaling on Cloud Run
  • Uptime: 99.9% target (Cloud Run SLA)
  • Throughput: Handles concurrent requests efficiently

๐Ÿ”’ Security

  • API key authentication (optional)
  • Environment variable management
  • Secret Manager integration (Cloud Run)
  • HTTPS by default (Cloud Run)
  • CORS configuration

๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines.

  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 MIT License.

๐Ÿ”— Links

  • GitHub Repository: https://github.com/mcpmessenger/LangchainMCP
  • Live Service: https://langchain-agent-mcp-server-554655392699.us-central1.run.app
  • API Documentation: https://langchain-agent-mcp-server-554655392699.us-central1.run.app/docs
  • Model Context Protocol: https://modelcontextprotocol.io/

๐Ÿ™ Acknowledgments


Status: โœ… Production-ready and deployed on Google Cloud Run

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured