Files
Mofox-Core/scripts/test/demo_mcp_server.py
明天好像没什么 f5e82685a0 feat(plugin): 集成 MCP 协议支持并优化代码风格
- 新增 fastmcp 依赖,支持通过 Streamable HTTP 连接外部工具服务器
- 在 component_registry 与 tool_api 中实现 MCP 工具加载、注册及调用链路
- 补充 README 中的 MCP 特性说明
- 统一修复多处 import 顺序、空行、引号及类型注解,提升代码整洁度
- 在 pyproject.toml 中忽略 PERF203 规则,允许循环内异常处理
- 优化语音缓存与本地 ASR 调用逻辑,减少冗余代码
2025-11-19 23:27:03 +08:00

16 lines
326 B
Python

from fastmcp import FastMCP
app = FastMCP(
name="Demo MCP Server",
streamable_http_path="/mcp"
)
@app.tool()
async def echo_tool(input: str) -> str:
"""一个简单的回声工具"""
return f"Echo: {input}"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, transport="streamable-http"
)