MCP服务器扫描程序
概述
此工具检测通过服务器发送事件(SSE)运行的MCP服务器,并枚举其可用工具。
⚠️ 重要提示:这是一个快速原型,尚未投入生产。代码故意草率,因为它是为快速反馈而构建的,因此可能会遗漏一些边缘情况。.
目的
创建此工具是为了测试关于暴露在互联网上的MCP服务器的假设。随着围绕MCP授权的持续讨论,它提供了一种方法:
- 识别暴露于互联网的MCP服务器
- 确定他们是否实施了适当的安全措施
用法
为基本HTTP URL提供可选的超时参数:
./mcp-scanner -url http://REDACTED -timeout 5
2025/04/29 12:16:56 Initiating connection
2025/04/29 12:16:56 Processing SSE stream
2025/04/29 12:16:56 Waiting for messages
2025/04/29 12:16:56 Sending message: /messages?sessionId=4ac0f3be-619e-4fc2-8b5b-cda90df2392c
2025/04/29 12:16:56 Sent message: /messages?sessionId=4ac0f3be-619e-4fc2-8b5b-cda90df2392c
2025/04/29 12:16:56 Received message: /messages?sessionId=4ac0f3be-619e-4fc2-8b5b-cda90df2392c
2025/04/29 12:16:56 Found messages endpoint: messages?sessionId=4ac0f3be-619e-4fc2-8b5b-cda90df2392c
2025/04/29 12:16:56 Successfully got the messagesEndpoint: messages?sessionId=4ac0f3be-619e-4fc2-8b5b-cda90df2392c
2025/04/29 12:16:56 Sending message: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{},"resources":{}},"serverInfo":{"name":"mcp-sse-server","version":"1.0.0"}},"jsonrpc":"2.0","id":0}
2025/04/29 12:16:56 Sent message: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{},"resources":{}},"serverInfo":{"name":"mcp-sse-server","version":"1.0.0"}},"jsonrpc":"2.0","id":0}
2025/04/29 12:16:56 Received message: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{},"resources":{}},"serverInfo":{"name":"mcp-sse-server","version":"1.0.0"}},"jsonrpc":"2.0","id":0}
2025/04/29 12:16:56 Sending message: {"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}},{"name":"search","inputSchema":{"type":"object","properties":{"query":{"type":"string"},"count":{"type":"number"}},"required":["query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]},"jsonrpc":"2.0","id":1}
2025/04/29 12:16:56 Sent message: {"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}},{"name":"search","inputSchema":{"type":"object","properties":{"query":{"type":"string"},"count":{"type":"number"}},"required":["query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]},"jsonrpc":"2.0","id":1}
2025/04/29 12:16:56 Received message: {"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}},{"name":"search","inputSchema":{"type":"object","properties":{"query":{"type":"string"},"count":{"type":"number"}},"required":["query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]},"jsonrpc":"2.0","id":1}
2025/04/29 12:16:56 Tools: {"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}},{"name":"search","inputSchema":{"type":"object","properties":{"query":{"type":"string"},"count":{"type":"number"}},"required":["query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]},"jsonrpc":"2.0","id":1}