# blankbydefault/mcp-sentinel architecture

> Architecture diagram of the GitHub repository blankbydefault/mcp-sentinel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blankbydefault/mcp-sentinel
- Repository: https://github.com/blankbydefault/mcp-sentinel

## Overview

MCP Sentinel is a stdio firewall and JSONL flight recorder for MCP servers. An MCP client sends framed JSON-RPC through Sentinel; the proxy evaluates tool requests and responses, blocks or forwards traffic to the wrapped server, redacts sensitive output, and records events. The CLI configures proxy operation and supports offline trace inspection and reporting. The README documents additional detection capabilities; some policy implementations were not excerpted, so their internal links are omitted where source evidence is unavailable.

Main entry points: [`src/runtime/proxy.ts`](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/proxy.ts) (Stdio proxy), [`src/cli/commands.ts`](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/cli/commands.ts) (CLI commands), [`src/policy/evaluator.ts`](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/evaluator.ts) (Policy evaluator), [`src/runtime/tracer.ts`](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/tracer.ts) (JSONL tracer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Wire protocol"]
  node_framing["Message framing<br/>[framing.ts]"]
  node_jsonrpc["JSON-RPC handling<br/>[jsonrpc.ts]"]
end

subgraph group_policy["Security policy"]
  node_evaluator["Policy evaluator<br/>[evaluator.ts]"]
  node_config["Policy configuration<br/>[config.ts]"]
  node_custom["Custom rules<br/>[custom-rules.ts]"]
  node_secrets["Secret detection<br/>[secrets.ts]"]
  node_loop["Loop protection<br/>[circuit-breaker.ts]"]
  node_policytypes["Policy types<br/>[types.ts]"]
end

subgraph group_runtime["Proxy and telemetry"]
  node_proxy["Stdio proxy<br/>[proxy.ts]"]
  node_tracer[("JSONL tracer<br/>[tracer.ts]")]
end

subgraph group_cli["CLI and reporting"]
  node_cli["CLI commands<br/>[commands.ts]"]
  node_format["CLI formatting<br/>[format.ts]"]
  node_report["Trace reports<br/>[report.ts]"]
end

node_client(("MCP client"))
node_server["MCP server"]

node_client -->|"sends traffic"| node_proxy
node_proxy -->|"parses frames"| node_framing
node_proxy -->|"inspects messages"| node_jsonrpc
node_proxy -->|"evaluates calls"| node_evaluator
node_proxy -->|"evaluates responses"| node_evaluator
node_proxy -->|"builds block errors"| node_jsonrpc
node_proxy -->|"forwards allowed traffic"| node_server
node_server -->|"returns responses"| node_proxy
node_proxy -->|"returns responses"| node_client
node_evaluator -->|"checks custom rules"| node_custom
node_evaluator -->|"scans for secrets"| node_secrets
node_config -->|"validates patterns"| node_custom
node_proxy -->|"checks repeated calls"| node_loop
node_proxy -->|"records events"| node_tracer
node_tracer -->|"redacts trace payloads"| node_secrets
node_cli -->|"loads configuration"| node_config
node_cli -->|"starts proxy"| node_proxy
node_cli -->|"reads traces"| node_tracer
node_cli -->|"builds reports"| node_report
node_cli -->|"formats output"| node_format
node_report -->|"uses trace data"| node_tracer

click node_framing "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/protocol/framing.ts"
click node_jsonrpc "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/protocol/jsonrpc.ts"
click node_proxy "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/proxy.ts"
click node_evaluator "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/evaluator.ts"
click node_config "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/config.ts"
click node_custom "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/custom-rules.ts"
click node_secrets "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/secrets.ts"
click node_loop "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/circuit-breaker.ts"
click node_policytypes "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/types.ts"
click node_tracer "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/tracer.ts"
click node_cli "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/cli/commands.ts"
click node_format "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/cli/format.ts"
click node_report "https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/report.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_framing,node_jsonrpc,node_client toneBlue
class node_evaluator,node_config,node_custom,node_secrets,node_loop,node_policytypes toneAmber
class node_proxy,node_tracer,node_server toneMint
class node_cli,node_format,node_report toneRose
```

## Components

### Wire protocol

- [Message framing](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/protocol/framing.ts): `src/protocol/framing.ts`
- [JSON-RPC handling](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/protocol/jsonrpc.ts): `src/protocol/jsonrpc.ts`

### Security policy

- [Policy evaluator](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/evaluator.ts): `src/policy/evaluator.ts`
- [Policy configuration](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/config.ts): `src/policy/config.ts`
- [Custom rules](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/custom-rules.ts): `src/policy/custom-rules.ts`
- [Secret detection](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/secrets.ts): `src/policy/secrets.ts`
- [Loop protection](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/circuit-breaker.ts): `src/policy/circuit-breaker.ts`
- [Policy types](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/policy/types.ts): `src/policy/types.ts`

### Proxy and telemetry

- [Stdio proxy](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/proxy.ts): `src/runtime/proxy.ts`
- [JSONL tracer](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/tracer.ts): `src/runtime/tracer.ts`

### CLI and reporting

- [CLI commands](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/cli/commands.ts): `src/cli/commands.ts`
- [CLI formatting](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/cli/format.ts): `src/cli/format.ts`
- [Trace reports](https://github.com/blankbydefault/mcp-sentinel/blob/main/src/runtime/report.ts): `src/runtime/report.ts`

### Other components

- **MCP client**
- **MCP server**

## Connections

- MCP client → Stdio proxy: sends traffic (evidence: `README.md`)
- Stdio proxy → Message framing: parses frames (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → JSON-RPC handling: inspects messages (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → Policy evaluator: evaluates calls (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → Policy evaluator: evaluates responses (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → JSON-RPC handling: builds block errors (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → MCP server: forwards allowed traffic (evidence: `README.md`)
- MCP server → Stdio proxy: returns responses (evidence: `README.md`)
- Stdio proxy → MCP client: returns responses (evidence: `README.md`)
- Policy evaluator → Custom rules: checks custom rules (evidence: `src/policy/evaluator.ts`)
- Policy evaluator → Secret detection: scans for secrets (evidence: `src/policy/evaluator.ts`)
- Policy configuration → Custom rules: validates patterns (evidence: `src/policy/config.ts`)
- Stdio proxy → Loop protection: checks repeated calls (evidence: `src/runtime/proxy.ts`)
- Stdio proxy → JSONL tracer: records events (evidence: `src/runtime/proxy.ts`)
- JSONL tracer → Secret detection: redacts trace payloads (evidence: `src/runtime/tracer.ts`)
- CLI commands → Policy configuration: loads configuration (evidence: `src/cli/commands.ts`)
- CLI commands → Stdio proxy: starts proxy (evidence: `src/cli/commands.ts`)
- CLI commands → JSONL tracer: reads traces (evidence: `src/cli/commands.ts`)
- CLI commands → Trace reports: builds reports (evidence: `src/cli/commands.ts`)
- CLI commands → CLI formatting: formats output (evidence: `src/cli/commands.ts`)
- Trace reports → JSONL tracer: uses trace data (evidence: `src/runtime/report.ts`)
