Doramagic Project Pack · Human Manual

mcp-ai-agent

The mcp-ai-agent is a multi-server AI agent built using the Model Context Protocol (MCP) that serves as a universal interface for connecting to multiple MCP servers simultaneously. The age...

Project Introduction

Related topics: System Architecture, Technology Stack

Section Related Pages

Continue reading this section for the full explanation and source context.

Section High-Level System Architecture

Continue reading this section for the full explanation and source context.

Section Component Architecture

Continue reading this section for the full explanation and source context.

Section MultiServerMCPClient

Continue reading this section for the full explanation and source context.

Related topics: System Architecture, Technology Stack

Project Introduction

Overview

The mcp-ai-agent is a multi-server AI agent built using the Model Context Protocol (MCP) that serves as a universal interface for connecting to multiple MCP servers simultaneously. The agent leverages GPT-5 Nano for autonomous reasoning and tool selection, enabling users to query diverse domains—including software library documentation and museum collections—through a natural language interface.

The project demonstrates advanced agentic AI patterns including multi-transport protocol management (STDIO and HTTP), persistent conversation memory, and LangGraph-based ReAct agent architecture.

Purpose and Scope

The primary purpose of this project is to showcase a "Universal Interface" pattern—similar to USB-C for AI systems—capable of:

  • Connecting to multiple MCP servers concurrently across different transport protocols
  • Autonomously selecting appropriate tools based on user queries
  • Maintaining persistent conversation memory across interaction sessions
  • Providing a unified natural language interface for multi-domain queries

The scope encompasses integration with two distinct MCP servers:

ServerTransport ProtocolDomain
Context7HTTP (streamable_http)Software library documentation
MetMuseum-MCPSTDIO (via npx)Metropolitan Museum artwork collection

Architecture

High-Level System Architecture

graph TD
    User[User CLI Interface] --> Agent[LangGraph ReAct Agent]
    Agent --> Model[GPT-5 Nano]
    Model --> ToolSel[Tool Selection]
    ToolSel --> Context7[Context7 Server]
    ToolSel --> MetMuseum[MetMuseum-MCP Server]
    Context7 --> Docs[Library Documentation]
    MetMuseum --> Artworks[400K+ Artworks]
    Agent --> Memory[InMemorySaver]
    Memory --> Thread[Thread-based Memory]
    
    subgraph Transport Layer
        HTTP[HTTP Transport]:::http
        STDIO[STDIO Transport]:::stdio
    end
    
    classDef http fill:#90EE90
    classDef stdio fill:#87CEEB
    
    Agent -.-> HTTP
    Agent -.-> STDIO

Component Architecture

graph TD
    subgraph Main Application
        Main[main.py] --> Client[MultiServerMCPClient]
        Client --> Context7Config[Context7 Config]
        Client --> MetMuseumConfig[MetMuseum Config]
        Client --> Tools[Available Tools]
        Main --> Model[ChatOpenAI]
        Main --> Agent[ReAct Agent]
        Main --> Checkpointer[InMemorySaver]
    end
    
    subgraph MCP Servers
        Context7[Context7 Server] --> URL[https://mcp.context7.com/mcp]
        MetMuseum[MetMuseum-MCP] --> NPX[npx metmuseum-mcp]
    end
    
    Tools --> Agent
    Model --> Agent
    Checkpointer --> Agent

Technology Stack

ComponentTechnologyVersion
LanguagePython3.10+
MCP Clientlangchain-mcp-adaptersLatest
Agent FrameworkLangGraphLatest
Language ModelOpenAI GPT-5 Nano-
MemoryInMemorySaver-
Async RuntimeasyncioBuilt-in

Core Components

MultiServerMCPClient

The MultiServerMCPClient from langchain_mcp_adapters manages connections to multiple MCP servers simultaneously.

Configuration Structure:

client = MultiServerMCPClient({
    "context7": {
        "url": "https://mcp.context7.com/mcp",
        "transport": "streamable_http",
    },
    "met-museum": {
        "command": "npx",
        "args": ["-y", "metmuseum-mcp"],
        "transport": "stdio",
    }
})

Sources: main.py:45-62

LangGraph ReAct Agent

The agent uses the ReAct (Reasoning + Acting) pattern implemented via create_react_agent:

agent = create_react_agent(
    model=openai_model,
    tools=tools,
    checkpointer=checkpointer
)

Agent Capabilities:

  • Receives user queries and generates responses
  • Selects appropriate tools based on query context
  • Maintains conversation history across interactions
  • Returns structured responses with tool execution results

Persistent Memory System

Conversation memory is managed using InMemorySaver with thread-based configuration:

checkpointer = InMemorySaver()
config = {"configurable": {"thread_id": "conversation_id"}}

Sources: main.py:68-70

Agent Workflow

graph LR
    A[User Query] --> B[GPT-5 Nano Reasoning]
    B --> C{Which Server?}
    C -->|Library Docs| D[Context7 HTTP]
    C -->|Museum Data| E[MetMuseum STDIO]
    D --> F[Tool Execution]
    E --> F
    F --> G[Result Returned]
    G --> H[LLM Response]
    H --> I[Memory Updated]
    I --> J[User Response]

Workflow Steps:

StepDescription
1User submits natural language query
2GPT-5 Nano reasons about which MCP server to use
3Agent calls appropriate tool(s) on selected server
4Tool results are returned to the LLM
5LLM generates natural language response
6Response is stored in InMemorySaver with thread_id
7User receives response with conversation context preserved

Integrated MCP Servers

Context7 Server

PropertyValue
TransportHTTP (streamable_http)
URLhttps://mcp.context7.com/mcp
PurposeLLM-optimized documentation search
DomainSoftware frameworks and libraries

MetMuseum-MCP Server

PropertyValue
TransportSTDIO
Executionnpx metmuseum-mcp
PurposeAccess museum artwork collection
DomainMetropolitan Museum of Art
Collection Size400,000+ artworks

Key Features

Multi-Server Architecture

  • Simultaneous connection to multiple MCP servers
  • Support for both HTTP and STDIO transport protocols
  • Automatic tool discovery and aggregation

Autonomous Tool Selection

The agent intelligently routes queries to appropriate servers:

User: "What is LangChain documentation for agents?"
→ Routes to Context7 → Returns docs

User: "Show me Van Gogh paintings in the Met Museum"
→ Routes to MetMuseum → Returns artwork metadata

Persistent Conversation Memory

  • Thread-based conversation management
  • Full conversation history preserved across turns
  • Context-aware responses using previous interactions

Asynchronous Operations

  • Full async/await implementation
  • Non-blocking I/O for MCP server communication
  • Efficient concurrent tool execution

Installation and Setup

Prerequisites

RequirementCommand
Python3.10+
npmFor npx execution

Dependencies

pip install langchain-mcp-adapters langgraph langchain-openai

Environment Configuration

export OPENAI_API_KEY="your-api-key-here"

Project Structure

mcp-ai-agent/
│
├── main.py          # Complete multi-server MCP agent implementation
└── README.md        # Project documentation

Usage Flow

sequenceDiagram
    participant User
    participant CLI
    participant Agent
    participant MCP
    participant Memory
    
    User->>CLI: Start application
    CLI->>Agent: Initial introduction request
    Agent->>MCP: Query available tools
    MCP-->>Agent: Tool definitions
    Agent-->>CLI: Introduction response
    CLI-->>User: Display response
    
    User->>CLI: Ask question
    CLI->>Agent: Forward query
    Agent->>Memory: Check conversation history
    Memory-->>Agent: Previous context
    Agent->>MCP: Execute appropriate tool
    MCP-->>Agent: Tool results
    Agent-->>Memory: Store interaction
    Agent-->>CLI: Response
    CLI-->>User: Display result

Conclusion

The mcp-ai-agent project demonstrates a production-ready implementation of multi-server MCP client architecture with autonomous tool selection. It serves as an educational reference for building agentic AI systems that can:

  • Connect to diverse MCP servers across different transport protocols
  • Maintain persistent conversation context
  • Leverage LLMs for intelligent tool routing
  • Provide unified natural language interfaces to complex data sources

Sources: README.md:1-100

Sources: main.py:45-62

Technology Stack

Related topics: Project Introduction, LangGraph ReAct Agent

Section Related Pages

Continue reading this section for the full explanation and source context.

Related topics: Project Introduction, LangGraph ReAct Agent

Technology Stack

Overview

The mcp-ai-agent project implements a multi-server MCP (Model Context Protocol) client architecture that connects to multiple external MCP servers simultaneously. The technology stack combines modern Python async programming with LangGraph's ReAct agent framework and OpenAI's language models to create an intelligent agent capable of autonomous tool selection across different domains.

Project Scope: The agent serves as a "Universal Interface" for AI systems, connecting to MCP servers via different transport protocols while maintaining persistent conversation memory and enabling autonomous tool selection powered by GPT-5 Nano.

Sources: README.md:1-20

Sources: README.md:1-20

System Architecture

Related topics: Agent Workflow, Transport Mechanisms, MCP Server Integration

Section Related Pages

Continue reading this section for the full explanation and source context.

Section MultiServerMCPClient

Continue reading this section for the full explanation and source context.

Section Configuration Parameters

Continue reading this section for the full explanation and source context.

Section LangGraph ReAct Agent

Continue reading this section for the full explanation and source context.

Related topics: Agent Workflow, Transport Mechanisms, MCP Server Integration

System Architecture

Overview

The mcp-ai-agent is a multi-server Model Context Protocol (MCP) client designed to act as a universal interface for AI agents. It simultaneously connects to multiple MCP servers across different transport protocols, providing persistent conversation memory and autonomous tool selection powered by GPT-5 Nano through a LangGraph ReAct agent implementation. Sources: README.md

High-Level Architecture

The system follows a layered architecture where the CLI interface communicates with a LangGraph ReAct agent that manages connections to multiple external MCP servers. The agent reasoning engine determines which server to query based on the user's domain, while the checkpointer maintains conversation state across interactions. Sources: README.md

graph TD
    User[User CLI Interface]
    Agent[LangGraph ReAct Agent]
    MCPClient[MultiServerMCPClient]
    Context7[Context7 Server]
    MetMuseum[MetMuseum-MCP Server]
    
    User -->|"User Query"| Agent
    Agent -->|"Tool Execution"| MCPClient
    MCPClient -->|"HTTP Transport"| Context7
    MCPClient -->|"STDIO Transport"| MetMuseum
    Agent -->|"Memory"| InMemorySaver[InMemorySaver]
    
    subgraph "Transport Layer"
        Context7
        MetMuseum
    end

Core Components

MultiServerMCPClient

The MultiServerMCPClient from the langchain-mcp-adapters package handles simultaneous connections to multiple MCP servers using different transport protocols. This component abstracts the complexity of managing HTTP and STDIO connections, providing a unified interface for tool retrieval. Sources: main.py:24

ServerTransport TypePurpose
Context7streamable_httpRemote cloud-based library documentation search
MetMuseum-MCPstdioLocal museum collection access via npx

Configuration Parameters

ParameterValueDescription
context7.urlhttps://mcp.context7.com/mcpEndpoint for Context7 MCP server
context7.transportstreamable_httpHTTP-based communication protocol
met-museum.commandnpxNode.js package runner
met-museum.args["-y", "metmuseum-mcp"]Auto-install and execute MetMuseum MCP
met-museum.transportstdioStandard input/output protocol

Sources: main.py:28-42

LangGraph ReAct Agent

The agent is created using LangGraph's create_react_agent factory function, combining the OpenAI language model with retrieved MCP tools and a checkpointer for conversation persistence. The ReAct (Reasoning + Acting) pattern enables the agent to reason about which tools to invoke before executing them. Sources: main.py:56-61

agent = create_react_agent(
    model=openai_model,         # GPT-5 Nano reasoning engine
    tools=tools,                # Available tools from MCP servers
    checkpointer=checkpointer   # Memory system for conversation history
)

Language Model Integration

The system uses OpenAI's GPT-5 Nano model through the langchain_openai package, configured with minimal parameters for cost-effective reasoning. Sources: main.py:44-46

openai_model = ChatOpenAI(
    model="gpt-5-nano",  # Using OpenAI's GPT-5 Nano model
)

Conversation Memory System

The InMemorySaver checkpointer provides thread-based conversation persistence. All messages within a session share the same thread_id, enabling the agent to maintain context across multiple user queries. Sources: main.py:48-52

checkpointer = InMemorySaver()
config = {"configurable": {"thread_id": "conversation_id"}}

Agent Workflow

graph TD
    A[User Query] --> B[GPT-5 Nano Reasoning]
    B --> C{Which Server Has Info?}
    C -->|"Code/Library Docs"| D[Context7 HTTP]
    C -->|"Art/Museum Data"| E[MetMuseum STDIO]
    D --> F[Tool Execution]
    E --> F
    F --> G[Result to LLM]
    G --> H[LLM Generates Response]
    H --> I[Store in InMemorySaver]
    I --> J[User Receives Response]

Workflow Steps

  1. User Query: The CLI receives a natural language question from the user
  2. LLM Reasoning: GPT-5 Nano analyzes the query to determine which MCP server contains relevant information
  3. Tool Selection: The agent autonomously selects the appropriate server based on domain classification
  4. Tool Execution: The selected MCP server is invoked via its transport protocol
  5. Result Processing: Tool results are returned to the LLM for natural language synthesis
  6. Memory Storage: The complete conversation exchange is persisted via InMemorySaver
  7. Response Delivery: The user receives the formatted response with preserved context

Sources: README.md

Transport Protocols

HTTP Transport (Context7)

The Context7 server uses streamable_http transport for remote cloud communication. This transport is optimized for latency-sensitive operations and supports scalable server deployments. Sources: main.py:29-31

"context7": {
    "url": "https://mcp.context7.com/mcp",
    "transport": "streamable_http",
}

STDIO Transport (MetMuseum)

The MetMuseum MCP server uses stdio transport for local process communication. The server is launched via npx and communicates through standard input/output streams. Sources: main.py:33-36

"met-museum": {
    "command": "npx",
    "args": ["-y", "metmuseum-mcp"],
    "transport": "stdio",
}

Async Architecture

The entire system is built on Python's asyncio framework, enabling concurrent handling of multiple MCP server connections and non-blocking I/O operations. The main entry point uses asyncio.run() to execute the async main() function. Sources: main.py:1

import asyncio

async def main():
    # Async MCP client initialization
    client = MultiServerMCPClient({...})
    
    # Async tool retrieval
    tools = await client.get_tools()
    
    # Async agent invocation
    response = await agent.ainvoke({"messages": query}, config=config)

if __name__ == "__main__":
    asyncio.run(main())

Interaction Flow

sequenceDiagram
    participant User
    participant CLI
    participant Agent
    participant MCPClient
    participant Server
    
    User->>CLI: Enter question
    CLI->>Agent: ainvoke(query)
    Agent->>MCPClient: get_tools()
    MCPClient->>Server: HTTP/STDIO Request
    Server->>MCPClient: Tool Response
    MCPClient->>Agent: Results
    Agent->>Agent: Generate natural language
    Agent->>CLI: Formatted response
    CLI->>User: Display response

Dependency Stack

LayerTechnologyVersionPurpose
LanguagePython3.10+Runtime environment
MCP Clientlangchain-mcp-adaptersLatestMulti-server MCP connections
Agent FrameworklanggraphLatestReAct agent orchestration
LLM Integrationlangchain-openaiLatestOpenAI API wrapper
Runtimenpx/Node.jsLatestLocal MCP server execution

Sources: README.md

System Initialization Sequence

# 1. Create MCP client with server configurations
client = MultiServerMCPClient(servers)

# 2. Initialize the language model
openai_model = ChatOpenAI(model="gpt-5-nano")

# 3. Retrieve all tools from connected servers
tools = await client.get_tools()

# 4. Set up conversation memory
checkpointer = InMemorySaver()

# 5. Create configuration with thread ID
config = {"configurable": {"thread_id": "conversation_id"}}

# 6. Build the ReAct agent
agent = create_react_agent(model, tools, checkpointer)

Sources: main.py:23-61

Autonomous Tool Selection

The agent demonstrates intelligent routing based on query domain classification:

Query TypeTarget ServerExample
Documentation/CodeContext7"What LangGraph tools are available?"
Art/MuseumMetMuseum"Show me Van Gogh paintings"

This autonomous selection is powered by GPT-5 Nano's reasoning capabilities, eliminating the need for explicit routing logic in the application code. Sources: README.md

Sources: main.py:28-42

Agent Workflow

Related topics: System Architecture, LangGraph ReAct Agent, Memory Management

Section Related Pages

Continue reading this section for the full explanation and source context.

Related topics: System Architecture, LangGraph ReAct Agent, Memory Management

Agent Workflow

The Agent Workflow in this MCP AI agent project defines how a user query flows through the system—from initial reasoning by the language model to autonomous tool selection and execution across multiple MCP servers, ultimately producing a contextual response with persistent conversation memory.

Source: https://github.com/LeelaissakAttota/mcp-ai-agent / Human Manual

LangGraph ReAct Agent

Related topics: Agent Workflow, Memory Management, MCP Server Integration

Section Related Pages

Continue reading this section for the full explanation and source context.

Related topics: Agent Workflow, Memory Management, MCP Server Integration

LangGraph ReAct Agent

Overview

The LangGraph ReAct Agent is the core reasoning and decision-making engine in the mcp-ai-agent project. It combines the ReAct (Reasoning + Acting) pattern with LangGraph's stateful graph architecture to create an autonomous agent capable of selecting and executing tools from multiple MCP (Model Context Protocol) servers.

Key Responsibilities:

  • Reasoning about user queries to determine which tools to invoke
  • Coordinating with multiple MCP servers across different transport protocols
  • Maintaining conversation history through persistent memory
  • Generating natural language responses based on tool execution results

Sources: README.md

Source: https://github.com/LeelaissakAttota/mcp-ai-agent / Human Manual

Memory Management

Related topics: LangGraph ReAct Agent, Agent Workflow

Section Related Pages

Continue reading this section for the full explanation and source context.

Related topics: LangGraph ReAct Agent, Agent Workflow

Memory Management

Overview

The mcp-ai-agent implements a persistent conversation memory system using LangGraph's checkpointing infrastructure. This system enables the AI agent to maintain context across multiple interaction turns within a single conversation session, ensuring coherent and contextually aware responses.

Memory management is critical for multi-turn conversations where the agent needs to reference previous user queries, tool invocations, and generated responses to provide meaningful follow-up interactions.

Source: https://github.com/LeelaissakAttota/mcp-ai-agent / Human Manual

MCP Server Integration

Related topics: Transport Mechanisms, System Architecture

Section Related Pages

Continue reading this section for the full explanation and source context.

Related topics: Transport Mechanisms, System Architecture

MCP Server Integration

Overview

The MCP Server Integration module serves as the core connectivity layer that enables the AI agent to communicate with multiple external services simultaneously. This integration leverages the Model Context Protocol (MCP) to establish connections between the agent and various MCP-compliant servers, providing access to diverse data sources and capabilities through a unified interface.

The integration supports both HTTP and STDIO transport protocols, allowing the agent to connect to remote cloud-based servers and local Node.js-based MCP servers concurrently. This dual-transport architecture enables seamless access to documentation services, museum collections, and other specialized data providers without requiring the agent to manage multiple connection protocols manually.

Sources: main.py:28-42

Sources: main.py:28-42

Transport Mechanisms

Related topics: MCP Server Integration, System Architecture

Section Related Pages

Continue reading this section for the full explanation and source context.

Section Multi-Transport Client Design

Continue reading this section for the full explanation and source context.

Section STDIO Transport

Continue reading this section for the full explanation and source context.

Section HTTP Transport (Streamable HTTP)

Continue reading this section for the full explanation and source context.

Related topics: MCP Server Integration, System Architecture

Transport Mechanisms

Overview

Transport mechanisms are the communication protocols that enable the MCP AI Agent to connect with external MCP (Model Context Protocol) servers. This project implements a multi-transport architecture that supports simultaneous connections to both remote and local MCP servers, allowing the agent to access diverse tools and data sources through a unified interface.

The transport layer abstracts the underlying communication details, enabling the agent to interact with different server types using a consistent tool interface while the agent reasoning engine autonomously selects the appropriate transport based on query domain.

Sources: main.py:1-70

Architecture

Multi-Transport Client Design

The MultiServerMCPClient from langchain-mcp-adapters serves as the central transport orchestration component. It manages concurrent connections to multiple MCP servers using different transport protocols while exposing a unified tools interface to the agent.

graph TD
    A[LangGraph ReAct Agent] --> B[MultiServerMCPClient]
    B --> C[HTTP Transport Layer]
    B --> D[STDIO Transport Layer]
    C --> E[Context7 Server<br/>Remote/Cloud]
    D --> F[MetMuseum-MCP<br/>Local/npx]
    
    style C fill:#e1f5fe
    style D fill:#fff3e0

Sources: main.py:41-55

Supported Transport Types

STDIO Transport

The STDIO (Standard Input/Output) transport is designed for local MCP servers that run as child processes on the same machine. Communication occurs through stdin and stdout streams, making it ideal for servers that are invoked via command-line tools.

#### Configuration Parameters

ParameterTypeDescriptionExample
commandstringExecutable command to launch the server"npx"
argsarrayCommand-line arguments passed to the executable["-y", "metmuseum-mcp"]
transportstringMust be set to "stdio""stdio"

#### Use Case

The STDIO transport is used for the MetMuseum-MCP server, which is executed locally via npx. This approach allows the agent to access over 400,000+ artworks from the Metropolitan Museum of Art collection without requiring a separate server process.

Sources: main.py:49-54 Sources: README.md

HTTP Transport (Streamable HTTP)

The HTTP transport enables communication with remote MCP servers over HTTP/HTTPS protocols. This transport type supports cloud-based or network-accessible MCP servers that expose REST-like endpoints.

#### Configuration Parameters

ParameterTypeDescriptionExample
urlstringFull URL endpoint of the MCP server"https://mcp.context7.com/mcp"
transportstringMust be set to "streamable_http""streamable_http"

#### Use Case

The HTTP transport is used for the Context7 server, which provides LLM-optimized documentation search across major software frameworks and libraries. This remote server is accessed via the streamable_http protocol for efficient streaming responses.

Sources: main.py:45-48 Sources: README.md

Transport Configuration

Complete Configuration Structure

The MCP client is initialized with a dictionary mapping server names to their transport configurations:

client = MultiServerMCPClient({
    "context7": {
        "url": "https://mcp.context7.com/mcp",
        "transport": "streamable_http",
    },
    "met-museum": {
        "command": "npx",
        "args": ["-y", "metmuseum-mcp"],
        "transport": "stdio",
    }
})

Server Comparison

AttributeContext7MetMuseum-MCP
Transport TypeHTTPSTDIO
LocationRemote/CloudLocal
InvocationDirect URLnpx command
Data DomainLibrary documentationArtwork/Museum data
Server ProcessHosted serviceSpawned child process

Sources: main.py:41-55

Tool Aggregation

The MultiServerMCPClient.get_tools() method retrieves all available tools from all configured MCP servers, regardless of their transport type. This aggregation enables the LangGraph ReAct agent to have a unified toolset while each tool maintains its underlying transport implementation.

tools = await client.get_tools()

The aggregated tools are then passed to the LangGraph agent:

agent = create_react_agent(
    model=openai_model,
    tools=tools,
    checkpointer=checkpointer
)

Sources: main.py:56-68

Transport Selection Workflow

The agent autonomously determines which transport/server to use based on the user's query. The selection occurs during the LLM reasoning phase of the ReAct agent loop.

graph TD
    A[User Query] --> B[GPT-5 Nano Reasoning]
    B --> C{Query Domain Analysis}
    C -->|Code/Library docs| D[HTTP Transport<br/>Context7]
    C -->|Art/Museum| E[STDIO Transport<br/>MetMuseum]
    D --> F[Execute Tool]
    E --> F
    F --> G[Return Result to LLM]
    G --> H[Generate Response]

Sources: README.md

Error Handling Considerations

When working with multiple transport mechanisms, consider the following potential failure points:

TransportPotential IssuesMitigation
STDIOnpx not installed, package not foundEnsure Node.js and npx are available
STDIOProcess spawning failuresCheck system permissions and PATH
HTTPNetwork connectivity issuesVerify internet access and URL
HTTPServer availabilityImplement retry logic if needed

Sources: main.py:49-54

Dependencies

The transport mechanism implementation requires the following packages:

PackagePurpose
langchain-mcp-adaptersProvides MultiServerMCPClient for multi-transport management
langgraphAgent framework with tool calling support
langchain-openaiOpenAI model integration

Installation command:

pip install langchain-mcp-adapters langgraph langchain-openai
npm install -g npx

Sources: README.md

Extending with Additional Transports

To add support for additional MCP servers with different transport types, extend the MultiServerMCPClient configuration dictionary:

client = MultiServerMCPClient({
    # Existing servers...
    "new-server": {
        # For HTTP-based servers
        "url": "https://example.com/mcp",
        "transport": "streamable_http",
        
        # OR for STDIO-based servers
        "command": "python",
        "args": ["-m", "my_mcp_server"],
        "transport": "stdio",
    }
})

Sources: main.py:41-55

Sources: main.py:1-70

Installation Guide

Related topics: Configuration

Section Related Pages

Continue reading this section for the full explanation and source context.

Section Step 1: Install Dependencies

Continue reading this section for the full explanation and source context.

Section Step 2: Configure Environment Variables

Continue reading this section for the full explanation and source context.

Section Step 3: Verify Installation Structure

Continue reading this section for the full explanation and source context.

Related topics: Configuration

Installation Guide

Overview

This guide provides complete instructions for setting up the mcp-ai-agent project locally. The mcp-ai-agent is a multi-server Model Context Protocol (MCP) client that connects to external MCP servers (Context7 and MetMuseum) to enable an AI agent with access to library documentation and museum collections.

Sources: README.md

Prerequisites

Before installing the mcp-ai-agent, ensure your development environment meets the following requirements:

RequirementMinimum VersionPurpose
Python3.10+Runtime environment
pipLatestPython package management
Node.jsRecentRequired for npx command
npxAvailableRunning MetMuseum MCP server

Sources: README.md

Project Architecture

The installation involves configuring multiple components that work together:

graph TD
    A[User Environment] --> B[Python 3.10+]
    A --> C[Node.js + npx]
    B --> D[mcp-ai-agent]
    C --> E[MetMuseum-MCP Server]
    D --> F[langchain-mcp-adapters]
    D --> G[LangGraph]
    D --> H[langchain-openai]
    F --> I[MultiServerMCPClient]
    I --> E
    I --> J[Context7 Server<br/>Remote HTTP]

Installation Steps

Step 1: Install Dependencies

Install the required Python packages using pip:

pip install langchain-mcp-adapters langgraph langchain-openai

Install npx globally for the MetMuseum MCP server:

npm install -g npx

Sources: README.md

Step 2: Configure Environment Variables

Set your OpenAI API key as an environment variable. This key is required for the agent to communicate with OpenAI's GPT-5 Nano model:

export OPENAI_API_KEY="your-api-key-here"

Important: Replace your-api-key-here with your actual OpenAI API key.

Sources: README.md

Step 3: Verify Installation Structure

The project has a minimal structure consisting of two files:

mcp-ai-agent/
├── main.py          # Complete multi-server MCP agent
└── README.md

Sources: README.md

Step 4: Run the Agent

Execute the main script to start the agent:

python main.py

Sources: README.md

MCP Server Configuration

The agent automatically configures connections to two MCP servers during initialization:

MultiServerMCPClient Setup

The configuration in main.py establishes connections to both servers:

client = MultiServerMCPClient({
    "context7": {
        "url": "https://mcp.context7.com/mcp",
        "transport": "streamable_http",
    },
    "met-museum": {
        "command": "npx",
        "args": ["-y", "metmuseum-mcp"],
        "transport": "stdio",
    }
})

Sources: main.py

Server Configuration Reference

ServerTransportConnection TypePurpose
Context7streamable_httpRemote/CloudLLM-optimized documentation search
MetMuseumstdioLocal (npx)Metropolitan Museum artwork access

Required Python Packages

PackageVersionRole
langchain-mcp-adaptersLatestMCP client for multi-server connections
langgraphLatestReAct agent framework
langchain-openaiLatestOpenAI GPT model integration

Sources: main.py

Post-Installation Verification

After installation, the agent will:

  1. Display an introduction message
  2. Show available tools from connected MCP servers
  3. Present an interactive menu

Expected output:

Agent introduces itself and available tools...

Menu:
1. Ask the agent a question
2. Quit
Enter your choice (1 or 2):

Troubleshooting

Common Issues

IssueSolution
Missing OPENAI_API_KEYEnsure the environment variable is set before running
npx not foundInstall Node.js or run npm install -g npx
MCP server connection failureCheck internet connection for Context7; verify npx works locally
Import errorsReinstall Python packages with pip install --upgrade

Verification Commands

Test your installation by checking each component:

# Verify Python packages
python -c "import langchain_mcp_adapters; import langgraph; import langchain_openai"

# Verify npx is available
npx --version

# Verify Python version
python --version

Project Dependencies Flow

graph LR
    A[main.py] --> B[langchain_mcp_adapters<br/>MultiServerMCPClient]
    A --> C[langgraph<br/>create_react_agent]
    A --> D[langchain_openai<br/>ChatOpenAI]
    A --> E[langgraph.checkpoint.memory<br/>InMemorySaver]
    B --> F[Context7 MCP]
    B --> G[MetMuseum MCP]

Sources: main.py

Next Steps

After successful installation, refer to the following:

  1. Usage Guide - How to interact with the agent
  2. Architecture Overview - Understanding the multi-server MCP client design
  3. MCP Server Documentation - Details on Context7 and MetMuseum capabilities

System Requirements Summary

ComponentSpecification
OSCross-platform (Windows, macOS, Linux)
Memory4GB minimum recommended
Disk Space500MB for dependencies
NetworkRequired for Context7 server and OpenAI API access

Sources: README.md

Configuration

Related topics: Installation Guide

Section Related Pages

Continue reading this section for the full explanation and source context.

Section Configuration Structure

Continue reading this section for the full explanation and source context.

Section Supported Transport Protocols

Continue reading this section for the full explanation and source context.

Section Context7 Server Configuration

Continue reading this section for the full explanation and source context.

Related topics: Installation Guide

Configuration

This document describes the configuration system for the mcp-ai-agent project, covering all configurable components including MCP servers, language models, memory systems, and agent behavior.

Overview

The mcp-ai-agent uses a multi-server Model Context Protocol (MCP) architecture that requires configuration for:

  • MCP server connections (transport protocols, endpoints)
  • Language model integration (OpenAI API)
  • Conversation memory persistence
  • Agent execution parameters

Sources: README.md

MCP Server Configuration

The agent connects to multiple MCP servers simultaneously using the MultiServerMCPClient from langchain-mcp-adapters. Each server defines its own transport protocol and connection parameters.

Sources: main.py:26-40

Configuration Structure

client = MultiServerMCPClient({
    "context7": {
        "url": "https://mcp.context7.com/mcp",
        "transport": "streamable_http",
    },
    "met-museum": {
        "command": "npx",
        "args": ["-y", "metmuseum-mcp"],
        "transport": "stdio",
    }
})

Supported Transport Protocols

TransportUse CaseConfiguration Required
streamable_httpRemote/cloud serversurl endpoint
stdioLocal/npx-based serverscommand and args

Sources: README.md

Context7 Server Configuration

ParameterValueDescription
Server Namecontext7Identifier for the MCP server
URLhttps://mcp.context7.com/mcpRemote endpoint for library documentation
Transportstreamable_httpHTTP-based streaming protocol
CapabilitiesLLM-optimized docs search across major frameworksProvides access to code library documentation

Sources: main.py:28-30

MetMuseum Server Configuration

ParameterValueDescription
Server Namemet-museumIdentifier for the MCP server
CommandnpxNode.js package runner
Args["-y", "metmuseum-mcp"]Auto-install and execute the museum MCP package
TransportstdioStandard input/output communication
CapabilitiesAccess to 400,000+ Metropolitan Museum artworksProvides art collection metadata and images

Sources: main.py:31-35

Language Model Configuration

The agent uses OpenAI's GPT-5 Nano model for reasoning and natural language generation.

OpenAI Model Initialization

openai_model = ChatOpenAI(
    model="gpt-5-nano",
)
ParameterValueDescription
Modelgpt-5-nanoOpenAI's lightweight reasoning engine
Integrationlangchain_openai.ChatOpenAILangChain wrapper for OpenAI API

Sources: main.py:42-44

API Key Configuration

The OpenAI API key must be set as an environment variable before running the agent:

export OPENAI_API_KEY="your-api-key-here"

Sources: README.md

Memory Configuration

The agent implements persistent conversation memory using LangGraph's InMemorySaver checkpointer.

Checkpointer Setup

checkpointer = InMemorySaver()
ComponentClassPurpose
MemoryInMemorySaverStores conversation history in memory
PersistenceThread-basedMessages grouped by thread_id

Sources: main.py:47-48

Thread Configuration

config = {"configurable": {"thread_id": "conversation_id"}}
ParameterValueDescription
Thread ID"conversation_id"Groups all messages in the current session
ScopeSession-levelMaintains context across all agent interactions

Sources: main.py:50-51

Agent Configuration

The ReAct (Reasoning + Acting) agent is created using LangGraph's create_react_agent factory function.

Agent Creation

agent = create_react_agent(
    model=openai_model,
    tools=tools,
    checkpointer=checkpointer
)
ParameterSourceDescription
modelChatOpenAI instanceGPT-5 Nano for reasoning
toolsMultiServerMCPClient.get_tools()All tools from both MCP servers
checkpointerInMemorySaver instanceConversation memory

Sources: main.py:53-57

System Prompt Configuration

The agent's behavior is defined through a system message passed during the initial invocation.

Default System Message

{"role": "system", "content": "You are a smart, useful agent with tools to access code library documentation and the Met Museum collection."}
FieldValuePurpose
RolesystemDefines agent persona
ContentAgent descriptionInstructs agent about available capabilities

Sources: main.py:67

Configuration Flow

graph TD
    A[Configuration Start] --> B[MCP Server Config]
    B --> C[MultiServerMCPClient]
    C --> D[Context7 HTTP]
    C --> E[MetMuseum STDIO]
    D --> F[Get Tools]
    E --> F
    F --> G[LLM Config]
    G --> H[ChatOpenAI gpt-5-nano]
    H --> I[Memory Config]
    I --> J[InMemorySaver]
    J --> K[Agent Config]
    K --> L[create_react_agent]
    L --> M[Ready for Invocation]

Runtime Configuration

Asynchronous Execution

The application runs using Python's asyncio event loop:

async def main():
    # All configuration and agent operations
    pass

if __name__ == "__main__":
    asyncio.run(main())

Agent Invocation

Each user interaction passes through the configured thread:

response = await agent.ainvoke(
    {"messages": query},
    config=config  # Contains thread_id for memory persistence
)

Sources: main.py:80-87

Configuration Dependencies

graph LR
    A[main.py] --> B[langchain_mcp_adapters.client]
    A --> C[langgraph.prebuilt]
    A --> D[langgraph.checkpoint.memory]
    A --> E[langchain_openai]
    B --> F[MultiServerMCPClient]
    C --> G[create_react_agent]
    D --> H[InMemorySaver]
    E --> I[ChatOpenAI]

Environment Requirements

RequirementVersionPurpose
Python3.10+Runtime environment
Node.js/npxLatestRequired for MetMuseum STDIO server
OpenAI API KeyValid keyLLM access

Required Python Packages

pip install langchain-mcp-adapters langgraph langchain-openai

Required npm Packages

npm install -g npx

Sources: README.md

Configuration Summary Table

ComponentClass/FunctionKey ParameterLocation
MCP ClientMultiServerMCPClientTransport definitionsmain.py:26-40
Context7HTTP configURL endpointmain.py:28-30
MetMuseumSTDIO confignpx commandmain.py:31-35
LLMChatOpenAImodel="gpt-5-nano"main.py:42-44
MemoryInMemorySaverIn-memory storagemain.py:47-48
ThreadDict configthread_idmain.py:50-51
Agentcreate_react_agentmodel + tools + checkpointermain.py:53-57

See Also

Sources: README.md

Doramagic Pitfall Log

Source-linked risks stay visible on the manual page so the preview does not read like a recommendation.

medium Project risk needs validation

The project should not be treated as fully validated until this signal is reviewed.

medium README/documentation is current enough for a first validation pass.

The project should not be treated as fully validated until this signal is reviewed.

medium Maintainer activity is unknown

Users cannot judge support quality until recent activity, releases, and issue response are checked.

medium no_demo

The project may affect permissions, credentials, data exposure, or host boundaries.

Doramagic Pitfall Log

Doramagic extracted 7 source-linked risk signals. Review them before installing or handing real data to the project.

1. Project risk: Project risk needs validation

  • Severity: medium
  • Finding: Project risk is backed by a source signal: Project risk needs validation. Treat it as a review item until the current version is checked.
  • User impact: The project should not be treated as fully validated until this signal is reviewed.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp

2. Capability assumption: README/documentation is current enough for a first validation pass.

  • Severity: medium
  • Finding: README/documentation is current enough for a first validation pass.
  • User impact: The project should not be treated as fully validated until this signal is reviewed.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass.

3. Maintenance risk: Maintainer activity is unknown

  • Severity: medium
  • Finding: Maintenance risk is backed by a source signal: Maintainer activity is unknown. Treat it as a review item until the current version is checked.
  • User impact: Users cannot judge support quality until recent activity, releases, and issue response are checked.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing

4. Security or permission risk: no_demo

  • Severity: medium
  • Finding: no_demo
  • User impact: The project may affect permissions, credentials, data exposure, or host boundaries.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium

5. Security or permission risk: no_demo

  • Severity: medium
  • Finding: no_demo
  • User impact: The project may affect permissions, credentials, data exposure, or host boundaries.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium

6. Maintenance risk: issue_or_pr_quality=unknown

  • Severity: low
  • Finding: issue_or_pr_quality=unknown。
  • User impact: Users cannot judge support quality until recent activity, releases, and issue response are checked.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown

7. Maintenance risk: release_recency=unknown

  • Severity: low
  • Finding: release_recency=unknown。
  • User impact: Users cannot judge support quality until recent activity, releases, and issue response are checked.
  • Recommended check: Open the linked source, confirm whether it still applies to the current version, and keep the first run isolated.
  • Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown

Source: Doramagic discovery, validation, and Project Pack records

Community Discussion Evidence

These external discussion links are review inputs, not standalone proof that the project is production-ready.

Sources 1

Count of project-level external discussion links exposed on this manual page.

Use Review before install

Open the linked issues or discussions before treating the pack as ready for your environment.

Community Discussion Evidence

Doramagic exposes project-level community discussion separately from official documentation. Review these links before using mcp-ai-agent with real data or production workflows.

Source: Project Pack community evidence and pitfall evidence