MCP: instance-scoped collection read/write (#91) - #101
Merged
Conversation
Add three MCP tools so an owner can read/write a subscribed instance's
collections over MCP instead of hand-rolling auth against
/v1/instances/:id/collections/*:
- list_instance_collections(instance_id) -> GET /v1/instances/:id/collections
- query_instance_records(instance_id, collection, where?, limit?, order_by?)
-> GET /v1/instances/:id/collections/:name/records
- insert_instance_record(instance_id, collection, data)
-> POST /v1/instances/:id/collections/:name/records ({data} body)
Reads gated behind the read scope, the write gated behind write, all
audited — matching the existing instance MCP tool conventions. Additive
only; agent-scoped storage tools are unchanged.
Closes #91
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closed
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #91.
Adds instance-scoped collection MCP tools — the agent-scoped storage tools 404 for instance ids, so there was no MCP path to read/write a subscribed instance's collections (external processes had to hand-roll REST auth).
Tools (in
workers/mcp/src/storage-tools.ts, auto-registered via existingregisterStorageTools)list_instance_collections(instance_id)→ GET/v1/instances/:id/collections—readscopequery_instance_records(instance_id, collection, where?, order_by?, limit?)→ GET records —readscopeinsert_instance_record(instance_id, collection, data)→ POST record —writescope, auditedMirror the agent-scoped equivalents exactly; route to
/v1/instances/...; owner-scoped + audited per instance-tool convention. Dedup/unique enforced by the DO (same path the console uses).Verify
pnpm --filter proagentstore-mcp typecheckcleanvitest run workers/mcp/→ 38 pass (6 new: registration, routes/methods, query-param build,{data}body, invalid-JSON rejection, write-scope gate)Reads are gated by
read(stricter than the ungated agent-scoped reads — followed the issue +list_instance_triggersprecedent).🤖 Generated with Claude Code