From 0d01478d6d2924145cd2b50d094367829a419d6d Mon Sep 17 00:00:00 2001 From: 4ndrelim Date: Tue, 11 Nov 2025 17:35:55 +0800 Subject: [PATCH] refactor: Make xtramcp backend host name configurable --- internal/libs/cfg/cfg.go | 12 +++++++++++- internal/services/toolkit/client/client.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/libs/cfg/cfg.go b/internal/libs/cfg/cfg.go index bdfea995..161c7331 100644 --- a/internal/libs/cfg/cfg.go +++ b/internal/libs/cfg/cfg.go @@ -10,7 +10,8 @@ type Cfg struct { OpenAIAPIKey string JwtSigningKey string - MongoURI string + MongoURI string + XtraMCPURI string } var cfg *Cfg @@ -21,11 +22,20 @@ func GetCfg() *Cfg { OpenAIAPIKey: os.Getenv("OPENAI_API_KEY"), JwtSigningKey: os.Getenv("JWT_SIGNING_KEY"), MongoURI: mongoURI(), + XtraMCPURI: xtraMCPURI(), } return cfg } +func xtraMCPURI() string { + val := os.Getenv("XTRAMCP_URI") + if val != "" { + return val + } + return "http://paperdebugger-xtra-mcp-server.com/mcp" +} + func mongoURI() string { val := os.Getenv("PD_MONGO_URI") if val != "" { diff --git a/internal/services/toolkit/client/client.go b/internal/services/toolkit/client/client.go index 34ca1975..23e253fd 100644 --- a/internal/services/toolkit/client/client.go +++ b/internal/services/toolkit/client/client.go @@ -51,7 +51,7 @@ func NewAIClient( // toolRegistry.Register("greeting", tools.GreetingToolDescription, tools.GreetingTool) // Load tools dynamically from backend - xtraMCPLoader := xtramcp.NewXtraMCPLoader(db, projectService, "http://paperdebugger-xtra-mcp-server.com/mcp") + xtraMCPLoader := xtramcp.NewXtraMCPLoader(db, projectService, cfg.XtraMCPURI) // initialize MCP session first and log session ID sessionID, err := xtraMCPLoader.InitializeMCP()