Langgraph-Mcp-Agents: An MCP-Integrated AI Agent System Built on LangGraph 137

小编 ·

Langgraph-Mcp-Agents: An MCP-Integrated AI Agent System Built on LangGraph

Langgraph-Mcp-Agents is an AI agent system built on LangGraph that integrates MCP, enabling AI assistants to easily access various data sources and APIs. It comes with a Streamlit web interface for seamless interaction with LangGraph and MCP tools. Users can dynamically add, remove, or configure MCP tools through the UI without restarting the app, and it supports the Smithery JSON format. The system also features streaming responses, allowing real-time viewing of agent outputs and tool calls.

Langgraph-Mcp-Agents: An MCP-Integrated AI Agent System Built on LangGraph

What is Langgraph-MCP-Agents?

Langgraph-Mcp-Agents is an AI agent system built on LangGraph. By integrating MCP, it enables AI assistants to easily access various data sources and APIs. The system comes with a Streamlit web interface, allowing users to interact with LangGraph and MCP tools. Users can dynamically add, remove, or configure MCP tools through the interface without restarting the application, and it supports the Smithery JSON format. In addition, the system also supports streaming responses, allowing users to view the agent's responses and tool call status in real time.

Langgraph-Mcp-Agents: An AI Agent System Integrating MCP and Built on LangGraph.webp

Langgraph-Mcp-Agents Features

  • Decoupling task logic from tool implementation: Developers can independently extend the tool library without affecting the agent core.

  • Long-term context support: Through LangGraph's persistence capabilities, achieve task continuity across sessions.

  • Multi-agent collaboration: Supports building multi-agent systems where different agents can divide labor to complete complex tasks.

  • Dynamic configuration and deployment: Dynamically configure and deploy AI Agents through the Streamlit interface.

  • Tool integration: Easily connect to multiple data sources and external tools.

  • State management: Manage state across each step of the workflow.

  • Flexible deployment: Supports both single-machine and multi-server deployment to meet application needs of different scales.

Technical Architecture and Core Components

LangGraph Framework

LangGraph is an extension library of LangChain, focused on building stateful, multi-role agent workflows.

  • State management: Maintains conversational context through StateGraph, supporting long-term memory and task continuity.

  • Dynamic flow control: Supports loops, branches, and conditional logic, suitable for tasks that require self-correction or iteration (such as code generation).

  • Multi-tool integration: Converts MCP tools into LangChain tools through langchain-mcp-adapters, enabling interaction with external services (such as search and databases).

MCP Protocol

MCP is an open standard that defines the interaction protocol between models and external tools.

  • Loosely coupled design: Allows AI to dynamically discover and call tools, enhancing flexibility.

  • Multi-server support: Connects to multiple MCP servers through MultiServerMCPClient, expanding tool call capabilities.

Use Cases

Complex Task Handling

  • Multi-step workflows: For example, in data analysis tasks, LangGraph can coordinate steps such as data acquisition, cleaning, and visualization, while MCP tools provide specific execution capabilities (such as calling Python libraries or database queries).

  • Cross-system collaboration: Connect services like GitHub and Slack through MCP to achieve cross-platform information integration.

Agent Collaboration

  • Role division of labor: Different agents can focus on specific tasks (such as code generation, chart drawing), sharing intermediate results through MCP.

  • Dynamic decision-making: LangGraph's state graph supports adjusting execution paths based on task progress, such as triggering a debugging flow when code generation fails.

Development Efficiency Improvement

  • Tools as a service: MCP encapsulates tools as standardized interfaces, allowing developers to extend functionality without modifying the agent's core logic.

  • Async support: async_tool_executor handles synchronous and asynchronous tool calls (such as generating code and real-time search), optimizing execution efficiency.

Project Implementation

  • Client-server architecture: MCP uses a client-server model, where LangGraph acts as the client connecting to the MCP server.

  • Tool node integration: Converts tools from the MCP server into tool nodes for LangGraph.

  • Multi-server support: Supports connecting to multiple MCP servers, flexibly using tools on different servers.