Skip to content

MCP OAuth, plugin update, ACP approvals, custom commands over ACP with allowed-tools and @file - #15

Merged
blockmandev merged 10 commits into
mainfrom
claude/laughing-darwin-hyqkjj
Oct 20, 2026
Merged

blockmandev merged 10 commits into
mainfrom
claude/laughing-darwin-hyqkjj

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Summary

This is the work pushed after PR #14 was merged; #14 carried only the sbx engine commit.

MCP

  • OAuth 2.1 for remote servers:
    • protected-resource and authorization-server discovery, dynamic client registration, PKCE (S256) and the resource parameter;
    • a loopback callback;
    • tokens stored with 0600 permissions in ~/.incode/mcp-tokens.json, refreshed on expiry or a 401;
    • incode mcp login / logout, and auth status in incode mcp list.
  • A server that needs a login it lacks is skipped with the command to run; nothing waits on a browser.
  • A server's oauth entry is part of its approval key, so a changed client or wider scopes is asked about again.
  • --acp approvals: the client is asked (session/request_permission: allow once / always / reject) about an unapproved project server after session/new has been answered, and the server connects in the background. "Always" is remembered like incode mcp approve.
  • Fix: an HTTP POST now waits for the notification sent before it. notifications/initialized could reach a server after tools/list, which is against MCP's ordering; the fake server saw that in about 3 runs of 8.

Plugins

  • incode plugin update [name] [--project] re-fetches from the recorded git or path source into a staging folder and swaps it in, or leaves the old copy if anything fails.
  • An update whose manifest names a different plugin is refused.

Custom commands

  • Over --acp: listed after the built-ins, with description and hint, and expanded there as in the REPL.
  • allowed-tools is enforced for that one turn through the toolbox, on the API and Claude routes and in -t.
    • It never overrides the deny or ask rules, the guards or the permission mode.
    • On codex and agy, which run their own tools, the user gets a notice that it is not enforced.
  • @path includes in the command file's text:
    • kept inside the workspace (.., absolute paths outside and symlinks pointing out are refused);
    • capped at 256 KB per file and 1 MB in total;
    • emails and @mentions are left alone, and typed arguments are never read as files.

Tests

  • The ACP role-picker test now also reads the update that can race the reply; it used to fail about one run in four.

Test plan

  • cargo fmt --check and cargo clippy --all-targets (no warnings)
  • cargo test --lib: 2100 passed; cargo test --bins: 50 passed
  • cargo test --test sbx_engine and cargo test -p incord-sandbox: 78 passed
  • OAuth end to end against a local fake authorization server and MCP server (401 → login → call → refresh)
  • Run alone: the MCP HTTP test passed 15/15 and the ACP role-picker test 12/12 (both used to be flaky)
  • Windows browser opening for login, on a real machine
  • --acp approval and custom commands with a real editor; plugin update against a real remote

Generated by Claude Code

claude added 10 commits October 20, 2026 18:08
`incode plugin update [name] [--project]`: `add` now records where a plugin
came from in `.incode-source` (`git = ...` or `path = ...`; a plugin cloned
before falls back to its git origin). `update` fetches it again the same
way into a staging folder, refuses a manifest that names another plugin,
and swaps it in, printing old -> new version. No name updates every plugin
in that folder.

`--acp`: a project `.mcp.json` server not yet approved is no longer only
skipped. Once the session is answered the client is sent
`session/request_permission` (allow once / allow always / reject) on a
thread of its own; an allowed server connects in the background into the
session's servers (`LateServers`), and allow always is remembered like
`incode mcp approve`. A client that cannot answer, or does not within ten
minutes, gets the old skip-and-approve-command message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
The session applies a picked role at once when idle, so its
config_option_update can arrive before the set_config_option reply, where
Client::call dropped it. The test now keeps what came before the reply and
looks there too. It failed about one run in four alone; 12 of 12 pass now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
incode mcp login <name> runs the MCP authorization flow: a 401's
WWW-Authenticate resource_metadata (RFC 9728) names the authorization
server, whose metadata is read from RFC 8414 or OpenID well-known
addresses; dynamic client registration (RFC 7591) or a client_id from the
server's "oauth" entry; authorization code with PKCE S256 and the
resource parameter (RFC 8707), redirected to a one-request listener on
127.0.0.1. Tokens are kept in ~/.incode/mcp-tokens.json (0600), keyed by
server name and url, sent as Authorization: Bearer, refreshed before
expiry and once on a 401. A session never waits on a browser: a server
needing a login is skipped with the command that logs in. incode mcp
logout forgets the tokens; incode mcp list shows the status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
Resolved against the --acp approval work: OAuth binding moved into
Configured::spec(data_dir), so servers started after an editor approves
them get their token too. A server's `oauth` entry is now part of its
approval key (only when present, so existing approvals stay valid): a
changed client or wider scopes is asked about again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
…udes

- ACP: the project's, user's and plugins' commands follow the built-ins in
  available_commands (description, origin, argument-hint as the input hint),
  and `/name args` in a prompt is expanded into the turn before the
  slash-command dispatch, exactly as the REPL does.
- allowed-tools now holds the turn the command starts: its entries are
  permission rules (parsed and matched by permissions::rules::Allowlist,
  reusing the allow-list logic, so a compound shell line is covered only
  when every part is). AgentSession::restrict_next_turn sets it, the turn
  puts it on the shared SessionTools for its duration (a drop guard lifts
  it), and Toolbox::run_call refuses anything outside it with the list
  named. Binds on the API route and Claude Code (and `-t`); Codex/agy, which
  run their own tools, get a notice that it was not enforced.
- `@path` in a command body includes the file in a fenced block headed by
  its path: must resolve inside the workspace (.., symlinks, absolute paths
  checked after canonicalization), 256 KB per file, 1 MB in all, markers for
  what cannot be included; emails and user arguments are never read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
Each message was POSTed from its own task, so notifications/initialized
could reach the server after the tools/list sent right behind it, against
MCP's order (the OAuth token lookup before each POST widened the window;
the fake server saw it in about 3 runs of 8). The next POST now waits for
the last notification's POST to finish; requests may still overlap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
@blockmandev
blockmandev merged commit d0ac4a8 into main Oct 20, 2026
0 of 4 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