Metadata-Version: 2.4
Name: obsigno
Version: 0.3.0
Summary: Tamper-evident audit and policy enforcement proxy for MCP tool calls
Project-URL: Homepage, https://github.com/amudhan22/obsigno
Project-URL: Repository, https://github.com/amudhan22/obsigno
Project-URL: Issues, https://github.com/amudhan22/obsigno/issues
Project-URL: Documentation, https://github.com/amudhan22/obsigno#readme
Author: Obsigno contributors
License: Apache License
        Version 2.0, January 2004
        http://www.apache.org/licenses/
        
        TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
        1. Definitions.
        
        "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
        
        "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
        
        "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
        
        "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
        
        "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
        
        "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
        
        "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
        
        "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
        
        "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
        
        "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
        
        2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
        
        3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
        
        4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
        
             (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
        
             (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
        
             (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
        
             (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
        
             You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
        
        5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
        
        6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
        
        7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
        
        8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
        
        9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
        
        END OF TERMS AND CONDITIONS
        
        APPENDIX: How to apply the Apache License to your work.
        
        To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!)  The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
        
        Copyright [yyyy] [name of copyright owner]
        
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        
        http://www.apache.org/licenses/LICENSE-2.0
        
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
License-File: LICENSE
Keywords: ai-agents,audit,mcp,policy,tamper-evident
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: cryptography>=42
Requires-Dist: portalocker<4,>=3.2
Requires-Dist: pyyaml<7,>=6
Provides-Extra: cedar
Requires-Dist: cedarpy==4.8.7; extra == 'cedar'
Provides-Extra: dev
Requires-Dist: cedarpy==4.8.7; extra == 'dev'
Requires-Dist: fastapi<1,>=0.115; extra == 'dev'
Requires-Dist: httpx<1,>=0.27; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: uvicorn[standard]<1,>=0.30; extra == 'dev'
Provides-Extra: web
Requires-Dist: fastapi<1,>=0.115; extra == 'web'
Requires-Dist: uvicorn[standard]<1,>=0.30; extra == 'web'
Description-Content-Type: text/markdown

# Obsigno

**Open-source runtime governance for AI agents at the MCP tool-call layer.**

Obsigno is a transparent stdio proxy between an MCP client and server. It evaluates each `tools/call` **before execution**, forwards allowed calls, returns MCP-compatible tool errors for denied calls, and writes every decision to an Ed25519-signed, hash-chained ledger.

It is the **policy gate + flight recorder** for tool-using agents:

- **Drop-in MCP enforcement** — replace the server command; do not change client or server code.
- **Native policy options** — built-in ordered JSON rules, OPA Data API, or Cedar via `cedarpy`.
- **Cross-server correlation** — sign a shared agent-task trace ID and stable MCP server identity at every hop.
- **Tamper-evident, policy-bound evidence** — hash arguments/results and exact local policy bytes, chain entries, and sign every record.
- **Portable trace evidence** — export a trace with a derived manifest, full chain prefix, optional exact policy snapshots, and public key for offline verification.
- **Independent verification** — detect edits, deletion, reordering, policy-reference changes, broken chains, or the wrong signer.
- **Live audit surface** — FastAPI endpoints and a self-hosted dashboard.
- **One-command demo** — Docker Compose launches a verified six-event cross-server agent trace.

> Cryptography makes historical modification detectable. Put production ledgers on append-only/WORM or object-lock storage to make modification operationally difficult or impossible.
>
> See [`COMPETITIVE.md`](COMPETITIVE.md) for the evidence-backed competitor matrix and why Obsigno is positioned as the **verifiable evidence layer for governed MCP actions**, not another general MCP gateway.

## Five-minute quickstart

Requires Docker with Compose.

```bash
docker compose up -d --build
```

Open **http://localhost:8787**. The quickstart runs six real `tools/call` requests through the stdio proxy and its demo upstream server, creates a persistent signing key, and records signed events across five server identities. The dashboard shows:

- chain verification status;
- allowed and denied agent actions;
- policy reasons;
- correlated task traces;
- MCP server identities and event hashes.

Check it without the UI:

```bash
curl http://localhost:8787/api/health
# {"status":"ok","entries":6,"integrity":"verified","checked":6}
```

Stop the services while preserving the ledger:

```bash
docker compose down
```

Remove the demo ledger and keys as well:

```bash
docker compose down -v
```

## Architecture

```text
AI agent / MCP client
          |
          | JSON-RPC over stdio
          v
+-------------------------------+
|            Obsigno            |
|  1. intercept tools/call      |
|  2. evaluate JSON/OPA/Cedar   |
|  3. deny or forward           |
|  4. sign policy evidence      |
+-------------------------------+
          |
          v
      MCP server

             +--------------------------+
             | signed JSONL ledger      |
             | FastAPI + live dashboard |
             | offline public verifier  |
             +--------------------------+
```

Non-`tools/call` traffic—including initialization, discovery, resources, prompts, notifications, and unrelated responses—passes through transparently. Protocol stdout remains reserved for MCP JSON-RPC; diagnostics stay on stderr.

## Install from source

Requires Python 3.10+.

```bash
python -m venv .venv

# Windows
.venv\Scripts\pip install -e ".[web,cedar,dev]"
.venv\Scripts\pytest -q

# macOS/Linux
.venv/bin/pip install -e ".[web,cedar,dev]"
.venv/bin/pytest -q
```

With `uv`:

```bash
uv venv
uv pip install -e ".[web,cedar,dev]"
uv run pytest -q
```

Available commands:

| Command | Purpose |
|---|---|
| `obsigno-mcp` | Transparent stdio MCP policy/audit proxy |
| `obsigno-verify` | Offline full-ledger chain and signature verifier |
| `obsigno-evidence` | Export or verify a portable trace evidence bundle |
| `obsigno-dashboard` | FastAPI audit API and live dashboard |
| `obsigno-demo-proxy` | Exercise the real proxy and demo upstream for Compose |

## Put any stdio MCP server behind Obsigno

Everything after `--` is the original MCP server command.

### Audit-only adoption

Omit a policy to allow all tools while recording signed evidence:

```bash
obsigno-mcp \
  --server-id filesystem-mcp \
  -- npx -y @modelcontextprotocol/server-filesystem /safe/root
```

On first run Obsigno creates:

```text
.obsigno/audit.jsonl
.obsigno/audit.jsonl.lock
.obsigno/private_key.pem
.obsigno/public_key.pem
```

### Built-in ordered YAML or JSON policy

```bash
obsigno-mcp \
  --policy policies/demo.policy.yaml \
  --server-id filesystem-mcp \
  -- npx -y @modelcontextprotocol/server-filesystem /safe/root
```

Use `.yaml`/`.yml` for YAML or `.json` for JSON. The first matching rule wins, and supplying a policy enables default deny. For example, the equivalent JSON shape is:

```json
{
  "default_reason": "no matching allow rule (default deny)",
  "rules": [
    {
      "id": "block-destructive",
      "effect": "deny",
      "tool": "delete_database",
      "reason": "destructive database operations are blocked"
    },
    {
      "id": "allow-reads",
      "effect": "allow",
      "tool": "read_file",
      "reason": "read-only file access is permitted"
    }
  ]
}
```

Rules may include an exact `actor`; `"*"` matches every actor or tool. Set the actor with `--actor agent://name/session`.

### Native Cedar policy

Install the `cedar` extra, then use the included policy:

```bash
obsigno-mcp \
  --policy-backend cedar \
  --policy policies/policy.example.cedar \
  --server-id filesystem-mcp \
  -- npx -y @modelcontextprotocol/server-filesystem /safe/root
```

Obsigno maps the request to Cedar as:

```text
principal = Agent::<actor>
action    = Action::<tool name>
resource  = MCPTool::<tool name>
context.arguments = tool arguments
```

Cedar evaluation is local. Forbid policy IDs, permit policy IDs, and reasons are included in the signed decision record. The optional dependency is pinned to `cedarpy==4.8.7` for deterministic engine semantics; `cedarpy` is Rust-backed but community-maintained and is not an official AWS/Cedar Team binding.

### Native OPA policy

Obsigno calls OPA's Data API and expects either a boolean result or this object:

```json
{
  "result": {
    "allow": true,
    "reason": "read-only and research tools are allowed",
    "rule_id": "allow-read-research",
    "policy_ref": "opa:obsigno-example:v1"
  }
}
```

Start the pinned OPA 1.19.0 sidecar with the included Rego policy:

```bash
docker compose --profile opa up -d opa
curl http://127.0.0.1:8181/health
```

The development profile binds OPA only to loopback because its server also exposes policy-management APIs. Then point the proxy at the decision endpoint:

```bash
obsigno-mcp \
  --policy-backend opa \
  --opa-url http://127.0.0.1:8181/v1/data/obsigno/decision \
  --server-id filesystem-mcp \
  -- npx -y @modelcontextprotocol/server-filesystem /safe/root
```

OPA receives:

```json
{
  "input": {
    "actor": "agent://researcher",
    "tool": "read_file",
    "arguments": {"path": "/safe/root/report.csv"}
  }
}
```

OPA network failures, malformed responses, responses without a boolean `allow`, and other backend errors **fail closed**. OPA can return `policy_ref` as a bundle revision, Git commit, or other deployment identifier; Obsigno signs that reference into the event. Built-in JSON and Cedar policies automatically use `sha256:<digest>` of the exact local policy bytes.

## Correlate one agent task across MCP servers

Supply the same trace ID in MCP's extensible `_meta` object to every tool call in a task:

```json
{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "tools/call",
  "params": {
    "name": "read_file",
    "arguments": {"path": "/workspace/brief.md"},
    "_meta": {
      "obsigno/trace_id": "task-research-2026-08-03"
    }
  }
}
```

Obsigno preserves that trace ID, adds `obsigno/server_id`, forwards the metadata, and signs both fields into the ledger. Configure each proxy with a distinct stable `--server-id`.

If the client does not provide a trace ID, Obsigno creates a UUID for that individual call. Task-level correlation therefore requires the client/orchestrator to propagate the same ID across calls. The dashboard groups signed records by trace ID and displays every server touched by that task.

The ledger serializes appends with both in-process and OS-level file locks, so separate proxy processes can safely extend one local chain. For distributed hosts, use a single append service or a storage backend that provides equivalent atomic ordering.

## Dashboard and audit API

Run against local files:

```bash
obsigno-dashboard \
  --host 127.0.0.1 \
  --port 8787 \
  --ledger .obsigno/audit.jsonl \
  --private-key .obsigno/private_key.pem \
  --public-key .obsigno/public_key.pem
```

The CLI initializes missing keys and an empty ledger. API endpoints:

| Endpoint | Description |
|---|---|
| `GET /api/health` | Service status, entry count, and live integrity result |
| `GET /api/events` | Newest signed events; supports `trace_id`, `decision`, `server_id`, and `limit` |
| `GET /api/traces` | Correlated trace summaries with servers and deny counts |
| `GET /api/traces/{trace_id}/evidence` | Portable offline-verifiable trace bundle |
| `GET /api/verify` | Full chain/signature verification details |
| `GET /` | Auto-refreshing self-hosted dashboard |

Example:

```bash
curl "http://localhost:8787/api/events?decision=deny&limit=20"
curl "http://localhost:8787/api/traces?limit=20"
```

## Drop-in Claude Desktop-style configuration on Windows

Replace the original server command with `obsigno-mcp.exe`, then append the original command after `--`:

```json
{
  "mcpServers": {
    "governed-filesystem": {
      "command": "C:\\path\\to\\obsigno\\.venv\\Scripts\\obsigno-mcp.exe",
      "args": [
        "--policy-backend",
        "cedar",
        "--policy",
        "C:\\path\\to\\obsigno\\policies\\policy.example.cedar",
        "--server-id",
        "filesystem-mcp",
        "--ledger",
        "C:\\path\\to\\obsigno\\.obsigno\\audit.jsonl",
        "--",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:\\safe\\root"
      ]
    }
  }
}
```

## Verify the evidence offline

```bash
obsigno-verify .obsigno/audit.jsonl .obsigno/public_key.pem
# OK  6 entries verified, chain + signatures intact
```

Export one trace as a portable evidence bundle and verify it without Obsigno running:

```bash
obsigno-evidence export \
  --ledger .obsigno/audit.jsonl \
  --public-key .obsigno/public_key.pem \
  --trace-id task-research-2026-08-03 \
  --policy-file policies/policy.example.cedar \
  --output task-research.evidence.json

obsigno-evidence verify task-research.evidence.json \
  --require-policy-snapshots
```

Repeat `--policy-file` when a trace used multiple local policies. Obsigno embeds only snapshots whose SHA-256 matches a signed `policy_ref`; strict verification fails if a required local snapshot is missing or changed. OPA references such as bundle revisions remain externally identified unless the exact policy bundle is supplied through a future attestation integration.

A linear hash chain needs every predecessor through the final selected event, so a trace bundle contains the complete ledger prefix up to that point plus `trace_event_seqs`. It does not contain raw arguments or results, but it can expose metadata for unrelated events in that prefix. Review that trade-off before sharing a bundle externally. Pin and compare the reported public-key fingerprint when the verifier receives the key through an untrusted channel.

Each signed record includes:

- actor, action, tool, timestamp, and sequence;
- trace ID and MCP server identity;
- allow/deny decision, reason, matched rule ID, and policy version/hash reference;
- SHA-256 hashes of arguments and results;
- previous-entry hash, record hash, and Ed25519 signature.

Raw tool arguments and results are not written to the ledger. This reduces accidental retention of prompts, PII, secrets, and customer payloads while still proving whether supplied evidence matches the original event.

## Python API

```python
from obsigno import AuditLedger, Gateway, PolicyEngine, Rule, generate_keypair

policy = PolicyEngine([
    Rule(id="reads", effect="allow", tool="read_file", reason="reads allowed"),
])
ledger = AuditLedger("audit.jsonl", generate_keypair())
gateway = Gateway(policy, ledger)
result = gateway.call("agent://bot", "read_file", read_file, {"path": "/a.txt"})
```

Run `python demo.py` for a local allow/deny and tamper-detection demonstration.

## Security boundary

Obsigno is unbypassable only when the MCP client can reach the target server exclusively through the proxy and cannot launch or connect to it separately.

For production:

1. Keep the private signing key outside the agent's permissions.
2. Restrict direct network/process access to governed MCP servers.
3. Export signed ledgers to append-only/WORM or object-lock storage.
4. Pin dependencies and container images.
5. Authenticate and authorize access to the dashboard/API; the Stage-0 dashboard intentionally has no built-in identity layer.
6. Monitor OPA availability; OPA decisions fail closed by design.

This repository provides tamper evidence, not absolute prevention of deletion. Loss of the only ledger copy is still loss of evidence.

## Compliance positioning

Obsigno can supply technical logging evidence for governance programs such as EU AI Act Article 12 record-keeping, SOC 2 controls, and ISO/IEC 42001 processes. It does **not** make a system compliant by itself and is not legal advice.

Article 12 requires high-risk AI systems to technically allow automatic event recording over the system lifetime. The Act does not specifically mandate MCP logging, and “tamper-evident” is a defensible engineering practice rather than verbatim Article 12 language. Applicability, retention, and required fields depend on the organization's role and system classification.

## Development

```bash
pytest -q
uv build
docker compose config
docker compose up -d --build
```

Repository layout:

```text
src/obsigno/mcp_proxy.py       transparent MCP enforcement proxy
src/obsigno/demo_proxy.py      real proxied Compose demo and upstream
src/obsigno/policy_backends.py native Cedar and OPA adapters
src/obsigno/ledger.py          signed append-only ledger
src/obsigno/verify.py          offline full-ledger verifier
src/obsigno/evidence.py        portable trace evidence export/verifier
src/obsigno/web.py             FastAPI audit and evidence API
src/obsigno/static/            live dashboard
policies/                         Cedar and Rego examples
landing/                          product landing page
tests/                            unit and end-to-end tests
```

## License

Apache-2.0 intended. The proxy, policy gate, ledger, verifier, API, and dashboard are designed to remain genuinely useful when self-hosted.
