Skip to content

MCP tools/list returns uncallable tool names for aliased services (events, apps-script, admin-reports) #162

@abhinavkale-dev

Description

@abhinavkale-dev

When running gws mcp with a service alias (for example -s events), tools/list can return Discovery-prefixed names (workspaceevents_*) while tools/call validates service prefixes against configured aliases (events).

This makes a tool returned by tools/list fail in the same MCP session.

Environment

  • gws (affected): 0.3.4 (./.local/bin/gws)
  • gws (local fixed verification): ./target/debug/gws
  • OS: macOS (Apple Silicon)
  • MCP transport: stdio (gws mcp -s <services>)

Repro (before)

printf '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}\n' \
| ./.local/bin/gws mcp -s events | jq '.result.tools[] | select(.name=="workspaceevents_subscriptions_list")'

printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"workspaceevents_subscriptions_list","arguments":{}}}\n' \
| ./.local/bin/gws mcp -s events | jq '.'

Actual

tools/call fails with:

Service 'workspaceevents' is not enabled in this MCP session

Expected

Any tool name returned by tools/list should be callable in the same MCP session.

Additional Repros

Same pattern appears for:

  • -s apps-script (script_* from list vs apps-script alias validation)
  • -s admin-reports (admin_* from list vs admin-reports alias validation)

Likely Root Cause

In src/mcp_server.rs:

  • build_tools_list prefixes tool names with Discovery doc name (doc.name)
  • handle_tools_call validates parsed prefix against configured aliases (config.services)

So list and call use different namespaces for aliased services.

Suggested Fix

In src/mcp_server.rs, make tools/list use the configured alias as prefix (same namespace used by tools/call).

Current line in build_tools_list:

  • walk_resources(&doc.name, &doc.resources, &mut tools);

Proposed change:

  • walk_resources(svc_name, &doc.resources, &mut tools);

This makes -s events return events_* tool names, consistent with tools/call validation.

Verification (after local fix)

printf '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}\n' \
| ./target/debug/gws mcp -s events | jq '.result.tools[] | select(.name=="events_subscriptions_list")'

printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"events_subscriptions_list","arguments":{}}}\n' \
| ./target/debug/gws mcp -s events | jq '.'

Observed:

  • tools/list returns events_subscriptions_list
  • namespace mismatch error is gone
  • call proceeds to normal API/auth checks (any remaining errors are separate, e.g. scopes/API enablement)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions