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

Method renderTableResult

backend/api/mcp/tool_schema.go:318–342  ·  view source on GitHub ↗

renderTableResult dispatches the `table=` drill-down path: it picks the unique match (or returns an appropriate error result) and renders it as TableDetail. schemaHint is the engine-adjusted schema filter (empty when dropped for single-schema engines) and is used for the candidate-lookup refetch too

(ctx context.Context, resolved *resolvedDatabase, input SchemaInput, schemaHint string, metadata *databaseMetadata, include string, warnings []string)

Source from the content-addressed store, hash-verified

316// schemaHint is the engine-adjusted schema filter (empty when dropped for
317// single-schema engines) and is used for the candidate-lookup refetch too.
318func (s *Server) renderTableResult(ctx context.Context, resolved *resolvedDatabase, input SchemaInput, schemaHint string, metadata *databaseMetadata, include string, warnings []string) (*mcp.CallToolResult, any) {
319 matches := findTableMatches(metadata, input.Table)
320 switch {
321 case len(matches) == 0:
322 // Re-fetch without table filter to surface candidates.
323 candidates := s.lookupTableCandidates(ctx, resolved.resourceName, schemaHint, input.Table)
324 return formatTableNotFound(input.Database, input.Table, candidates), nil
325 case len(matches) > 1:
326 // Same table name in multiple schemas. Don't silently pick one.
327 schemas := make([]string, 0, len(matches))
328 for _, m := range matches {
329 schemas = append(schemas, m.schema)
330 }
331 return formatAmbiguousTable(input.Database, input.Table, schemas), nil
332 }
333 entry := buildTableEntry(matches[0].table, schemaIncludeDetails)
334 output := &SchemaOutput{
335 Database: resolved.resourceName,
336 Engine: resolved.engine,
337 Table: &entry,
338 }
339 return &mcp.CallToolResult{
340 Content: []mcp.Content{&mcp.TextContent{Text: formatSchemaOutput(output, include, warnings)}},
341 }, output
342}
343
344// renderSchemasResult handles the bulk schema listing path (no table drill-down).
345func renderSchemasResult(resolved *resolvedDatabase, metadata *databaseMetadata, include string, warnings []string) (*mcp.CallToolResult, any) {

Callers 1

handleGetSchemaMethod · 0.95

Calls 6

lookupTableCandidatesMethod · 0.95
findTableMatchesFunction · 0.85
formatTableNotFoundFunction · 0.85
formatAmbiguousTableFunction · 0.85
buildTableEntryFunction · 0.85
formatSchemaOutputFunction · 0.85

Tested by

no test coverage detected