Skip to content

feat(read): HTTP file reads can run repository read plugins - #34

Merged
qiansc merged 1 commit into
mainfrom
sync/http-read-plugins
Dec 3, 2026
Merged

qiansc merged 1 commit into
mainfrom
sync/http-read-plugins

Conversation

@qiansc

@qiansc qiansc commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Background

Repository read plugins (for example a knowledge workspace's evidence plugin) ran only for MCP read/read_many. HTTP clients reading files through POST /v1/repo/read could not get the plugin attachments.

Changes

  • POST /v1/repo/read accepts two optional fields:
    • PluginMode: off (default) or auto. auto selects the plugins whose Wasm declares default_enabled, the same as an MCP read without plugins.
    • Plugins: [{"Name","Args"}] runs exactly these plugins and wins over PluginMode. [] runs none.
  • Invalid names, duplicate names, more than 16 names or an unknown PluginMode return 400 INVALID_PLUGINS. Validation is the same as MCP.
  • When plugins added something, the file object gains:
    • Attachments: [{"Plugin","Text"}], with "Batch":true on whole-invocation supplements, in the MCP order.
    • PluginDiagnostics: [{"Code","Message"}].
  • A plugin failure never changes Content or the HTTP status.
  • The handler calls the same Service.ReadWithPlugins as MCP. Without the new fields it calls Read as before.
  • docs/ref/repository-plugins.md and web/plugins/llms.txt gain an "HTTP 读取" section.

Compatibility

Without the new fields, requests, responses and performance are unchanged. A test checks that the response is byte-identical.

Tests

  • go test -p 1 ./... with MongoDB: all packages pass except sitesettings TestMongoStoreLoadsAllSections. That test is pre-existing, fails the same way on main and is not touched here.
  • New tests cover:
    • unchanged bytes without the new fields;
    • auto and explicit selection;
    • plugin scope and nearest-ancestor shadowing;
    • plugin failure keeping the body;
    • INVALID_PLUGINS at the service and route level;
    • attachment shape and the diagnostics budget.
  • bun run build:web and bun run check:web pass.

🤖 Generated with Claude Code

POST /v1/repo/read accepts two optional fields:

- PluginMode: "off" (default) or "auto" (plugins whose Wasm declares
  default_enabled for read, as MCP read without plugins).
- Plugins: [{"Name","Args"}] runs exactly these plugins and wins over
  PluginMode; [] runs none. Names and limits follow MCP; invalid choices
  return 400 INVALID_PLUGINS.

When plugins ran and produced something, the file object gains
Attachments ([{"Plugin","Text"}], whole-invocation supplements carry
"Batch":true; MCP order) and PluginDiagnostics ([{"Code","Message"}]).
A plugin failure keeps the body and the HTTP status. The read runs the
same Service.ReadWithPlugins as MCP read; without the new fields the
handler calls Read exactly as before and the response is byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 13b7daa into main Dec 3, 2026
3 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.

1 participant