Used for environment variable management, storing sensitive information like API keys for ZhipuAI and Tencent Map services
Used for version control and project cloning during setup
Source repository hosting for the MCP demo project
Core runtime environment for the MCP server implementation
Provides the web interface for interacting with the MCP server's capabilities
Used for project configuration through pyproject.toml
MCP Python Demo
这是一个基于 MCP (Model Context Protocol) 的项目,集成了智谱 AI 和腾讯地图 API,提供了天气查询、地理编码和网络搜索等功能。项目包含命令行界面和 Web 界面两种交互方式。
功能特性
- 🤖 智谱 AI 驱动的对话系统
- 🌤️ 腾讯地图天气查询
- 🗺️ 地理编码查询
- 🔍 智能网络搜索
- 💻 命令行和 Web 界面双重支持
- 🌐 支持外网访问
项目结构
快速开始
环境要求
- Python >= 3.10
- uv (推荐) 或 pip
安装
- 克隆项目:
- 使用 uv 安装依赖:
配置
- 创建
.env
文件并配置必要的环境变量:
运行
Web 界面(推荐)
访问以下地址之一:
- 本地访问:http://localhost:8501
- 局域网访问:http://[your-local-ip]:8501
- 外网访问:http://[your-public-ip]:8501
页面配置
- 直接输入server.py,点击连接
- 新建一个terminal,运行下方命令然后在web页面输入http://127.0.0.1:8000
命令行界面
可用工具
1. 天气查询
2. 地理编码查询
3. 网络搜索
开发说明
添加新工具
- 在
server.py
中使用@mcp.tool()
装饰器添加新工具:
- 工具会自动在客户端可用
环境变量
- 所有敏感信息和配置都应该放在
.env
文件中 - 不要将
.env
文件提交到版本控制系统 - 参考
.env.example
进行配置
常见问题
- 连接错误
- 检查服务器地址是否正确
- 确认所有环境变量都已正确配置
- 确保服务器正在运行且端口可访问
- API 调用失败
- 验证 API 密钥是否有效
- 检查网络连接
- 确认 API 调用频率是否超限
- Web UI 无法访问
- 检查防火墙设置
- 确认端口是否开放
- 验证服务器 IP 地址是否正确
致谢
本项目基于以下开源项目:
- Model Context Protocol Servers - MCP 官方服务器参考实现,提供了丰富的示例和最佳实践
- MCP Python SDK - Python SDK 实现,提供了简洁优雅的 API 接口
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
An MCP-based project that integrates Zhipu AI and Tencent Map APIs to provide weather queries, geocoding, and web search functionality through both command-line and web interfaces.
Related MCP Servers
- AsecurityFlicenseAqualityA basic MCP server template that can be integrated with Cursor to enable AI tools like weather information retrieval using Claude-3.7-sonnet model.Last updated -2TypeScript
- -securityFlicense-qualityA simple MCP service that allows users to query weather conditions for cities worldwide through the Cursor AI assistant.Last updated -JavaScript
- -securityFlicense-qualityAn MCP server implementation that allows users to fetch and display weather information for specified cities, including temperature, humidity, wind speed, and weather descriptions.Last updated -Python
- -securityAlicense-qualityA server that integrates the MCP library with OpenAI's API, allowing users to interact with various tools, such as the weather tool, through natural language queries.Last updated -PythonMIT License