当前位置: 首页 > news >正文

DeepChat使用MCP-Hub 案例六 (结合FastMcp案例四)

1、安装Mcp-hub

https://github.com/samanhappy/mcphub
# 端口结合自己机器配置
docker run -p 3001:3000 samanhappy/mcphub   

2、打开网站

http://localhost:3001/     # 账号密码: admin/admin123

image

 3、根据 《FastMcp案例四》 启动程序

import json
from datetime import datetimeimport requests
from fastmcp import FastMCP
mcp = FastMCP("Demo 🚀")@mcp.tool()
def get_public_ip_address() -> str:"""获取服务器公网 IP 地址返回:str: 当前网络的公网 IP 地址"""try:response = requests.get("http://ip-api.com/json")response.raise_for_status()  # 检查 HTTP 请求是否成功content = json.loads(response.text)return content.get("query", "Unknown IP")  # 提供默认值以防字段缺失except requests.RequestException as e:print(f"请求错误: {e}")return "Request Failed"except json.JSONDecodeError as e:print(f"JSON 解码错误: {e}")return "Invalid Response"@mcp.tool()
def greet(name: str) -> str:"""向用户打招呼"""return f"Hello, {name}!"@mcp.tool
def get_current_time():"""Get current time"""return datetime.now()if __name__ == "__main__":# mcp.run()mcp.run(transport="streamable-http",host="0.0.0.0", port=9000, path="/mcp")
View Code
python server-sh.py  # 执行server程序

4、在Mcp-hub配置

image

 5、测试mcp-hub

image

 6、在DeepChat配置mcp-hub的mcp

image

 7、DeepChat测试一下

image

 

http://www.sczhlp.com/news/1998/

相关文章:

  • webapi第五天
  • 完整教程:WPF的一些基础知识学习记录
  • 普通用户修改repo文件下载rpm包
  • MX galaxy Day14
  • 【Could not find Chrome This can occur if either】
  • ModelGate 支持 Claude Code,一键设置AI编程助手,开发效率极速提升!
  • linux storage stack 学习
  • JAVA语言学习总结(第29天)
  • 7.28闲话
  • MX galaxy Day17
  • 1111111111111111111111111111111111111111 - 苦瓜大王
  • IDEA初步了解
  • 读书笔记:Oracle数据库连接与进程的奥秘
  • 7
  • 7.30随笔
  • 回溯算法实现全排列2
  • CF1456E XOR-ranges 题解
  • Feign - Charlie
  • 进程间通信(IPC)机制详解
  • TTS-1技术报告:基于Transformer的文本转语音模型
  • 兴业寰宇人生卡
  • 幻兽帕鲁服务器部署完整指南 - sherlock
  • 基于PaddleOCR的图像验证码快速识别实践
  • 每天阅读30分钟-阿里测试之道读书笔记(一)(二)
  • webapi第三天
  • PG系列:PostgreSQL连接内存开销测量
  • 高并发处理的Rust实现方案(9639)
  • HTTP请求处理的高效封装(3087)
  • 微服务架构的轻量级解决方案(6417)
  • 高性能路由系统的设计与实现(9854)