LangChain Agent MCP Server

LangChain Agent MCP Server

langchainmcp•bymcpmessenger

A standalone MCP server that exposes a LangChain ReAct agent as a high-level MCP tool, built with FastAPI and deployed on Google Cloud Run.

License: MIT License•Runtime: Awaiting documentation review•Category: ai agents-models

WHAT IT DOES

  • •Exposes a single agent_executor MCP tool that runs complex multi-step reasoning tasks using a ReAct-pattern LangChain agent.
  • •Serves an MCP manifest describing available tools and an invoke endpoint for calling them.
  • •Supports an optional per-invocation system_instruction argument to customize agent behavior.
  • •Includes a Playwright Sandbox that generates structured accessibility snapshots of websites for AI consumption.

BEST FOR

  • •Connecting MCP-compliant clients to a hosted multi-step reasoning agent.
  • •Running agent tasks with customized personas or instructions per request.
  • •Exploring how AI agents interpret web pages via accessibility snapshots.

ABOUT LANGCHAINMCP

LangChain Agent MCP Server is cataloged as an MCP server attributed to mcpmessenger. A standalone MCP server that exposes a LangChain ReAct agent as a high-level MCP tool, built with FastAPI and deployed on Google Cloud Run. It is categorized under ai agents-models. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for LangChain Agent MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does the server let callers customize the agent's behavior for a single request?

Yes, the agent_executor tool accepts an optional system_instruction parameter that customizes the agent's behavior per invocation; each such invocation creates a new agent instance.

What does the agent's response look like?

Responses are returned as content containing a text block with the agent's answer and an isError flag.

Can the Playwright Sandbox test prompts against a snapshot?

Yes, a test-prompt endpoint accepts a snapshot and a prompt and returns matching elements from the snapshot.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 29afc19a0a0b · 采集于 2026-11-13 13:59:39 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

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
  • ✅ Playwright Sandbox - Interactive preview of accessibility snapshots (NEW!)
  • ✅ 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

ComponentTechnologyPurpose
Backend FrameworkFastAPIHigh-performance, asynchronous web server
Agent FrameworkLangChainMulti-step reasoning and tool execution
DeploymentGoogle Cloud RunServerless, auto-scaling hosting
ContainerizationDockerConsistent deployment environment
ProtocolModel 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:

  6. Start the frontend (optional):

    # Install frontend dependencies (first time only)
    npm install
    
    # Start frontend dev server
    npm run dev
    

    Then visit http://localhost:8080/sandbox to use the Playwright Sandbox preview feature.

☁️ 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

📡 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"
          },
          "system_instruction": {
            "type": "string",
            "description": "Optional system-level instructions to customize agent behavior"
          }
        },
        "required": ["query"]
      }
    }
  ]
}

Invoke Tool

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

{
  "tool": "agent_executor",
  "arguments": {
    "query": "What is the capital of France?",
    "task_id": "optional-workflow-id"
  }
}

With System Instruction (Optional):

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

{
  "tool": "agent_executor",
  "arguments": {
    "query": "Analyze Tesla stock",
    "system_instruction": "You are a financial analyst. Provide detailed analysis with specific numbers."
  }
}

Response:

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

System Instructions

The agent_executor tool supports an optional system_instruction parameter that allows you to customize the agent's behavior on a per-invocation basis.

Usage:

  • Basic Query (uses default prompt):

    {
      "tool": "agent_executor",
      "arguments": {
        "query": "What is the weather today?"
      }
    }
    
  • Query with Custom Instruction:

    {
      "tool": "agent_executor",
      "arguments": {
        "query": "Explain quantum computing",
        "system_instruction": "You are a physics professor. Explain concepts clearly and use examples."
      }
    }
    
  • Personality Customization:

    {
      "tool": "agent_executor",
      "arguments": {
        "query": "Tell me about space",
        "system_instruction": "You are a pirate explaining complex topics. Use pirate terminology!"
      }
    }
    

Notes:

  • If system_instruction is omitted, the agent uses its default prompt
  • Empty or whitespace-only instructions are ignored (default prompt is used)
  • Each invocation with a custom instruction creates a new agent instance

Playwright Sandbox Endpoints

Generate Accessibility Snapshot

POST /api/playwright/snapshot
Content-Type: application/json

{
  "url": "wikipedia.org",
  "use_cache": true
}

Response:

{
  "snapshot": "[body]\n  Name: Wikipedia\n  [main]\n    Name: Main content...",
  "url": "https://wikipedia.org",
  "cached": false,
  "token_count": 3307
}

Features:

  • Generates structured accessibility snapshots of any website
  • Shows how AI "views" websites through structured data
  • Caching support for popular sites
  • Token count estimation
  • Windows-compatible (uses ProactorEventLoop)

Test Prompt Against Snapshot

POST /api/playwright/test-prompt
Content-Type: application/json

{
  "snapshot": "[body]\n  [button]\n    Name: Login",
  "prompt": "Find the login button"
}

Response:

{
  "matches": [
    {
      "line": 2,
      "content": "[button] Name: Login",
      "context": "..."
    }
  ],
  "prompt": "Find the login button",
  "total_matches": 1
}

Playwright Sandbox UI: Visit http://localhost:8080/sandbox to use the interactive preview feature:

  • Enter any URL to generate a snapshot
  • View live website side-by-side with AI accessibility snapshot
  • Test prompts to find elements in the snapshot
  • See token savings compared to full HTML/screenshots

Other Endpoints

  • GET / - Server information
  • GET /health - Health check
  • GET /api/tasks - Safe task summaries (optional monitoring)
  • GET /api/tasks/{task_id} - Safe task summary (optional monitoring)
  • GET /docs - Interactive API documentation (Swagger UI)

🔧 Configuration

Environment Variables

VariableDescriptionDefaultRequired
OPENAI_API_KEYOpenAI API key-✅ Yes
OPENAI_MODELOpenAI model to usegpt-4o-miniNo
PORTServer port8000No
API_KEYOptional API key for authentication-No
MAX_ITERATIONSMaximum agent iterations10No
DEFAULT_SYSTEM_INSTRUCTIONDefault system prompt (Glazyr)-No
VERBOSEEnable verbose loggingfalseNo
POLICY_ENFORCEMENTEnforce /mcp/invoke policy gatesfalseNo
MAX_QUERY_CHARSMax allowed query size5000000No
ALLOWLISTED_DOMAINSComma-separated domain allowlist (query URLs)-No
REDIS_URLEnable Redis state store + task monitoring-No
TASK_TTL_SECONDSTask summary TTL86400No
RECENT_TASKS_MAXRecent task index size200No

📚 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

# Test with system instruction
$bodyWithInstruction = @{
    tool = "agent_executor"
    arguments = @{
        query = "What is 2+2?"
        system_instruction = "You are a math teacher. Explain your reasoning step by step."
    }
} | ConvertTo-Json

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

🎭 Playwright Sandbox Feature

The Playwright Sandbox is an interactive preview feature that demonstrates how AI agents "view" websites through structured accessibility data. This feature is particularly useful for understanding the value of structured snapshots compared to full HTML or screenshots.

Features

  • Dual-View Interface: See the live website alongside its structured accessibility snapshot
  • Token Efficiency: Compare token counts - snapshots are typically 90%+ smaller than full HTML
  • Interactive Testing: Test prompts to find elements in the snapshot
  • Caching: Popular sites are cached for faster demo results
  • Windows Compatible: Fixed NotImplementedError on Windows using ProactorEventLoop

Quick Start

  1. Install Playwright:

    py -m pip install playwright
    py -m playwright install chromium
    
  2. Start Backend:

    py run_server.py
    
  3. Start Frontend:

    npm install  # First time only
    npm run dev
    
  4. Visit Sandbox: Open http://localhost:8080/sandbox and try URLs like:

    • wikipedia.org
    • github.com
    • google.com

How It Works

  1. Enter a URL - The system navigates to the website using Playwright
  2. Generate Snapshot - Extracts structured accessibility information (roles, names, descriptions)
  3. View Comparison - See the live site vs. the AI's structured view
  4. Test Prompts - Try asking the AI to find specific elements

Technical Details

  • Backend: FastAPI endpoint with Playwright integration
  • Frontend: React + Vite with TanStack Query
  • Event Loop: Uses ProactorEventLoop on Windows for subprocess support
  • Stealth Mode: Anti-bot detection measures for better compatibility
  • Error Handling: Graceful handling of sites that block automated access

See PLAYWRIGHT_SANDBOX_SETUP.md for detailed setup instructions.

🏗️ Project Structure

.
├── src/
│   ├── main.py              # FastAPI application with MCP endpoints
│   ├── agent.py             # LangChain agent definition and tools
│   ├── pages/
│   │   └── Sandbox.tsx      # Playwright Sandbox UI component
│   ├── 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 (includes playwright)
├── deploy-cloud-run.ps1     # Windows deployment script
├── deploy-cloud-run.sh      # Linux/Mac deployment script
└── cloudbuild.yaml          # Cloud Build configuration

🚀 Deployment Options

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

🙏 Acknowledgments


Status: ✅ Production-ready and deployed on Google Cloud Run

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for LangChain Agent MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/langchainmcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related ai agents-models MCP Servers

Alternative and complementary servers in the same category

View all in ai agents-models →
Knowledge Graph Memory
@modelcontextprotocol/server-memory•Model Context Protocol

Store and retrieve entities, relations and observations in a persistent local knowledge graph.

create_entitiescreate_relationsadd_observations+6 more
92K
AI & Multi-Agent
Sequential Thinking
@modelcontextprotocol/server-sequential-thinking•Model Context Protocol

Organize problem solving into revisable, branching thought steps through an MCP tool.

sequential_thinking
92K
AI & Multi-Agent

Query-aware context compression with an MCP plugin for coding agents, plus Python and HTTP interfaces for reducing the context sent to a language model.

146
AI & Multi-Agent