使用说明
🔌 MCP服务器
从头开始构建的生产级MCP服务器——将LLM连接到现实世界的工具。
🧠 概述
此存储库包含越来越多的 模型上下文协议(MCP)服务器 --轻量级的工具调用后端,为Claude等LLM提供对外部功能的结构化访问。
MCP对AI代理来说就像REST对web应用程序一样: 标准化协议 用于向语言模型公开工具、资源和提示。
LLM Client (Claude Desktop / Cursor)
│
│ JSON-RPC over stdio / SSE
▼
MCP Server (this repo)
│
▼
Tool Logic (APIs, math, files, databases...)
📦 服务器
| 服务器 | 描述 | 工具 | 状态 |
|---|---|---|---|
my-first-mcp-server |
使用FastMCP的计算器服务器 | add |
✅ 完成 |
| 更多即将到来。.. | 🔧 进行中 |
🚀 入门指南
先决条件
- Python 3.10+
pip install mcp
克隆仓库
git clone https://github.com/asfandyar-prog/mcp-servers.git
cd mcp-servers
运行服务器
cd my-first-mcp-server
python fastmcp_calculator.py
⚠️ 直接在终端中运行将显示JSON错误——这是 预期.MCP服务器被设计为与MCP客户端通信,而不是与终端通信。看 连接到克劳德桌面 在......下面
🏗 建筑
每个服务器都遵循以下结构:
mcp-servers/
├── my-first-mcp-server/
│ └── fastmcp_calculator.py # FastMCP server with tool definitions
├── README.md
如何定义工具
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-first-server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
mcp.run()
就是这样——FastMCP自动处理所有JSON-RPC管道。
🖥 连接到克劳德桌面
使用任何服务器 克劳德桌面,将其添加到您的配置文件中:
地点: C:\Users\<YOU>\AppData\Roaming\Claude\claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "python",
"args": ["C:\\Users\\<YOU>\\mcp-servers\\my-first-mcp-server\\fastmcp_calculator.py"]
}
}
}
重新启动克劳德桌面→ 寻找🔨 锤图标→ 你的工具是活的。
🔗 相关存储库
更广泛的人工智能工程组合的一部分:
agentic-systems-with-langgraph--基于LangGraph的多智能体系统framework-free-agent--从头开始的自治ReAct代理DeepLearning--变压器、CNN、从头开始实现
👤 作者
阿斯凡德·亚尔 --AI工程师|多代理系统| LLM基础设施
Built with ☕ in Debrecen, Hungary