fix(container): wire shared agent lookup for MCP handler
parent
cab16dcacb
commit
2d37f8fd7d
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue