5da71e3449
The go-SDK migration changed MCP protocol handling to require proper initialization before tool calls. This updates the script to: - Add initialize request with protocol version and client info - Add notifications/initialized notification - Add arguments field to tools/call params - Keep stdin open with sleep for response - Gracefully handle missing jq dependency
18 lines
654 B
Bash
Executable File
18 lines
654 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# MCP requires initialize -> notifications/initialized -> tools/call
|
|
output=$(
|
|
(
|
|
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"get-me-script","version":"1.0.0"}}}'
|
|
echo '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}'
|
|
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_me","arguments":{}}}'
|
|
sleep 1
|
|
) | go run cmd/github-mcp-server/main.go stdio 2>/dev/null | tail -1
|
|
)
|
|
|
|
if command -v jq &> /dev/null; then
|
|
echo "$output" | jq '.result.content[0].text | fromjson'
|
|
else
|
|
echo "$output"
|
|
fi
|