|
5 | 5 | "fmt" |
6 | 6 | "sort" |
7 | 7 | "strings" |
8 | | - |
9 | | - "github.com/google/jsonschema-go/jsonschema" |
10 | 8 | ) |
11 | 9 |
|
12 | 10 | // ToolFilter is a function that determines if a tool should be included. |
@@ -43,7 +41,6 @@ type Builder struct { |
43 | 41 | featureChecker FeatureFlagChecker |
44 | 42 | filters []ToolFilter // filters to apply to all tools |
45 | 43 | generateInstructions bool |
46 | | - insidersMode bool |
47 | 44 | } |
48 | 45 |
|
49 | 46 | // NewBuilder creates a new Builder. |
@@ -138,15 +135,6 @@ func (b *Builder) WithFilter(filter ToolFilter) *Builder { |
138 | 135 | return b |
139 | 136 | } |
140 | 137 |
|
141 | | -// WithInsidersMode enables or disables insiders mode features. |
142 | | -// When insiders mode is disabled (default), UI-related parameters like "show_ui" |
143 | | -// are removed from tool schemas to hide experimental features. |
144 | | -// Returns self for chaining. |
145 | | -func (b *Builder) WithInsidersMode(enabled bool) *Builder { |
146 | | - b.insidersMode = enabled |
147 | | - return b |
148 | | -} |
149 | | - |
150 | 138 | // cleanTools trims whitespace and removes duplicates from tool names. |
151 | 139 | // Empty strings after trimming are excluded. |
152 | 140 | func cleanTools(tools []string) []string { |
@@ -174,14 +162,8 @@ func cleanTools(tools []string) []string { |
174 | 162 | // (i.e., they don't exist in the tool set and are not deprecated aliases). |
175 | 163 | // This ensures invalid tool configurations fail fast at build time. |
176 | 164 | func (b *Builder) Build() (*Inventory, error) { |
177 | | - // When insiders mode is disabled, strip show_ui parameters from tool schemas |
178 | | - tools := b.tools |
179 | | - if !b.insidersMode { |
180 | | - tools = stripInsidersParameters(b.tools) |
181 | | - } |
182 | | - |
183 | 165 | r := &Inventory{ |
184 | | - tools: tools, |
| 166 | + tools: b.tools, |
185 | 167 | resourceTemplates: b.resourceTemplates, |
186 | 168 | prompts: b.prompts, |
187 | 169 | deprecatedAliases: b.deprecatedAliases, |
@@ -344,60 +326,3 @@ func (b *Builder) processToolsets() (map[ToolsetID]bool, []string, []ToolsetID, |
344 | 326 | } |
345 | 327 | return enabledToolsets, unrecognized, allToolsetIDs, validIDs, defaultToolsetIDList, descriptions |
346 | 328 | } |
347 | | - |
348 | | -// stripInsidersParameters removes insiders-only parameters from tool schemas. |
349 | | -// This creates shallow copies of tools that have insiders parameters to avoid |
350 | | -// mutating the original tool definitions. |
351 | | -func stripInsidersParameters(tools []ServerTool) []ServerTool { |
352 | | - result := make([]ServerTool, len(tools)) |
353 | | - for i, tool := range tools { |
354 | | - if modified, ok := removeInsidersParameters(tool.Tool.InputSchema); ok { |
355 | | - // Make a shallow copy of the tool |
356 | | - toolCopy := tool |
357 | | - toolCopy.Tool.InputSchema = modified |
358 | | - result[i] = toolCopy |
359 | | - } else { |
360 | | - result[i] = tool |
361 | | - } |
362 | | - } |
363 | | - return result |
364 | | -} |
365 | | - |
366 | | -// insidersParameters lists the parameter names that are insiders-only |
367 | | -var insidersParameters = map[string]bool{ |
368 | | - "show_ui": true, |
369 | | -} |
370 | | - |
371 | | -// removeInsidersParameters removes insiders-only parameters from a schema. |
372 | | -// Returns the modified schema and true if any changes were made. |
373 | | -// Handles *jsonschema.Schema type used by most tools. |
374 | | -func removeInsidersParameters(schema any) (any, bool) { |
375 | | - // Handle *jsonschema.Schema (the most common case) |
376 | | - if js, ok := schema.(*jsonschema.Schema); ok && js != nil { |
377 | | - if js.Properties == nil { |
378 | | - return schema, false |
379 | | - } |
380 | | - hasInsidersParam := false |
381 | | - for name := range js.Properties { |
382 | | - if insidersParameters[name] { |
383 | | - hasInsidersParam = true |
384 | | - break |
385 | | - } |
386 | | - } |
387 | | - if !hasInsidersParam { |
388 | | - return schema, false |
389 | | - } |
390 | | - // Create a new schema with insiders parameters removed |
391 | | - newProps := make(map[string]*jsonschema.Schema, len(js.Properties)) |
392 | | - for name, prop := range js.Properties { |
393 | | - if !insidersParameters[name] { |
394 | | - newProps[name] = prop |
395 | | - } |
396 | | - } |
397 | | - newSchema := *js // shallow copy |
398 | | - newSchema.Properties = newProps |
399 | | - return &newSchema, true |
400 | | - } |
401 | | - // For other types (json.RawMessage, map[string]any, etc.), leave unchanged |
402 | | - return schema, false |
403 | | -} |
0 commit comments