Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(container): wire shared agent lookup for MCP handler

wizardchen2d37f8fd7d18
diff --git a/internal/container/container.go b/internal/container/container.go
index 04fc0b6b7..5493ee040 100644
--- a/internal/container/container.go
+++ b/internal/container/container.go
@@ -537,7 +537,17 @@ func BuildContainer(container *dig.Container) *dig.Container {
must(container.Provide(handler.NewInitializationHandler))
must(container.Provide(handler.NewAuthHandler))
must(container.Provide(handler.NewSystemHandler))
- must(container.Provide(handler.NewMCPServiceHandler))
+ // Dig resolves exact types; adapt the registered service to the handler's
+ // narrower SharedAgentLookup interface at the composition boundary.
+ must(container.Provide(func(
+ mcpService interfaces.MCPServiceService,
+ toolApprovals interfaces.MCPToolApprovalService,
+ gate *approval.Gate,
+ models interfaces.ModelService,
+ agents interfaces.AgentShareService,
+ ) *handler.MCPServiceHandler {
+ return handler.NewMCPServiceHandler(mcpService, toolApprovals, gate, models, agents)
+ }))
must(container.Provide(handler.NewMCPCredentialsHandler))
must(container.Provide(handler.NewMCPOAuthHandler))
must(container.Provide(handler.NewModelCredentialsHandler))
diff --git a/internal/container/router_wiring_test.go b/internal/container/router_wiring_test.go
new file mode 100644
index 000000000..db4449821
--- /dev/null
+++ b/internal/container/router_wiring_test.go
@@ -0,0 +1,28 @@
+package container
+
+import (
+ "testing"
+
+ "github.com/gin-gonic/gin"
+ "go.uber.org/dig"
+)
+
+// Resolve the production dependency graph without opening connections or
+// starting background workers. Handler tests alone do not catch missing DI types.
+func TestRouterWiring(t *testing.T) {
+ for _, mode := range []struct {
+ name string
+ redisAddr string
+ }{
+ {name: "lite"},
+ {name: "redis", redisAddr: "localhost:6379"},
+ } {
+ t.Run(mode.name, func(t *testing.T) {
+ t.Setenv("REDIS_ADDR", mode.redisAddr)
+ c := BuildContainer(dig.New(dig.DryRun(true)))
+ if err := c.Invoke(func(*gin.Engine) {}); err != nil {
+ t.Fatalf("resolve router dependencies: %v", err)
+ }
+ })
+ }
+}