Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/server/distributed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func parent() {
}

func child(port string) {
// Create a server with a single tool that increments a counter.
// Create a server with a single tool that increments a counter and sends a notification.
server := mcp.NewServer(&mcp.Implementation{Name: "counter"}, nil)

var count atomic.Int64
Expand All @@ -153,6 +153,9 @@ func child(port string) {
if *verbose {
log.Printf("request %d (session %s)", n, req.Session.ID())
}
// Send a notification in the context of the request
// Hint: in stateless mode, at least log level 'info' is required to send notifications
req.Session.Log(ctx, &mcp.LoggingMessageParams{Data: fmt.Sprintf("request %d (session %s)", n, req.Session.ID()), Level: "info"})
return nil, struct{ Count int64 }{n}, nil
}
mcp.AddTool(server, &mcp.Tool{Name: "inc"}, inc)
Expand Down
1 change: 1 addition & 0 deletions mcp/streamable.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
if !hasInitialized {
state.InitializedParams = new(InitializedParams)
}
state.LogLevel = "info"
connectOpts = &ServerSessionOptions{
State: state,
}
Expand Down