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

Method formatSchemaDetail

backend/api/mcp/tool_search.go:158–187  ·  view source on GitHub ↗
(schemaName string)

Source from the content-addressed store, hash-verified

156}
157
158func (s *Server) formatSchemaDetail(schemaName string) string {
159 props, ok := s.openAPIIndex.GetSchema(schemaName)
160 if !ok {
161 return fmt.Sprintf("Unknown schema: %s\n\nUse search_api(operationId=\"...\") to see schemas in request/response bodies.", schemaName)
162 }
163
164 var sb strings.Builder
165
166 // Normalize name for display
167 displayName := schemaName
168 if !strings.HasPrefix(schemaName, "bytebase.v1.") {
169 displayName = "bytebase.v1." + schemaName
170 }
171
172 fmt.Fprintf(&sb, "## %s\n\n", displayName)
173
174 // Check if it's an enum
175 if len(props) == 1 && props[0].Name == "enum" {
176 sb.WriteString("**Enum values:** ")
177 sb.WriteString(props[0].Description)
178 sb.WriteString("\n")
179 return sb.String()
180 }
181
182 for _, prop := range props {
183 s.formatProperty(&sb, prop)
184 }
185
186 return sb.String()
187}
188
189func (*Server) formatProperty(sb *strings.Builder, prop PropertyInfo) {
190 required := ""

Callers 1

handleSearchAPIMethod · 0.95

Calls 3

formatPropertyMethod · 0.95
StringMethod · 0.65
GetSchemaMethod · 0.45

Tested by

no test coverage detected