forgingstack-quorum 0.1.0__py3-none-any.whl
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.
- app/__init__.py +0 -0
- app/mcp_server.py +188 -0
- forgingstack_quorum-0.1.0.dist-info/LICENSE +21 -0
- forgingstack_quorum-0.1.0.dist-info/METADATA +92 -0
- forgingstack_quorum-0.1.0.dist-info/RECORD +8 -0
- forgingstack_quorum-0.1.0.dist-info/WHEEL +5 -0
- forgingstack_quorum-0.1.0.dist-info/entry_points.txt +2 -0
- forgingstack_quorum-0.1.0.dist-info/top_level.txt +1 -0
app/__init__.py
ADDED
|
File without changes
|
app/mcp_server.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""MCP wrapper client for ForgingStack Quorum, v0.1.0.
|
|
2
|
+
|
|
3
|
+
An agent-native service must be usable by agents, not just by humans
|
|
4
|
+
with curl. MCP is the standard interface agents already speak, so the
|
|
5
|
+
wrapper exposes the same live REST API as MCP tools, with no duplicated
|
|
6
|
+
decision logic: every tool call goes through the REST API, so metering
|
|
7
|
+
and receipts stay in one place. The service itself is private; this
|
|
8
|
+
file is only a client.
|
|
9
|
+
|
|
10
|
+
Protocol: JSON-RPC 2.0 over stdio, no new dependencies (stdlib only).
|
|
11
|
+
Supported methods: initialize, ping, tools/list, tools/call.
|
|
12
|
+
Notifications (no id, e.g. notifications/initialized) get no response.
|
|
13
|
+
|
|
14
|
+
Environment:
|
|
15
|
+
FORGINGSTACK_API_BASE default https://forgingstack-quorum.jkbattles.workers.dev
|
|
16
|
+
FORGINGSTACK_API_KEY required; sign up via POST /v1/signup (key shown once)
|
|
17
|
+
|
|
18
|
+
Run: python -m app.mcp_server
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
import urllib.error
|
|
25
|
+
import urllib.request
|
|
26
|
+
|
|
27
|
+
BASE = os.environ.get(
|
|
28
|
+
"FORGINGSTACK_API_BASE",
|
|
29
|
+
"https://forgingstack-quorum.jkbattles.workers.dev",
|
|
30
|
+
)
|
|
31
|
+
API_KEY = os.environ.get("FORGINGSTACK_API_KEY", "")
|
|
32
|
+
|
|
33
|
+
TOOLS = [
|
|
34
|
+
{
|
|
35
|
+
"name": "create_proposal",
|
|
36
|
+
"description": "Propose an action for quorum approval. Each approver "
|
|
37
|
+
"gets a one-time emailed link; when the required number approve, "
|
|
38
|
+
"the proposal is approved and a hash-chained receipt is issued. "
|
|
39
|
+
"Costs 1 credit per proposal; approvals are free.",
|
|
40
|
+
"inputSchema": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"action": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "The action to approve, non-empty, at most 500 characters.",
|
|
46
|
+
},
|
|
47
|
+
"approvers": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {"type": "string"},
|
|
50
|
+
"description": "Email addresses of the approvers (at least as many as required_approvals).",
|
|
51
|
+
},
|
|
52
|
+
"required_approvals": {
|
|
53
|
+
"type": "integer",
|
|
54
|
+
"description": "How many approvals are needed for quorum (1 or more).",
|
|
55
|
+
},
|
|
56
|
+
"expires_at": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "Proposal expiry, ISO 8601, must be in the future.",
|
|
59
|
+
},
|
|
60
|
+
"mandate_ref": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Optional reference to a mandate (at most 500 characters).",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
"required": ["action", "approvers", "required_approvals", "expires_at"],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "get_proposal",
|
|
70
|
+
"description": "Fetch a proposal by id, with its approval state and, once approved, its receipt id.",
|
|
71
|
+
"inputSchema": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"properties": {"proposal_id": {"type": "string"}},
|
|
74
|
+
"required": ["proposal_id"],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "get_credits",
|
|
79
|
+
"description": "Remaining credit balance for the configured API key.",
|
|
80
|
+
"inputSchema": {"type": "object", "properties": {}},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "get_receipt",
|
|
84
|
+
"description": "Fetch a past quorum receipt by id.",
|
|
85
|
+
"inputSchema": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"properties": {"receipt_id": {"type": "integer"}},
|
|
88
|
+
"required": ["receipt_id"],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _http(method, path, body=None):
|
|
95
|
+
req = urllib.request.Request(
|
|
96
|
+
BASE + path,
|
|
97
|
+
data=json.dumps(body).encode() if body is not None else None,
|
|
98
|
+
method=method,
|
|
99
|
+
)
|
|
100
|
+
req.add_header("X-API-Key", API_KEY)
|
|
101
|
+
req.add_header("Content-Type", "application/json")
|
|
102
|
+
# A User-Agent is required: the default Python urllib agent is
|
|
103
|
+
# rejected (Cloudflare 1010) through some egress paths.
|
|
104
|
+
req.add_header("User-Agent", "ForgingStack-Quorum/0.1.0")
|
|
105
|
+
try:
|
|
106
|
+
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
107
|
+
return resp.status, json.loads(resp.read().decode() or "{}")
|
|
108
|
+
except urllib.error.HTTPError as e:
|
|
109
|
+
try:
|
|
110
|
+
return e.code, json.loads(e.read().decode() or "{}")
|
|
111
|
+
except Exception:
|
|
112
|
+
return e.code, {"detail": "api error"}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _text(payload, is_error=False):
|
|
116
|
+
return {
|
|
117
|
+
"content": [{"type": "text", "text": json.dumps(payload)}],
|
|
118
|
+
"isError": is_error,
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def handle(msg):
|
|
123
|
+
method = msg.get("method")
|
|
124
|
+
params = msg.get("params") or {}
|
|
125
|
+
if method == "initialize":
|
|
126
|
+
return {
|
|
127
|
+
"protocolVersion": "2024-11-05",
|
|
128
|
+
"capabilities": {"tools": {}},
|
|
129
|
+
"serverInfo": {"name": "forgingstack-quorum", "version": "0.1.0"},
|
|
130
|
+
}
|
|
131
|
+
if method == "ping":
|
|
132
|
+
return {}
|
|
133
|
+
if method == "tools/list":
|
|
134
|
+
return {"tools": TOOLS}
|
|
135
|
+
if method == "tools/call":
|
|
136
|
+
name = params.get("name")
|
|
137
|
+
args = params.get("arguments") or {}
|
|
138
|
+
if name == "create_proposal":
|
|
139
|
+
body = {k: args[k] for k in
|
|
140
|
+
("action", "approvers", "required_approvals", "expires_at")
|
|
141
|
+
if k in args}
|
|
142
|
+
if "mandate_ref" in args:
|
|
143
|
+
body["mandate_ref"] = args["mandate_ref"]
|
|
144
|
+
status, data = _http("POST", "/v1/proposals", body)
|
|
145
|
+
return _text(data, is_error=status >= 400)
|
|
146
|
+
if name == "get_proposal":
|
|
147
|
+
status, data = _http(
|
|
148
|
+
"GET", f"/v1/proposals/{args['proposal_id']}"
|
|
149
|
+
)
|
|
150
|
+
return _text(data, is_error=status >= 400)
|
|
151
|
+
if name == "get_credits":
|
|
152
|
+
status, data = _http("GET", "/v1/credits")
|
|
153
|
+
return _text(data, is_error=status >= 400)
|
|
154
|
+
if name == "get_receipt":
|
|
155
|
+
status, data = _http(
|
|
156
|
+
"GET", f"/v1/receipts/{args['receipt_id']}"
|
|
157
|
+
)
|
|
158
|
+
return _text(data, is_error=status >= 400)
|
|
159
|
+
raise ValueError(f"unknown tool: {name}")
|
|
160
|
+
raise ValueError(f"unknown method: {method}")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def main():
|
|
164
|
+
for line in sys.stdin:
|
|
165
|
+
line = line.strip()
|
|
166
|
+
if not line:
|
|
167
|
+
continue
|
|
168
|
+
try:
|
|
169
|
+
msg = json.loads(line)
|
|
170
|
+
except json.JSONDecodeError:
|
|
171
|
+
continue
|
|
172
|
+
# Notifications carry no id and get no response.
|
|
173
|
+
if "id" not in msg:
|
|
174
|
+
continue
|
|
175
|
+
try:
|
|
176
|
+
result = handle(msg)
|
|
177
|
+
out = {"jsonrpc": "2.0", "id": msg["id"], "result": result}
|
|
178
|
+
except Exception as exc: # noqa: BLE001 - MCP error surface
|
|
179
|
+
out = {
|
|
180
|
+
"jsonrpc": "2.0", "id": msg["id"],
|
|
181
|
+
"error": {"code": -32603, "message": str(exc)},
|
|
182
|
+
}
|
|
183
|
+
sys.stdout.write(json.dumps(out) + "\n")
|
|
184
|
+
sys.stdout.flush()
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if __name__ == "__main__":
|
|
188
|
+
main()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jonathan Battles
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: forgingstack-quorum
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Before an agent acts alone, get the quorum. One proposal, N approvals, one receipt.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
|
|
10
|
+
# ForgingStack Quorum
|
|
11
|
+
|
|
12
|
+
Before an agent acts alone, get the quorum. One proposal, N approvals, one receipt.
|
|
13
|
+
|
|
14
|
+
mcp-name: io.github.jdkabattles/forgingstack-quorum
|
|
15
|
+
|
|
16
|
+
This is the **public client** for Quorum. The service itself —
|
|
17
|
+
the approval flow, the receipt chain, the key store, and billing —
|
|
18
|
+
runs on ForgingStack's private service and is **not** in this repo.
|
|
19
|
+
Copying this repo does not give you the service: you still need an
|
|
20
|
+
API key and credits, from signup below.
|
|
21
|
+
|
|
22
|
+
Live API: https://forgingstack-quorum.jkbattles.workers.dev
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
1. You propose an action, name the approvers, and set how many
|
|
27
|
+
approvals are needed (N) and when the proposal expires.
|
|
28
|
+
2. Each approver gets a one-time emailed link. Approvals are free.
|
|
29
|
+
3. At quorum the proposal is approved and a hash-chained receipt is
|
|
30
|
+
issued. If it expires first, it expires — no receipt, and the
|
|
31
|
+
proposal cannot be approved afterwards.
|
|
32
|
+
4. You can also reject a pending proposal yourself.
|
|
33
|
+
|
|
34
|
+
What it does **not** do: decide if an action is wise, legal, or
|
|
35
|
+
safe. Quorum only — the approvers decide the rest.
|
|
36
|
+
|
|
37
|
+
## Signup
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curl -X POST https://forgingstack-quorum.jkbattles.workers.dev/v1/signup \
|
|
41
|
+
-H "Content-Type: application/json" \
|
|
42
|
+
-d '{"email":"you@example.com"}'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Returns an API key **once** and 100 starter credits. Save the key
|
|
46
|
+
immediately — it is stored only as a hash and cannot be shown again.
|
|
47
|
+
Click the verification link in the signup email before the key can
|
|
48
|
+
create proposals (if the mail does not arrive, check spam, or
|
|
49
|
+
`POST /v1/verify/resend`).
|
|
50
|
+
|
|
51
|
+
## Create a proposal
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
curl -X POST https://forgingstack-quorum.jkbattles.workers.dev/v1/proposals \
|
|
55
|
+
-H "X-API-Key: YOUR_PRIMARY_KEY" -H "Content-Type: application/json" \
|
|
56
|
+
-d '{"action":"deploy the new build","approvers":["a@example.com","b@example.com"],"required_approvals":2,"expires_at":"2027-01-01T00:00:00Z"}'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Returns the proposal (201) with its approval state and which
|
|
60
|
+
approval emails were sent. Read it back with
|
|
61
|
+
`GET /v1/proposals/{id}`, list yours with `GET /v1/proposals`,
|
|
62
|
+
reject a pending one with `POST /v1/proposals/{id}/reject`.
|
|
63
|
+
Approvers approve by clicking the link in their email — each link
|
|
64
|
+
works once. The receipt, once issued, is at `GET /v1/receipts/{id}`.
|
|
65
|
+
|
|
66
|
+
## Use it (MCP, stdio)
|
|
67
|
+
|
|
68
|
+
Set the key, then run the MCP server in this repo:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export FORGINGSTACK_API_KEY="your-key-here"
|
|
72
|
+
python -m app.mcp_server
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Tools: `create_proposal`, `get_proposal`, `get_credits`, `get_receipt`.
|
|
76
|
+
See `SKILL.md` for when to use it and when not to.
|
|
77
|
+
|
|
78
|
+
## Price
|
|
79
|
+
|
|
80
|
+
1 credit per proposal. Approvals are free. 100 starter credits on
|
|
81
|
+
signup. $10 for 1,000 credits via `POST /v1/billing/checkout`
|
|
82
|
+
(Payment Link). Credits land after payment is verified — usually
|
|
83
|
+
within the hour.
|
|
84
|
+
|
|
85
|
+
## Files in this repo
|
|
86
|
+
|
|
87
|
+
- `app/mcp_server.py` — MCP wrapper client (stdio, stdlib only)
|
|
88
|
+
- `SKILL.md` — when to use it, how to read the result
|
|
89
|
+
- `agent-card.json` — A2A-style discovery card
|
|
90
|
+
- `server.json` — MCP Registry metadata
|
|
91
|
+
- `pyproject.toml` — package metadata for the MCP client
|
|
92
|
+
- `llms.txt` — short index for language-model readers
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
app/mcp_server.py,sha256=-skhMtjtWwdVMiXguIpaVqNd4a0dy0gBfganXxZgxqk,6716
|
|
3
|
+
forgingstack_quorum-0.1.0.dist-info/LICENSE,sha256=kDoUXgBDydvygXjgDe1nE4S2ZeXHI2C_4tc_-THZ2S4,1073
|
|
4
|
+
forgingstack_quorum-0.1.0.dist-info/METADATA,sha256=NibpDu4bKvm3jZz0CQ7eAVpnhdBgO0XVKeZET5EpbF8,3366
|
|
5
|
+
forgingstack_quorum-0.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
6
|
+
forgingstack_quorum-0.1.0.dist-info/entry_points.txt,sha256=6yHZCQJh49Pvb7uA4JVLLKUhPVK6SProTf_iMX7M6HM,60
|
|
7
|
+
forgingstack_quorum-0.1.0.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
|
8
|
+
forgingstack_quorum-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
app
|