
Advanced practice with MCP (Implementation from scratch)
概览
Python implementation for building AI Agent with MCP (Model Context Protocol) tools and MCP server/client architecture. Create and run an MCP server with custom tools, then implement an AI Agent with MCP Client that utilizes tools from the created server. This task demonstrates the full MCP workflow from server implementation to client integration. By completing this project, you will learn: - : Understand the Model Context Protocol specification and JSON-RPC communication - : Create custom tools that follow MCP standards - : Connect AI agents to MCP servers and handle tool execution - : Implement proper session handling and state management - : Work with Server-Sent Events (SSE) for real-time communication - : Implement robust error handling in distributed systems - : 3.11 or higher - : Listed in requirements.txt - : Postman for API testing 1. Create virtual environment 2. Install Dependencies 0. Run docker desctop with UMS 1.
README
以下为原文 README 节选,完整内容请查看原文。
Advanced MCP (Server & Client) Practice Task
Python implementation for building AI Agent with MCP (Model Context Protocol) tools and MCP server/client architecture.
🎯 Task Overview
Create and run an MCP server with custom tools, then implement an AI Agent with MCP Client that utilizes tools from the created server. This task demonstrates the full MCP workflow from server implementation to client integration.
🎓 Learning Goals
By completing this project, you will learn:
- MCP Protocol Implementation: Understand the Model Context Protocol specification and JSON-RPC communication
- Server-Side Tool Development: Create custom tools that follow MCP standards
- Client Integration: Connect AI agents to MCP servers and handle tool execution
- Session Management: Implement proper session handling and state management
- Streaming Responses: Work with Server-Sent Events (SSE) for real-time communication
- Error Handling: Implement robust error handling in distributed systems
🏗️ Architecture
├── agent/ # MCP Client Implementation
│ ├── clients/
│ │ ├── custom_mcp_client.py 🚧 TODO: Pure Python MCP client
│ │ ├── mcp_client.py ✅ Complete: Framework-based client
│ │ └── openai_client.py ✅ Complete: AI model integration
│ ├── models/
│ │ └── message.py ✅ Complete: Message structures
│ └── app.py 🚧 TODO: Test it with MCPClient and CustomMCPClient
└── mcp_server/ # MCP Server Implementation
├── models/
│ ├── request.py ✅ Complete: Request model
│ └── response.py ✅ Complete: Response model
├── services/
│ └── mcp_server.py 🚧 TODO: Implement core server logic
├── tools/
│ ├── base.py ✅ Complete: Abstract tool interface
│ ├── create_user_tool.py 🚧 TODO: Implement web search tool
│ ├── delete_user_tool.py 🚧 TODO: Implement web search tool
│ ├── update_user_tool.py 🚧 TODO: Implement web search tool
│ ├── get_user_by_id_tool.py 🚧 TODO: Implement web search tool
│ └── search_users.py 🚧 TODO: Implement web search tool
└── server.py 🚧 TODO: Implement FastAPI server
📋 Requirements
- Python: 3.11 or higher
- Dependencies: Listed in
requirements.txt - Optional: Postman for API testing
🔧 Setup Instructions
- Create virtual environment
python -m venv .venv - Install Dependencies
pip install -r requirements.txt
🚀 Task:
If the task in the main branch is hard for you, then switch to the with-detailed-description branch
Create MCP Server:
- Run docker desctop with UMS
- Open mcp_server and review mcp server structure:
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →