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

Function formatSchemaOutput

backend/api/mcp/tool_schema.go:663–683  ·  view source on GitHub ↗

formatSchemaOutput produces a text header + JSON body (same pattern as query_database).

(output *SchemaOutput, include string, warnings []string)

Source from the content-addressed store, hash-verified

661
662// formatSchemaOutput produces a text header + JSON body (same pattern as query_database).
663func formatSchemaOutput(output *SchemaOutput, include string, warnings []string) string {
664 var sb strings.Builder
665
666 for _, w := range warnings {
667 fmt.Fprintf(&sb, "Note: %s\n", w)
668 }
669
670 fmt.Fprintf(&sb, "Database: %s (%s)\n", output.Database, output.Engine)
671
672 if output.Table != nil {
673 writeTableHeader(&sb, output.Table)
674 } else {
675 writeSchemasHeader(&sb, output.Schemas, include)
676 }
677
678 sb.WriteString("\n")
679 jsonBytes, _ := json.Marshal(output)
680 sb.Write(jsonBytes)
681
682 return sb.String()
683}
684
685// writeTableHeader writes the single-table header line.
686func writeTableHeader(sb *strings.Builder, t *TableDetail) {

Callers 2

renderTableResultMethod · 0.85
renderSchemasResultFunction · 0.85

Calls 3

writeTableHeaderFunction · 0.85
writeSchemasHeaderFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected