internal/mcp: generate method names
Augment the generator to create constants for all method names. Change-Id: I858e516b1afec0aa3cf3b9852cbdfc16aec4c553 Reviewed-on: https://go-review.googlesource.com/c/tools/+/673177 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
This commit is contained in:
parent
9bcc6c758f
commit
74340f088d
1 changed files with 66 additions and 21 deletions
|
|
@ -325,12 +325,12 @@ func (ss *ServerSession) Ping(ctx context.Context, _ *PingParams) error {
|
|||
|
||||
// ListRoots lists the client roots.
|
||||
func (ss *ServerSession) ListRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) {
|
||||
return standardCall[ListRootsResult](ctx, ss.conn, "roots/list", params)
|
||||
return standardCall[ListRootsResult](ctx, ss.conn, methodListRoots, params)
|
||||
}
|
||||
|
||||
// CreateMessage sends a sampling request to the client.
|
||||
func (ss *ServerSession) CreateMessage(ctx context.Context, params *CreateMessageParams) (*CreateMessageResult, error) {
|
||||
return standardCall[CreateMessageResult](ctx, ss.conn, "sampling/createMessage", params)
|
||||
return standardCall[CreateMessageResult](ctx, ss.conn, methodCreateMessage, params)
|
||||
}
|
||||
|
||||
// AddMiddleware wraps the server's current method handler using the provided
|
||||
|
|
@ -347,14 +347,14 @@ func (s *Server) AddMiddleware(middleware ...Middleware[ServerSession]) {
|
|||
|
||||
// serverMethodInfos maps from the RPC method name to serverMethodInfos.
|
||||
var serverMethodInfos = map[string]methodInfo[ServerSession]{
|
||||
"initialize": newMethodInfo(sessionMethod((*ServerSession).initialize)),
|
||||
"ping": newMethodInfo(sessionMethod((*ServerSession).ping)),
|
||||
"prompts/list": newMethodInfo(serverMethod((*Server).listPrompts)),
|
||||
"prompts/get": newMethodInfo(serverMethod((*Server).getPrompt)),
|
||||
"tools/list": newMethodInfo(serverMethod((*Server).listTools)),
|
||||
"tools/call": newMethodInfo(serverMethod((*Server).callTool)),
|
||||
"resources/list": newMethodInfo(serverMethod((*Server).listResources)),
|
||||
"resources/read": newMethodInfo(serverMethod((*Server).readResource)),
|
||||
methodInitialize: newMethodInfo(sessionMethod((*ServerSession).initialize)),
|
||||
methodPing: newMethodInfo(sessionMethod((*ServerSession).ping)),
|
||||
methodListPrompts: newMethodInfo(serverMethod((*Server).listPrompts)),
|
||||
methodGetPrompt: newMethodInfo(serverMethod((*Server).getPrompt)),
|
||||
methodListTools: newMethodInfo(serverMethod((*Server).listTools)),
|
||||
methodCallTool: newMethodInfo(serverMethod((*Server).callTool)),
|
||||
methodListResources: newMethodInfo(serverMethod((*Server).listResources)),
|
||||
methodReadResource: newMethodInfo(serverMethod((*Server).readResource)),
|
||||
// TODO: notifications
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue