Skip to content

examples: add mcp-shared-drive, an MCP server secured per tool call - #83

Merged
samkim merged 13 commits into
mainfrom
demo/mcp-shared-drive
Nov 30, 2026
Merged

samkim merged 13 commits into
mainfrom
demo/mcp-shared-drive

Conversation

@sohanmaheshwar

Copy link
Copy Markdown
Contributor

Motivation

We had no example showing what OAP adds in front of an existing MCP server. The common real-world setup is one MCP server reached with one shared credential. A prompt injection in any file the agent reads can then steer it to anything that credential reaches, and the server has no idea who is asking.

This sample shows that situation and the fix side by side. A new docs tutorial walks through it: authzed/docs#612.

Summary of changes

Adds examples/mcp-shared-drive, a before/after demo over one unmodified MCP filesystem server (@modelcontextprotocol/server-filesystem, served over Streamable HTTP) that holds a fictional company drive:

  • server/: the filesystem server image and the drive. /shared/eng/q3-budget-update-template.md carries the planted instruction to list per-person salaries from /shared/finance.
  • before/: a plain Python agent that connects straight to the server. It follows the template, reads payroll.csv, and writes salaries into a draft all of eng can read.
  • manifests/ and oap.yaml: the same model and authored system prompt on OAP. A SidecarToolbox puts a SpiceDB check on every tool, mapping the path argument to a file or folder. The AgentClass checks as currentRequester in enforcing mode.
  • cluster/: the permission model and its seed. Nobody holds approve on the finance folder or payroll.csv, so those refusals are final. Bob holds approve on eng-budget-q3.csv, so a request for it routes to him in Slack.
  • README.md: the runbook, plus what the demo does and does not claim.

Everything is under examples/; nothing outside it changes.

Alternatives considered

  • Claude Code as the "before" agent. OAP runs its own agent loop rather than wrapping a harness, so a small script that uses the same model and system prompt is the fairer comparison.
  • A purpose-built MCP server with per-user checks inside it. That would hide the point: the server stays unmodified and the checks live in OAP and SpiceDB.

Provenance

  • Author (person, or model and version): Claude Opus 5.5 (claude-opus-5-5), directed by @sohanmaheshwar
  • Harness or tooling, with version: Claude Code
  • Person who read the diff: not yet

Ship gate

  • mage test:unit
  • mage test:integration
  • mage test:e2e

Results:

Run sequentially on f57130a1 (this branch rebased on main), GOTOOLCHAIN=go1.26.6:
mage test:unit         exit 0   570 packages ok, 0 FAIL   (load 8.05 at end)
mage test:integration  exit 0   509 packages ok, 0 FAIL   (load 4.88 at end)
mage test:e2e          exit 0    64 packages ok, 0 FAIL   (load 2.85 at end)

Beyond the gate, the branch is rebased on current main, and oap agent package examples/mcp-shared-drive, run from a clean git archive, produces shared-drive-agent.oap. The publish-agents workflow packages every example after a merge to main. The whole flow in the tutorial was also run by hand against a fresh kind cluster and Slack.

Regeneration

  • Changed a +kubebuilder:rbac marker or a CRD-shaping field in
    pkg/apis/v1alpha1/*_types.go → ran mage gen:api and
    mage manifests: n/a
  • Edited anything under config/** → ran mage manifests: n/a
  • Changed a cobra command or a CRD schema → ran mage docs:cli /
    mage docs:crd: n/a
  • Ran mage fmt:all until mage fmt:check is clean: n/a, no Go changes

Coverage

  • This adds user-visible behavior, and a bronzethread bundle exercises it
    (test/e2e/bronzethread/testdata/<name>/), or it does not add
    user-visible behavior. It adds an example, not product behavior.
  • This touches authorization, the SpiceDB schema, or the approver model, and
    mage test:integration + mage test:e2e are green, or it touches
    none of those. The example's schema is its own, seeded into the demo cluster only.

Before requesting review

  • The PR holds a single change. Its 12 commits build up the one example and can't land separately.
  • A person has read every line of the diff, or the note below explains how
    to check the parts they did not.

server/package-lock.json is generated by npm install from server/package.json. To check it, regenerate it and compare.

The SpiceboxClass needs an image and a tool to be Valid, even though a
sidecar uses neither. The SidecarToolbox controller type-checks argument
constraints against the SpiceboxToolspec CEL environment, not the MCP one
the runner evaluates them with, so it rejects any args.path constraint.
Drop the path constraints: a path is checked as the exact ID it names, and
only seeded folders and files have relationships, so path tricks are
still refused.
How to run the before and after halves, the scenes as they ran live,
the optional cold open and revocation scenes, the reset, and the
limitations found while running them: what an approval covers, the
approval card not naming the requester, DM sessions, and the toolbox's
missing path constraints. Also drop a .pyc committed by mistake.
Keep file contents out of the container log: supergateway's info log on
stdout copies every message verbatim, so discard stdout and keep stderr.
Run Scene 3 and the revocation scene in a private channel Alice is not
in. Say who an approval reaches, that each session has its own copy of
the drive, and that the sidecar's network mode is declared, not
enforced. Scope the reset to this agent's sessions, restore the seed,
and stop the port-forward. List zed and npx as prerequisites.
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

Deployment failed for project openagentprimitives with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: openagentprimitives.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

- Format the README and the two drive markdown files with oxfmt so
  `mage fmt:check` passes.
- Scene 2: tell Bob to only click Approve. Tool calls are checked as
  whoever sent the latest message, so a reply from Bob in Alice's thread
  would let the next payroll read pass where Alice can see it.
- Say that /shared is itself a symlink to /tmp/shared and that the server
  lists both; only /shared/... is seeded, so the other spelling is refused.
- Give write_file and create_directory a resourceIDHint, so a path with no
  "/" tells the agent to use a full path instead of an "internal:" error.
- before/agent.py prints usage and exits 2 without a prompt argument.

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

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openagentprimitives Ignored Ignored Preview Nov 30, 2026 5:51pm UTC

Request Review

@samkim samkim 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 PR adds the examples/mcp-shared-drive demo: a plain agent that leaks payroll through an unmodified MCP filesystem server, and the same agent on OAP with a per-person SpiceDB check on every tool call. The schema, seed, toolbox allowlist and path escaping hold together: nobody can derive approve on finance/ or payroll.csv, Bob's approve covers only eng-budget-q3.csv, only six of the server's 14 tools reach the model, and path variants such as .., // and /tmp/shared/... name unseeded IDs and are refused.

Verdict: approve. The five nits from my first pass are fixed in f4142ca:

  • mage fmt:check now passes (README and the two drive markdown files reformatted; wrapping and table alignment only).
  • Scene 2 tells Bob to only click Approve, since a reply from him in Alice's thread would make the next turn run as Bob.
  • The toolbox comment and README now say /shared is a symlink to /tmp/shared, that the server lists both, and that only /shared/... is seeded.
  • write_file and create_directory carry a resourceIDHint, so a path with no / gets a usable message instead of an internal: error (checked against the runner's checker).
  • before/agent.py prints usage and exits 2 without a prompt.

oap agent lint and oap agent package pass on the example.

Follow-ups, not blocking:

  1. After merge, publish-agents will push, sign and move :latest for shared-drive-agent, but the package does not carry server/ (the image build context), so installing from the registry stops with "install from the bundle's folder source". The README already says to install from the folder. Consider opting this example out of scripts/publish-example-agents.sh, or publishing the image.
  2. The demo's authorization claims are checked only by hand. A bronzethread bundle (or a lint/package pass over every example in CI) would keep it from rotting.

Not verified: the "before" leak with the pinned model and the README commands on a live cluster (both need live runs).

This review was drafted by an automated pipeline and checked before submission.

@samkim
samkim merged commit 75676b9 into main Nov 30, 2026
9 of 10 checks passed
@samkim
samkim deleted the demo/mcp-shared-drive branch November 30, 2026 17:57
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