MCP服务工具

一个基于Python的MCP服务器和客户端,用于调用外部HTTP服务获取创作者的练习和产品数据。

  • by dinukasaminda
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 dinukasaminda/chatgpt-codex-test-v2

使用说明

chatgpt-codex-test-v2

这个存储库包含一个用Python编写的简单MCP服务器和客户端。 服务器公开了调用外部HTTP服务以检索数据的工具 关于创作者的练习和产品。客户端可以发现服务器 工具并调用它们。

结构

  • server/ -实现MCP服务器的FastAPI应用程序
  • client/ -发现和调用服务器工具的Python脚本

运行服务器

pip install -r server/requirements.txt
# Optionally set the base URL of the external service
export EXTERNAL_SERVICE_BASE_URL="https://example.com/api"
python server/app.py

服务器将在上运行 http://localhost:5000 默认情况下。

使用客户端

pip install -r client/requirements.txt
python client/client.py            # lists tools and sample prompts
python client/client.py get_exercise_list johndoe
python client/client.py get_products johndoe

客户端首先从服务器获取可用工具 /tools 端点, 然后使用所选的工具端点检索数据。