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

电子商务网站建设课程设计报告网站建设分为哪几种类型

电子商务网站建设课程设计报告,网站建设分为哪几种类型,各大网站发布信息,价格低怎么说好听Python-MCPInspector调试 使用FastMCP开发MCPServer#xff0c;熟悉【McpServer编码过程】【MCPInspector调试方法】- 可以这样理解#xff1a;只编写一个McpServer#xff0c;然后使用MCPInspector作为McpClient进行McpServer的调试 1-核心知识点 1-熟悉【McpServer编…Python-MCPInspector调试 使用FastMCP开发MCPServer熟悉【McpServer编码过程】【MCPInspector调试方法】- 可以这样理解只编写一个McpServer然后使用MCPInspector作为McpClient进行McpServer的调试 1-核心知识点 1-熟悉【McpServer编码过程】2-熟悉【McpServer调试方法-MCP Inspector】 2-思路整理 1-核心思路 1-编写传统的Service业务代码2-在Service业务代码头上添加tool装饰器即可实现FastMCP的Tool功能3-在Service业务代码头上添加mcp.tool()装饰器即可实现FastMCP的McpServer功能4-主程序指定运行方法-stdio进程启动但是不要自己去启动5-使用MCPInspector调试McpServer2个步骤 【mcp dev city_02_mcp_server.py】是启动mcpInspector并指定mcpServer的路径然后在Inspector中启动city_02_mcp_server.py-【uv run --with mcp mcp run city_02_mcp_server.py】 2-核心代码 1-在Service业务代码头上添加tool装饰器即可实现FastMCP的Tool功能 # 假设 mcp 已经正确导入 try:from mcp import tool except ImportError:# 如果 mcp 未找到模拟一个 tool 装饰器def tool(func):return func# 在 Service 业务代码头上添加 tool 装饰器 tool async def get_city_list(self) - list:获取所有的城市信息。返回:str: 所有的城市信息列表logging.info(f获取所有的城市信息)city_list []for city in self.CITY_WEATHER_DATA:city_list.append(city)return city_list 2-在Service业务代码头上添加mcp.tool()装饰器即可实现FastMCP的McpServer功能 from mcp.server.fastmcp import FastMCPfrom city_01_service import CityDataServer# 1-初始化 MCP 服务器 mcp FastMCP(CityDataServer)# 2-初始化城市信息服务器(业务代码tool装饰器) city_server CityDataServer()# 3-在 Service 业务代码头上添加mcp.tool()装饰器 mcp.tool() # 获取所有城市列表 async def get_city_list():获取所有城市列表。返回:str: 所有城市列表city_list await city_server.get_city_list()return city_list# 4-主程序指定运行方法-stdio进程启动 if __name__ __main__:mcp.run(transportstdio) 3-参考网址 个人代码实现仓库https://gitee.com/enzoism/python_mcp_01_inspector 4-上手实操 1-空工程初始化环境 mkdir my_project cd my_project python -m venv .venv2-激活环境 # Windows source .venv/Scripts/activate# Mac source .venv/bin/activate 3-添加依赖 对应的依赖是在激活的环境中 # uv用于后续MCP Inspector的连接 pip install uv httpx mcp 4-项目结构 city_01_service.py城市服务脚本city_02_mcp_server.pyMCP 服务器脚本 5-创建Python城市服务 city_01_service.py城市服务脚本 import logging# 假设 mcp 已经正确导入 try:from mcp import tool except ImportError:# 如果 mcp 未找到模拟一个 tool 装饰器def tool(func):return func# 配置日志打印级别 logger logging.getLogger(__name__) logging.basicConfig(levellogging.INFO)# 定义城市服务 class CityDataServer:# 模拟城市的天气数据CITY_WEATHER_DATA {北京: {condition: 晴, temperature: 25, humidity: 40},上海: {condition: 多云, temperature: 27, humidity: 60},广州: {condition: 雨, temperature: 30, humidity: 80},深圳: {condition: 多云, temperature: 29, humidity: 70},杭州: {condition: 晴, temperature: 26, humidity: 50},}toolasync def get_city_weather(self, city: str) - str:获取指定城市的天气信息。参数:city (str): 城市名称返回:str: 天气信息描述logging.info(f获取天气信息: {city})if city in self.CITY_WEATHER_DATA:weather self.CITY_WEATHER_DATA[city]return f{city} : {weather[condition]} , {weather[temperature]} °C,湿度 {weather[humidity]} %else:return f抱歉,未找到 {city} 的天气信息toolasync def get_city_list(self) - list:获取所有的城市信息。返回:str: 所有的城市信息列表logging.info(f获取所有的城市信息)city_list []for city in self.CITY_WEATHER_DATA:city_list.append(city)return city_listtoolasync def get_city_detail(self, city: str) - str:获取指定城市的信息。参数:city (str): 城市名称返回:str: 城市信息logging.info(f获取指定城市的信息: {city})if city in await self.get_city_list():return f{city} : 一个风景秀丽的城市你值得去玩一把else:return f抱歉,未找到 {city} 的城市信息 6-暴露Python城市MCPServer服务 city_02_mcp_server.pyMCP 服务器脚本 from mcp.server.fastmcp import FastMCPfrom city_01_service import CityDataServer# 初始化 MCP 服务器 mcp FastMCP(CityDataServer) # 初始化城市信息服务器 city_server CityDataServer()# 获取天气信息的工具 mcp.tool() async def get_city_weather(city: str) - str:获取指定城市的天气信息。参数:city (str): 城市名称返回:str: 天气信息描述city_weather_info await city_server.get_city_weather(city)return city_weather_infomcp.tool() # 获取所有城市列表 async def get_city_list():获取所有城市列表。返回:str: 所有城市列表city_list await city_server.get_city_list()return city_listmcp.tool() # 获取指定城市的信息 async def get_city_detail(city: str):获取指定城市的信息。参数:city (str): 城市名称返回:str: 指定城市的信息city_info await city_server.get_city_detail(city)return city_info# 主程序 if __name__ __main__:mcp.run(transportstdio) 7-MCP Inspector调试 1-安装MCP Inspector 运行机制先运行【MCPInspector】再运行【uv run --with mcp mcp run city_02_mcp_server.py】 # 1-安装MCP Inspector pip install mcp[cli]2-运行MCP Inspector服务 # 2-运行MCP Inspector mcp dev city_02_mcp_server.py3-访问MCP Inspector网页 再运行【uv run --with mcp mcp run city_02_mcp_server.py】 http://127.0.0.1:6274
http://www.zqtcl.cn/news/728464/

相关文章:

  • 专业做家居的网站佛山做网站永网
  • 医疗网站建设讯息企业门户网站建设思路
  • 四川建设安全监督管理局网站网站传送门怎么做
  • 哪家网站做推广好优化师和运营区别
  • 鹰潭网站建设公司南宁行业平台开发公司
  • 织梦如何仿手机网站源码奉贤区专业建网站
  • 上海网站建设接单wordpress htaccess 404
  • 长春网站优化指导网站怎样做301跳转
  • 做网站域名是什么意思临沧网站开发
  • 怎么在网站上做网页专业图库网站 西安
  • 龙南建设局网站wordpress 购物导航网站
  • 做数据分析好看的网站自己做背景的网站
  • 做纸棋的网站制作什么网站做毕业设计
  • 上海易雅达网站建设公司广元网站开发
  • 网站备案注销北京优化健康宝
  • 网站地图怎么做XML深圳公共资源交易中心
  • 高碑店做网站的公司湛江专业建站推荐
  • 中国建设银行官网的网站首页c2c电子商务网站建设栏目结构图
  • 做网站的软件图标上海建站外贸
  • 保定网站建设推广成都移动端网站建设
  • 服务平台型网站做那个网站比较好
  • 网站做icp备案需要多久上海人才引进官网
  • 国外的设计网站app有什么好的免费网站做教育宣传语
  • 做期货都看那些网站淮北网
  • 网站建设的需求怎么写网站头条怎么做
  • 宜春seoseo网站自动推广
  • 张家界酒店网站建设人人设计网网址
  • 电脑系统做的好的网站什么网站做一手房好
  • 为什么用MyEclipse做网站上海境外输入
  • 做的比较好的小众网站go 是做网站的吗