Skip to content

Commit 0ecd1c4

Browse files
committed
refactor: replace magic string "public" with DefaultSchema constant
Replace all hardcoded "public" string literals in main.go with app.DefaultSchema constant for improved maintainability and consistency. This eliminates magic strings and provides a single source of truth for the default PostgreSQL schema name. Changes: - Update tool descriptions to use fmt.Sprintf with app.DefaultSchema - Replace default schema assignments with app.DefaultSchema - Improves code clarity and makes future changes easier Closes #34
1 parent 90ab316 commit 0ecd1c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func setupListTablesTool(s *server.MCPServer, appInstance *app.App, debugLogger
269269
listTablesTool := mcp.NewTool("list_tables",
270270
mcp.WithDescription("List tables in a specific schema"),
271271
mcp.WithString("schema",
272-
mcp.Description("Schema name to list tables from (default: public)"),
272+
mcp.Description(fmt.Sprintf("Schema name to list tables from (default: %s)", app.DefaultSchema)),
273273
),
274274
mcp.WithBoolean("include_size",
275275
mcp.Description("Include table size and row count information (default: false)"),
@@ -326,7 +326,7 @@ func handleTableSchemaToolRequest(
326326
}
327327

328328
// Extract schema (optional)
329-
schema := "public"
329+
schema := app.DefaultSchema
330330
if schemaArg, ok := args["schema"].(string); ok && schemaArg != "" {
331331
schema = schemaArg
332332
}
@@ -364,7 +364,7 @@ func setupTableTool(s *server.MCPServer, appInstance *app.App, debugLogger *slog
364364
mcp.Description(config.TableDesc),
365365
),
366366
mcp.WithString("schema",
367-
mcp.Description("Schema name (default: public)"),
367+
mcp.Description(fmt.Sprintf("Schema name (default: %s)", app.DefaultSchema)),
368368
),
369369
)
370370

@@ -539,7 +539,7 @@ func setupGetTableStatsTool(s *server.MCPServer, appInstance *app.App, debugLogg
539539
mcp.Description("Table name to get statistics for"),
540540
),
541541
mcp.WithString("schema",
542-
mcp.Description("Schema name (default: public)"),
542+
mcp.Description(fmt.Sprintf("Schema name (default: %s)", app.DefaultSchema)),
543543
),
544544
)
545545

@@ -555,7 +555,7 @@ func setupGetTableStatsTool(s *server.MCPServer, appInstance *app.App, debugLogg
555555
}
556556

557557
// Extract schema (optional)
558-
schema := "public"
558+
schema := app.DefaultSchema
559559
if schemaArg, ok := args["schema"].(string); ok && schemaArg != "" {
560560
schema = schemaArg
561561
}

0 commit comments

Comments
 (0)