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
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
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:
| Server | Transport Protocol | Domain |
|---|---|---|
| Context7 | HTTP (streamable_http) | Software library documentation |
| MetMuseum-MCP | STDIO (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 -.-> STDIOComponent 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 --> AgentTechnology Stack
| Component | Technology | Version |
|---|---|---|
| Language | Python | 3.10+ |
| MCP Client | langchain-mcp-adapters | Latest |
| Agent Framework | LangGraph | Latest |
| Language Model | OpenAI GPT-5 Nano | - |
| Memory | InMemorySaver | - |
| Async Runtime | asyncio | Built-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:
| Step | Description |
|---|---|
| 1 | User submits natural language query |
| 2 | GPT-5 Nano reasons about which MCP server to use |
| 3 | Agent calls appropriate tool(s) on selected server |
| 4 | Tool results are returned to the LLM |
| 5 | LLM generates natural language response |
| 6 | Response is stored in InMemorySaver with thread_id |
| 7 | User receives response with conversation context preserved |
Integrated MCP Servers
Context7 Server
| Property | Value |
|---|---|
| Transport | HTTP (streamable_http) |
| URL | https://mcp.context7.com/mcp |
| Purpose | LLM-optimized documentation search |
| Domain | Software frameworks and libraries |
MetMuseum-MCP Server
| Property | Value |
|---|---|
| Transport | STDIO |
| Execution | npx metmuseum-mcp |
| Purpose | Access museum artwork collection |
| Domain | Metropolitan Museum of Art |
| Collection Size | 400,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
| Requirement | Command |
|---|---|
| Python | 3.10+ |
| npm | For 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 resultConclusion
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
Continue reading this section for the full explanation and source context.
Related Pages
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
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
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
endCore 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
| Server | Transport Type | Purpose |
|---|---|---|
| Context7 | streamable_http | Remote cloud-based library documentation search |
| MetMuseum-MCP | stdio | Local museum collection access via npx |
Configuration Parameters
| Parameter | Value | Description |
|---|---|---|
context7.url | https://mcp.context7.com/mcp | Endpoint for Context7 MCP server |
context7.transport | streamable_http | HTTP-based communication protocol |
met-museum.command | npx | Node.js package runner |
met-museum.args | ["-y", "metmuseum-mcp"] | Auto-install and execute MetMuseum MCP |
met-museum.transport | stdio | Standard 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
- User Query: The CLI receives a natural language question from the user
- LLM Reasoning: GPT-5 Nano analyzes the query to determine which MCP server contains relevant information
- Tool Selection: The agent autonomously selects the appropriate server based on domain classification
- Tool Execution: The selected MCP server is invoked via its transport protocol
- Result Processing: Tool results are returned to the LLM for natural language synthesis
- Memory Storage: The complete conversation exchange is persisted via InMemorySaver
- 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 responseDependency Stack
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Language | Python | 3.10+ | Runtime environment |
| MCP Client | langchain-mcp-adapters | Latest | Multi-server MCP connections |
| Agent Framework | langgraph | Latest | ReAct agent orchestration |
| LLM Integration | langchain-openai | Latest | OpenAI API wrapper |
| Runtime | npx/Node.js | Latest | Local 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 Type | Target Server | Example |
|---|---|---|
| Documentation/Code | Context7 | "What LangGraph tools are available?" |
| Art/Museum | MetMuseum | "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
Continue reading this section for the full explanation and source context.
Related Pages
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
Continue reading this section for the full explanation and source context.
Related Pages
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
Continue reading this section for the full explanation and source context.
Related Pages
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
Continue reading this section for the full explanation and source context.
Related Pages
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
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
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:#fff3e0Sources: 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
| Parameter | Type | Description | Example |
|---|---|---|---|
command | string | Executable command to launch the server | "npx" |
args | array | Command-line arguments passed to the executable | ["-y", "metmuseum-mcp"] |
transport | string | Must 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
| Parameter | Type | Description | Example |
|---|---|---|---|
url | string | Full URL endpoint of the MCP server | "https://mcp.context7.com/mcp" |
transport | string | Must 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
| Attribute | Context7 | MetMuseum-MCP |
|---|---|---|
| Transport Type | HTTP | STDIO |
| Location | Remote/Cloud | Local |
| Invocation | Direct URL | npx command |
| Data Domain | Library documentation | Artwork/Museum data |
| Server Process | Hosted service | Spawned 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:
| Transport | Potential Issues | Mitigation |
|---|---|---|
| STDIO | npx not installed, package not found | Ensure Node.js and npx are available |
| STDIO | Process spawning failures | Check system permissions and PATH |
| HTTP | Network connectivity issues | Verify internet access and URL |
| HTTP | Server availability | Implement retry logic if needed |
Sources: main.py:49-54
Dependencies
The transport mechanism implementation requires the following packages:
| Package | Purpose |
|---|---|
langchain-mcp-adapters | Provides MultiServerMCPClient for multi-transport management |
langgraph | Agent framework with tool calling support |
langchain-openai | OpenAI 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
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
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:
| Requirement | Minimum Version | Purpose |
|---|---|---|
| Python | 3.10+ | Runtime environment |
| pip | Latest | Python package management |
| Node.js | Recent | Required for npx command |
| npx | Available | Running 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
| Server | Transport | Connection Type | Purpose |
|---|---|---|---|
| Context7 | streamable_http | Remote/Cloud | LLM-optimized documentation search |
| MetMuseum | stdio | Local (npx) | Metropolitan Museum artwork access |
Required Python Packages
| Package | Version | Role |
|---|---|---|
| langchain-mcp-adapters | Latest | MCP client for multi-server connections |
| langgraph | Latest | ReAct agent framework |
| langchain-openai | Latest | OpenAI GPT model integration |
Sources: main.py
Post-Installation Verification
After installation, the agent will:
- Display an introduction message
- Show available tools from connected MCP servers
- 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
| Issue | Solution |
|---|---|
| Missing OPENAI_API_KEY | Ensure the environment variable is set before running |
| npx not found | Install Node.js or run npm install -g npx |
| MCP server connection failure | Check internet connection for Context7; verify npx works locally |
| Import errors | Reinstall 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:
- Usage Guide - How to interact with the agent
- Architecture Overview - Understanding the multi-server MCP client design
- MCP Server Documentation - Details on Context7 and MetMuseum capabilities
System Requirements Summary
| Component | Specification |
|---|---|
| OS | Cross-platform (Windows, macOS, Linux) |
| Memory | 4GB minimum recommended |
| Disk Space | 500MB for dependencies |
| Network | Required for Context7 server and OpenAI API access |
Sources: README.md
Configuration
Related topics: Installation Guide
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Continue reading this section for the full explanation and source context.
Related Pages
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
| Transport | Use Case | Configuration Required |
|---|---|---|
streamable_http | Remote/cloud servers | url endpoint |
stdio | Local/npx-based servers | command and args |
Sources: README.md
Context7 Server Configuration
| Parameter | Value | Description |
|---|---|---|
| Server Name | context7 | Identifier for the MCP server |
| URL | https://mcp.context7.com/mcp | Remote endpoint for library documentation |
| Transport | streamable_http | HTTP-based streaming protocol |
| Capabilities | LLM-optimized docs search across major frameworks | Provides access to code library documentation |
Sources: main.py:28-30
MetMuseum Server Configuration
| Parameter | Value | Description |
|---|---|---|
| Server Name | met-museum | Identifier for the MCP server |
| Command | npx | Node.js package runner |
| Args | ["-y", "metmuseum-mcp"] | Auto-install and execute the museum MCP package |
| Transport | stdio | Standard input/output communication |
| Capabilities | Access to 400,000+ Metropolitan Museum artworks | Provides 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",
)
| Parameter | Value | Description |
|---|---|---|
| Model | gpt-5-nano | OpenAI's lightweight reasoning engine |
| Integration | langchain_openai.ChatOpenAI | LangChain 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()
| Component | Class | Purpose |
|---|---|---|
| Memory | InMemorySaver | Stores conversation history in memory |
| Persistence | Thread-based | Messages grouped by thread_id |
Sources: main.py:47-48
Thread Configuration
config = {"configurable": {"thread_id": "conversation_id"}}
| Parameter | Value | Description |
|---|---|---|
| Thread ID | "conversation_id" | Groups all messages in the current session |
| Scope | Session-level | Maintains 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
)
| Parameter | Source | Description |
|---|---|---|
model | ChatOpenAI instance | GPT-5 Nano for reasoning |
tools | MultiServerMCPClient.get_tools() | All tools from both MCP servers |
checkpointer | InMemorySaver instance | Conversation 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."}
| Field | Value | Purpose |
|---|---|---|
| Role | system | Defines agent persona |
| Content | Agent description | Instructs 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
| Requirement | Version | Purpose |
|---|---|---|
| Python | 3.10+ | Runtime environment |
| Node.js/npx | Latest | Required for MetMuseum STDIO server |
| OpenAI API Key | Valid key | LLM 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
| Component | Class/Function | Key Parameter | Location |
|---|---|---|---|
| MCP Client | MultiServerMCPClient | Transport definitions | main.py:26-40 |
| Context7 | HTTP config | URL endpoint | main.py:28-30 |
| MetMuseum | STDIO config | npx command | main.py:31-35 |
| LLM | ChatOpenAI | model="gpt-5-nano" | main.py:42-44 |
| Memory | InMemorySaver | In-memory storage | main.py:47-48 |
| Thread | Dict config | thread_id | main.py:50-51 |
| Agent | create_react_agent | model + tools + checkpointer | main.py:53-57 |
See Also
- Installation Guide - Setup instructions
- Architecture Overview - System design
- MCP Servers - Available tool providers
Sources: README.md
Doramagic Pitfall Log
Source-linked risks stay visible on the manual page so the preview does not read like a recommendation.
The project should not be treated as fully validated until this signal is reviewed.
The project should not be treated as fully validated until this signal is reviewed.
Users cannot judge support quality until recent activity, releases, and issue response are checked.
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.
Count of project-level external discussion links exposed on this manual page.
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.
- Project risk needs validation - GitHub / issue
Source: Project Pack community evidence and pitfall evidence