Skip to content

fix(mcp): resolve mcp: selectors for servers with directTools "search" or ${NAME:-default} - #3201

Open
acolomba wants to merge 4 commits into
nicobailon:mainfrom
acolomba:fix/mcp-adapter-config-compat
Open

acolomba wants to merge 4 commits into
nicobailon:mainfrom
acolomba:fix/mcp-adapter-config-compat

Conversation

@acolomba

@acolomba acolomba commented Nov 5, 2026 •

Copy link
Copy Markdown

pi-subagents reads the configuration and the metadata cache of pi-mcp-adapter to resolve mcp:<server>/<tool> selectors. To do this, it must accept the same configuration values as the adapter and hash each server the same way. Two adapter behaviors left selectors unresolved for servers that work in the parent session.

First, a server or the settings block can set directTools: "search". The configuration validator accepted only a boolean or a string array, so it dropped such a server from the loaded configuration and reported every selector for it as unresolved. A runtime snapshot of such a server failed validation the same way.

Second, env, headers, url, paths, and the bearer token can contain ${NAME:-default}. The adapter expands this value before it hashes a server for its metadata cache, and it uses the default only when NAME is unset, as Claude Code does in .mcp.json (see nicobailon/pi-mcp-adapter#878). pi-subagents expanded only ${NAME}, so its hashes never matched the cached configHash and the selectors stayed unresolved. A URL that used a default did not parse, and the launch failed.

Changes

  • isMcpServerDefinition and parseSettings accept "search". Selector resolution does not read directTools, and in the adapter the child's MCP_DIRECT_TOOLS selection overrides it, so nothing else changes.
  • interpolateEnvVars uses the adapter's ${NAME:-default} pattern, and a variable that has a default is no longer reported as missing from a server URL. Both functions now match the adapter's utils.ts.
  • New tests: a "search" server resolves its selectors. For variables with defaults in env, headers, and url that are set, empty, or unset, computeMcpServerHash returns the same hash as the adapter's computeServerHash with the same environment.
  • A CHANGELOG entry under Unreleased, Fixed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EDUMG8NLFeCSk6tpjb3zGL

acolomba and others added 2 commits November 5, 2026 18:41
…-default}

pi-mcp-adapter accepts `directTools: "search"` on a server and in
`settings`, and expands `${NAME:-default}` in a server's env, headers,
url, paths and bearer token before it hashes the server for its
metadata cache. pi-subagents handled neither:

- Its config validator accepted only a boolean or a string array for
  `directTools`, so it dropped a "search" server from the loaded config
  and reported every `mcp:<server>/<tool>` selector for it as
  unresolved. A runtime snapshot of such a server failed the same way.
- It expanded only `${NAME}`, so a server that used a default never
  matched the adapter's cache key and its selectors stayed unresolved.
  A url that used a default failed to parse, which failed the launch.

Accept "search" in both places. Selector resolution does not read
`directTools`, and the child's MCP_DIRECT_TOOLS selection overrides it
in the adapter, so "search" needs no other handling. Use the adapter's
`${NAME:-default}` pattern in interpolateEnvVars, and do not report a
variable with a default as missing from a server url.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EDUMG8NLFeCSk6tpjb3zGL
@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No code findings remain, but merge readiness still depends on confirming required CI on the exact PR head.

Summary

The PR accepts directTools: "search" and expands ${NAME:-default} so MCP selectors can match the adapter’s cached tools.

  • Servers marked directTools: "search" can resolve MCP selectors.
  • MCP selectors match servers that use environment defaults.

Reviews (3) · Last reviewed commit: "docs(changelog): credit #3201 in the mcp..." · Reviewed by Greptile

Comment thread CHANGELOG.md Resolved
@acolomba acolomba changed the title fix(mcp): resolve mcp: selectors for directTools "search" and ${NAME:-default} fix(mcp): resolve mcp: selectors for servers with directTools "search" or ${NAME:-default} Nov 5, 2026
acolomba and others added 2 commits November 5, 2026 18:52

This branch has not been deployed

No deployments
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.

1 participant