Govern an MCP Server¶
This walkthrough takes about 10 minutes. You will register an MCP server, pin a version, scan inbound results for prompt injection, and quarantine the server on demand.
1. Register the server¶
Save as mcp-github.yaml:
apiVersion: tools.joch.dev/v1alpha1
kind: MCPServer
metadata: { name: github }
spec:
transport: streamable_http
endpoint:
url: https://mcp.example.com/github
auth:
type: oauth2
secretRef: { name: github-mcp-oauth }
exposes: { tools: true, resources: true, prompts: false }
discovery:
enabled: true
refreshInterval: 10m
onSchemaDrift: quarantine
security:
sandbox: true
allowStdio: false
pinServerVersion: true
pinnedVersion: 1.2.0
trustedPublisher: github
minTrustScore: 0.75
scanning:
promptInjectionScan: true
policies:
- name: mcp-tool-safety
The discovery output lists the server's tools, resources, and version, plus the computed trust score.
2. Add the policy¶
Save as mcp-policy.yaml:
apiVersion: joch.dev/v1alpha1
kind: Policy
metadata: { name: mcp-tool-safety }
spec:
appliesTo:
agents: { selector: { matchLabels: { env: prod } } }
rules:
- when: { mcpServer.trustScore: "<0.75" }
action: { deny: true, reason: trust-score-too-low }
- when: { mcpServer.schemaDrift: true }
action: { deny: true, reason: schema-drift-detected }
- when: { mcpResult.injectionScan.hit: true }
action: { modify: redact, reason: prompt-injection-stripped }
3. Use it from an agent¶
Reference the server from an agent record (any framework):
spec:
framework:
adapterRef: { name: openai-agents-sdk }
pythonModule: my_agents.coder:agent
mcpServers:
- name: github
The trace captures every outbound JSON-RPC and inbound result through protocols/MCP hooks. Inbound results are scanned for prompt-injection patterns before reaching the agent.
4. Pin and upgrade safely¶
The review surfaces the schema diff (added tools, removed tools, changed schemas). Apply with:
Until you pin, the server stays at 1.2.0 for every agent that uses it.
5. Quarantine on incident¶
Schema drift, denial spike, or trust-score drop:
The quarantine takes effect fleet-wide immediately. Every agent that depends on github receives a denial reason for the duration of the quarantine.
6. Audit¶
joch get toolcalls --mcpserver github --since 24h
joch trace exec-20260510-001
joch denials ls --policy mcp-tool-safety --since 24h
joch agbom ls --using-mcpserver github
joch agbom support-triage --diff --from 16 --to 17
The AgBOM diff makes MCP version changes auditable.