MCP Streamable HTTP Demo
TP5 MCP 可流式 HTTP 演示
本项目旨在重现以下演示目标:
提供两个工具的 MCP 服务器。
使用
@modelcontextprotocol/inspector进行测试。使用通过可流式 HTTP 连接 MCP 的 LangChain/LangGraph 兼容智能体。
使用通过可流式 HTTP 连接 MCP 的 n8n AI 智能体设置。
重要安全提示
提示词中粘贴的 OpenAI 密钥已在聊天中泄露。在运行智能体之前,请撤销该密钥并创建一个新密钥。将新密钥放入 .env 文件中;请勿将其提交到版本控制系统。
设置
Copy-Item .env.example .env
npm install编辑 .env 并设置:
OPENAI_API_KEY=your_new_key启动 MCP 服务器
npm run serverMCP 端点为:
http://127.0.0.1:3000/mcp健康检查端点为:
http://127.0.0.1:3000/health使用 MCP Inspector 进行测试
在一个终端中,保持服务器运行:
npm run server在另一个终端中,使用 Inspector CLI 列出工具:
npm run inspector:list-tools在 Windows 上,当前的 Inspector CLI 可能会打印正确的 JSON 响应,然后以 Node/libuv 断言错误退出。如果您看到包含 calculate 和 text_stats 的 tools JSON,则说明 MCP 调用本身已成功。
使用 Inspector CLI 调用工具:
npx --yes @modelcontextprotocol/inspector --cli http://127.0.0.1:3000/mcp --transport http --method tools/call --tool-name calculate --tool-arg operation=add --tool-arg "numbers=[2,3,4]"您也可以打开 Inspector UI:
npm run inspector然后选择:
Transport: Streamable HTTP
URL: http://127.0.0.1:3000/mcp本地冒烟测试
npm run smoke这将列出 MCP 工具并调用 calculate。
LangChain 智能体
确保服务器正在运行且 .env 包含有效的已轮换 OPENAI_API_KEY。
npm run agent自定义提示词:
npm run agent -- "Calcule 42 / 6 puis analyse le texte: Bonjour depuis MCP."n8n 智能体
请遵循 docs/n8n-agent.md。
n8n MCP 客户端工具配置如下:
Endpoint: http://127.0.0.1:3000/mcp
Server Transport: HTTP Streamable
Authentication: None
Tools to Include: AllThis server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/flamekk/Model-Context-Protocol'
If you have feedback or need assistance with the MCP directory API, please join our Discord server