Skip to content

A deployment can serve code.scip_ingest and code.scip_status over MCP, for its repositories only - #916

Merged
zlareb1 merged 4 commits into
mainfrom
pufit/mcp-code-upload-tools
Nov 18, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
pufit/mcp-code-upload-tools

Conversation

@pufit

@pufit pufit commented Nov 18, 2026

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

LOOM_MCP_CODE_UPLOAD_TOOLS=true serves code.scip_ingest and code.scip_status over MCP, by tool name and through loom_op, for an uploader that reaches Loom through MCP only. With it on, code.scip_ingest accepts an upload only for a namespace that has a repository entry. Default off.

Why

MCP hides code.scip_ingest and code.scip_status with the rest of the ingest surface. The callers they were written for post to /v1: a CI job, and the compiler-tier workers' own harness. A producer whose only route to the deployment is an MCP connection, such as a build environment behind an MCP gateway, builds a compiler-tier index and cannot deliver it: a direct tools/call and loom_op both answer OP_NOT_ON_MCP.

LOOM_MCP_CODE_UPLOAD_TOOLS takes the two ops off the hidden set for the deployment that sets it. Both are then callable by tool name and through loom_op on every toolset but assistant; on readonly, loom_op routes the status only, as it routes no write. all lists them by its existing rules (both are stable, and a code.* op needs LOOM_MCP_CODE_TOOLS=true), readonly then lists code.scip_status, and no curated roster names either. A scripted uploader calls a tool by name, and a tool listed on core or coding costs tokens in every session.

Serving the upload over MCP changes who reaches it. Hidden, it is reached by programs that post to /v1. On MCP it is reached by every caller that holds the writer role on some namespace, and an agent holds that role on its own memory namespace. The handler takes any namespace its caller may write, the staging table keeps a part for seven days, and the apply worker reads a complete batch whole. So with the setting on, the handler accepts a part only for a namespace that has a repository entry, operator-configured or self-service, and answers RESOURCE_NOT_FOUND for any other, as code.refresh answers for a namespace that is not configured. With the setting off the handler makes no such check.

The operation catalogue stays a registry fact. ops.capabilities, the reach census and the generated operation tables report both ops as hidden whatever the setting, as they report the code.* ops without reading LOOM_MCP_CODE_TOOLS. The MCP reference says what the setting serves.

Alternatives and what each costs:

  • Listing the two ops on core or coding. An uploader needs a callable tool, not a listed one, and both listings have a token ceiling.
  • Taking both ops off the hidden set on every deployment. Every deployment's agents would reach the upload, and the namespace rule would have to hold everywhere, where it refuses the uploads the apply worker takes today for a namespace without an entry.
  • Applying the namespace rule only to a call that arrives over MCP. The handler does not know its transport, and one rule per deployment is simpler to state and to test than one per transport.

Scope and risk

  • Touches server/settings (one field, one clause in the mcp_toolset comment), server/operations/toolsets.py (the two ops in their own set, one predicate, a keyword on listed_under_all), the three MCP modules that tested the hidden set (mcp_op.py, mcp_call.py, mcp_tools.py), server/code/app/ingest.py (one check before any write), three documentation pages and the generated settings references.
  • Leaves alone: the two ops' declarations, roles, audit and rate limits; the upload size limits; the apply worker; code.refresh; the curated rosters and their token ceilings; and what describes the default, which is ops.capabilities, op_toolsets, the reach census, the action manifest and the mentor's notes.
  • Auth and tenant isolation: no gate changes. Over MCP the two ops pass the pre-dispatch namespace screen and the role check every op passes, and a restricted namespace keeps its rule. With the setting on, an MCP caller that holds the writer role on a repository's namespace can upload a delta there, as the same token could over HTTP, and the apply worker applies it. A flat token whose namespaces claim is * holds the role it carries on every standard code namespace of its org. A grant row of its subject does not narrow it: the cap applies to a claim that names the namespace, never to *; an ns_write claim and the restricted classification do narrow it. Such a token could already upload to each of them over HTTP, and the setting adds the MCP route. So a deployment that turns the setting on gives no agent a flat * token with the writer role, and gives its uploader a token that names the repository's namespace.
  • With the setting on, a namespace without a repository entry takes no upload, over HTTP either. The apply worker names the case this excludes, a namespace indexed by the CLI alone; listing the repository in LOOM_CODE_REPOS_JSON restores its uploads.
  • The entry check reads the process's repository snapshot, as code.refresh and the code reads do. A self-service repository added on another replica is known within LOOM_CODE_REPOS_REFRESH_SECONDS (30 by default), and until the registry's first read the op answers 503, as the other code ops do.
  • Over MCP, a code tool's namespace that the caller cannot read and that names a repository (owner/name, or its name) resolves to that repository's code namespace, the default branch's when it has several, and the result says so (namespace_resolved). The upload is a code tool, so an uploader names the exact namespace.
  • No stored data, schema or concurrency change.

Compatibility, rollout and rollback

  • Wire: no op or field added, changed or removed, and no new error code. With the setting on, the two ops stop answering OP_NOT_ON_MCP over MCP, and code.scip_ingest answers RESOURCE_NOT_FOUND (404 over HTTP) for a namespace without a repository entry on every transport.
  • Settings: one new boolean, LOOM_MCP_CODE_UPLOAD_TOOLS, default false, read at start. No default changes.
  • Operator steps: none for a deployment that leaves it off. To use it, set it and restart. Uploads are applied by the code_scip_apply worker, which LOOM_CODE_SCIP_APPLY_ENABLED starts, as before.
  • Rolling upgrade: a build that does not know the setting logs and ignores it, so its processes keep answering OP_NOT_ON_MCP until they are replaced.
  • Rollback: reverting hides the two ops again. Parts and batches uploaded meanwhile stay in the staging tables until their TTL, and a complete batch is applied as before. No migration; the generated references and the defaults snapshot revert with the code.

Tests

  • tests/unit/test_mcp_code_upload_tools.py (new) calls the MCP endpoint with the real handlers and a store that keeps the parts in memory.
    • Off: no toolset lists either op with the code tools on, a call by tool name and one through loom_op answer OP_NOT_ON_MCP for both ops, and the loom_op help catalogue omits both.
    • On: one part sent by tool name and one through loom_op complete a batch, and code.scip_status reports it by either route. all lists both with the code tools and neither without, readonly lists the status only, and core, coding, atomic, tasks, tracker and assistant list neither.
    • On, a part for a namespace without a repository entry answers RESOURCE_NOT_FOUND by either route and stores nothing.
    • On, the two upload ops are the only hidden ops MCP serves, and code.refresh, hidden beside them, still answers OP_NOT_ON_MCP by either route.
    • ops.capabilities reports both ops as hidden with the setting on.
  • tests/unit/test_code_scip_ingest.py: the handler takes a part for a namespace without an entry while the setting is off and refuses the next part once it is on; an operator entry and a self-service entry both take a part; with the setting on and the self-service registry not read yet, the op answers 503 and stores nothing.
  • tests/unit/test_op_transport_contract.py: with the setting on, a viewer's upload over MCP answers AUTH_INSUFFICIENT and runs no handler, and a writer's upload and a viewer's status call reach their handlers.
  • The MCP listing tests (test_mcp_listing_budget.py, test_mcp_toolset.py, test_mcp_coding_toolset.py, test_mcp_assistant_toolset.py) also pass with the setting forced on, so listing the two tools under all breaks no text rule or token ceiling.
  • make lint and make typecheck pass. The regenerated diff is the new setting in configuration.md, status.md, loom.example.yaml, the settings schema and the defaults snapshot, plus the reworded mcp_toolset description; docs/reference/operations.md, operations/code.md, errors.md, the reach manifest and the SDK tables are unchanged.
  • Format: ruff format --check, Biome, Prettier and Taplo pass over the tree. make format-check itself did not start locally because shfmt is not installed there; the change has no shell file.
  • pytest tests/unit -n auto ran on macOS, where the suite is red with or without this change: the parse child's address-space limit is refused there, so the tests that parse source fail, and the local clickhouse binary rejects settings the SQL tests pass. With coverage it reported 1221 failed and 38677 passed; on the base commit, without coverage, 1223 failed and 38666 passed. No test fails only with this change, and the nine test ids it had at that point pass; the two added since pass in the focused runs. pytest bench -q passes (251). CI's Linux run is the gate for the full suite.
  • Not run locally: the integration suite, the mixed-version gate and the container smoke jobs. With the setting off, the MCP hidden-set test answers as before and code.scip_ingest skips the new check.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked: every place the MCP transport tests the hidden set (the listing, the direct call, loom_op's routing, its help catalogue and its refusal); the three states through the MCP endpoint with the real handlers; that the catalogue and every generated operation table are unchanged; the regenerated diff, which holds the one setting and the reworded mcp_toolset description; each documentation sentence against the code path it names.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

…, for its repositories only

MCP hides the two compiler-tier upload ops with the rest of the ingest surface:
their callers post to /v1. A producer whose only route to the deployment is an MCP
connection builds a compiler-tier index and cannot deliver it, since a call by tool
name and one through loom_op both answer OP_NOT_ON_MCP.

LOOM_MCP_CODE_UPLOAD_TOOLS takes the two ops off the hidden set. Both are then
callable by tool name and through loom_op, and `all` lists them by its own rules.
No curated roster names them, so the default listings keep their token ceilings,
and the operation catalogue keeps describing the default.

On MCP the upload is reached by every caller that may write some namespace, a
memory namespace of its own included, and the handler took any namespace. With the
setting on it accepts a part only for a namespace that has a repository entry and
answers RESOURCE_NOT_FOUND for any other, as code.refresh does. With the setting
off neither the listing nor the handler changes.

Signed-off-by: pufit <[email protected]>
… named repository's upload lands

No test failed if the predicate that takes code.scip_ingest and code.scip_status
off the hidden set started to un-hide another op: every assertion named the two
ops, and the test that every hidden op answers OP_NOT_ON_MCP runs with the setting
off. The 503 the upload answers while the self-service registry is not read yet,
when which namespaces have a repository entry is not known, had no test either.

The MCP reference tells an uploader to send the namespace itself: a code tool's
namespace that names a repository, and is not a namespace the caller can read,
resolves to the index of the repository's default branch, and the upload lands
there. The system overview said that MCP never calls a hidden op; it names the
setting that serves the two.

Signed-off-by: pufit <[email protected]>
@zlareb1 zlareb1 self-assigned this Nov 18, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No findings in MCP visibility and routing, role and namespace authorization, repository-entry refusals, or the unchanged default catalogue. All 291 focused upload, transport, toolset and settings tests pass locally; the four generated-reference checks pass. Live database uploads were validated by CI rather than locally.

@zlareb1 zlareb1 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This branch has a merge conflict with main. Resolve the conflict and let CI pass before merging.

@zlareb1
zlareb1 merged commit d9299a6 into main Nov 18, 2026
51 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
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