|
@@ -40,14 +40,17 @@ func ServerAddTools(s *server.MCPServer, srv any, svcDesc grpc.ServiceDesc) erro
|
|
|
for j := 0; j < ser.Methods().Len(); j++ {
|
|
for j := 0; j < ser.Methods().Len(); j++ {
|
|
|
method := ser.Methods().Get(j)
|
|
method := ser.Methods().Get(j)
|
|
|
t, h := serverAddToolsByMethod(serviceName, srv, method, handlerMap)
|
|
t, h := serverAddToolsByMethod(serviceName, srv, method, handlerMap)
|
|
|
|
|
+ if t == nil || h == nil {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
s.AddTool(*t, h)
|
|
s.AddTool(*t, h)
|
|
|
}
|
|
}
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func serverAddToolsByMethod(serviceName string, srv any, method protoreflect.MethodDescriptor, handlerMap map[string]grpc.MethodDesc) (*mcp2.Tool, server.ToolHandlerFunc) {
|
|
func serverAddToolsByMethod(serviceName string, srv any, method protoreflect.MethodDescriptor, handlerMap map[string]grpc.MethodDesc) (*mcp2.Tool, server.ToolHandlerFunc) {
|
|
|
- methodMcpOpts, _ := proto.GetExtension(method.Options(), annotations2.E_Options).(*annotations2.McpOptions)
|
|
|
|
|
- if methodMcpOpts == nil || !methodMcpOpts.Enabled {
|
|
|
|
|
|
|
+ methodMcpOpts, _ := proto.GetExtension(method.Options(), annotations2.E_Options).(*annotations2.Options)
|
|
|
|
|
+ if methodMcpOpts == nil || methodMcpOpts.McpOptions == nil || !methodMcpOpts.GetMcpOptions().Enabled {
|
|
|
return nil, nil
|
|
return nil, nil
|
|
|
}
|
|
}
|
|
|
methodOperation, _ := proto.GetExtension(method.Options(), openapi_v3.E_Operation).(*openapi_v3.Operation)
|
|
methodOperation, _ := proto.GetExtension(method.Options(), openapi_v3.E_Operation).(*openapi_v3.Operation)
|