@@ -13,13 +13,13 @@ import (
1313)
1414
1515// DynamicToolDependencies contains dependencies for dynamic toolset management tools.
16- // It includes the managed ToolsetGroup , the server for registration, and the deps
16+ // It includes the managed Registry , the server for registration, and the deps
1717// that will be passed to tools when they are dynamically enabled.
1818type DynamicToolDependencies struct {
1919 // Server is the MCP server to register tools with
2020 Server * mcp.Server
21- // ToolsetGroup contains all available tools that can be enabled dynamically
22- ToolsetGroup * toolsets.ToolsetGroup
21+ // Registry contains all available tools that can be enabled dynamically
22+ Registry * toolsets.Registry
2323 // ToolDeps are the dependencies passed to tools when they are registered
2424 ToolDeps any
2525 // T is the translation helper function
@@ -33,20 +33,9 @@ func NewDynamicTool(toolset toolsets.ToolsetMetadata, tool mcp.Tool, handler fun
3333 })
3434}
3535
36- // AllToolsetIDsEnum returns all available toolset IDs as an enum for JSON Schema.
37- func AllToolsetIDsEnum () []any {
38- toolsets := AvailableToolsets ()
39- result := make ([]any , len (toolsets ))
40- for i , ts := range toolsets {
41- result [i ] = ts .ID
42- }
43- return result
44- }
45-
46- // ToolsetEnum returns the list of toolset IDs as an enum for JSON Schema.
47- // Deprecated: Use AllToolsetIDsEnum() instead.
48- func ToolsetEnum (toolsetGroup * toolsets.ToolsetGroup ) []any {
49- toolsetIDs := toolsetGroup .ToolsetIDs ()
36+ // toolsetIDsEnum returns the list of toolset IDs as an enum for JSON Schema.
37+ func toolsetIDsEnum (r * toolsets.Registry ) []any {
38+ toolsetIDs := r .ToolsetIDs ()
5039 result := make ([]any , len (toolsetIDs ))
5140 for i , id := range toolsetIDs {
5241 result [i ] = id
@@ -56,16 +45,17 @@ func ToolsetEnum(toolsetGroup *toolsets.ToolsetGroup) []any {
5645
5746// DynamicTools returns the tools for dynamic toolset management.
5847// These tools allow runtime discovery and enablement of toolsets.
59- func DynamicTools () []toolsets.ServerTool {
48+ // The r parameter provides the available toolset IDs for JSON Schema enums.
49+ func DynamicTools (r * toolsets.Registry ) []toolsets.ServerTool {
6050 return []toolsets.ServerTool {
6151 ListAvailableToolsets (),
62- GetToolsetsTools (),
63- EnableToolset (),
52+ GetToolsetsTools (r ),
53+ EnableToolset (r ),
6454 }
6555}
6656
6757// EnableToolset creates a tool that enables a toolset at runtime.
68- func EnableToolset () toolsets.ServerTool {
58+ func EnableToolset (r * toolsets. Registry ) toolsets.ServerTool {
6959 return NewDynamicTool (
7060 ToolsetMetadataDynamic ,
7161 mcp.Tool {
@@ -81,7 +71,7 @@ func EnableToolset() toolsets.ServerTool {
8171 "toolset" : {
8272 Type : "string" ,
8373 Description : "The name of the toolset to enable" ,
84- Enum : AllToolsetIDsEnum ( ),
74+ Enum : toolsetIDsEnum ( r ),
8575 },
8676 },
8777 Required : []string {"toolset" },
@@ -96,19 +86,19 @@ func EnableToolset() toolsets.ServerTool {
9686
9787 toolsetID := toolsets .ToolsetID (toolsetName )
9888
99- if ! deps .ToolsetGroup .HasToolset (toolsetID ) {
89+ if ! deps .Registry .HasToolset (toolsetID ) {
10090 return utils .NewToolResultError (fmt .Sprintf ("Toolset %s not found" , toolsetName )), nil , nil
10191 }
10292
103- if deps .ToolsetGroup .IsToolsetEnabled (toolsetID ) {
93+ if deps .Registry .IsToolsetEnabled (toolsetID ) {
10494 return utils .NewToolResultText (fmt .Sprintf ("Toolset %s is already enabled" , toolsetName )), nil , nil
10595 }
10696
10797 // Mark the toolset as enabled so IsToolsetEnabled returns true
108- deps .ToolsetGroup .EnableToolset (toolsetID )
98+ deps .Registry .EnableToolset (toolsetID )
10999
110100 // Get tools for this toolset and register them with the managed deps
111- toolsForToolset := deps .ToolsetGroup .ToolsForToolset (toolsetID )
101+ toolsForToolset := deps .Registry .ToolsForToolset (toolsetID )
112102 for _ , st := range toolsForToolset {
113103 st .RegisterFunc (deps .Server , deps .ToolDeps )
114104 }
@@ -137,16 +127,16 @@ func ListAvailableToolsets() toolsets.ServerTool {
137127 },
138128 func (deps DynamicToolDependencies ) mcp.ToolHandlerFor [map [string ]any , any ] {
139129 return func (_ context.Context , _ * mcp.CallToolRequest , _ map [string ]any ) (* mcp.CallToolResult , any , error ) {
140- toolsetIDs := deps .ToolsetGroup .ToolsetIDs ()
141- descriptions := deps .ToolsetGroup .ToolsetDescriptions ()
130+ toolsetIDs := deps .Registry .ToolsetIDs ()
131+ descriptions := deps .Registry .ToolsetDescriptions ()
142132
143133 payload := make ([]map [string ]string , 0 , len (toolsetIDs ))
144134 for _ , id := range toolsetIDs {
145135 t := map [string ]string {
146136 "name" : string (id ),
147137 "description" : descriptions [id ],
148138 "can_enable" : "true" ,
149- "currently_enabled" : fmt .Sprintf ("%t" , deps .ToolsetGroup .IsToolsetEnabled (id )),
139+ "currently_enabled" : fmt .Sprintf ("%t" , deps .Registry .IsToolsetEnabled (id )),
150140 }
151141 payload = append (payload , t )
152142 }
@@ -163,7 +153,7 @@ func ListAvailableToolsets() toolsets.ServerTool {
163153}
164154
165155// GetToolsetsTools creates a tool that lists all tools in a specific toolset.
166- func GetToolsetsTools () toolsets.ServerTool {
156+ func GetToolsetsTools (r * toolsets. Registry ) toolsets.ServerTool {
167157 return NewDynamicTool (
168158 ToolsetMetadataDynamic ,
169159 mcp.Tool {
@@ -179,7 +169,7 @@ func GetToolsetsTools() toolsets.ServerTool {
179169 "toolset" : {
180170 Type : "string" ,
181171 Description : "The name of the toolset you want to get the tools for" ,
182- Enum : AllToolsetIDsEnum ( ),
172+ Enum : toolsetIDsEnum ( r ),
183173 },
184174 },
185175 Required : []string {"toolset" },
@@ -194,12 +184,12 @@ func GetToolsetsTools() toolsets.ServerTool {
194184
195185 toolsetID := toolsets .ToolsetID (toolsetName )
196186
197- if ! deps .ToolsetGroup .HasToolset (toolsetID ) {
187+ if ! deps .Registry .HasToolset (toolsetID ) {
198188 return utils .NewToolResultError (fmt .Sprintf ("Toolset %s not found" , toolsetName )), nil , nil
199189 }
200190
201191 // Get all tools for this toolset (ignoring current filters for discovery)
202- toolsInToolset := deps .ToolsetGroup .ToolsForToolset (toolsetID )
192+ toolsInToolset := deps .Registry .ToolsForToolset (toolsetID )
203193 payload := make ([]map [string ]string , 0 , len (toolsInToolset ))
204194
205195 for _ , st := range toolsInToolset {
0 commit comments