From 0ecd1c47d86dc648bd848b7b8f0e8e11f8a5f112 Mon Sep 17 00:00:00 2001 From: Sylvain <1552102+sgaunet@users.noreply.github.com> Date: Sun, 7 Dec 2025 13:22:18 +0100 Subject: [PATCH] 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 --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d3f9bde..ecbb16a 100644 --- a/main.go +++ b/main.go @@ -269,7 +269,7 @@ func setupListTablesTool(s *server.MCPServer, appInstance *app.App, debugLogger listTablesTool := mcp.NewTool("list_tables", mcp.WithDescription("List tables in a specific schema"), mcp.WithString("schema", - mcp.Description("Schema name to list tables from (default: public)"), + mcp.Description(fmt.Sprintf("Schema name to list tables from (default: %s)", app.DefaultSchema)), ), mcp.WithBoolean("include_size", mcp.Description("Include table size and row count information (default: false)"), @@ -326,7 +326,7 @@ func handleTableSchemaToolRequest( } // Extract schema (optional) - schema := "public" + schema := app.DefaultSchema if schemaArg, ok := args["schema"].(string); ok && schemaArg != "" { schema = schemaArg } @@ -364,7 +364,7 @@ func setupTableTool(s *server.MCPServer, appInstance *app.App, debugLogger *slog mcp.Description(config.TableDesc), ), mcp.WithString("schema", - mcp.Description("Schema name (default: public)"), + mcp.Description(fmt.Sprintf("Schema name (default: %s)", app.DefaultSchema)), ), ) @@ -539,7 +539,7 @@ func setupGetTableStatsTool(s *server.MCPServer, appInstance *app.App, debugLogg mcp.Description("Table name to get statistics for"), ), mcp.WithString("schema", - mcp.Description("Schema name (default: public)"), + mcp.Description(fmt.Sprintf("Schema name (default: %s)", app.DefaultSchema)), ), ) @@ -555,7 +555,7 @@ func setupGetTableStatsTool(s *server.MCPServer, appInstance *app.App, debugLogg } // Extract schema (optional) - schema := "public" + schema := app.DefaultSchema if schemaArg, ok := args["schema"].(string); ok && schemaArg != "" { schema = schemaArg }