MCP Streamable HTTP Demo
TP5 MCP 可流式 HTTP 演示
本项目旨在重现以下演示目标:
提供两个工具的 MCP 服务器。
使用
@modelcontextprotocol/inspector进行测试。使用通过可流式 HTTP 连接 MCP 的 LangChain/LangGraph 兼容智能体。
使用通过可流式 HTTP 连接 MCP 的 n8n AI 智能体设置。
重要安全提示
提示词中粘贴的 OpenAI 密钥已在聊天中泄露。在运行智能体之前,请撤销该密钥并创建一个新密钥。将新密钥放入 .env 文件中;请勿将其提交到版本控制系统。
Related MCP server: SampleMCP
设置
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 deployed
Maintenance
Related MCP Connectors
Open-source Zapier/n8n alternative as an MCP server: agents build, run and debug your workflows.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Python-based MCP server demonstrating basic math and text tools, supporting both SSE and STDIO transports for integration with AI assistants like Cline in VS Code.-
- FlicenseNot gradedqualityDmaintenanceA demonstration MCP server that provides math (add/multiply) and weather tools, connecting via stdio and streamable HTTP, and integrates with LangChain and LangGraph for agentic workflows.-
- FlicenseNot gradedqualityDmaintenanceProvides math and weather tools accessible via LangGraph agent using MCP protocol with stdio and streamable HTTP transports.1-
- FlicenseNot gradedqualityDmaintenanceA calculator MCP server providing add and subtract tools, along with file resources and a code review prompt, supporting in-memory, HTTP, and STDIO transports. It also includes a LangGraph ReAct agent example that uses the tools.-