Skip to content

Add tool enable/disable and auto-discovery of function names#3

Merged
BillJr99 merged 1 commit into
mainfrom
claude/function-menu-introspection-fSuvc
May 25, 2026
Merged

Add tool enable/disable and auto-discovery of function names#3
BillJr99 merged 1 commit into
mainfrom
claude/function-menu-introspection-fSuvc

Conversation

@BillJr99

Copy link
Copy Markdown
Owner

Summary

This PR adds the ability to enable/disable individual tools in provider configurations and implements automatic discovery of available function/tool names from code blocks and package introspection. Tools can now be toggled on/off without losing their schema, and the UI provides smart dropdowns for selecting function names when available.

Key Changes

Tool Enable/Disable Feature

  • Added enabled field to tool specs (defaults to true when missing)
  • Tools with enabled: false are kept in YAML but not registered with MCP or advertised to the LLM
  • UI includes a toggle switch in each tool card header to enable/disable tools
  • Disabled tools are visually de-emphasized with reduced opacity and a "disabled" badge
  • Both _provider_to_structured() and _structured_to_yaml() now handle the enabled field

Tool Name Prefixing & Normalization

  • Implemented normalize_provider_name() to convert provider names to MCP-safe identifiers ([a-zA-Z0-9-])
  • Implemented advertised_tool_name() to create namespaced tool names: <provider>__<tool>
  • Updated register_tool() to accept an optional advertised_name parameter for prefixed registration
  • Updated register_provider() to skip disabled tools and register enabled tools with prefixed names
  • Built-in tools now use the __ separator: mcpproxy__listfiles and mcpproxy__getfile

Auto-Discovery of Function Names

  • Added discoverFunctions() JS function that:
    • For code providers: parses the code block to extract async def function names
    • For package providers: introspects the command via /api/introspect to get available tools
    • Updates knownFunctions array and displays discovery status
  • Added /api/extract-functions endpoint to parse Python code and extract function definitions
  • Function/tool name fields now render as a dropdown + text input combo when names are known
  • Dropdown includes discovered names plus an "Other…" option for custom values
  • Discovery runs automatically when:
    • A provider is opened
    • Code changes (debounced 300ms)
    • Package command field loses focus
    • User clicks the new "↻ Re-scan" button
  • Failure is silent — UI gracefully falls back to free-form text input

UI Improvements

  • Replaced manual "🔍 Introspect Tools" and "🔍 Analyze Functions" buttons with auto-discovery
  • Added "↻ Re-scan" button to manually trigger discovery
  • Added discovery status indicator showing "Analyzing code…", "Introspecting package…", or results
  • Function/tool name picker uses a new .fn-pick-row layout with dropdown + input
  • Added visual styling for disabled tools (.badge-disabled, .tool-card.disabled)
  • Added form styling for checkboxes (.form-check-input)
  • Wizard now auto-introspects on "Next" button click instead of requiring manual action

Wizard Improvements

  • Package wizard auto-introspects when advancing to the next step
  • Code wizard provides live function detection as user types
  • Both use debounced analysis to avoid excessive processing

Testing

  • Added comprehensive tests for normalize_provider_name(), advertised_tool_name(), and tool_is_enabled()
  • Added tests for register_provider() prefixing and disabled tool filtering
  • Updated existing tests to expect the new enabled field in tool specs
  • Updated test assertions to use the new __ separator in tool names

Notable Implementation Details

  • The enabled field is always written explicitly to YAML (never omitted) for clarity
  • Missing enabled field in existing YAML defaults to true for backward compatibility
  • Tool names in YAML remain unprefixed; the prefix is added only when registering with MCP
  • Discovery status is stored in module-level JS variables (knownFunctions, knownFnStatus, knownFnMessage)
  • Dropdown selection is kept in sync with text input via _syncFnPick() as user types
  • Disabled tools are skipped during registration without attempting to load their handlers

https://claude.ai/code/session_01KRZQTKxffN7toaSDh71D6e

… names

The UI no longer requires manually clicking Introspect / Analyze — both run
automatically (introspect on provider open / package-command blur; analyze
on every code edit, debounced). When discovery succeeds, the tool-name and
function-name fields become a dropdown of legal values plus an "Other…"
option for free-form entry. Failure is silent: the dropdown only shows
"Other…" so users can always type a custom value, matching the previous
behaviour.

Each tool now has a per-card enable/disable switch persisted to YAML as
`enabled: true|false` (always written; absent means true for backward
compatibility with pre-existing YAML files). Disabled tools are kept in
the file but skipped during MCP registration, so they never reach the LLM.

Every tool is now advertised to MCP clients as `<provider>__<tool>`. The
provider name is the YAML filename normalized to `[a-zA-Z0-9-]`. This makes
tool-name collisions across providers impossible. Built-in tools follow
the same convention: `mcpproxy__listfiles` and `mcpproxy__getfile`. The
upstream tool name used when proxying to package subprocesses is still the
unprefixed name from the YAML.

Tests, README, and the integration shell script are updated accordingly;
existing YAML files require no migration.

https://claude.ai/code/session_01KRZQTKxffN7toaSDh71D6e
@BillJr99 BillJr99 merged commit 8149f60 into main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants