Skip to main content
Glama
flamekk

MCP Streamable HTTP Demo

by flamekk

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 server

MCP 端点为:

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 断言错误退出。如果您看到包含 calculatetext_statstools 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: All
F
license - not found
-
quality - not tested
C
maintenance

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