Skip to content

feat(mcp): list tools exposed by MCP servers - #49151

Open
zonemeen wants to merge 1 commit into
anomalyco:devfrom
zonemeen:mcp-tools
Open

zonemeen wants to merge 1 commit into
anomalyco:devfrom
zonemeen:mcp-tools

Conversation

@zonemeen

Copy link
Copy Markdown

Issue for this PR

Closes #41499

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • Add opencode mcp tools to list tools grouped by server, and opencode mcp tools <name> to include tool descriptions without starting a chat.
  • Reuse existing MCP discovery and preserve original tool names. Report disabled servers, authentication requirements, and connection failures separately from empty tool lists.

How did you verify your code works?

  • CLI integration tests, help snapshots, and MCP/session regression tests: 102 passed, 1 existing skip.
  • bun typecheck, Prettier, and git diff --check passed.

Screenshots / recordings

Actual CLI output rendered from a local MCP demo, showing the server overview and tool descriptions.

image image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@holny holny left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the new suite locally at 3dce088: mcp-tools 7/7 and the help snapshots 35/35 pass (had to run the snapshots with LC_ALL=C — with my default locale yargs prints localized labels, which is a local environment thing, not this PR). The status branch coverage is good: aggregate vs named mode, description suppression in aggregate mode, empty tool list, missing server, disabled/failed/needs_auth all checked.

Two things I'd ask about before this lands:

  1. mcp tools exits non-zero whenever any configured server isn't connected, while mcp list always exits 0. In the unfiltered overview a disabled server is tolerated but needs_auth isn't, so plain opencode mcp tools fails on any machine where one unrelated server happens to need auth. If that's deliberate it probably deserves a comment marking the asymmetry; if the overview is meant to be informational, only failing for a requested name (or not failing at all in overview mode) would match the rest of the subcommands.

  2. The listing prints the raw MCP tool name, but the registered name is sanitize(server)_sanitize(tool) (catalog.ts:119, applied at mcp/index.ts:624) — that's what shows up in tool calls and permission configs. Worth saying which one this command lists, or showing the registered form, so people don't copy a name that doesn't match what they see in a session.

Small thing otherwise, but the needs_auth hint pointing at opencode mcp auth <name> is a nice touch.

@zonemeen

Copy link
Copy Markdown
Author

Ran the new suite locally at 3dce088: mcp-tools 7/7 and the help snapshots 35/35 pass (had to run the snapshots with LC_ALL=C — with my default locale yargs prints localized labels, which is a local environment thing, not this PR). The status branch coverage is good: aggregate vs named mode, description suppression in aggregate mode, empty tool list, missing server, disabled/failed/needs_auth all checked.

Two things I'd ask about before this lands:

  1. mcp tools exits non-zero whenever any configured server isn't connected, while mcp list always exits 0. In the unfiltered overview a disabled server is tolerated but needs_auth isn't, so plain opencode mcp tools fails on any machine where one unrelated server happens to need auth. If that's deliberate it probably deserves a comment marking the asymmetry; if the overview is meant to be informational, only failing for a requested name (or not failing at all in overview mode) would match the rest of the subcommands.
  2. The listing prints the raw MCP tool name, but the registered name is sanitize(server)_sanitize(tool) (catalog.ts:119, applied at mcp/index.ts:624) — that's what shows up in tool calls and permission configs. Worth saying which one this command lists, or showing the registered form, so people don't copy a name that doesn't match what they see in a session.

Small thing otherwise, but the needs_auth hint pointing at opencode mcp auth <name> is a nice touch.

Thanks for testing this and sharing the feedback!

The current exit behavior treats connection/authentication failures as an incomplete tool listing, while disabled servers are intentionally skipped in overview mode.

For naming, this command lists the tools exposed by each MCP server, so it preserves the original names and groups them by server. I agree that these can differ from the registered names used in sessions and permission configs.

I'd prefer to keep the current behavior, but I'm open to maintainer guidance on these two choices.

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.

[FEATURE]: opencode cli can list tools available through connected mcp server

2 participants