formatAmbiguousTable returns an MCP result when the requested table name exists in multiple schemas. The caller must pick a schema.
(database, table string, schemas []string)
| 756 | // formatAmbiguousTable returns an MCP result when the requested table name |
| 757 | // exists in multiple schemas. The caller must pick a schema. |
| 758 | func formatAmbiguousTable(database, table string, schemas []string) *mcp.CallToolResult { |
| 759 | result := struct { |
| 760 | Code string `json:"code"` |
| 761 | Message string `json:"message"` |
| 762 | Suggestion string `json:"suggestion"` |
| 763 | Schemas []string `json:"schemas"` |
| 764 | }{ |
| 765 | Code: "AMBIGUOUS_TABLE", |
| 766 | Message: fmt.Sprintf("table %q exists in multiple schemas of %s", table, database), |
| 767 | Suggestion: fmt.Sprintf("re-run with schema= set to one of: %s", strings.Join(schemas, ", ")), |
| 768 | Schemas: schemas, |
| 769 | } |
| 770 | |
| 771 | jsonBytes, _ := json.MarshalIndent(result, "", " ") |
| 772 | return &mcp.CallToolResult{ |
| 773 | Content: []mcp.Content{&mcp.TextContent{Text: string(jsonBytes)}}, |
| 774 | IsError: true, |
| 775 | } |
| 776 | } |