使用说明
MCP服务器POC
看https://github.com/afsalthaj/simple-mcp-server/blob/master/src/rmcp_streamable_http.rs
# manual handshake
cargo run --example manual_server
# rust sdk
cargo run --example golem_server_rmcp
# or
golem_server_flattened_rmcp
# This is important why because, none of the clients can connect to a local
# MCP servers through http (all of them use this STDIO which is of no use to us)
cloudflared tunnel --url http://127.0.0.1:8000
然后,复制URL并添加工具 MCP Server 在https://platform.openai.com/chat/edit?models=gpt-4.1分钟或
您选择的客户。如果这在Claude Desktop中有效,我会感到惊讶(因为我无法实现)。
显然,这个游乐场也将是我们对傀儡服务器进行手动测试的地方
手动服务器握手详细信息(无论是否使用SDK,GOLEM中都必须存在的最低要求)
请注意,该流是JSON-RPC 2.0的简单HTTP,因此您可以使用任何HTTP客户端与MCP服务器进行交互。
下面是一些例子 curl 命令来演示流程。
SSE或流式http响应可以/应该很快启用。但我也读过克劳德桌面公司正在摆脱SSE的例子
初始化
curl -i -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": {
"name": "curl-client",
"version": "1.0.0"
}
}
}'
已初始化通知
curl -i -X POST https://telecom-exam-chances-developer.trycloudflare.com/my-agent/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Mcp-Session-Id: 59fcd8cf-0399-481a-97ed-24284327b880" \
-d '{
"jsonrpc": "2.0",
"method": "notifications/initialized",
"params": {}
}'
响应的标头中有SessionId。
列出功能
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Mcp-Session-Id: <SESSION_ID>" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}'
实际工具
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Mcp-Session-Id: <SESSION_ID>" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "counter",
"arguments": {
"number": 1
}
}
}'
现在,要测试简单协议是否有效,请使用openai的playground。但我们需要首先将其暴露在公共互联网上。 吸烟
