Skip to content

feat: enforce shadow mcp access rules#2771

Merged
alx-xo merged 6 commits into
mainfrom
alexm/shadow-mcp-runtime-enforcement
May 28, 2026
Merged

feat: enforce shadow mcp access rules#2771
alx-xo merged 6 commits into
mainfrom
alexm/shadow-mcp-runtime-enforcement

Conversation

@alx-xo
Copy link
Copy Markdown
Contributor

@alx-xo alx-xo commented May 12, 2026

Summary

This PR wires Shadow MCP runtime enforcement to the generic Redis-backed access rules added in #2763.

The runtime path now:

  • injects accesscontrol.Store into shadowmcp.Client
  • evaluates matching shadow_mcp rules for the active organization/project
  • supports match evidence by full URL, URL host, and server identity
  • normalizes runtime evidence before matching
  • applies deny-wins semantics when multiple rules match
  • falls back to existing valid-toolset provenance checks when no rule matches
  • fails closed when access-rule evaluation errors

This PR also removes the legacy Shadow MCP approval Redis store/files. Runtime server-identity rules now only apply after a configured MCP server was actually matched, so an identity allow rule cannot allow an unconfigured server alias.

Verification

  • Runtime branch: mise run test:server ./internal/hooks ./internal/shadowmcp -run 'TestClaude_PreToolUse_DoesNotAllowUnconfiguredServerByIdentityRule|TestClaude_PreToolUse_AllowsApprovedLocalStdioServer|TestEvaluateAccessRules' -count=1 passed, 5 tests
  • Top of stack: rg -n "shadow-mcp-allow|AddShadowMCPApproval|RemoveShadowMCPApproval|IsShadowMCPApproved|func CanonicalizeMatch\(" server/internal client/dashboard returned no matches
  • Top of stack: mise run test:server ./internal/accesscontrol ./internal/access ./internal/risk ./internal/shadowmcp ./internal/hooks -count=1 passed, 458 tests
  • Top of stack: mise run lint:server passed
  • Top of stack: pnpm --dir client/dashboard type-check passed
  • Top of stack: pnpm --dir client/dashboard exec vitest run src/components/access/ShadowMCPAccessContent.test.tsx passed, 3 tests
  • Top of stack: git diff --check passed

Stack

https://linear.app/speakeasy/issue/AGE-2586/feat-enforce-shadow-mcp-access-rules

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

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

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment May 28, 2026 10:19pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: c234311

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

atlas migrate lint on server/migrations

Status Step Result
1 new migration file detected 20260512194918_shadow-mcp-access-controls.sql
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@github-actions
Copy link
Copy Markdown
Contributor

atlas migrate lint on server/clickhouse/migrations

Status Step Result
No migration files detected  
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@blacksmith-sh

This comment has been minimized.

@alx-xo alx-xo marked this pull request as ready for review May 13, 2026 16:21
@alx-xo alx-xo requested a review from a team as a code owner May 13, 2026 16:21
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@alx-xo alx-xo force-pushed the alexm/shadow-mcp-access-controls-api branch from b619982 to 3c1bdba Compare May 14, 2026 16:05
@alx-xo alx-xo requested a review from a team as a code owner May 14, 2026 16:05
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-runtime-enforcement branch from c80e96d to a8c75ec Compare May 14, 2026 16:12
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-access-controls-api branch from 3c1bdba to 8f8b84d Compare May 14, 2026 16:57
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-runtime-enforcement branch from 2f5e167 to 7a121ef Compare May 14, 2026 16:58
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-access-controls-api branch from 8f8b84d to 7f980c0 Compare May 14, 2026 17:11
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-runtime-enforcement branch from 7a121ef to bfc2dd6 Compare May 14, 2026 17:11
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-runtime-enforcement branch from b728224 to 38546a7 Compare May 14, 2026 17:58
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

AGE-2586

@alx-xo alx-xo force-pushed the alexm/shadow-mcp-access-controls-api branch from c27ea56 to d1f9e60 Compare May 28, 2026 21:26
@alx-xo alx-xo force-pushed the alexm/shadow-mcp-runtime-enforcement branch from 635f6d2 to 4b26085 Compare May 28, 2026 21:26
Base automatically changed from alexm/shadow-mcp-access-controls-api to main May 28, 2026 22:17
@github-actions
Copy link
Copy Markdown
Contributor

Prompt-injection risk report

Corpus: 933 cases (384 malicious / 549 benign)
This PR: a06e0fdb · 2026-05-28T22:20:56Z

No main baseline artifact found yet; this comment shows the current run only.

Operational Modes

mode status total TP FP FN precision recall F1 FP-rate
L0 only ok 933 76 0 308 1 0.1979 0.3304 0
L0 + L1 opt-in skipped - - - - - - - -

L1 opt-in was not evaluated in this run: classifier URL is not set.

Generated by .github/scripts/risk-metrics-comment.py. Full source/rule breakdown and samples are in the risk-accuracy-metrics artifact.

@github-actions github-actions Bot added the preview Spawn a preview environment label May 28, 2026
@speakeasybot
Copy link
Copy Markdown
Collaborator

speakeasybot commented May 28, 2026

🚀 Preview Environment (PR #2771)

Preview URL: https://pr-2771.dev.getgram.ai

Component Status Details Updated (UTC)
✅ Database Ready Created and validated 2026-05-28 22:26:18.
✅ Images Available Container images ready 2026-05-28 22:25:36.

Gram Preview Bot

@alx-xo alx-xo added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit 1c428e4 May 28, 2026
31 checks passed
@alx-xo alx-xo deleted the alexm/shadow-mcp-runtime-enforcement branch May 28, 2026 22:31
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

preview Spawn a preview environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants