MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / handleFormatSQL

Function handleFormatSQL

pkg/mcp/tools.go:269–282  ·  view source on GitHub ↗

handleFormatSQL is the MCP tool handler for "format_sql".

(ctx context.Context, req mcpmcp.CallToolRequest)

Source from the content-addressed store, hash-verified

267
268// handleFormatSQL is the MCP tool handler for "format_sql".
269func 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".
285func handleParseSQL(ctx context.Context, req mcpmcp.CallToolRequest) (*mcpmcp.CallToolResult, error) {

Calls 3

formatSQLInternalFunction · 0.85
toolResultFunction · 0.85
ErrorfMethod · 0.65

Tested by 3

TestHandleFormatSQLFunction · 0.68