Skip nil MCP servers in WithMCPServers
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -306,7 +306,11 @@ func WithResetToolChoice(reset bool) Option {
|
||||
|
||||
func WithMCPServers(servers ...*MCPServer) Option {
|
||||
return func(a *Agent) {
|
||||
a.mcpServers = append(a.mcpServers, servers...)
|
||||
for _, s := range servers {
|
||||
if s != nil {
|
||||
a.mcpServers = append(a.mcpServers, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,19 @@ import (
|
||||
"go.probo.inc/probo/pkg/llm"
|
||||
)
|
||||
|
||||
func TestWithMCPServers_SkipsNilEntries(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
valid := NewMCPServer("valid", nil)
|
||||
a := &Agent{}
|
||||
|
||||
opt := WithMCPServers(nil, valid, nil)
|
||||
opt(a)
|
||||
|
||||
require.Len(t, a.mcpServers, 1)
|
||||
assert.Equal(t, "valid", a.mcpServers[0].Name())
|
||||
}
|
||||
|
||||
func TestNewMCPServer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user