Skip to content

Commit a4e6668

Browse files
committed
fix design doc
1 parent 60b8bb4 commit a4e6668

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

design/design.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ type Tool struct {
618618
}
619619

620620
// A ToolHandlerFor handles a call to tools/call with typed arguments and results.
621-
type ToolHandlerFor[In, Out any] func(context.Context, *RequestFor[*ServerSession, *CallToolParamsFor[In]]) (*CallToolResultFor[Out], error)
621+
type ToolHandlerFor[In, Out any] func(context.Context, *ServerRequest[*CallToolParamsFor[In]]) (*CallToolResultFor[Out], error)
622622

623623
```
624624
@@ -669,7 +669,7 @@ type AddParams struct {
669669
Y int `json:"y"`
670670
}
671671

672-
func addHandler(ctx context.Context, req *mcp.RequestFor[*mcp.ServerSession, *mcp.CallToolParamsFor[AddParams]]) (*mcp.CallToolResultFor[int], error) {
672+
func addHandler(ctx context.Context, req *mcp.ServerRequest[*mcp.CallToolParamsFor[AddParams]]) (*mcp.CallToolResultFor[int], error) {
673673
return &mcp.CallToolResultFor[int]{StructuredContent: req.Params.Arguments.X + req.Params.Arguments.Y}, nil
674674
}
675675
```
@@ -772,9 +772,9 @@ If a server author wants to support resource subscriptions, they must provide ha
772772
type ServerOptions struct {
773773
...
774774
// Function called when a client session subscribes to a resource.
775-
SubscribeHandler func(context.Context, *RequestFor[*ServerSession, *SubscribeParams]) error
775+
SubscribeHandler func(context.Context, *ServerRequest[*SubscribeParams]) error
776776
// Function called when a client session unsubscribes from a resource.
777-
UnsubscribeHandler func(context.Context, *RequestFor[*ServerSession, *UnsubscribeParams]) error
777+
UnsubscribeHandler func(context.Context, *ServerRequest[*UnsubscribeParams]) error
778778
}
779779
```
780780
@@ -793,10 +793,10 @@ When a list of tools, prompts or resources changes as the result of an AddXXX or
793793
```go
794794
type ClientOptions struct {
795795
...
796-
ToolListChangedHandler func(context.Context, *RequestFor[*ClientSession, *ToolListChangedParams])
797-
PromptListChangedHandler func(context.Context, *RequestFor[*ClientSession, *PromptListChangedParams])
796+
ToolListChangedHandler func(context.Context, *ClientRequest[*ToolListChangedParams])
797+
PromptListChangedHandler func(context.Context, *ClientRequest[*PromptListChangedParams])
798798
// For both resources and resource templates.
799-
ResourceListChangedHandler func(context.Context, *RequestFor[*ClientSession, *ResourceListChangedParams])
799+
ResourceListChangedHandler func(context.Context, *ClientRequest[*ResourceListChangedParams])
800800
}
801801
```
802802
@@ -810,7 +810,7 @@ Clients call the spec method `Complete` to request completions. If a server inst
810810
type ServerOptions struct {
811811
...
812812
// If non-nil, called when a client sends a completion request.
813-
CompletionHandler func(context.Context, *RequestFor[*ServerSession, *CompleteParams]) (*CompleteResult, error)
813+
CompletionHandler func(context.Context, *ServerRequest[*CompleteParams]) (*CompleteResult, error)
814814
}
815815
```
816816

mcp/shared.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,26 +359,19 @@ func setProgressToken(p Params, pt any) {
359359
}
360360

361361
// A Request is a method request with parameters and additional information, such as the session.
362-
// The parameters are untyped; see [RequestFor] for the typed version.
362+
// The parameters are untyped; see [ClientRequest] and [ServerRequest] for the typed versions.
363363
type Request[S Session] struct {
364364
Session S
365365
Params Params
366366
}
367367

368-
// A RequestFor is a method request with parameters and additional information, such as the session.
369-
// The parameters are typed; see [Request] for the untyped version.
370-
// type RequestFor[S Session, P Params] struct {
371-
// Session S
372-
// Params P
373-
// // TODO: HTTPHeader http.Header
374-
// // TODO: auth.TokenInfo
375-
// }
376-
368+
// A ClientRequest is a request to a client.
377369
type ClientRequest[P Params] struct {
378370
Session *ClientSession
379371
Params P
380372
}
381373

374+
// A ServerRequest is a request to a server.
382375
type ServerRequest[P Params] struct {
383376
Session *ServerSession
384377
Params P

0 commit comments

Comments
 (0)