Sponsored by Deepsite.site

MCP Demo

Created By
guobinqiu8 months ago
测试mcp host连接到mcp server
Content

MCP Demo

LLM 使用的 DeepSeek-V3

安装

uv init mcp-demo
cd mcp-demo
uv venv
source .venv/bin/activate
uv add "mcp[cli]" httpx
uv add mcp openai python-dotenv
rm main.py

运行

运行前把.env文件里的OPENAI_API_KEY换成你的deepseek api key

python3 client.py weather.py

输出

[04/23/25 21:11:54] INFO     Processing request of type ListToolsRequest                                                                                 server.py:534

Connected to server with tools: ['get_alerts', 'get_forecast']

MCP Client Started!
Type your queries or 'quit' to exit.

Query: what's the weather in new york 
[04/23/25 21:12:09] INFO     Processing request of type ListToolsRequest                                                                                 server.py:534
[04/23/25 21:12:15] INFO     Processing request of type CallToolRequest                                                                                  server.py:534
                    INFO     HTTP Request: GET https://api.weather.gov/points/40.7128,-74.006 "HTTP/1.1 200 OK"                                        _client.py:1740
[04/23/25 21:12:16] INFO     HTTP Request: GET https://api.weather.gov/gridpoints/OKX/33,35/forecast "HTTP/1.1 200 OK"                                 _client.py:1740
[DEBUG] final_text[0] type: <class 'str'>, value: Here's the current weather forecast for New York:

### Today:  
- **Temperature:** 73°F  
- **Wind:** 7 mph NW  
- **Forecast:** Mostly sunny, with a high near 73.  

### Tonight:  
- **Temperature:** 57°F  
- **Wind:** 3 to 7 mph SE  
- **Forecast:** Mostly clear.  

### Thursday:  
- **Temperature:** 68°F (falling to 64°F in the afternoon)  
- **Wind:** 3 to 12 mph SE  
- **Forecast:** Sunny.  

### Thursday Night:  
- **Temperature:** 56°F  
- **Wind:** 6 to 12 mph S  
- **Forecast:** Mostly clear.  

### Friday:  
- **Temperature:** 70°F (falling to 66°F in the afternoon)  
- **Wind:** 5 to 14 mph S  
- **Forecast:** Partly sunny.  

Let me know if you'd like more details!

Here's the current weather forecast for New York:

### Today:  
- **Temperature:** 73°F  
- **Wind:** 7 mph NW  
- **Forecast:** Mostly sunny, with a high near 73.  

### Tonight:  
- **Temperature:** 57°F  
- **Wind:** 3 to 7 mph SE  
- **Forecast:** Mostly clear.  

### Thursday:  
- **Temperature:** 68°F (falling to 64°F in the afternoon)  
- **Wind:** 3 to 12 mph SE  
- **Forecast:** Sunny.  

### Thursday Night:  
- **Temperature:** 56°F  
- **Wind:** 6 to 12 mph S  
- **Forecast:** Mostly clear.  

### Friday:  
- **Temperature:** 70°F (falling to 66°F in the afternoon)  
- **Wind:** 5 to 14 mph S  
- **Forecast:** Partly sunny.  

Let me know if you'd like more details!

Query: 

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
ChatWiseThe second fastest AI chatbot™
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
CursorThe AI Code Editor
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
DeepChatYour AI Partner on Desktop
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server