定制MCP项目
该项目利用 mcp 具有CLI支持的库,并与OpenAI的API集成。
需求
请确保在运行项目之前安装所需的依赖项:
pip install -r requirements.txt用法
- 将您的OpenAI API密钥配置为环境变量:
export OPENAI_API_KEY="your-api-key"- 启动MCP服务器:
python server.py- 使用客户端与服务器交互:
python client.py- 或者,使用编排器查询LLM和工具:
python main.py示例
查询天气工具
运行客户端并调用 get_weather 工具:
python client.py交互示例:
You: List tools
Assistant: {
"tools": [
{
"name": "get_weather",
"description": "Get weather for a city",
"parameters": {
"city": {
"type": "string",
"description": "Name of the city"
}
}
}
]
}
You: Call get_weather with {"city": "Beijing"}
Assistant: 北京的天气是晴天依赖项
openai==1.70.0mcp[cli]==1.6.0
许可证
该项目根据MIT许可证获得许可。
