An MCP-based server integrating Zhipu AI and Tencent Maps API to provide weather updates, geocoding, intelligent web search, and dual CLI and web interfaces with external network access.
Unlock the full potential of MCP Python Demo through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
这是一个基于 MCP (Model Context Protocol) 的项目,集成了智谱 AI 和腾讯地图 API,提供了天气查询、地理编码和网络搜索等功能。项目包含命令行界面和 Web 界面两种交互方式。
mcp-python-demo/
├── src/
│ └── mcp_python_demo/
│ ├── __init__.py
│ ├── server.py
│ ├── client.py
│ ├── web_client.py
│ └── main.py
├── images/
├── pyproject.toml
├── .env
├── .env.example
├── .gitignore
└── README.md
git clone https://github.com/chenchen0611/mcp-python-demo.git cd mcp-python-demo
uv venv source .venv/bin/activate # Linux/Mac # 或 .venv\Scripts\activate # Windows uv pip install -e .
.env
文件并配置必要的环境变量:# 智谱AI配置 ZHIPU_API_KEY="your-zhipu-api-key" ZHIPU_MODEL="glm-4-plus" ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4/" # 腾讯地图API配置 TENCENT_MAP_API_KEY="your-tencent-map-api-key" TENCENT_MAP_API_BASE="https://apis.map.qq.com/ws/"
cd src/mcp_python_demo streamlit run web_client.py
访问以下地址之一:
!configcd src/mcp_python_demo uv run server.py
cd src/mcp_python_demo # 使用本地服务器 uv run client.py --agent server.py # 或使用远程服务器 uv run server.py uv run client.py --agent http://127.0.0.1:8000
!config
async def query_weather(adcode: str, search_type: str = "now") -> str: """获取中国城市天气信息"""
async def query_adcode(region_name: str) -> str: """获取行政区划代码"""
async def web_search(search_query: str, search_engine: str = "search_std") -> str: """使用智谱AI进行网络搜索"""
server.py
中使用 @mcp.tool()
装饰器添加新工具:@mcp.tool() async def your_tool(param1: str, param2: str = "default") -> str: """工具描述""" # 实现逻辑 return result
.env
文件中.env
文件提交到版本控制系统.env.example
进行配置连接错误
API 调用失败
Web UI 无法访问
本项目基于以下开源项目:
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!