mcp: introduce Requests (#267)
Handlers and client/server methods take a single request argument combining the session and params. This slightly simplifies the signature for handlers, since there is no longer an often-ignored session argument. But more importantly, it opens the door to adding more information in requests, such as auth info and HTTP request headers. For #243.
This commit is contained in:
parent
e097918484
commit
6e03217c83
1 changed files with 517 additions and 380 deletions
|
|
@ -281,10 +281,10 @@ func TestServerCapabilities(t *testing.T) {
|
|||
s.AddResourceTemplate(&ResourceTemplate{URITemplate: "file:///rt"}, nil)
|
||||
},
|
||||
serverOpts: ServerOptions{
|
||||
SubscribeHandler: func(ctx context.Context, _ *ServerSession, sp *SubscribeParams) error {
|
||||
SubscribeHandler: func(context.Context, *ServerRequest[*SubscribeParams]) error {
|
||||
return nil
|
||||
},
|
||||
UnsubscribeHandler: func(ctx context.Context, _ *ServerSession, up *UnsubscribeParams) error {
|
||||
UnsubscribeHandler: func(context.Context, *ServerRequest[*UnsubscribeParams]) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
|
|
@ -307,7 +307,7 @@ func TestServerCapabilities(t *testing.T) {
|
|||
name: "With completions",
|
||||
configureServer: func(s *Server) {},
|
||||
serverOpts: ServerOptions{
|
||||
CompletionHandler: func(ctx context.Context, ss *ServerSession, params *CompleteParams) (*CompleteResult, error) {
|
||||
CompletionHandler: func(context.Context, *ServerRequest[*CompleteParams]) (*CompleteResult, error) {
|
||||
return nil, nil
|
||||
},
|
||||
},
|
||||
|
|
@ -325,13 +325,13 @@ func TestServerCapabilities(t *testing.T) {
|
|||
s.AddTool(tool, nil)
|
||||
},
|
||||
serverOpts: ServerOptions{
|
||||
SubscribeHandler: func(ctx context.Context, _ *ServerSession, sp *SubscribeParams) error {
|
||||
SubscribeHandler: func(context.Context, *ServerRequest[*SubscribeParams]) error {
|
||||
return nil
|
||||
},
|
||||
UnsubscribeHandler: func(ctx context.Context, _ *ServerSession, up *UnsubscribeParams) error {
|
||||
UnsubscribeHandler: func(context.Context, *ServerRequest[*UnsubscribeParams]) error {
|
||||
return nil
|
||||
},
|
||||
CompletionHandler: func(ctx context.Context, ss *ServerSession, params *CompleteParams) (*CompleteResult, error) {
|
||||
CompletionHandler: func(context.Context, *ServerRequest[*CompleteParams]) (*CompleteResult, error) {
|
||||
return nil, nil
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue