| 43 | } |
| 44 | |
| 45 | func (s *Server) handleSearchAPI(_ context.Context, _ *mcp.CallToolRequest, input SearchInput) (*mcp.CallToolResult, any, error) { |
| 46 | var text string |
| 47 | |
| 48 | switch { |
| 49 | case input.OperationID != "": |
| 50 | // Detail mode: get full schema for a specific endpoint |
| 51 | text = s.formatEndpointDetail(input.OperationID) |
| 52 | |
| 53 | case input.Schema != "": |
| 54 | // Schema lookup mode: get properties of a message type |
| 55 | text = s.formatSchemaDetail(input.Schema) |
| 56 | |
| 57 | case input.Service == "": |
| 58 | // List all services |
| 59 | text = s.formatServiceList() |
| 60 | |
| 61 | default: |
| 62 | // List all endpoints in a service (no limit) |
| 63 | endpoints := s.openAPIIndex.GetServiceEndpoints(input.Service) |
| 64 | if len(endpoints) == 0 { |
| 65 | text = fmt.Sprintf("No endpoints found for service: %s\n\nAvailable services:\n%s", |
| 66 | input.Service, s.formatServiceList()) |
| 67 | } else { |
| 68 | text = s.formatEndpoints(endpoints, 0) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return &mcp.CallToolResult{ |
| 73 | Content: []mcp.Content{&mcp.TextContent{Text: text}}, |
| 74 | }, nil, nil |
| 75 | } |
| 76 | |
| 77 | func (s *Server) formatServiceList() string { |
| 78 | services := s.openAPIIndex.Services() |