|
| 1 | +# MCP Security |
| 2 | + |
| 3 | +The Model Context Protocol (MCP) enables powerful tool access for AI agents. CapiscIO's **MCP Guard** brings trust infrastructure to MCP with two complementary specifications. |
| 4 | + |
| 5 | +## The Problem |
| 6 | + |
| 7 | +MCP servers expose powerful tools to autonomous agents—file systems, databases, APIs, code execution. But MCP itself doesn't define: |
| 8 | + |
| 9 | +- **Who** is calling a tool (authentication) |
| 10 | +- **Whether** they should have access (authorization) |
| 11 | +- **What** happened for post-incident review (audit) |
| 12 | + |
| 13 | +## The Solution: Two RFCs |
| 14 | + |
| 15 | +MCP Guard implements two CapiscIO specifications: |
| 16 | + |
| 17 | +### RFC-006: MCP Tool Authority and Evidence |
| 18 | + |
| 19 | +**Server-side protection.** Define trust level requirements for individual tools. |
| 20 | + |
| 21 | +```python |
| 22 | +from capiscio_mcp import guard |
| 23 | + |
| 24 | +@guard(min_trust_level=2) |
| 25 | +async def read_database(query: str) -> list[dict]: |
| 26 | + """Only Level 2+ agents can query the database.""" |
| 27 | + return await db.execute(query) |
| 28 | + |
| 29 | +@guard(min_trust_level=3) |
| 30 | +async def write_database(table: str, data: dict): |
| 31 | + """Only Level 3+ (org-validated) agents can write.""" |
| 32 | + return await db.insert(table, data) |
| 33 | +``` |
| 34 | + |
| 35 | +**Key features:** |
| 36 | + |
| 37 | +- **Trust level enforcement** — Require minimum verification level |
| 38 | +- **Evidence logging** — Cryptographic audit trail for every call |
| 39 | +- **Parameter hashing** — PII-safe evidence records |
| 40 | +- **Async and sync** — Both decorator styles supported |
| 41 | + |
| 42 | +[:octicons-arrow-right-24: RFC-006 Full Specification](https://github.com/capiscio/capiscio-rfcs/blob/main/docs/006-mcp-tool-authority-evidence.md) |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### RFC-007: MCP Server Identity Disclosure |
| 47 | + |
| 48 | +**Client-side verification.** Verify MCP server identity before connecting. |
| 49 | + |
| 50 | +```python |
| 51 | +from capiscio_mcp import verify_server, ServerState |
| 52 | + |
| 53 | +result = await verify_server( |
| 54 | + server_did="did:web:mcp.example.com", |
| 55 | + server_badge="eyJhbGc...", |
| 56 | + transport_origin="https://mcp.example.com", |
| 57 | +) |
| 58 | + |
| 59 | +if result.state == ServerState.VERIFIED_PRINCIPAL: |
| 60 | + print(f"✓ Trusted server at Level {result.trust_level}") |
| 61 | +else: |
| 62 | + print("⚠ Server identity not verified") |
| 63 | +``` |
| 64 | + |
| 65 | +**Key features:** |
| 66 | + |
| 67 | +- **Server identity verification** — Confirm who you're connecting to |
| 68 | +- **Transport binding** — Verify server controls the transport endpoint |
| 69 | +- **Trust level inspection** — Check server's verification level |
| 70 | +- **Three states** — VERIFIED_PRINCIPAL, DECLARED_PRINCIPAL, UNVERIFIED_ORIGIN |
| 71 | + |
| 72 | +[:octicons-arrow-right-24: RFC-007 Full Specification](https://github.com/capiscio/capiscio-rfcs/blob/main/docs/007-mcp-server-identity-discovery.md) |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## How They Work Together |
| 77 | + |
| 78 | +``` |
| 79 | +┌─────────────────────────────────────────────────────────────────┐ |
| 80 | +│ MCP Security Flow │ |
| 81 | +├─────────────────────────────────────────────────────────────────┤ |
| 82 | +│ │ |
| 83 | +│ MCP CLIENT MCP SERVER │ |
| 84 | +│ ┌─────────────┐ ┌─────────────┐ │ |
| 85 | +│ │ Agent A │ │ File Tool │ │ |
| 86 | +│ │ (Level 2) │ │ Server │ │ |
| 87 | +│ └─────────────┘ └─────────────┘ │ |
| 88 | +│ │ │ │ |
| 89 | +│ │ 1. Verify server identity │ │ |
| 90 | +│ │ (RFC-007) │ │ |
| 91 | +│ │ ─────────────────────────────────────>│ │ |
| 92 | +│ │ │ │ |
| 93 | +│ │ 2. Call tool with badge │ │ |
| 94 | +│ │ ─────────────────────────────────────>│ │ |
| 95 | +│ │ │ │ |
| 96 | +│ │ 3. Guard evaluates │ │ |
| 97 | +│ │ (RFC-006) │ │ |
| 98 | +│ │ ▼ │ |
| 99 | +│ │ ┌─────────────┐ │ |
| 100 | +│ │ │ @guard(2) │ │ |
| 101 | +│ │ │ → ALLOW │ │ |
| 102 | +│ │ │ → log audit │ │ |
| 103 | +│ │ └─────────────┘ │ |
| 104 | +│ │ │ │ |
| 105 | +│ │ 4. Return result │ │ |
| 106 | +│ │ <─────────────────────────────────────│ │ |
| 107 | +│ │ |
| 108 | +└─────────────────────────────────────────────────────────────────┘ |
| 109 | +``` |
| 110 | + |
| 111 | +1. **Client verifies server** using RFC-007 before connecting |
| 112 | +2. **Client calls tool** with their trust badge attached |
| 113 | +3. **Server guard evaluates** the caller's trust level (RFC-006) |
| 114 | +4. **Evidence logged** regardless of allow/deny decision |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## Trust Levels in MCP Context |
| 119 | + |
| 120 | +| Level | Server Use | Client Use | |
| 121 | +|:-----:|------------|------------| |
| 122 | +| **0** | Development servers | Anonymous tool access | |
| 123 | +| **1** | Personal project servers | Registered agents | |
| 124 | +| **2** | Production read-only tools | Domain-verified agents | |
| 125 | +| **3** | Write operations | Org-verified agents | |
| 126 | +| **4** | Admin tools | Enterprise agents | |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Next Steps |
| 131 | + |
| 132 | +<div class="grid cards" markdown> |
| 133 | + |
| 134 | +- [:material-shield-check: **Protect Your Tools**](../../mcp-guard/guides/server-side/) |
| 135 | + |
| 136 | + Add `@guard` to your MCP server tools |
| 137 | + |
| 138 | +- [:material-check-decagram: **Verify Servers**](../../mcp-guard/guides/client-side/) |
| 139 | + |
| 140 | + Implement server verification in your MCP client |
| 141 | + |
| 142 | +- [:material-file-document: **Evidence Logging**](../../mcp-guard/guides/evidence/) |
| 143 | + |
| 144 | + Set up cryptographic audit trails |
| 145 | + |
| 146 | +- [:material-api: **API Reference**](../../reference/sdk-python/mcp/) |
| 147 | + |
| 148 | + Complete MCP Guard API documentation |
| 149 | + |
| 150 | +</div> |
0 commit comments