-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
Describe the bug
I'm starting a MCP SSE example and hitting it with simple curl. I get a weird Nil dereference.
To Reproduce
git clone git@github.com:wkoszek/go-sdk.git
cd go-sdk
git checkout ex1
cd examples/sse
go build .
./sse -port 7000
Then from another terminal, I'm doing
curl http://127.0.0.1:7000
Expected behavior
Some reasonable reply.
Logs
2025/07/23 11:08:32 MCP servers serving at localhost:7000
2025/07/23 11:08:34 Handling request for URL /
2025/07/23 11:08:34 http: panic serving 127.0.0.1:62918: runtime error: invalid memory address or nil pointer dereference
goroutine 21 [running]:
net/http.(*conn).serve.func1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/net/http/server.go:1947 +0xb0
panic({0x1043cac60?, 0x104675fb0?})
/opt/homebrew/Cellar/go/1.24.4/libexec/src/runtime/panic.go:792 +0x124
github.com/modelcontextprotocol/go-sdk/mcp.(*Server).bind(0x0, 0x14000119520)
/Users/wkoszek/Local/go-sdk/mcp/server.go:464 +0x60
github.com/modelcontextprotocol/go-sdk/mcp.connect[...].func1()
/Users/wkoszek/Local/go-sdk/mcp/transport.go:110 +0x4c
github.com/modelcontextprotocol/go-sdk/internal/jsonrpc2.NewConnection({0x1044411d0?, 0x140000f24b0?}, {{0x1293821d8, 0x140000b12c0}, {0x1293821f8, 0x140000b12c0}, {0x129382218, 0x140000b12c0}, {0x10443d560, 0x1400009a1c8}, ...})
/Users/wkoszek/Local/go-sdk/internal/jsonrpc2/conn.go:221 +0x130
github.com/modelcontextprotocol/go-sdk/mcp.connect[...]({0x1044411d0, 0x140000f24b0}, {0x10443d500, 0x140000b12c0?}, {0x10443f388?, 0x0})
/Users/wkoszek/Local/go-sdk/mcp/transport.go:114 +0x268
github.com/modelcontextprotocol/go-sdk/mcp.(*Server).Connect(...)
/Users/wkoszek/Local/go-sdk/mcp/server.go:487
github.com/modelcontextprotocol/go-sdk/mcp.(*SSEHandler).ServeHTTP(0x140000a5ae0, {0x104440938, 0x1400013a000}, 0x140000fc140)
/Users/wkoszek/Local/go-sdk/mcp/sse.go:213 +0x6d8
net/http.serverHandler.ServeHTTP({0x140001263f0?}, {0x104440938?, 0x1400013a000?}, 0x1?)
/opt/homebrew/Cellar/go/1.24.4/libexec/src/net/http/server.go:3301 +0xbc
net/http.(*conn).serve(0x140000e86c0, {0x104441198, 0x14000126300})
/opt/homebrew/Cellar/go/1.24.4/libexec/src/net/http/server.go:2102 +0x52c
created by net/http.(*Server).Serve in goroutine 1
/opt/homebrew/Cellar/go/1.24.4/libexec/src/net/http/server.go:3454 +0x3d8
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working