writ-mcp 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {writ_mcp-0.2.2/src/writ_mcp.egg-info → writ_mcp-0.2.4}/PKG-INFO +4 -1
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/README.md +3 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/pyproject.toml +1 -1
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp/__init__.py +1 -1
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp/server.py +64 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4/src/writ_mcp.egg-info}/PKG-INFO +4 -1
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp.egg-info/SOURCES.txt +3 -1
- writ_mcp-0.2.4/tests/test_badge_tokens.py +83 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/tests/test_server.py +4 -1
- writ_mcp-0.2.4/tests/test_verify_receipts.py +70 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/LICENSE +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/setup.cfg +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp.egg-info/dependency_links.txt +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp.egg-info/entry_points.txt +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp.egg-info/requires.txt +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/src/writ_mcp.egg-info/top_level.txt +0 -0
- {writ_mcp-0.2.2 → writ_mcp-0.2.4}/tests/test_lease_execute.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: writ-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Writ MCP server: point-of-action policy checks for AI agent writes (ALLOW/DENY/STEP_UP) with a tamper-evident audit log
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://withwrit.com
|
|
@@ -106,6 +106,7 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
106
106
|
| `writ_grant` | sponsor | Approve a STEP_UP (one-time grant) |
|
|
107
107
|
| `writ_revoke` / `writ_reinstate` | sponsor | Kill switch on/off for a principal |
|
|
108
108
|
| `writ_receipts` | agent | Audit trail of decisions |
|
|
109
|
+
| `writ_verify_receipts` | agent | Verify the audit-log hash chain |
|
|
109
110
|
| `writ_policy` | agent | Tenant verb policy |
|
|
110
111
|
| `writ_sandbox` | anyone | Free 90-second demo grant, no key needed |
|
|
111
112
|
| `writ_github_installations` | admin | List connected GitHub App installations |
|
|
@@ -117,6 +118,8 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
117
118
|
| `writ_principals` | admin | List the tenant's principals |
|
|
118
119
|
| `writ_verbs` | admin | List the tenant's verb vocabulary |
|
|
119
120
|
| `writ_keys` | admin | List API key metadata |
|
|
121
|
+
| `writ_badge_token` | agent | Mint a public README badge token |
|
|
122
|
+
| `writ_badge_revoke` | agent | Revoke a badge token; its badge image URL 404s |
|
|
120
123
|
|
|
121
124
|
Try it with no key: `writ_sandbox` → `writ_check` with `verb="demo_write"`.
|
|
122
125
|
|
|
@@ -90,6 +90,7 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
90
90
|
| `writ_grant` | sponsor | Approve a STEP_UP (one-time grant) |
|
|
91
91
|
| `writ_revoke` / `writ_reinstate` | sponsor | Kill switch on/off for a principal |
|
|
92
92
|
| `writ_receipts` | agent | Audit trail of decisions |
|
|
93
|
+
| `writ_verify_receipts` | agent | Verify the audit-log hash chain |
|
|
93
94
|
| `writ_policy` | agent | Tenant verb policy |
|
|
94
95
|
| `writ_sandbox` | anyone | Free 90-second demo grant, no key needed |
|
|
95
96
|
| `writ_github_installations` | admin | List connected GitHub App installations |
|
|
@@ -101,6 +102,8 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
101
102
|
| `writ_principals` | admin | List the tenant's principals |
|
|
102
103
|
| `writ_verbs` | admin | List the tenant's verb vocabulary |
|
|
103
104
|
| `writ_keys` | admin | List API key metadata |
|
|
105
|
+
| `writ_badge_token` | agent | Mint a public README badge token |
|
|
106
|
+
| `writ_badge_revoke` | agent | Revoke a badge token; its badge image URL 404s |
|
|
104
107
|
|
|
105
108
|
Try it with no key: `writ_sandbox` → `writ_check` with `verb="demo_write"`.
|
|
106
109
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "writ-mcp"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.4"
|
|
8
8
|
description = "Writ MCP server: point-of-action policy checks for AI agent writes (ALLOW/DENY/STEP_UP) with a tamper-evident audit log"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -302,6 +302,29 @@ def writ_receipts(limit: int = 10) -> str:
|
|
|
302
302
|
return _fmt({"error": str(e), "status": e.status, "detail": e.payload})
|
|
303
303
|
|
|
304
304
|
|
|
305
|
+
@mcp.tool()
|
|
306
|
+
def writ_verify_receipts(limit: int = 200) -> str:
|
|
307
|
+
"""Verify the tenant audit-log hash chain and report whether it is intact.
|
|
308
|
+
|
|
309
|
+
Walks the tenant's receipt chain from its head, recomputing every visited
|
|
310
|
+
receipt's HMAC. This is the endpoint behind `./writ verify-chain`: use it
|
|
311
|
+
to prove the audit log has not been tampered with.
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
limit: Max receipts to verify, newest first. Default 200, clamped to
|
|
315
|
+
the range 1..1000.
|
|
316
|
+
|
|
317
|
+
Returns the gate payload verbatim: ok (chain intact), checked (receipts
|
|
318
|
+
verified), tip and tipReceipt (chain head), chainedFrom, legacyCount, and
|
|
319
|
+
complete. Verification stops at legacy (pre-chain) receipts and reports
|
|
320
|
+
them as legacyCount.
|
|
321
|
+
"""
|
|
322
|
+
try:
|
|
323
|
+
n = min(1000, max(1, limit))
|
|
324
|
+
return _fmt(_key_call("GET", f"/v1/receipts/verify?limit={n}"))
|
|
325
|
+
except WritError as e:
|
|
326
|
+
return _fmt({"error": str(e), "status": e.status, "detail": e.payload})
|
|
327
|
+
|
|
305
328
|
@mcp.tool()
|
|
306
329
|
def writ_policy() -> str:
|
|
307
330
|
"""Read the tenant's verb policy: which verbs allow, deny, require a grant, or step up."""
|
|
@@ -456,6 +479,47 @@ def writ_keys() -> str:
|
|
|
456
479
|
return _fmt({"error": str(e), "status": e.status, "detail": e.payload})
|
|
457
480
|
|
|
458
481
|
|
|
482
|
+
@mcp.tool()
|
|
483
|
+
def writ_badge_token(label: str = "") -> str:
|
|
484
|
+
"""Mint a public badge token for the tenant and return its embed snippet.
|
|
485
|
+
|
|
486
|
+
The badge renders the tenant's live gated-write count over the trailing
|
|
487
|
+
30 days. The token is shown exactly once: store it, it is needed to
|
|
488
|
+
revoke the badge. It is public by design (it lives in a README image
|
|
489
|
+
URL) and cannot be used as an API key. See
|
|
490
|
+
https://docs.withwrit.com/readme-badge for the verification model.
|
|
491
|
+
|
|
492
|
+
Args:
|
|
493
|
+
label: Optional private label for your own bookkeeping (max 40
|
|
494
|
+
chars, letters/digits/space/_/.-). Never rendered on the badge.
|
|
495
|
+
|
|
496
|
+
Returns the gate payload verbatim: badgeToken (writ_badge_...),
|
|
497
|
+
badgeUrl, markdown (ready-to-paste README snippet), label, and a note.
|
|
498
|
+
"""
|
|
499
|
+
try:
|
|
500
|
+
body = {"label": label} if label else None
|
|
501
|
+
return _fmt(_key_call("POST", "/v1/badge/tokens", body))
|
|
502
|
+
except WritError as e:
|
|
503
|
+
return _fmt({"error": str(e), "status": e.status, "detail": e.payload})
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
@mcp.tool()
|
|
507
|
+
def writ_badge_revoke(badge_token: str) -> str:
|
|
508
|
+
"""Revoke one of the tenant's badge tokens.
|
|
509
|
+
|
|
510
|
+
Its badge image URL 404s from that moment on, so embeds show a broken
|
|
511
|
+
image rather than a stale claim. Only tokens belonging to the caller's
|
|
512
|
+
tenant can be revoked.
|
|
513
|
+
|
|
514
|
+
Args:
|
|
515
|
+
badge_token: The writ_badge_ token to revoke (shown once at mint time).
|
|
516
|
+
"""
|
|
517
|
+
try:
|
|
518
|
+
return _fmt(_key_call("POST", "/v1/badge/tokens/revoke",
|
|
519
|
+
{"badgeToken": badge_token}))
|
|
520
|
+
except WritError as e:
|
|
521
|
+
return _fmt({"error": str(e), "status": e.status, "detail": e.payload})
|
|
522
|
+
|
|
459
523
|
def main():
|
|
460
524
|
"""Console-script entry point: run the MCP server over stdio."""
|
|
461
525
|
mcp.run()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: writ-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Writ MCP server: point-of-action policy checks for AI agent writes (ALLOW/DENY/STEP_UP) with a tamper-evident audit log
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://withwrit.com
|
|
@@ -106,6 +106,7 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
106
106
|
| `writ_grant` | sponsor | Approve a STEP_UP (one-time grant) |
|
|
107
107
|
| `writ_revoke` / `writ_reinstate` | sponsor | Kill switch on/off for a principal |
|
|
108
108
|
| `writ_receipts` | agent | Audit trail of decisions |
|
|
109
|
+
| `writ_verify_receipts` | agent | Verify the audit-log hash chain |
|
|
109
110
|
| `writ_policy` | agent | Tenant verb policy |
|
|
110
111
|
| `writ_sandbox` | anyone | Free 90-second demo grant, no key needed |
|
|
111
112
|
| `writ_github_installations` | admin | List connected GitHub App installations |
|
|
@@ -117,6 +118,8 @@ The tool descriptions teach the agent this flow, but the short version:
|
|
|
117
118
|
| `writ_principals` | admin | List the tenant's principals |
|
|
118
119
|
| `writ_verbs` | admin | List the tenant's verb vocabulary |
|
|
119
120
|
| `writ_keys` | admin | List API key metadata |
|
|
121
|
+
| `writ_badge_token` | agent | Mint a public README badge token |
|
|
122
|
+
| `writ_badge_revoke` | agent | Revoke a badge token; its badge image URL 404s |
|
|
120
123
|
|
|
121
124
|
Try it with no key: `writ_sandbox` → `writ_check` with `verb="demo_write"`.
|
|
122
125
|
|
|
@@ -9,5 +9,7 @@ src/writ_mcp.egg-info/dependency_links.txt
|
|
|
9
9
|
src/writ_mcp.egg-info/entry_points.txt
|
|
10
10
|
src/writ_mcp.egg-info/requires.txt
|
|
11
11
|
src/writ_mcp.egg-info/top_level.txt
|
|
12
|
+
tests/test_badge_tokens.py
|
|
12
13
|
tests/test_lease_execute.py
|
|
13
|
-
tests/test_server.py
|
|
14
|
+
tests/test_server.py
|
|
15
|
+
tests/test_verify_receipts.py
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""writ_badge_token and writ_badge_revoke tests, mocked gate, no network."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from writ_mcp import server
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
BADGE_MINT_PAYLOAD = {
|
|
9
|
+
"badgeToken": "writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn",
|
|
10
|
+
"badgeUrl": "https://api.withwrit.com/v1/badge/writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn.svg",
|
|
11
|
+
"markdown": "[](https://withwrit.com)",
|
|
12
|
+
"label": "support-agent repo",
|
|
13
|
+
"note": "The badge token is public by design: it lives in your README. It cannot be used as an API key. Store it: it is shown once and is required to revoke the badge.",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
TOKEN = "writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _Recorder:
|
|
20
|
+
def __init__(self, payload=None):
|
|
21
|
+
self.calls = []
|
|
22
|
+
self.payload = payload if payload is not None else BADGE_MINT_PAYLOAD
|
|
23
|
+
|
|
24
|
+
def __call__(self, method, path, body=None):
|
|
25
|
+
self.calls.append((method, path, body))
|
|
26
|
+
return self.payload
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _raise_401(method, path, body=None):
|
|
30
|
+
raise server.WritError(401, {"error": "API key required."})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _raise_404(method, path, body=None):
|
|
34
|
+
raise server.WritError(404, {"error": "unknown badge token"})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _loads(s):
|
|
38
|
+
return json.loads(s)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_mint_with_no_label_posts_none_body(monkeypatch):
|
|
42
|
+
rec = _Recorder()
|
|
43
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
44
|
+
out = _loads(server.writ_badge_token())
|
|
45
|
+
assert out == BADGE_MINT_PAYLOAD
|
|
46
|
+
assert rec.calls == [("POST", "/v1/badge/tokens", None)]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_mint_with_label_passes_label_body(monkeypatch):
|
|
50
|
+
rec = _Recorder()
|
|
51
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
52
|
+
_loads(server.writ_badge_token(label="support-agent repo"))
|
|
53
|
+
assert rec.calls == [("POST", "/v1/badge/tokens", {"label": "support-agent repo"})]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_gate_payload_returned_verbatim(monkeypatch):
|
|
57
|
+
rec = _Recorder()
|
|
58
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
59
|
+
assert _loads(server.writ_badge_token()) == BADGE_MINT_PAYLOAD
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_mint_writ_error_surfaces_as_standard_error_json(monkeypatch):
|
|
63
|
+
monkeypatch.setattr(server, "_key_call", _raise_401)
|
|
64
|
+
out = _loads(server.writ_badge_token())
|
|
65
|
+
assert out["status"] == 401
|
|
66
|
+
assert "Writ API error 401" in out["error"]
|
|
67
|
+
assert out["detail"] == {"error": "API key required."}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_revoke_posts_badge_token_body(monkeypatch):
|
|
71
|
+
rec = _Recorder({"revoked": True})
|
|
72
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
73
|
+
out = _loads(server.writ_badge_revoke(badge_token=TOKEN))
|
|
74
|
+
assert out == {"revoked": True}
|
|
75
|
+
assert rec.calls == [("POST", "/v1/badge/tokens/revoke", {"badgeToken": TOKEN})]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_revoke_writ_error_surfaces_as_standard_error_json(monkeypatch):
|
|
79
|
+
monkeypatch.setattr(server, "_key_call", _raise_404)
|
|
80
|
+
out = _loads(server.writ_badge_revoke(badge_token=TOKEN))
|
|
81
|
+
assert out["status"] == 404
|
|
82
|
+
assert "Writ API error 404" in out["error"]
|
|
83
|
+
assert out["detail"] == {"error": "unknown badge token"}
|
|
@@ -14,6 +14,7 @@ EXPECTED_TOOLS = {
|
|
|
14
14
|
"writ_revoke",
|
|
15
15
|
"writ_reinstate",
|
|
16
16
|
"writ_receipts",
|
|
17
|
+
"writ_verify_receipts",
|
|
17
18
|
"writ_policy",
|
|
18
19
|
"writ_sandbox",
|
|
19
20
|
"writ_github_installations",
|
|
@@ -25,11 +26,13 @@ EXPECTED_TOOLS = {
|
|
|
25
26
|
"writ_principals",
|
|
26
27
|
"writ_verbs",
|
|
27
28
|
"writ_keys",
|
|
29
|
+
"writ_badge_token",
|
|
30
|
+
"writ_badge_revoke",
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
def test_version():
|
|
32
|
-
assert writ_mcp.__version__ == "0.2.
|
|
35
|
+
assert writ_mcp.__version__ == "0.2.4"
|
|
33
36
|
|
|
34
37
|
|
|
35
38
|
def test_public_base_url_default():
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""writ_verify_receipts tests — mocked gate, no network."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from writ_mcp import server
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
VERIFY_PAYLOAD = {
|
|
9
|
+
"ok": True,
|
|
10
|
+
"checked": 200,
|
|
11
|
+
"tip": "9f2cdeadbeef",
|
|
12
|
+
"tipReceipt": "rcpt_9d2f",
|
|
13
|
+
"chainedFrom": "rcpt_51ab",
|
|
14
|
+
"legacyCount": 0,
|
|
15
|
+
"complete": True,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _Recorder:
|
|
20
|
+
def __init__(self, payload=None):
|
|
21
|
+
self.calls = []
|
|
22
|
+
self.payload = payload if payload is not None else VERIFY_PAYLOAD
|
|
23
|
+
|
|
24
|
+
def __call__(self, method, path, body=None):
|
|
25
|
+
self.calls.append((method, path, body))
|
|
26
|
+
return self.payload
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _raise_401(method, path, body=None):
|
|
30
|
+
raise server.WritError(401, {"error": "API key required."})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _loads(s):
|
|
34
|
+
return json.loads(s)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_default_limit_is_200(monkeypatch):
|
|
38
|
+
rec = _Recorder()
|
|
39
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
40
|
+
out = _loads(server.writ_verify_receipts())
|
|
41
|
+
assert out == VERIFY_PAYLOAD
|
|
42
|
+
assert rec.calls == [("GET", "/v1/receipts/verify?limit=200", None)]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_limit_zero_clamps_to_1(monkeypatch):
|
|
46
|
+
rec = _Recorder()
|
|
47
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
48
|
+
_loads(server.writ_verify_receipts(limit=0))
|
|
49
|
+
assert rec.calls == [("GET", "/v1/receipts/verify?limit=1", None)]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_limit_5000_clamps_to_1000(monkeypatch):
|
|
53
|
+
rec = _Recorder()
|
|
54
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
55
|
+
_loads(server.writ_verify_receipts(limit=5000))
|
|
56
|
+
assert rec.calls == [("GET", "/v1/receipts/verify?limit=1000", None)]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_gate_payload_returned_verbatim(monkeypatch):
|
|
60
|
+
rec = _Recorder()
|
|
61
|
+
monkeypatch.setattr(server, "_key_call", rec)
|
|
62
|
+
assert _loads(server.writ_verify_receipts(limit=42)) == VERIFY_PAYLOAD
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_writ_error_surfaces_as_standard_error_json(monkeypatch):
|
|
66
|
+
monkeypatch.setattr(server, "_key_call", _raise_401)
|
|
67
|
+
out = _loads(server.writ_verify_receipts())
|
|
68
|
+
assert out["status"] == 401
|
|
69
|
+
assert "Writ API error 401" in out["error"]
|
|
70
|
+
assert out["detail"] == {"error": "API key required."}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|