学习制作MCP服务器

学习制作MCP服务器

学习如何创建MCP服务器,支持Python 3.12及以上版本。

快速入门

安装

使用 Smithery 安装

运行以下命令以通过 Smithery 自动安装:

npx -y @smithery/cli install @yiGmMk/mcp-server --client claude

前置依赖

macOS/Linux 安装 uv:

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows 在 PowerShell 下安装:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

配置文件

推荐使用以下配置:

command: uv args:

  • --directory
  • /path/to/your/mcp-server
  • run
  • main.py env: JINA_API_KEY: 从 https://jina.ai/reader 获取 PYTHONIOENCODING: utf-8

或者使用虚拟环境:

env: VIRTUAL_ENV: /path/to/your/mcp-server/.venv JINA_API_KEY: 从 https://jina.ai/reader 获取 PYTHONIOENCODING: utf-8

启动服务后即可开始使用。