MCPcopy Create free account
hub / github.com/bytebase/bytebase / handleSearchAPI

Method handleSearchAPI

backend/api/mcp/tool_search.go:45–75  ·  view source on GitHub ↗
(_ context.Context, _ *mcp.CallToolRequest, input SearchInput)

Source from the content-addressed store, hash-verified

43}
44
45func (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
77func (s *Server) formatServiceList() string {
78 services := s.openAPIIndex.Services()

Calls 5

formatEndpointDetailMethod · 0.95
formatSchemaDetailMethod · 0.95
formatServiceListMethod · 0.95
formatEndpointsMethod · 0.95
GetServiceEndpointsMethod · 0.80