From 619bc41581e699bf64ad13ec334fadd2fbc327a0 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 29 Jul 2025 01:18:03 +0900 Subject: [PATCH] internal/jsonrpc2,mcp: fix typos (#183) - add links to doc strings - use correct symbol and package names --- internal/jsonrpc2/conn.go | 4 ++-- mcp/server.go | 7 +++---- mcp/shared.go | 4 ++-- mcp/transport.go | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/jsonrpc2/conn.go b/internal/jsonrpc2/conn.go index 3223945..fbe0688 100644 --- a/internal/jsonrpc2/conn.go +++ b/internal/jsonrpc2/conn.go @@ -125,7 +125,7 @@ func (c *Connection) updateInFlight(f func(*inFlightState)) { // that and avoided making any updates that would cause the state to be // non-idle.) if !s.idle() { - panic("jsonrpc2_v2: updateInFlight transitioned to non-idle when already done") + panic("jsonrpc2: updateInFlight transitioned to non-idle when already done") } return default: @@ -718,7 +718,7 @@ func (c *Connection) processResult(from any, req *incomingRequest, result any, e req.cancel() c.updateInFlight(func(s *inFlightState) { if s.incoming == 0 { - panic("jsonrpc2_v2: processResult called when incoming count is already zero") + panic("jsonrpc2: processResult called when incoming count is already zero") } s.incoming-- }) diff --git a/mcp/server.go b/mcp/server.go index 960d35f..4270578 100644 --- a/mcp/server.go +++ b/mcp/server.go @@ -29,7 +29,7 @@ const DefaultPageSize = 1000 // A Server is an instance of an MCP server. // // Servers expose server-side MCP features, which can serve one or more MCP -// sessions by using [Server.Start] or [Server.Run]. +// sessions by using [Server.Run]. type Server struct { // fixed at creation impl *Implementation @@ -74,8 +74,7 @@ type ServerOptions struct { // NewServer creates a new MCP server. The resulting server has no features: // add features using the various Server.AddXXX methods, and the [AddTool] function. // -// The server can be connected to one or more MCP clients using [Server.Start] -// or [Server.Run]. +// The server can be connected to one or more MCP clients using [Server.Run]. // // The first argument must not be nil. // @@ -733,7 +732,7 @@ func (ss *ServerSession) handle(ctx context.Context, req *jsonrpc.Request) (any, } // For the streamable transport, we need the request ID to correlate // server->client calls and notifications to the incoming request from which - // they originated. See [idContext] for details. + // they originated. See [idContextKey] for details. ctx = context.WithValue(ctx, idContextKey{}, req.ID) return handleReceive(ctx, ss, req) } diff --git a/mcp/shared.go b/mcp/shared.go index 49dd2b1..cb5234a 100644 --- a/mcp/shared.go +++ b/mcp/shared.go @@ -44,7 +44,7 @@ type MethodHandler[S Session] func(ctx context.Context, _ S, method string, para // the compiler would complain. type methodHandler any // MethodHandler[*ClientSession] | MethodHandler[*ServerSession] -// A Session is either a ClientSession or a ServerSession. +// A Session is either a [ClientSession] or a [ServerSession]. type Session interface { *ClientSession | *ServerSession // ID returns the session ID, or the empty string if there is none. @@ -57,7 +57,7 @@ type Session interface { getConn() *jsonrpc2.Connection } -// Middleware is a function from MethodHandlers to MethodHandlers. +// Middleware is a function from [MethodHandler] to [MethodHandler]. type Middleware[S Session] func(MethodHandler[S]) MethodHandler[S] // addMiddleware wraps the handler in the middleware functions. diff --git a/mcp/transport.go b/mcp/transport.go index 0441c61..5175f6f 100644 --- a/mcp/transport.go +++ b/mcp/transport.go @@ -134,7 +134,7 @@ type canceller struct { conn *jsonrpc2.Connection } -// Preempt implements jsonrpc2.Preempter. +// Preempt implements [jsonrpc2.Preempter]. func (c *canceller) Preempt(ctx context.Context, req *jsonrpc.Request) (result any, err error) { if req.Method == "notifications/cancelled" { var params CancelledParams @@ -203,7 +203,7 @@ type loggingConn struct { func (c *loggingConn) SessionID() string { return c.delegate.SessionID() } -// loggingReader is a stream middleware that logs incoming messages. +// Read is a stream middleware that logs incoming messages. func (s *loggingConn) Read(ctx context.Context) (jsonrpc.Message, error) { msg, err := s.delegate.Read(ctx) if err != nil { @@ -218,7 +218,7 @@ func (s *loggingConn) Read(ctx context.Context) (jsonrpc.Message, error) { return msg, err } -// loggingWriter is a stream middleware that logs outgoing messages. +// Write is a stream middleware that logs outgoing messages. func (s *loggingConn) Write(ctx context.Context, msg jsonrpc.Message) error { err := s.delegate.Write(ctx, msg) if err != nil {