Skip to content

Latest commit

 

History

History
90 lines (76 loc) · 4.16 KB

File metadata and controls

90 lines (76 loc) · 4.16 KB

MCP-Langchain Integration: Enhanced Technical Overview

Project Overview

A web-based demonstration of the Model Context Protocol (MCP) paired with LangChain that couples a Python FastAPI backend and a Vue.js 3 frontend. The stack showcases extensible AI agents, real-time communication, and interactive configuration flows.

Architecture Components

Backend (mcp_web_app/)

  • FastAPI application for REST, WebSocket streaming, and async request handling.
  • LangChain integration that orchestrates agents across DeepSeek, OpenAI, and Ollama with fallback ordering.
  • MCP protocol support via mcp>=1.8.0 and mcp-client>=0.2.0 for extensible tool connectivity.

Frontend (mcp_vue_frontend/)

  • Vue.js 3 UI built with the Composition API and TypeScript.
  • Server management dashboard for MCP server monitoring and lifecycle control.
  • Configuration interface with validated, reactive forms for servers and LLM providers.

Core Dependencies

  • Backend: FastAPI, Uvicorn (standard extras), LangChain, Pydantic, MCP client libraries, aiohttp.
  • Frontend: Vue.js 3, Vite, TypeScript, and modern web tooling.
  • Communication: WebSockets for streaming, REST APIs for configuration, and MCP for tool integration.

Key Features

  1. Agentic chat system
    • WebSocket streaming responses.
    • Markdown rendering with syntax highlighting across common languages.
    • Dynamic LLM provider selection with fallback order.
  2. MCP tool integration
    • Runtime MCP server discovery and connection.
    • External tool augmentation without code changes.
    • Management UI for server start/stop/status.
  3. Server process management
    • Programmatic lifecycle control with background tasking and PID tracking.
    • Live status tracking with capability discovery.
    • JSON-backed configuration with hot reload.
  4. Configuration management
    • Provider-specific LLM settings and API key handling.
    • Comprehensive server definitions (command, args, env, transport).
    • Runtime selection and switching without restarting services.

Technical Implementation Patterns

  • Factory pattern: MCPServerToolFactory builds tools from MCP servers with filtering/conversion.
  • Service layer: LangchainAgentService centralizes orchestration, session state, and caching.
  • Process management: ProcessManager controls MCP server lifecycles and cleanup.

Communication Protocols & Data Flow

  • REST APIs for CRUD over configurations and server control.
  • WebSockets for bidirectional streaming of chat and status updates.
  • MCP protocol for stdio and HTTP transports.

Data flow overview:

  1. Frontend sends chat or config requests via WebSocket/HTTP with tool settings.
  2. Backend coordinates LLM selection, tool composition, and session state.
  3. MCP servers execute tools through the standardized protocol.
  4. Responses stream back in real time with chunked delivery and robust error handling.

Advanced Behaviors

  • Session management with intelligent per-session caching and cleanup.
  • Error handling through error boundaries, graceful degradation, and fallbacks.
  • Caching strategy spanning LLM instances and tool configurations.
  • Async processing with full async/await coverage for throughput.

Development Environment Expectations

Backend

  • Python 3.10+ (3.13+ recommended) with uv for dependency management.
  • Secure handling of LLM provider secrets and API keys.

Frontend

  • Node.js LTS with npm and Vite-based builds.
  • TypeScript-first development with Vue DevTools support.

Configuration Examples

Server configuration (servers.json)

{
  "server_name": {
    "name": "unique_identifier",
    "command": "executable_command",
    "args": ["arg1", "arg2"],
    "transport": "stdio",
    "env": {"KEY": "value"}
  }
}

LLM configuration

  • Providers: DeepSeek, OpenAI, Ollama with automatic fallback.
  • Model parameters are configurable alongside generation settings and API validation.

Notes

This overview summarizes how the MCP-LangChain integration composes backend orchestration with frontend control surfaces to deliver extensible agent capabilities, real-time streaming, and secure configuration management.