formatTableNotFound returns an MCP result for the TABLE_NOT_FOUND error path.
(database, table string, candidates []string)
| 734 | |
| 735 | // formatTableNotFound returns an MCP result for the TABLE_NOT_FOUND error path. |
| 736 | func formatTableNotFound(database, table string, candidates []string) *mcp.CallToolResult { |
| 737 | result := struct { |
| 738 | Code string `json:"code"` |
| 739 | Message string `json:"message"` |
| 740 | Suggestion string `json:"suggestion"` |
| 741 | Candidates []string `json:"candidates,omitempty"` |
| 742 | }{ |
| 743 | Code: "TABLE_NOT_FOUND", |
| 744 | Message: fmt.Sprintf("no table matching %q in %s", table, database), |
| 745 | Suggestion: "call get_schema without table= to see available tables", |
| 746 | Candidates: candidates, |
| 747 | } |
| 748 | |
| 749 | jsonBytes, _ := json.MarshalIndent(result, "", " ") |
| 750 | return &mcp.CallToolResult{ |
| 751 | Content: []mcp.Content{&mcp.TextContent{Text: string(jsonBytes)}}, |
| 752 | IsError: true, |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | // formatAmbiguousTable returns an MCP result when the requested table name |
| 757 | // exists in multiple schemas. The caller must pick a schema. |