Skip to content

Add a command to list the Platform MCP server's tools - #25

Merged
miqui merged 1 commit into
mainfrom
mcp-tools-list
Nov 17, 2026
Merged

miqui merged 1 commit into
mainfrom
mcp-tools-list

Conversation

@miqui

@miqui miqui commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Closes #3

Summary

  • adapt mcp tools lists the built-in tools of Platform's hosted MCP server (POST /mcp, JSON-RPC tools/list). A terminal shows NAME, ACCESS (read-only, write or destructive, from each tool's annotations) and the first sentence of each description. Piped or --json output is the server's {"tools":[...]} result, unchanged.
  • adapt mcp tools NAME prints one tool's full description, input schema and annotations.
  • The CLI sends Accept: application/json, text/event-stream and MCP-Protocol-Version: 2025-03-26, the version Platform's docs and tests use, and reads either a JSON or an event-stream reply. It skips notifications and returns as soon as the response with its request ID arrives.
  • It follows nextCursor to the last page and stops on a repeated cursor. Platform currently returns every tool in one page.
  • A JSON-RPC error inside an HTTP 200 exits with code 1 (MCP tools/list failed: CODE MESSAGE).

Authentication

The issue asks for the existing authentication, but /mcp deliberately accepts organization API keys and never CLI sign-in sessions. Platform's mcp.integration.test.ts has a test named "never accepts session bearer tokens". So:

  • A saved browser login is refused before any request is sent. The message explains how to save a key with adapt auth login --token-stdin (optionally in its own --profile) or use ADAPT_TOKEN.
  • A 401 gets an API-key hint instead of the usual "run adapt auth login", which would only produce another session. A session token supplied through ADAPT_TOKEN can't be detected up front, so it gets this message.
  • A 403 for an organization mismatch explains that a key works only in its own organization. X-Organization-Id is sent as for every other command.

Changes beyond mcp tools

  • The terminal table renderer moves out of output::print into output::table, which takes any writer. Existing tables are byte-for-byte unchanged (checked in a terminal against the 0.1.0 release), and the renderer now has unit tests.
  • The SSE Decoder in stream.rs is now pub(crate) so the new module can reuse it.
  • mcp list and mcp revoke get help text.

Docs

docs/cli-reference.md gets a Platform MCP tools section and drops the line that put the /mcp transport out of scope. docs/api-coverage.md and the bundled skill are updated.

Testing

  • tests/mcp_tools/mod.rs has 13 mock-server tests: SSE and JSON replies, request headers and body, following two pages, a repeated cursor, a JSON-RPC error, a stream that ends before the result, the 401 and 403 hints, refusing a saved session without sending a request, a saved API key, not signed in, a tool by name and an unknown name.
  • Unit tests cover the access mapping (with MCP's hint defaults), the first-sentence summary, JSON-RPC response matching and the table renderer.
  • I also ran it against a local Platform (a local branch with current main merged), using an API key from a throwaway local account:
    • mcp tools --json is identical to the result of the docs' curl request (39 tools).
    • The table and single-tool views render in a terminal.
    • Session refusal, 401 for a session token and for a deleted key, 403 for a wrong --org, and an unknown name all exit 1 with the expected messages.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test --locked pass.

Known limits

  • There is no automatic retry. The request is a POST, and the CLI only retries GET and HEAD reads.
  • The protocol version is pinned to 2025-03-26. If Platform stops serving 2025-era MCP, the command fails with the server's unsupported-version error.
  • ACCESS is the tool's own hint, not the key's permissions. Platform lists every tool to every caller.

🤖 Generated with Claude Code

`adapt mcp tools` sends a JSON-RPC `tools/list` request to Platform's
hosted MCP server at `/mcp` and lists its built-in tools: a NAME / ACCESS /
DESCRIPTION table in a terminal, or the server's `{"tools":[...]}` result
as JSON. `adapt mcp tools NAME` prints one tool's full definition,
including its input schema.

Platform serves 2025-era MCP statelessly, so one request per page needs no
initialize handshake. The CLI sends the required Accept and
MCP-Protocol-Version (2025-03-26) headers, reads JSON or event-stream
replies, follows nextCursor, and exits non-zero on JSON-RPC errors.

`/mcp` accepts organization API keys but never CLI sign-in sessions, so the
command refuses a saved browser login before sending it, and 401 and 403
replies explain the API-key requirement instead of suggesting a new login.

The terminal table renderer moves into a shared `output::table` function
with unit tests; existing tables are unchanged.

Closes #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@the-adaptile the-adaptile Bot 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.

Confidence Score: 4/5

Summary

Adds API-key-authenticated MCP tool discovery, pagination, and terminal output. Risk centers on transport compatibility and shared rendering. Local formatting, Clippy, 99 tests, and 14 additional checks passed; deployed Platform integration was not exercised.

Deployed verification not applicable: adapt/platform-cli is outside the adapt/adapt and adapt/platform pilot. Its CI builds CLI artifacts, not PR previews. No webhook sent.

Important Files Changed

File Changes
src/mcp.rs MCP transport, response matching, pagination, authentication guidance, and tool formatting.
src/commands.rs Credential-kind detection and MCP tools dispatch using existing origin and organization resolution.
src/cli.rs New tools subcommand and MCP client-management help.
src/output.rs Shared table renderer extraction and formatting tests.
src/stream.rs Exposes the existing incremental SSE decoder within the crate.
tests/mcp_tools/mod.rs Mock-server coverage for transport, pagination, authentication, errors, and named tool lookup.
docs/cli-reference.md Documents tool discovery, API-key authentication, output, and transport limits.
skills/adapt/SKILL.md Distinguishes hosted Platform tools from connected services and authorized MCP clients.

Run info

Field ID
Agent 0d6ccd7e-b62f-4075-a561-199d1a7b1bf0
Automation ec14e69d-634f-4af0-a6dd-27aa06a1f6b3
Run 270e68e1-15de-472b-99aa-645cfa712cf6

Reviewed: 27e068c-dae4675 · ↻ Re-run review

@miqui
miqui merged commit 8939b72 into main Nov 17, 2026
8 checks passed
@scsmithr

Copy link
Copy Markdown
Contributor

This isn't an acceptable ux

$ adapt mcp tools
error: The Platform MCP server accepts organization API keys, not CLI sign-in sessions. Create a key with `adapt keys create NAME` and save it in its o
wn profile with `adapt --profile PROFILE auth login --token-stdin`, or set ADAPT_TOKEN to the key

@adapt adapt deleted a comment from adapt Bot Nov 17, 2026
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.

Add a command to list the Platform MCP server tools

2 participants