registerTools adds all 7 GoSQLX tools with their JSON Schema definitions.
()
| 86 | |
| 87 | // registerTools adds all 7 GoSQLX tools with their JSON Schema definitions. |
| 88 | func (s *Server) registerTools() { |
| 89 | // validate_sql |
| 90 | s.mcpSrv.AddTool( |
| 91 | mcp.NewTool("validate_sql", |
| 92 | mcp.WithDescription("Validate SQL syntax. Returns {valid: bool, error?: string, dialect?: string}."), |
| 93 | mcp.WithReadOnlyHintAnnotation(true), |
| 94 | mcp.WithDestructiveHintAnnotation(false), |
| 95 | mcp.WithIdempotentHintAnnotation(true), |
| 96 | mcp.WithOpenWorldHintAnnotation(false), |
| 97 | mcp.WithString("sql", |
| 98 | mcp.Required(), |
| 99 | mcp.Description("The SQL string to validate"), |
| 100 | ), |
| 101 | mcp.WithString("dialect", |
| 102 | mcp.Description("SQL dialect: generic, mysql, postgresql, sqlite, sqlserver, oracle, snowflake"), |
| 103 | mcp.Enum("generic", "mysql", "postgresql", "sqlite", "sqlserver", "oracle", "snowflake"), |
| 104 | ), |
| 105 | ), |
| 106 | handleValidateSQL, |
| 107 | ) |
| 108 | |
| 109 | // format_sql |
| 110 | s.mcpSrv.AddTool( |
| 111 | mcp.NewTool("format_sql", |
| 112 | mcp.WithDescription("Format SQL with configurable indentation and keyword casing."), |
| 113 | mcp.WithReadOnlyHintAnnotation(true), |
| 114 | mcp.WithDestructiveHintAnnotation(false), |
| 115 | mcp.WithIdempotentHintAnnotation(true), |
| 116 | mcp.WithOpenWorldHintAnnotation(false), |
| 117 | mcp.WithString("sql", |
| 118 | mcp.Required(), |
| 119 | mcp.Description("The SQL string to format"), |
| 120 | ), |
| 121 | mcp.WithNumber("indent_size", |
| 122 | mcp.Description("Spaces per indent level (default: 2)"), |
| 123 | ), |
| 124 | mcp.WithBoolean("uppercase_keywords", |
| 125 | mcp.Description("Uppercase SQL keywords (default: false)"), |
| 126 | ), |
| 127 | mcp.WithBoolean("add_semicolon", |
| 128 | mcp.Description("Append a trailing semicolon (default: false)"), |
| 129 | ), |
| 130 | ), |
| 131 | handleFormatSQL, |
| 132 | ) |
| 133 | |
| 134 | // parse_sql |
| 135 | s.mcpSrv.AddTool( |
| 136 | mcp.NewTool("parse_sql", |
| 137 | mcp.WithDescription("Parse SQL and return an AST summary: statement count and types."), |
| 138 | mcp.WithReadOnlyHintAnnotation(true), |
| 139 | mcp.WithDestructiveHintAnnotation(false), |
| 140 | mcp.WithIdempotentHintAnnotation(true), |
| 141 | mcp.WithOpenWorldHintAnnotation(false), |
| 142 | mcp.WithString("sql", |
| 143 | mcp.Required(), |
| 144 | mcp.Description("The SQL string to parse"), |
| 145 | ), |
no test coverage detected