mcp: rename logging symbols (#321)

Fixes #279.
This commit is contained in:
Jonathan Amsterdam 2025-08-19 07:49:56 -04:00 • committed by GitHub
commit 52734fd414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 9 deletions

View file

@ -103,8 +103,7 @@ func (e unsupportedProtocolVersionError) Error() string {
} }
// ClientSessionOptions is reserved for future use. // ClientSessionOptions is reserved for future use.
type ClientSessionOptions struct { type ClientSessionOptions struct{}
}
// Connect begins an MCP session by connecting to a server over the given // Connect begins an MCP session by connecting to a server over the given
// transport, and initializing the session. // transport, and initializing the session.
@ -398,7 +397,7 @@ func (cs *ClientSession) CallTool(ctx context.Context, params *CallToolParams) (
return handleSend[*CallToolResult](ctx, methodCallTool, newClientRequest(cs, orZero[Params](params))) return handleSend[*CallToolResult](ctx, methodCallTool, newClientRequest(cs, orZero[Params](params)))
} }
func (cs *ClientSession) SetLevel(ctx context.Context, params *SetLevelParams) error { func (cs *ClientSession) SetLoggingLevel(ctx context.Context, params *SetLoggingLevelParams) error {
_, err := handleSend[*emptyResult](ctx, methodSetLevel, newClientRequest(cs, orZero[Params](params))) _, err := handleSend[*emptyResult](ctx, methodSetLevel, newClientRequest(cs, orZero[Params](params)))
return err return err
} }

View file

@ -404,7 +404,7 @@ func TestEndToEnd(t *testing.T) {
// Nothing should be logged until the client sets a level. // Nothing should be logged until the client sets a level.
mustLog("info", "before") mustLog("info", "before")
if err := cs.SetLevel(ctx, &SetLevelParams{Level: "warning"}); err != nil { if err := cs.SetLoggingLevel(ctx, &SetLoggingLevelParams{Level: "warning"}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
mustLog("warning", want[0].Data) mustLog("warning", want[0].Data)

View file

@ -826,7 +826,7 @@ func (m *SamplingMessage) UnmarshalJSON(data []byte) error {
return nil return nil
} }
type SetLevelParams struct { type SetLoggingLevelParams struct {
// This property is reserved by the protocol to allow clients and servers to // This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses. // attach additional metadata to their responses.
Meta `json:"_meta,omitempty"` Meta `json:"_meta,omitempty"`
@ -836,9 +836,9 @@ type SetLevelParams struct {
Level LoggingLevel `json:"level"` Level LoggingLevel `json:"level"`
} }
func (x *SetLevelParams) isParams() {} func (x *SetLoggingLevelParams) isParams() {}
func (x *SetLevelParams) GetProgressToken() any { return getProgressToken(x) } func (x *SetLoggingLevelParams) GetProgressToken() any { return getProgressToken(x) }
func (x *SetLevelParams) SetProgressToken(t any) { setProgressToken(x, t) } func (x *SetLoggingLevelParams) SetProgressToken(t any) { setProgressToken(x, t) }
// Definition for a tool the client can call. // Definition for a tool the client can call.
type Tool struct { type Tool struct {

View file

@ -857,7 +857,7 @@ func (ss *ServerSession) cancel(context.Context, *CancelledParams) (Result, erro
return nil, nil return nil, nil
} }
func (ss *ServerSession) setLevel(_ context.Context, params *SetLevelParams) (*emptyResult, error) { func (ss *ServerSession) setLevel(_ context.Context, params *SetLoggingLevelParams) (*emptyResult, error) {
ss.updateState(func(state *ServerSessionState) { ss.updateState(func(state *ServerSessionState) {
state.LogLevel = params.Level state.LogLevel = params.Level
}) })