Skip to content

Commit 4e413da

Browse files
authored
mcp: rename mcp{Params,Result} to is{Params,Result} (#270)
For some reason, when making these marker methods, the standard naming convention escaped me.
1 parent 388e000 commit 4e413da

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

mcp/protocol.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type CallToolResultFor[Out any] struct {
7878
IsError bool `json:"isError,omitempty"`
7979
}
8080

81-
func (*CallToolResultFor[Out]) mcpResult() {}
81+
func (*CallToolResultFor[Out]) isResult() {}
8282

8383
// UnmarshalJSON handles the unmarshalling of content into the Content
8484
// interface.
@@ -99,7 +99,7 @@ func (x *CallToolResultFor[Out]) UnmarshalJSON(data []byte) error {
9999
return nil
100100
}
101101

102-
func (x *CallToolParamsFor[Out]) mcpParams() {}
102+
func (x *CallToolParamsFor[Out]) isParams() {}
103103
func (x *CallToolParamsFor[Out]) GetProgressToken() any { return getProgressToken(x) }
104104
func (x *CallToolParamsFor[Out]) SetProgressToken(t any) { setProgressToken(x, t) }
105105

@@ -117,7 +117,7 @@ type CancelledParams struct {
117117
RequestID any `json:"requestId"`
118118
}
119119

120-
func (x *CancelledParams) mcpParams() {}
120+
func (x *CancelledParams) isParams() {}
121121
func (x *CancelledParams) GetProgressToken() any { return getProgressToken(x) }
122122
func (x *CancelledParams) SetProgressToken(t any) { setProgressToken(x, t) }
123123

@@ -211,7 +211,7 @@ type CompleteParams struct {
211211
Ref *CompleteReference `json:"ref"`
212212
}
213213

214-
func (*CompleteParams) mcpParams() {}
214+
func (*CompleteParams) isParams() {}
215215

216216
type CompletionResultDetails struct {
217217
HasMore bool `json:"hasMore,omitempty"`
@@ -227,7 +227,7 @@ type CompleteResult struct {
227227
Completion CompletionResultDetails `json:"completion"`
228228
}
229229

230-
func (*CompleteResult) mcpResult() {}
230+
func (*CompleteResult) isResult() {}
231231

232232
type CreateMessageParams struct {
233233
// This property is reserved by the protocol to allow clients and servers to
@@ -253,7 +253,7 @@ type CreateMessageParams struct {
253253
Temperature float64 `json:"temperature,omitempty"`
254254
}
255255

256-
func (x *CreateMessageParams) mcpParams() {}
256+
func (x *CreateMessageParams) isParams() {}
257257
func (x *CreateMessageParams) GetProgressToken() any { return getProgressToken(x) }
258258
func (x *CreateMessageParams) SetProgressToken(t any) { setProgressToken(x, t) }
259259

@@ -273,7 +273,7 @@ type CreateMessageResult struct {
273273
StopReason string `json:"stopReason,omitempty"`
274274
}
275275

276-
func (*CreateMessageResult) mcpResult() {}
276+
func (*CreateMessageResult) isResult() {}
277277
func (r *CreateMessageResult) UnmarshalJSON(data []byte) error {
278278
type result CreateMessageResult // avoid recursion
279279
var wire struct {
@@ -301,7 +301,7 @@ type GetPromptParams struct {
301301
Name string `json:"name"`
302302
}
303303

304-
func (x *GetPromptParams) mcpParams() {}
304+
func (x *GetPromptParams) isParams() {}
305305
func (x *GetPromptParams) GetProgressToken() any { return getProgressToken(x) }
306306
func (x *GetPromptParams) SetProgressToken(t any) { setProgressToken(x, t) }
307307

@@ -315,7 +315,7 @@ type GetPromptResult struct {
315315
Messages []*PromptMessage `json:"messages"`
316316
}
317317

318-
func (*GetPromptResult) mcpResult() {}
318+
func (*GetPromptResult) isResult() {}
319319

320320
type InitializeParams struct {
321321
// This property is reserved by the protocol to allow clients and servers to
@@ -328,7 +328,7 @@ type InitializeParams struct {
328328
ProtocolVersion string `json:"protocolVersion"`
329329
}
330330

331-
func (x *InitializeParams) mcpParams() {}
331+
func (x *InitializeParams) isParams() {}
332332
func (x *InitializeParams) GetProgressToken() any { return getProgressToken(x) }
333333
func (x *InitializeParams) SetProgressToken(t any) { setProgressToken(x, t) }
334334

@@ -352,15 +352,15 @@ type InitializeResult struct {
352352
ServerInfo *Implementation `json:"serverInfo"`
353353
}
354354

355-
func (*InitializeResult) mcpResult() {}
355+
func (*InitializeResult) isResult() {}
356356

357357
type InitializedParams struct {
358358
// This property is reserved by the protocol to allow clients and servers to
359359
// attach additional metadata to their responses.
360360
Meta `json:"_meta,omitempty"`
361361
}
362362

363-
func (x *InitializedParams) mcpParams() {}
363+
func (x *InitializedParams) isParams() {}
364364
func (x *InitializedParams) GetProgressToken() any { return getProgressToken(x) }
365365
func (x *InitializedParams) SetProgressToken(t any) { setProgressToken(x, t) }
366366

@@ -373,7 +373,7 @@ type ListPromptsParams struct {
373373
Cursor string `json:"cursor,omitempty"`
374374
}
375375

376-
func (x *ListPromptsParams) mcpParams() {}
376+
func (x *ListPromptsParams) isParams() {}
377377
func (x *ListPromptsParams) GetProgressToken() any { return getProgressToken(x) }
378378
func (x *ListPromptsParams) SetProgressToken(t any) { setProgressToken(x, t) }
379379
func (x *ListPromptsParams) cursorPtr() *string { return &x.Cursor }
@@ -389,7 +389,7 @@ type ListPromptsResult struct {
389389
Prompts []*Prompt `json:"prompts"`
390390
}
391391

392-
func (x *ListPromptsResult) mcpResult() {}
392+
func (x *ListPromptsResult) isResult() {}
393393
func (x *ListPromptsResult) nextCursorPtr() *string { return &x.NextCursor }
394394

395395
type ListResourceTemplatesParams struct {
@@ -401,7 +401,7 @@ type ListResourceTemplatesParams struct {
401401
Cursor string `json:"cursor,omitempty"`
402402
}
403403

404-
func (x *ListResourceTemplatesParams) mcpParams() {}
404+
func (x *ListResourceTemplatesParams) isParams() {}
405405
func (x *ListResourceTemplatesParams) GetProgressToken() any { return getProgressToken(x) }
406406
func (x *ListResourceTemplatesParams) SetProgressToken(t any) { setProgressToken(x, t) }
407407
func (x *ListResourceTemplatesParams) cursorPtr() *string { return &x.Cursor }
@@ -417,7 +417,7 @@ type ListResourceTemplatesResult struct {
417417
ResourceTemplates []*ResourceTemplate `json:"resourceTemplates"`
418418
}
419419

420-
func (x *ListResourceTemplatesResult) mcpResult() {}
420+
func (x *ListResourceTemplatesResult) isResult() {}
421421
func (x *ListResourceTemplatesResult) nextCursorPtr() *string { return &x.NextCursor }
422422

423423
type ListResourcesParams struct {
@@ -429,7 +429,7 @@ type ListResourcesParams struct {
429429
Cursor string `json:"cursor,omitempty"`
430430
}
431431

432-
func (x *ListResourcesParams) mcpParams() {}
432+
func (x *ListResourcesParams) isParams() {}
433433
func (x *ListResourcesParams) GetProgressToken() any { return getProgressToken(x) }
434434
func (x *ListResourcesParams) SetProgressToken(t any) { setProgressToken(x, t) }
435435
func (x *ListResourcesParams) cursorPtr() *string { return &x.Cursor }
@@ -445,7 +445,7 @@ type ListResourcesResult struct {
445445
Resources []*Resource `json:"resources"`
446446
}
447447

448-
func (x *ListResourcesResult) mcpResult() {}
448+
func (x *ListResourcesResult) isResult() {}
449449
func (x *ListResourcesResult) nextCursorPtr() *string { return &x.NextCursor }
450450

451451
type ListRootsParams struct {
@@ -454,7 +454,7 @@ type ListRootsParams struct {
454454
Meta `json:"_meta,omitempty"`
455455
}
456456

457-
func (x *ListRootsParams) mcpParams() {}
457+
func (x *ListRootsParams) isParams() {}
458458
func (x *ListRootsParams) GetProgressToken() any { return getProgressToken(x) }
459459
func (x *ListRootsParams) SetProgressToken(t any) { setProgressToken(x, t) }
460460

@@ -468,7 +468,7 @@ type ListRootsResult struct {
468468
Roots []*Root `json:"roots"`
469469
}
470470

471-
func (*ListRootsResult) mcpResult() {}
471+
func (*ListRootsResult) isResult() {}
472472

473473
type ListToolsParams struct {
474474
// This property is reserved by the protocol to allow clients and servers to
@@ -479,7 +479,7 @@ type ListToolsParams struct {
479479
Cursor string `json:"cursor,omitempty"`
480480
}
481481

482-
func (x *ListToolsParams) mcpParams() {}
482+
func (x *ListToolsParams) isParams() {}
483483
func (x *ListToolsParams) GetProgressToken() any { return getProgressToken(x) }
484484
func (x *ListToolsParams) SetProgressToken(t any) { setProgressToken(x, t) }
485485
func (x *ListToolsParams) cursorPtr() *string { return &x.Cursor }
@@ -495,7 +495,7 @@ type ListToolsResult struct {
495495
Tools []*Tool `json:"tools"`
496496
}
497497

498-
func (x *ListToolsResult) mcpResult() {}
498+
func (x *ListToolsResult) isResult() {}
499499
func (x *ListToolsResult) nextCursorPtr() *string { return &x.NextCursor }
500500

501501
// The severity of a log message.
@@ -517,7 +517,7 @@ type LoggingMessageParams struct {
517517
Logger string `json:"logger,omitempty"`
518518
}
519519

520-
func (x *LoggingMessageParams) mcpParams() {}
520+
func (x *LoggingMessageParams) isParams() {}
521521
func (x *LoggingMessageParams) GetProgressToken() any { return getProgressToken(x) }
522522
func (x *LoggingMessageParams) SetProgressToken(t any) { setProgressToken(x, t) }
523523

@@ -579,7 +579,7 @@ type PingParams struct {
579579
Meta `json:"_meta,omitempty"`
580580
}
581581

582-
func (x *PingParams) mcpParams() {}
582+
func (x *PingParams) isParams() {}
583583
func (x *PingParams) GetProgressToken() any { return getProgressToken(x) }
584584
func (x *PingParams) SetProgressToken(t any) { setProgressToken(x, t) }
585585

@@ -599,7 +599,7 @@ type ProgressNotificationParams struct {
599599
Total float64 `json:"total,omitempty"`
600600
}
601601

602-
func (*ProgressNotificationParams) mcpParams() {}
602+
func (*ProgressNotificationParams) isParams() {}
603603

604604
// A prompt or prompt template that the server offers.
605605
type Prompt struct {
@@ -638,7 +638,7 @@ type PromptListChangedParams struct {
638638
Meta `json:"_meta,omitempty"`
639639
}
640640

641-
func (x *PromptListChangedParams) mcpParams() {}
641+
func (x *PromptListChangedParams) isParams() {}
642642
func (x *PromptListChangedParams) GetProgressToken() any { return getProgressToken(x) }
643643
func (x *PromptListChangedParams) SetProgressToken(t any) { setProgressToken(x, t) }
644644

@@ -679,7 +679,7 @@ type ReadResourceParams struct {
679679
URI string `json:"uri"`
680680
}
681681

682-
func (x *ReadResourceParams) mcpParams() {}
682+
func (x *ReadResourceParams) isParams() {}
683683
func (x *ReadResourceParams) GetProgressToken() any { return getProgressToken(x) }
684684
func (x *ReadResourceParams) SetProgressToken(t any) { setProgressToken(x, t) }
685685

@@ -691,7 +691,7 @@ type ReadResourceResult struct {
691691
Contents []*ResourceContents `json:"contents"`
692692
}
693693

694-
func (*ReadResourceResult) mcpResult() {}
694+
func (*ReadResourceResult) isResult() {}
695695

696696
// A known resource that the server is capable of reading.
697697
type Resource struct {
@@ -733,7 +733,7 @@ type ResourceListChangedParams struct {
733733
Meta `json:"_meta,omitempty"`
734734
}
735735

736-
func (x *ResourceListChangedParams) mcpParams() {}
736+
func (x *ResourceListChangedParams) isParams() {}
737737
func (x *ResourceListChangedParams) GetProgressToken() any { return getProgressToken(x) }
738738
func (x *ResourceListChangedParams) SetProgressToken(t any) { setProgressToken(x, t) }
739739

@@ -791,7 +791,7 @@ type RootsListChangedParams struct {
791791
Meta `json:"_meta,omitempty"`
792792
}
793793

794-
func (x *RootsListChangedParams) mcpParams() {}
794+
func (x *RootsListChangedParams) isParams() {}
795795
func (x *RootsListChangedParams) GetProgressToken() any { return getProgressToken(x) }
796796
func (x *RootsListChangedParams) SetProgressToken(t any) { setProgressToken(x, t) }
797797

@@ -836,7 +836,7 @@ type SetLevelParams struct {
836836
Level LoggingLevel `json:"level"`
837837
}
838838

839-
func (x *SetLevelParams) mcpParams() {}
839+
func (x *SetLevelParams) isParams() {}
840840
func (x *SetLevelParams) GetProgressToken() any { return getProgressToken(x) }
841841
func (x *SetLevelParams) SetProgressToken(t any) { setProgressToken(x, t) }
842842

@@ -912,7 +912,7 @@ type ToolListChangedParams struct {
912912
Meta `json:"_meta,omitempty"`
913913
}
914914

915-
func (x *ToolListChangedParams) mcpParams() {}
915+
func (x *ToolListChangedParams) isParams() {}
916916
func (x *ToolListChangedParams) GetProgressToken() any { return getProgressToken(x) }
917917
func (x *ToolListChangedParams) SetProgressToken(t any) { setProgressToken(x, t) }
918918

@@ -926,7 +926,7 @@ type SubscribeParams struct {
926926
URI string `json:"uri"`
927927
}
928928

929-
func (*SubscribeParams) mcpParams() {}
929+
func (*SubscribeParams) isParams() {}
930930

931931
// Sent from the client to request cancellation of resources/updated
932932
// notifications from the server. This should follow a previous
@@ -939,7 +939,7 @@ type UnsubscribeParams struct {
939939
URI string `json:"uri"`
940940
}
941941

942-
func (*UnsubscribeParams) mcpParams() {}
942+
func (*UnsubscribeParams) isParams() {}
943943

944944
// A notification from the server to the client, informing it that a resource
945945
// has changed and may need to be read again. This should only be sent if the
@@ -952,7 +952,7 @@ type ResourceUpdatedNotificationParams struct {
952952
URI string `json:"uri"`
953953
}
954954

955-
func (*ResourceUpdatedNotificationParams) mcpParams() {}
955+
func (*ResourceUpdatedNotificationParams) isParams() {}
956956

957957
// TODO(jba): add CompleteRequest and related types.
958958

mcp/shared.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ func setProgressToken(p Params, pt any) {
337337

338338
// Params is a parameter (input) type for an MCP call or notification.
339339
type Params interface {
340-
// mcpParams discourages implementation of Params outside of this package.
341-
mcpParams()
340+
// isParams discourages implementation of Params outside of this package.
341+
isParams()
342342

343343
// GetMeta returns metadata from a value.
344344
GetMeta() map[string]any
@@ -361,8 +361,8 @@ type RequestParams interface {
361361

362362
// Result is a result of an MCP call.
363363
type Result interface {
364-
// mcpResult discourages implementation of Result outside of this package.
365-
mcpResult()
364+
// isResult discourages implementation of Result outside of this package.
365+
isResult()
366366

367367
// GetMeta returns metadata from a value.
368368
GetMeta() map[string]any
@@ -374,7 +374,7 @@ type Result interface {
374374
// Those methods cannot return nil, because jsonrpc2 cannot handle nils.
375375
type emptyResult struct{}
376376

377-
func (*emptyResult) mcpResult() {}
377+
func (*emptyResult) isResult() {}
378378
func (*emptyResult) GetMeta() map[string]any { panic("should never be called") }
379379
func (*emptyResult) SetMeta(map[string]any) { panic("should never be called") }
380380

0 commit comments

Comments
 (0)