mcp-code-guidance
@JavaPentesters
这是一个使用 Python 语言从 0 到 1 搭建 MCP server 的代码学习教程
Overview
What is mcp-code-guidance?
mcp-code-guidance is a tutorial for learning the MCP (Model Context Protocol) and A2A (Agent-to-Agent) protocol from scratch using Python. It focuses on the interaction between agents and external tools as well as collaboration between agents, and provides example MCP server implementations and a detailed tutorial.
How to use mcp-code-guidance?
Clone or download the repository, ensure Python 3.10+ and the uv package manager are installed. Then navigate into a specific example directory (e.g., mcp-server-01quickstart) and run uv init, uv venv, source .venv/bin/activate, and uv add "mcp[cli]" httpx to set up the environment. Detailed steps are provided in the README for each example.
Key features of mcp-code-guidance
- Provides step‑by‑step tutorials for MCP and A2A protocols
- Includes multiple ready‑to‑run MCP server examples (quickstart, weather, stock)
- Uses Python 3.10+ and the FastMCP library
- Managed with
uvfor clean project isolation - Covers the three MCP capabilities: Tool, Resource, and Prompt
- Licensed under MIT for open‑source use
Use cases of mcp-code-guidance
- Learning how to build a basic MCP server from scratch
- Implementing a weather‑query MCP service (see
mcp-server-02weather) - Building a stock‑price MCP service (see
mcp-server-03stock) - Understanding how MCP tools, resources, and prompts work in practice
- Exploring A2A agent‑to‑agent collaboration alongside MCP
FAQ from mcp-code-guidance
What are the required dependencies?
Python 3.10+ and the FastMCP library. The examples also use httpx and the mcp CLI package.
How do I set up the project environment?
Use the uv package manager: run uv init (specifying Python 3.11), uv venv, source .venv/bin/activate, then uv add "mcp[cli]" httpx.
What MCP capabilities are covered in this tutorial?
The tutorial covers all three MCP capabilities: Tool (direct function calls), Resource (context information), and Prompt (reusable templates).
Where does each example code live?
Each example is in its own directory under the repository root: mcp-server-01quickstart, mcp-server-02weather, mcp-server-03stock. A tutorial/ directory contains detailed development guides.
What is the official MCP resource linked in the README?
The README links to https://modelcontextprotocol.io/introduction for the official MCP introduction.