一个简单的MCP服务器,基于提供的描述符文件或使用反射功能代理到gRPC后端。
安装二进制文件:go install . 或 go install github.com/adiom-data/grpcmcp 确保Go的bin目录在你的PATH中。
在终端中运行示例gRPC服务器 go run example/main.go。这将在8090端口启动一个带有服务器反射功能的gRPC健康服务。请注意,这运行在默认端口上,该端口是grpcmcp将连接的端口。
SSE传输 在另一个终端中运行 grpcmcp --hostport=localhost:3000 --reflect。指定hostport将使用SSE。SSE端点将在http://localhost:3000/sse提供服务。
STDIN传输 设置MCP配置。例如:
"grpcmcp": {
"command": "grpcmcp",
"args": ["--reflect"]
}
通过 grpcmcp --help 查看所有选项列表。
hostport 字符串 - 当设置时,使用SSE,并作为服务器主机:端口。
descriptors 字符串 - 指定从 buf build -o protos.pb 或 protoc --descriptor_set_out=protos.pb 生成的protobuf定义文件的位置,而不是使用gRPC反射。
reflect - 如果设置,则使用反射来检索gRPC端点,而不是描述符文件。
url 字符串 - 指定后端服务器的URL。
services 字符串 - 以逗号分隔的完全限定gRPC服务名称列表,用于过滤。
bearer 字符串 - 要附加到Authorization: Bearer头中的令牌。
bearer-env 字符串 - 用于附加到Authorization: Bearer头中的令牌的环境变量。覆盖bearer。
header 字符串(可重复) - 以键: 值格式添加的头。
加入我们的Discord:https://discord.gg/hDjx3DehwG