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.
type ClientSessionOptions struct {
}
type ClientSessionOptions struct{}
// Connect begins an MCP session by connecting to a server over the given
// 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)))
}
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)))
return err
}

View file

@ -404,7 +404,7 @@ func TestEndToEnd(t *testing.T) {
// Nothing should be logged until the client sets a level.
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)
}
mustLog("warning", want[0].Data)

View file

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

View file

@ -857,7 +857,7 @@ func (ss *ServerSession) cancel(context.Context, *CancelledParams) (Result, erro
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) {
state.LogLevel = params.Level
})