handleFormatSQL is the MCP tool handler for "format_sql".
(ctx context.Context, req mcpmcp.CallToolRequest)
| 267 | |
| 268 | // handleFormatSQL is the MCP tool handler for "format_sql". |
| 269 | func handleFormatSQL(ctx context.Context, req mcpmcp.CallToolRequest) (*mcpmcp.CallToolResult, error) { |
| 270 | sql := req.GetString("sql", "") |
| 271 | if sql == "" { |
| 272 | return nil, fmt.Errorf("parameter 'sql' is required and must not be empty") |
| 273 | } |
| 274 | indentSize := req.GetInt("indent_size", 2) |
| 275 | uppercaseKeywords := req.GetBool("uppercase_keywords", false) |
| 276 | addSemicolon := req.GetBool("add_semicolon", false) |
| 277 | result, err := formatSQLInternal(sql, indentSize, uppercaseKeywords, addSemicolon) |
| 278 | if err != nil { |
| 279 | return nil, err |
| 280 | } |
| 281 | return toolResult(result) |
| 282 | } |
| 283 | |
| 284 | // handleParseSQL is the MCP tool handler for "parse_sql". |
| 285 | func handleParseSQL(ctx context.Context, req mcpmcp.CallToolRequest) (*mcpmcp.CallToolResult, error) { |