@@ -38,23 +38,6 @@ import (
3838 mcptools "github.com/docker/cagent/pkg/tools/mcp"
3939)
4040
41- // UnwrapMCPToolset extracts an MCP toolset from a potentially wrapped StartableToolSet.
42- // Returns the MCP toolset if found, or nil if the toolset is not an MCP toolset.
43- func UnwrapMCPToolset (toolset tools.ToolSet ) * mcptools.Toolset {
44- var innerToolset tools.ToolSet
45- if startableTS , ok := toolset .(* agent.StartableToolSet ); ok {
46- innerToolset = startableTS .ToolSet
47- } else {
48- innerToolset = toolset
49- }
50-
51- if mcpToolset , ok := innerToolset .(* mcptools.Toolset ); ok {
52- return mcpToolset
53- }
54-
55- return nil
56- }
57-
5841type ResumeType string
5942
6043// ElicitationResult represents the result of an elicitation request
@@ -459,7 +442,7 @@ func (r *LocalRuntime) CurrentMCPPrompts(ctx context.Context) map[string]mcptool
459442
460443 // Iterate through all toolsets of the current agent
461444 for _ , toolset := range currentAgent .ToolSets () {
462- if mcpToolset := UnwrapMCPToolset (toolset ); mcpToolset != nil {
445+ if mcpToolset , ok := tools. As [ * mcptools. Toolset ] (toolset ); ok {
463446 slog .Debug ("Found MCP toolset" , "toolset" , mcpToolset )
464447 // Discover prompts from this MCP toolset
465448 mcpPrompts := r .discoverMCPPrompts (ctx , mcpToolset )
@@ -639,7 +622,7 @@ func (r *LocalRuntime) emitToolsProgressively(ctx context.Context, a *agent.Agen
639622 isLast := i == totalToolsets - 1
640623
641624 // Start the toolset if needed
642- if startable , ok := toolset .(* agent .StartableToolSet ); ok {
625+ if startable , ok := toolset .(* tools .StartableToolSet ); ok {
643626 if ! startable .IsStarted () {
644627 if err := startable .Start (ctx ); err != nil {
645628 slog .Warn ("Toolset start failed; skipping" , "agent" , a .Name (), "toolset" , fmt .Sprintf ("%T" , startable .ToolSet ), "error" , err )
@@ -1013,11 +996,11 @@ func (r *LocalRuntime) getTools(ctx context.Context, a *agent.Agent, sessionSpan
1013996// configureToolsetHandlers sets up elicitation and OAuth handlers for all toolsets of an agent.
1014997func (r * LocalRuntime ) configureToolsetHandlers (a * agent.Agent , events chan Event ) {
1015998 for _ , toolset := range a .ToolSets () {
1016- toolset . SetElicitationHandler ( r . elicitationHandler )
1017- toolset . SetOAuthSuccessHandler ( func () {
1018- events <- Authorization (tools .ElicitationActionAccept , r .currentAgent )
1019- })
1020- toolset . SetManagedOAuth ( r . managedOAuth )
999+ tools . ConfigureHandlers ( toolset ,
1000+ r . elicitationHandler ,
1001+ func () { events <- Authorization (tools .ElicitationActionAccept , r .currentAgent ) },
1002+ r . managedOAuth ,
1003+ )
10211004 }
10221005}
10231006
0 commit comments