@scopebond/mcp 0.2.0
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.
- package/LICENSE +201 -0
- package/README.md +61 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +180 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud.d.ts +13 -0
- package/dist/cloud.d.ts.map +1 -0
- package/dist/cloud.js +37 -0
- package/dist/cloud.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +10 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +26 -0
- package/dist/init.js.map +1 -0
- package/dist/proxy.d.ts +43 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +51 -0
- package/dist/proxy.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Avouro LLC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @scopebond/mcp
|
|
2
|
+
|
|
3
|
+
The Scopebond **MCP proxy** — one policy for every Model Context Protocol tool
|
|
4
|
+
call, in front of the servers an agent uses. It sits in-path between an MCP client
|
|
5
|
+
and an upstream server, checks each `tools/call` against your policy before it is
|
|
6
|
+
forwarded, and records a signed **PEP-authorized receipt**. A denied call is never
|
|
7
|
+
forwarded.
|
|
8
|
+
|
|
9
|
+
- **Label:** in-path · prevents. The proxy decides the caller's request (no agent
|
|
10
|
+
signature), so its receipts are `pep_authorized` — the identity is the
|
|
11
|
+
configured principal, and the receipt attests that the proxy authorized the
|
|
12
|
+
call, never that an agent signed it.
|
|
13
|
+
|
|
14
|
+
## Use it
|
|
15
|
+
|
|
16
|
+
Point your MCP client at `scopebond-mcp` and give it the real server after `--`:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
scopebond-mcp --server filesystem --policy scopebond.policy.json --key scopebond-agent.key \
|
|
20
|
+
-- npx -y @modelcontextprotocol/server-filesystem /path/to/workspace
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`tools/call` is checked; everything else (`initialize`, `tools/list`, …) passes
|
|
24
|
+
through. A denial returns a JSON-RPC error to the client and is never sent
|
|
25
|
+
upstream. Set `--receipts log.jsonl` to keep the signed receipts locally.
|
|
26
|
+
|
|
27
|
+
**Ceiling.** The proxy governs **tool invocations** (`tools/call`). It does not
|
|
28
|
+
gate resource reads (`resources/read`) or prompt fetches (`prompts/get`), which
|
|
29
|
+
pass through — so a server that exposes data as resources rather than tools is not
|
|
30
|
+
covered by a tool policy. Govern such data at the server, or front only servers
|
|
31
|
+
whose sensitive operations are tools.
|
|
32
|
+
|
|
33
|
+
## Policy
|
|
34
|
+
|
|
35
|
+
Bound MCP calls with the Action Taxonomy's `mcp.tool.call` type — "read-only
|
|
36
|
+
filesystem tools only":
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"vocabulary_version": "1.0", "policy_id": "mcp", "version": 1,
|
|
41
|
+
"clauses": [
|
|
42
|
+
{ "id": "fs", "type": "action_allowlist", "mode": "enforce",
|
|
43
|
+
"action_types": ["mcp.tool.call"],
|
|
44
|
+
"param_bounds": { "server": { "enum": ["filesystem"] }, "tool": { "pattern": "^(?!delete_|write_).+" } } }
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Library
|
|
50
|
+
|
|
51
|
+
The proxy core is exported and transport-agnostic:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { createMcpProxy, mapMcpToolCall } from "@scopebond/mcp";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`createMcpProxy({ policy, principal, server, attesterKeyPem, upstream })` returns
|
|
58
|
+
`{ handle(message) }`; inject `upstream` to test the decision path without a real
|
|
59
|
+
server.
|
|
60
|
+
|
|
61
|
+
Experimental alpha; controlled test use only.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// scopebond-mcp — a stdio Model Context Protocol proxy. It sits between an MCP
|
|
3
|
+
// client and an upstream server: the client speaks MCP to this process, and this
|
|
4
|
+
// process speaks MCP to the upstream command (everything after `--`). Every
|
|
5
|
+
// tools/call is checked against policy before it is forwarded; a denial returns a
|
|
6
|
+
// JSON-RPC error and is never sent upstream.
|
|
7
|
+
//
|
|
8
|
+
// scopebond-mcp init --server <id> scaffold a key + starter policy
|
|
9
|
+
// scopebond-mcp --server <id> [--policy p.json] [--key k.pem] [--principal sub] \
|
|
10
|
+
// [--receipts log.jsonl] -- <upstream-command...>
|
|
11
|
+
//
|
|
12
|
+
// Env: SCOPEBOND_MCP_POLICY, SCOPEBOND_MCP_KEY, SCOPEBOND_MCP_SERVER,
|
|
13
|
+
// SCOPEBOND_MCP_PRINCIPAL, SCOPEBOND_MCP_RECEIPTS.
|
|
14
|
+
// MCP stdio is newline-delimited JSON-RPC. Fail closed: any setup error exits 1.
|
|
15
|
+
import { readFileSync, appendFileSync } from "node:fs";
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
import { createInterface } from "node:readline";
|
|
18
|
+
import { createMcpProxy } from "./proxy.js";
|
|
19
|
+
import { scaffold } from "./init.js";
|
|
20
|
+
import { connectCloud, loadMcpConnection, connectionFileFor, openExporter } from "./cloud.js";
|
|
21
|
+
function arg(name, fallback) {
|
|
22
|
+
const i = process.argv.indexOf(name);
|
|
23
|
+
return i >= 0 ? process.argv[i + 1] : fallback;
|
|
24
|
+
}
|
|
25
|
+
function die(message) { process.stderr.write(`scopebond-mcp: ${message}\n`); process.exit(1); }
|
|
26
|
+
// `init`: scaffold a key + a starter policy for one server, then exit.
|
|
27
|
+
if (process.argv[2] === "init") {
|
|
28
|
+
const server = arg("--server", process.env.SCOPEBOND_MCP_SERVER);
|
|
29
|
+
if (!server)
|
|
30
|
+
die("usage: scopebond-mcp init --server <upstream-server-id>");
|
|
31
|
+
const { keyFile, policyFile } = scaffold(server, { force: process.argv.includes("--force") });
|
|
32
|
+
console.log(`Scopebond MCP proxy enrolled for server "${server}":`);
|
|
33
|
+
console.log(` key ${keyFile}`);
|
|
34
|
+
console.log(` policy ${policyFile} (starter — edit the tool bounds)`);
|
|
35
|
+
console.log("");
|
|
36
|
+
console.log("Point your MCP client at the proxy:");
|
|
37
|
+
console.log(` scopebond-mcp --server ${server} -- <your real MCP server command>`);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
// `connect`: enroll the proxy's key with a workspace and store a scoped credential.
|
|
41
|
+
if (process.argv[2] === "connect") {
|
|
42
|
+
const url = process.argv[3];
|
|
43
|
+
const bundleFile = process.argv[4];
|
|
44
|
+
const keyPath = arg("--key", process.env.SCOPEBOND_MCP_KEY ?? "scopebond-agent.key");
|
|
45
|
+
if (!url || !bundleFile)
|
|
46
|
+
die("usage: scopebond-mcp connect <workspace-url> <enrollment-bundle.json> [--key k.pem]");
|
|
47
|
+
let bundle;
|
|
48
|
+
try {
|
|
49
|
+
bundle = JSON.parse(readFileSync(bundleFile, "utf8"));
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
die(`could not read the enrollment bundle ${bundleFile}: ${e.message}`);
|
|
53
|
+
}
|
|
54
|
+
connectCloud(keyPath, url, bundle).then((c) => {
|
|
55
|
+
console.log(`Connected to ${c.url} (org ${c.organization_id} · env ${c.environment_id})`);
|
|
56
|
+
console.log(` credential stored in ${connectionFileFor(keyPath)} — a secret, do not commit`);
|
|
57
|
+
console.log("Run the proxy as usual; every governed tool call is now mirrored to your workspace.");
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}).catch((e) => die(`connect failed: ${e.message}`));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const dashDash = process.argv.indexOf("--");
|
|
63
|
+
if (dashDash < 0 || dashDash === process.argv.length - 1)
|
|
64
|
+
die("provide the upstream command after `--`");
|
|
65
|
+
const upstreamCmd = process.argv.slice(dashDash + 1);
|
|
66
|
+
const server = arg("--server", process.env.SCOPEBOND_MCP_SERVER);
|
|
67
|
+
const policyPath = arg("--policy", process.env.SCOPEBOND_MCP_POLICY ?? "scopebond.policy.json");
|
|
68
|
+
const keyPath = arg("--key", process.env.SCOPEBOND_MCP_KEY ?? "scopebond-agent.key");
|
|
69
|
+
const principal = arg("--principal", process.env.SCOPEBOND_MCP_PRINCIPAL ?? "mcp-client");
|
|
70
|
+
const receiptsPath = arg("--receipts", process.env.SCOPEBOND_MCP_RECEIPTS);
|
|
71
|
+
if (!server)
|
|
72
|
+
die("--server (the upstream server id) is required");
|
|
73
|
+
let policy;
|
|
74
|
+
let attesterKeyPem;
|
|
75
|
+
try {
|
|
76
|
+
policy = JSON.parse(readFileSync(policyPath, "utf8"));
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
die(`could not read policy ${policyPath}: ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
attesterKeyPem = readFileSync(keyPath, "utf8");
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
die(`could not read signing key ${keyPath}: ${e.message}`);
|
|
86
|
+
}
|
|
87
|
+
// When connected to a workspace, mirror the PEP-authorized receipts to the portal
|
|
88
|
+
// through a durable outbox. The proxy is long-running, so the exporter's own timer
|
|
89
|
+
// delivers; a final flush runs on shutdown.
|
|
90
|
+
const connection = loadMcpConnection(keyPath);
|
|
91
|
+
let exporter;
|
|
92
|
+
if (connection) {
|
|
93
|
+
try {
|
|
94
|
+
exporter = openExporter(keyPath, connection);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
die(`durable Cloud outbox could not open: ${e.message}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Spawn the upstream server and correlate its responses by id.
|
|
101
|
+
const child = spawn(upstreamCmd[0], upstreamCmd.slice(1), { stdio: ["pipe", "pipe", "inherit"] });
|
|
102
|
+
child.on("error", (e) => die(`could not start the upstream server: ${e.message}`));
|
|
103
|
+
const shutdown = (code) => {
|
|
104
|
+
if (!exporter)
|
|
105
|
+
process.exit(code);
|
|
106
|
+
void exporter.flush().finally(() => { exporter.stop(); process.exit(code); });
|
|
107
|
+
};
|
|
108
|
+
child.on("exit", (code) => shutdown(code ?? 0));
|
|
109
|
+
process.on("SIGINT", () => shutdown(0));
|
|
110
|
+
process.on("SIGTERM", () => shutdown(0));
|
|
111
|
+
const pending = new Map();
|
|
112
|
+
const key = (id) => JSON.stringify(id ?? null);
|
|
113
|
+
createInterface({ input: child.stdout }).on("line", (line) => {
|
|
114
|
+
if (!line.trim())
|
|
115
|
+
return;
|
|
116
|
+
let msg;
|
|
117
|
+
try {
|
|
118
|
+
msg = JSON.parse(line);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const waiter = msg.id !== undefined ? pending.get(key(msg.id)) : undefined;
|
|
124
|
+
if (waiter) {
|
|
125
|
+
pending.delete(key(msg.id));
|
|
126
|
+
waiter(msg);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
process.stdout.write(line + "\n"); // upstream-initiated notification → pass to the client
|
|
130
|
+
});
|
|
131
|
+
const upstream = {
|
|
132
|
+
call(message) {
|
|
133
|
+
return new Promise((resolve) => {
|
|
134
|
+
if (message.id === undefined || message.id === null) { // notification: fire and forget
|
|
135
|
+
child.stdin.write(JSON.stringify(message) + "\n");
|
|
136
|
+
resolve({ jsonrpc: "2.0", result: null });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
pending.set(key(message.id), resolve);
|
|
140
|
+
child.stdin.write(JSON.stringify(message) + "\n");
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
const proxy = createMcpProxy({
|
|
145
|
+
policy, principal: { subject: `client:${principal}`, issuer: "scopebond:mcp-proxy" }, server: server,
|
|
146
|
+
attesterKeyPem, upstream,
|
|
147
|
+
onReceipt: (r) => {
|
|
148
|
+
if (receiptsPath) {
|
|
149
|
+
try {
|
|
150
|
+
appendFileSync(receiptsPath, JSON.stringify(r) + "\n");
|
|
151
|
+
}
|
|
152
|
+
catch { /* best effort */ }
|
|
153
|
+
}
|
|
154
|
+
exporter?.enqueue(r); // mirror to the workspace when connected
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
createInterface({ input: process.stdin }).on("line", async (line) => {
|
|
158
|
+
if (!line.trim())
|
|
159
|
+
return;
|
|
160
|
+
let msg;
|
|
161
|
+
try {
|
|
162
|
+
msg = JSON.parse(line);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const response = await proxy.handle(msg);
|
|
169
|
+
if (msg.id !== undefined && msg.id !== null)
|
|
170
|
+
process.stdout.write(JSON.stringify(response) + "\n");
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
// Fail closed: a proxy error becomes a JSON-RPC error, never a silent forward.
|
|
174
|
+
if (msg.id !== undefined && msg.id !== null) {
|
|
175
|
+
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, error: { code: -32000, message: `scopebond-mcp failed closed: ${e.message}` } }) + "\n");
|
|
176
|
+
}
|
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Q,CAAC,GAAG,IAAI,CAAC,CAAC;QACrG,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,+EAA+E;YAC/E,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;gBAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,gCAAiC,CAAW,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACxK,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACH,CAAC","sourcesContent":["#!/usr/bin/env node\n// scopebond-mcp — a stdio Model Context Protocol proxy. It sits between an MCP\n// client and an upstream server: the client speaks MCP to this process, and this\n// process speaks MCP to the upstream command (everything after `--`). Every\n// tools/call is checked against policy before it is forwarded; a denial returns a\n// JSON-RPC error and is never sent upstream.\n//\n// scopebond-mcp init --server <id> scaffold a key + starter policy\n// scopebond-mcp --server <id> [--policy p.json] [--key k.pem] [--principal sub] \\\n// [--receipts log.jsonl] -- <upstream-command...>\n//\n// Env: SCOPEBOND_MCP_POLICY, SCOPEBOND_MCP_KEY, SCOPEBOND_MCP_SERVER,\n// SCOPEBOND_MCP_PRINCIPAL, SCOPEBOND_MCP_RECEIPTS.\n// MCP stdio is newline-delimited JSON-RPC. Fail closed: any setup error exits 1.\n\nimport { readFileSync, appendFileSync } from \"node:fs\";\nimport { spawn } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\nimport type { SignedReceipt, CloudExporter } from \"@scopebond/gateway\";\nimport { createMcpProxy } from \"./proxy.js\";\nimport type { JsonRpcMessage, McpUpstream } from \"./proxy.js\";\nimport { scaffold } from \"./init.js\";\nimport { connectCloud, loadMcpConnection, connectionFileFor, openExporter } from \"./cloud.js\";\n\nfunction arg(name: string, fallback?: string): string | undefined {\n const i = process.argv.indexOf(name);\n return i >= 0 ? process.argv[i + 1] : fallback;\n}\nfunction die(message: string): never { process.stderr.write(`scopebond-mcp: ${message}\\n`); process.exit(1); }\n\n// `init`: scaffold a key + a starter policy for one server, then exit.\nif (process.argv[2] === \"init\") {\n const server = arg(\"--server\", process.env.SCOPEBOND_MCP_SERVER);\n if (!server) die(\"usage: scopebond-mcp init --server <upstream-server-id>\");\n const { keyFile, policyFile } = scaffold(server as string, { force: process.argv.includes(\"--force\") });\n console.log(`Scopebond MCP proxy enrolled for server \"${server}\":`);\n console.log(` key ${keyFile}`);\n console.log(` policy ${policyFile} (starter — edit the tool bounds)`);\n console.log(\"\");\n console.log(\"Point your MCP client at the proxy:\");\n console.log(` scopebond-mcp --server ${server} -- <your real MCP server command>`);\n process.exit(0);\n}\n\n// `connect`: enroll the proxy's key with a workspace and store a scoped credential.\nif (process.argv[2] === \"connect\") {\n const url = process.argv[3];\n const bundleFile = process.argv[4];\n const keyPath = arg(\"--key\", process.env.SCOPEBOND_MCP_KEY ?? \"scopebond-agent.key\")!;\n if (!url || !bundleFile) die(\"usage: scopebond-mcp connect <workspace-url> <enrollment-bundle.json> [--key k.pem]\");\n let bundle;\n try { bundle = JSON.parse(readFileSync(bundleFile, \"utf8\")); }\n catch (e) { die(`could not read the enrollment bundle ${bundleFile}: ${(e as Error).message}`); }\n connectCloud(keyPath, url, bundle).then((c) => {\n console.log(`Connected to ${c.url} (org ${c.organization_id} · env ${c.environment_id})`);\n console.log(` credential stored in ${connectionFileFor(keyPath)} — a secret, do not commit`);\n console.log(\"Run the proxy as usual; every governed tool call is now mirrored to your workspace.\");\n process.exit(0);\n }).catch((e) => die(`connect failed: ${(e as Error).message}`));\n} else {\n\nconst dashDash = process.argv.indexOf(\"--\");\nif (dashDash < 0 || dashDash === process.argv.length - 1) die(\"provide the upstream command after `--`\");\nconst upstreamCmd = process.argv.slice(dashDash + 1);\n\nconst server = arg(\"--server\", process.env.SCOPEBOND_MCP_SERVER);\nconst policyPath = arg(\"--policy\", process.env.SCOPEBOND_MCP_POLICY ?? \"scopebond.policy.json\");\nconst keyPath = arg(\"--key\", process.env.SCOPEBOND_MCP_KEY ?? \"scopebond-agent.key\");\nconst principal = arg(\"--principal\", process.env.SCOPEBOND_MCP_PRINCIPAL ?? \"mcp-client\");\nconst receiptsPath = arg(\"--receipts\", process.env.SCOPEBOND_MCP_RECEIPTS);\nif (!server) die(\"--server (the upstream server id) is required\");\n\nlet policy: unknown;\nlet attesterKeyPem: string;\ntry { policy = JSON.parse(readFileSync(policyPath as string, \"utf8\")); } catch (e) { die(`could not read policy ${policyPath}: ${(e as Error).message}`); }\ntry { attesterKeyPem = readFileSync(keyPath as string, \"utf8\"); } catch (e) { die(`could not read signing key ${keyPath}: ${(e as Error).message}`); }\n\n// When connected to a workspace, mirror the PEP-authorized receipts to the portal\n// through a durable outbox. The proxy is long-running, so the exporter's own timer\n// delivers; a final flush runs on shutdown.\nconst connection = loadMcpConnection(keyPath as string);\nlet exporter: CloudExporter | undefined;\nif (connection) {\n try { exporter = openExporter(keyPath as string, connection); }\n catch (e) { die(`durable Cloud outbox could not open: ${(e as Error).message}`); }\n}\n\n// Spawn the upstream server and correlate its responses by id.\nconst child = spawn(upstreamCmd[0], upstreamCmd.slice(1), { stdio: [\"pipe\", \"pipe\", \"inherit\"] });\nchild.on(\"error\", (e) => die(`could not start the upstream server: ${e.message}`));\nconst shutdown = (code: number) => {\n if (!exporter) process.exit(code);\n void exporter.flush().finally(() => { exporter!.stop(); process.exit(code); });\n};\nchild.on(\"exit\", (code) => shutdown(code ?? 0));\nprocess.on(\"SIGINT\", () => shutdown(0));\nprocess.on(\"SIGTERM\", () => shutdown(0));\n\nconst pending = new Map<string, (m: JsonRpcMessage) => void>();\nconst key = (id: unknown) => JSON.stringify(id ?? null);\n\ncreateInterface({ input: child.stdout }).on(\"line\", (line) => {\n if (!line.trim()) return;\n let msg: JsonRpcMessage;\n try { msg = JSON.parse(line); } catch { return; }\n const waiter = msg.id !== undefined ? pending.get(key(msg.id)) : undefined;\n if (waiter) { pending.delete(key(msg.id)); waiter(msg); return; }\n process.stdout.write(line + \"\\n\"); // upstream-initiated notification → pass to the client\n});\n\nconst upstream: McpUpstream = {\n call(message) {\n return new Promise((resolve) => {\n if (message.id === undefined || message.id === null) { // notification: fire and forget\n child.stdin.write(JSON.stringify(message) + \"\\n\");\n resolve({ jsonrpc: \"2.0\", result: null });\n return;\n }\n pending.set(key(message.id), resolve);\n child.stdin.write(JSON.stringify(message) + \"\\n\");\n });\n },\n};\n\nconst proxy = createMcpProxy({\n policy, principal: { subject: `client:${principal}`, issuer: \"scopebond:mcp-proxy\" }, server: server as string,\n attesterKeyPem, upstream,\n onReceipt: (r: SignedReceipt) => {\n if (receiptsPath) { try { appendFileSync(receiptsPath, JSON.stringify(r) + \"\\n\"); } catch { /* best effort */ } }\n exporter?.enqueue(r); // mirror to the workspace when connected\n },\n});\n\ncreateInterface({ input: process.stdin }).on(\"line\", async (line) => {\n if (!line.trim()) return;\n let msg: JsonRpcMessage;\n try { msg = JSON.parse(line); } catch { return; }\n try {\n const response = await proxy.handle(msg);\n if (msg.id !== undefined && msg.id !== null) process.stdout.write(JSON.stringify(response) + \"\\n\");\n } catch (e) {\n // Fail closed: a proxy error becomes a JSON-RPC error, never a silent forward.\n if (msg.id !== undefined && msg.id !== null) {\n process.stdout.write(JSON.stringify({ jsonrpc: \"2.0\", id: msg.id, error: { code: -32000, message: `scopebond-mcp failed closed: ${(e as Error).message}` } }) + \"\\n\");\n }\n }\n});\n}\n"]}
|
package/dist/cloud.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CloudEnrollmentBundle, type CloudEnrollmentResult, type CloudExporter } from "@scopebond/gateway";
|
|
2
|
+
export interface McpConnection extends CloudEnrollmentResult {
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const connectionFileFor: (keyPath: string) => string;
|
|
6
|
+
export declare function loadMcpConnection(keyPath: string): McpConnection | null;
|
|
7
|
+
/** Enroll the proxy's signing key (its attester) with a workspace via the one-use
|
|
8
|
+
* handoff, then persist the scoped machine credential next to the key. */
|
|
9
|
+
export declare function connectCloud(keyPath: string, url: string, bundle: CloudEnrollmentBundle, fetchImpl?: typeof fetch): Promise<McpConnection>;
|
|
10
|
+
/** A durable exporter for a connection; enqueue each receipt and it flushes on the
|
|
11
|
+
* proxy's lifetime (timer) plus an explicit flush on shutdown. */
|
|
12
|
+
export declare function openExporter(keyPath: string, connection: McpConnection, fetchImpl?: typeof fetch): CloudExporter;
|
|
13
|
+
//# sourceMappingURL=cloud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAC3E,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,aAAc,SAAQ,qBAAqB;IAC1D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,MAAiC,CAAC;AAEtF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAQvE;AAED;2EAC2E;AAC3E,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,GACpF,OAAO,CAAC,aAAa,CAAC,CAMxB;AAED;mEACmE;AACnE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,GAAG,aAAa,CAGhH"}
|
package/dist/cloud.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// scopebond-mcp → Scopebond Cloud: enroll the proxy's signing key with a workspace
|
|
2
|
+
// and export the PEP-authorized receipts it emits, so governed MCP tool calls show
|
|
3
|
+
// in the hosted portal. Reuses the gateway's enrollment and durable exporter (D40).
|
|
4
|
+
// The proxy is long-running, so the exporter's own flush timer delivers; a durable
|
|
5
|
+
// outbox next to the key survives restarts.
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { completeCloudEnrollment, createCloudExporter, } from "@scopebond/gateway";
|
|
8
|
+
import { SqliteCloudOutbox, loadOrCreateAttester } from "@scopebond/gateway/node";
|
|
9
|
+
export const connectionFileFor = (keyPath) => keyPath + ".cloud.json";
|
|
10
|
+
export function loadMcpConnection(keyPath) {
|
|
11
|
+
const path = connectionFileFor(keyPath);
|
|
12
|
+
if (!existsSync(path))
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
16
|
+
if (typeof parsed.url === "string" && typeof parsed.credential === "string")
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
catch { /* fall through */ }
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/** Enroll the proxy's signing key (its attester) with a workspace via the one-use
|
|
23
|
+
* handoff, then persist the scoped machine credential next to the key. */
|
|
24
|
+
export async function connectCloud(keyPath, url, bundle, fetchImpl) {
|
|
25
|
+
const { attester } = loadOrCreateAttester({ file: keyPath });
|
|
26
|
+
const result = await completeCloudEnrollment({ url, bundle, attester, fetch: fetchImpl });
|
|
27
|
+
const connection = { url, ...result };
|
|
28
|
+
writeFileSync(connectionFileFor(keyPath), JSON.stringify(connection, null, 2) + "\n", { mode: 0o600 });
|
|
29
|
+
return connection;
|
|
30
|
+
}
|
|
31
|
+
/** A durable exporter for a connection; enqueue each receipt and it flushes on the
|
|
32
|
+
* proxy's lifetime (timer) plus an explicit flush on shutdown. */
|
|
33
|
+
export function openExporter(keyPath, connection, fetchImpl) {
|
|
34
|
+
const outbox = new SqliteCloudOutbox(keyPath + ".cloud-outbox.db");
|
|
35
|
+
return createCloudExporter({ url: connection.url, credential: connection.credential, outbox, fetch: fetchImpl });
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,mFAAmF;AACnF,oFAAoF;AACpF,mFAAmF;AACnF,4CAA4C;AAE5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EACL,uBAAuB,EAAE,mBAAmB,GAE7C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAMlF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,OAAO,GAAG,aAAa,CAAC;AAEtF,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA2B,CAAC;QAChF,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,MAAuB,CAAC;IAC9G,CAAC;IAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;2EAC2E;AAC3E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EAAE,GAAW,EAAE,MAA6B,EAAE,SAAwB;IAErF,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1F,MAAM,UAAU,GAAkB,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IACrD,aAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvG,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;mEACmE;AACnE,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,UAAyB,EAAE,SAAwB;IAC/F,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAC;IACnE,OAAO,mBAAmB,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACnH,CAAC","sourcesContent":["// scopebond-mcp → Scopebond Cloud: enroll the proxy's signing key with a workspace\n// and export the PEP-authorized receipts it emits, so governed MCP tool calls show\n// in the hosted portal. Reuses the gateway's enrollment and durable exporter (D40).\n// The proxy is long-running, so the exporter's own flush timer delivers; a durable\n// outbox next to the key survives restarts.\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport {\n completeCloudEnrollment, createCloudExporter,\n type CloudEnrollmentBundle, type CloudEnrollmentResult, type CloudExporter,\n} from \"@scopebond/gateway\";\nimport { SqliteCloudOutbox, loadOrCreateAttester } from \"@scopebond/gateway/node\";\n\nexport interface McpConnection extends CloudEnrollmentResult {\n url: string;\n}\n\nexport const connectionFileFor = (keyPath: string): string => keyPath + \".cloud.json\";\n\nexport function loadMcpConnection(keyPath: string): McpConnection | null {\n const path = connectionFileFor(keyPath);\n if (!existsSync(path)) return null;\n try {\n const parsed = JSON.parse(readFileSync(path, \"utf8\")) as Partial<McpConnection>;\n if (typeof parsed.url === \"string\" && typeof parsed.credential === \"string\") return parsed as McpConnection;\n } catch { /* fall through */ }\n return null;\n}\n\n/** Enroll the proxy's signing key (its attester) with a workspace via the one-use\n * handoff, then persist the scoped machine credential next to the key. */\nexport async function connectCloud(\n keyPath: string, url: string, bundle: CloudEnrollmentBundle, fetchImpl?: typeof fetch,\n): Promise<McpConnection> {\n const { attester } = loadOrCreateAttester({ file: keyPath });\n const result = await completeCloudEnrollment({ url, bundle, attester, fetch: fetchImpl });\n const connection: McpConnection = { url, ...result };\n writeFileSync(connectionFileFor(keyPath), JSON.stringify(connection, null, 2) + \"\\n\", { mode: 0o600 });\n return connection;\n}\n\n/** A durable exporter for a connection; enqueue each receipt and it flushes on the\n * proxy's lifetime (timer) plus an explicit flush on shutdown. */\nexport function openExporter(keyPath: string, connection: McpConnection, fetchImpl?: typeof fetch): CloudExporter {\n const outbox = new SqliteCloudOutbox(keyPath + \".cloud-outbox.db\");\n return createCloudExporter({ url: connection.url, credential: connection.credential, outbox, fetch: fetchImpl });\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createMcpProxy, mapMcpToolCall } from "./proxy.js";
|
|
2
|
+
export type { McpProxy, McpProxyConfig, McpUpstream, JsonRpcMessage } from "./proxy.js";
|
|
3
|
+
export { starterMcpPolicy } from "./init.js";
|
|
4
|
+
export { connectCloud, loadMcpConnection, openExporter, connectionFileFor } from "./cloud.js";
|
|
5
|
+
export type { McpConnection } from "./cloud.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9F,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @scopebond/mcp — the Model Context Protocol proxy connector. The library
|
|
2
|
+
// surface is the deterministic mapper and the transport-agnostic proxy core; the
|
|
3
|
+
// `scopebond-mcp` binary provides the stdio transport to a real upstream server.
|
|
4
|
+
export { createMcpProxy, mapMcpToolCall } from "./proxy.js";
|
|
5
|
+
export { starterMcpPolicy } from "./init.js";
|
|
6
|
+
export { connectCloud, loadMcpConnection, openExporter, connectionFileFor } from "./cloud.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iFAAiF;AACjF,iFAAiF;AAEjF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// @scopebond/mcp — the Model Context Protocol proxy connector. The library\n// surface is the deterministic mapper and the transport-agnostic proxy core; the\n// `scopebond-mcp` binary provides the stdio transport to a real upstream server.\n\nexport { createMcpProxy, mapMcpToolCall } from \"./proxy.js\";\nexport type { McpProxy, McpProxyConfig, McpUpstream, JsonRpcMessage } from \"./proxy.js\";\nexport { starterMcpPolicy } from \"./init.js\";\nexport { connectCloud, loadMcpConnection, openExporter, connectionFileFor } from \"./cloud.js\";\nexport type { McpConnection } from \"./cloud.js\";\n"]}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A starter MCP policy: allow read-ish tools on the server, deny destructive
|
|
2
|
+
* ones by name. Every threshold is the operator's to edit. */
|
|
3
|
+
export declare function starterMcpPolicy(server: string): Record<string, unknown>;
|
|
4
|
+
export declare function scaffold(server: string, opts?: {
|
|
5
|
+
force?: boolean;
|
|
6
|
+
}): {
|
|
7
|
+
keyFile: string;
|
|
8
|
+
policyFile: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA;+DAC+D;AAC/D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASxE;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAQhH"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// `scopebond-mcp init` — scaffold the local enrollment for the proxy: a signing
|
|
2
|
+
// key and a starter policy for one upstream server. Keys and receipts stay local.
|
|
3
|
+
import { writeFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { loadOrCreateAttester } from "@scopebond/gateway/node";
|
|
5
|
+
/** A starter MCP policy: allow read-ish tools on the server, deny destructive
|
|
6
|
+
* ones by name. Every threshold is the operator's to edit. */
|
|
7
|
+
export function starterMcpPolicy(server) {
|
|
8
|
+
return {
|
|
9
|
+
vocabulary_version: "1.0", policy_id: "mcp", version: 1,
|
|
10
|
+
clauses: [{
|
|
11
|
+
id: "tools", type: "action_allowlist", mode: "enforce", action_types: ["mcp.tool.call"],
|
|
12
|
+
param_bounds: { server: { enum: [server] }, tool: { pattern: "^(?!delete_|write_|remove_|drop_|rm_).+" } },
|
|
13
|
+
description: `Allow non-destructive tools on ${server}; deny delete/write/remove/drop/rm tools.`,
|
|
14
|
+
}],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function scaffold(server, opts = {}) {
|
|
18
|
+
const keyFile = "scopebond-agent.key";
|
|
19
|
+
const policyFile = "scopebond.policy.json";
|
|
20
|
+
loadOrCreateAttester({ file: keyFile }); // reused if present
|
|
21
|
+
if (!existsSync(policyFile) || opts.force) {
|
|
22
|
+
writeFileSync(policyFile, JSON.stringify(starterMcpPolicy(server), null, 2) + "\n");
|
|
23
|
+
}
|
|
24
|
+
return { keyFile, policyFile };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,kFAAkF;AAElF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D;+DAC+D;AAC/D,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO;QACL,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QACvD,OAAO,EAAE,CAAC;gBACR,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,eAAe,CAAC;gBACvF,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,yCAAyC,EAAE,EAAE;gBAC1G,WAAW,EAAE,kCAAkC,MAAM,2CAA2C;aACjG,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,OAA4B,EAAE;IACrE,MAAM,OAAO,GAAG,qBAAqB,CAAC;IACtC,MAAM,UAAU,GAAG,uBAAuB,CAAC;IAC3C,oBAAoB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,oBAAoB;IAC7D,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1C,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// `scopebond-mcp init` — scaffold the local enrollment for the proxy: a signing\n// key and a starter policy for one upstream server. Keys and receipts stay local.\n\nimport { writeFileSync, existsSync } from \"node:fs\";\nimport { loadOrCreateAttester } from \"@scopebond/gateway/node\";\n\n/** A starter MCP policy: allow read-ish tools on the server, deny destructive\n * ones by name. Every threshold is the operator's to edit. */\nexport function starterMcpPolicy(server: string): Record<string, unknown> {\n return {\n vocabulary_version: \"1.0\", policy_id: \"mcp\", version: 1,\n clauses: [{\n id: \"tools\", type: \"action_allowlist\", mode: \"enforce\", action_types: [\"mcp.tool.call\"],\n param_bounds: { server: { enum: [server] }, tool: { pattern: \"^(?!delete_|write_|remove_|drop_|rm_).+\" } },\n description: `Allow non-destructive tools on ${server}; deny delete/write/remove/drop/rm tools.`,\n }],\n };\n}\n\nexport function scaffold(server: string, opts: { force?: boolean } = {}): { keyFile: string; policyFile: string } {\n const keyFile = \"scopebond-agent.key\";\n const policyFile = \"scopebond.policy.json\";\n loadOrCreateAttester({ file: keyFile }); // reused if present\n if (!existsSync(policyFile) || opts.force) {\n writeFileSync(policyFile, JSON.stringify(starterMcpPolicy(server), null, 2) + \"\\n\");\n }\n return { keyFile, policyFile };\n}\n"]}
|
package/dist/proxy.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SignedReceipt } from "@scopebond/gateway";
|
|
2
|
+
export interface JsonRpcMessage {
|
|
3
|
+
jsonrpc?: string;
|
|
4
|
+
id?: string | number | null;
|
|
5
|
+
method?: string;
|
|
6
|
+
params?: Record<string, unknown>;
|
|
7
|
+
result?: unknown;
|
|
8
|
+
error?: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** Map an MCP `tools/call` to a normalized `mcp.tool.call` action. Arguments are
|
|
11
|
+
* digested, never stored. */
|
|
12
|
+
export declare function mapMcpToolCall(server: string, params: Record<string, unknown> | undefined): {
|
|
13
|
+
action_type: string;
|
|
14
|
+
params: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** A pre-authenticated forwarder to the upstream MCP server. Tests inject it; the
|
|
17
|
+
* CLI implements it over stdio. */
|
|
18
|
+
export interface McpUpstream {
|
|
19
|
+
call(message: JsonRpcMessage): Promise<JsonRpcMessage>;
|
|
20
|
+
}
|
|
21
|
+
export interface McpProxyConfig {
|
|
22
|
+
policy: unknown;
|
|
23
|
+
/** The validated caller identity recorded on every receipt. */
|
|
24
|
+
principal: {
|
|
25
|
+
subject: string;
|
|
26
|
+
issuer: string;
|
|
27
|
+
};
|
|
28
|
+
/** The upstream server id, used as the action's `server` parameter. */
|
|
29
|
+
server: string;
|
|
30
|
+
/** PEM of the key that signs the PEP receipts (the enrolled proxy key). */
|
|
31
|
+
attesterKeyPem: string;
|
|
32
|
+
upstream: McpUpstream;
|
|
33
|
+
now?: () => string;
|
|
34
|
+
/** Sink for each emitted receipt (e.g. a local log / exporter). */
|
|
35
|
+
onReceipt?: (receipt: SignedReceipt) => void | Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export interface McpProxy {
|
|
38
|
+
handle(message: JsonRpcMessage): Promise<JsonRpcMessage>;
|
|
39
|
+
}
|
|
40
|
+
/** Build a proxy handler. Every `tools/call` is decided against policy; anything
|
|
41
|
+
* else is passed through to the upstream unchanged. */
|
|
42
|
+
export declare function createMcpProxy(config: McpProxyConfig): McpProxy;
|
|
43
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,oBAAoB,CAAC;AAIlE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAID;6BAC6B;AAC7B,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAKpJ;AAED;mCACmC;AACnC,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,+DAA+D;IAC/D,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,mEAAmE;IACnE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1D;AAED;uDACuD;AACvD,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAgC/D"}
|
package/dist/proxy.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// The MCP proxy core: sit in front of an upstream MCP server, check each
|
|
2
|
+
// `tools/call` against policy before forwarding it, and emit a signed
|
|
3
|
+
// PEP-authorized receipt. A denied call is never forwarded. Deterministic and
|
|
4
|
+
// transport-agnostic — the upstream is injected, so the decision path is
|
|
5
|
+
// conformance-tested directly; the `scopebond-mcp` CLI provides the real stdio
|
|
6
|
+
// transport. The proxy decides the caller's request (no agent signature), so its
|
|
7
|
+
// receipts are pep_authorized (§15) — the identity is the configured principal.
|
|
8
|
+
import { violates } from "@scopebond/verify";
|
|
9
|
+
import { buildPepReceipt, attesterFromPrivateKeyPem } from "@scopebond/gateway";
|
|
10
|
+
import { canonical } from "@scopebond/policy-schema/canonical";
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
const digest = (value) => "sha256:" + createHash("sha256").update(canonical(value)).digest("hex");
|
|
13
|
+
/** Map an MCP `tools/call` to a normalized `mcp.tool.call` action. Arguments are
|
|
14
|
+
* digested, never stored. */
|
|
15
|
+
export function mapMcpToolCall(server, params) {
|
|
16
|
+
return {
|
|
17
|
+
action_type: "mcp.tool.call",
|
|
18
|
+
params: { server, tool: String(params?.name ?? ""), args_digest: digest(params?.arguments ?? {}) },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Build a proxy handler. Every `tools/call` is decided against policy; anything
|
|
22
|
+
* else is passed through to the upstream unchanged. */
|
|
23
|
+
export function createMcpProxy(config) {
|
|
24
|
+
const attester = attesterFromPrivateKeyPem(config.attesterKeyPem);
|
|
25
|
+
return {
|
|
26
|
+
async handle(message) {
|
|
27
|
+
if (message?.method !== "tools/call")
|
|
28
|
+
return config.upstream.call(message);
|
|
29
|
+
const intent = mapMcpToolCall(config.server, message.params);
|
|
30
|
+
const claimed = {
|
|
31
|
+
intent,
|
|
32
|
+
executed: true,
|
|
33
|
+
timestamp: config.now?.() ?? new Date().toISOString(),
|
|
34
|
+
intent_hash: digest(intent).slice(7),
|
|
35
|
+
};
|
|
36
|
+
const verdict = violates(config.policy, [], claimed, {});
|
|
37
|
+
const decision = verdict.violated ? "deny" : "allow";
|
|
38
|
+
const receipt = await buildPepReceipt({ intent, policy: config.policy, principal: config.principal, realtimeResult: decision, now: config.now }, attester);
|
|
39
|
+
await config.onReceipt?.(receipt);
|
|
40
|
+
if (decision === "deny") {
|
|
41
|
+
return {
|
|
42
|
+
jsonrpc: "2.0",
|
|
43
|
+
id: message.id ?? null,
|
|
44
|
+
error: { code: -32000, message: `Scopebond policy denied ${intent.params.tool}: ${verdict.explanation || "out of policy"}` },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return config.upstream.call(message);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sEAAsE;AACtE,8EAA8E;AAC9E,yE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IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACrD,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;aACrC,CAAC;YACF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAe,EAAE,EAAE,EAAE,OAAgB,EAAE,EAAE,CAAC,CAAC;YAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;YAErD,MAAM,OAAO,GAAG,MAAM,eAAe,CACnC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAe,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,EAClH,QAAQ,CACT,CAAC;YACF,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;YAElC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,IAAI;oBACtB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,2BAA2B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,WAAW,IAAI,eAAe,EAAE,EAAE;iBAC7H,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// The MCP proxy core: sit in front of an upstream MCP server, check each\n// `tools/call` against policy before forwarding it, and emit a signed\n// PEP-authorized receipt. A denied call is never forwarded. Deterministic and\n// transport-agnostic — the upstream is injected, so the decision path is\n// conformance-tested directly; the `scopebond-mcp` CLI provides the real stdio\n// transport. The proxy decides the caller's request (no agent signature), so its\n// receipts are pep_authorized (§15) — the identity is the configured principal.\n\nimport { violates } from \"@scopebond/verify\";\nimport { buildPepReceipt, attesterFromPrivateKeyPem } from \"@scopebond/gateway\";\nimport type { SignedReceipt, Attester } from \"@scopebond/gateway\";\nimport { canonical } from \"@scopebond/policy-schema/canonical\";\nimport { createHash } from \"node:crypto\";\n\nexport interface JsonRpcMessage {\n jsonrpc?: string;\n id?: string | number | null;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: unknown;\n}\n\nconst digest = (value: unknown): string => \"sha256:\" + createHash(\"sha256\").update(canonical(value as never)).digest(\"hex\");\n\n/** Map an MCP `tools/call` to a normalized `mcp.tool.call` action. Arguments are\n * digested, never stored. */\nexport function mapMcpToolCall(server: string, params: Record<string, unknown> | undefined): { action_type: string; params: Record<string, unknown> } {\n return {\n action_type: \"mcp.tool.call\",\n params: { server, tool: String(params?.name ?? \"\"), args_digest: digest(params?.arguments ?? {}) },\n };\n}\n\n/** A pre-authenticated forwarder to the upstream MCP server. Tests inject it; the\n * CLI implements it over stdio. */\nexport interface McpUpstream {\n call(message: JsonRpcMessage): Promise<JsonRpcMessage>;\n}\n\nexport interface McpProxyConfig {\n policy: unknown;\n /** The validated caller identity recorded on every receipt. */\n principal: { subject: string; issuer: string };\n /** The upstream server id, used as the action's `server` parameter. */\n server: string;\n /** PEM of the key that signs the PEP receipts (the enrolled proxy key). */\n attesterKeyPem: string;\n upstream: McpUpstream;\n now?: () => string;\n /** Sink for each emitted receipt (e.g. a local log / exporter). */\n onReceipt?: (receipt: SignedReceipt) => void | Promise<void>;\n}\n\nexport interface McpProxy {\n handle(message: JsonRpcMessage): Promise<JsonRpcMessage>;\n}\n\n/** Build a proxy handler. Every `tools/call` is decided against policy; anything\n * else is passed through to the upstream unchanged. */\nexport function createMcpProxy(config: McpProxyConfig): McpProxy {\n const attester: Attester = attesterFromPrivateKeyPem(config.attesterKeyPem);\n return {\n async handle(message: JsonRpcMessage): Promise<JsonRpcMessage> {\n if (message?.method !== \"tools/call\") return config.upstream.call(message);\n\n const intent = mapMcpToolCall(config.server, message.params);\n const claimed = {\n intent,\n executed: true,\n timestamp: config.now?.() ?? new Date().toISOString(),\n intent_hash: digest(intent).slice(7),\n };\n const verdict = violates(config.policy as never, [], claimed as never, {});\n const decision = verdict.violated ? \"deny\" : \"allow\";\n\n const receipt = await buildPepReceipt(\n { intent, policy: config.policy as never, principal: config.principal, realtimeResult: decision, now: config.now },\n attester,\n );\n await config.onReceipt?.(receipt);\n\n if (decision === \"deny\") {\n return {\n jsonrpc: \"2.0\",\n id: message.id ?? null,\n error: { code: -32000, message: `Scopebond policy denied ${intent.params.tool}: ${verdict.explanation || \"out of policy\"}` },\n };\n }\n return config.upstream.call(message);\n },\n };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scopebond/mcp",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Scopebond MCP proxy — one policy for every Model Context Protocol tool call, in front of the servers an agent uses. In-path enforcement with a signed PEP-authorized receipt.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Avouro LLC",
|
|
7
|
+
"homepage": "https://github.com/avouro-com/scopebond/tree/main/packages/mcp#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/avouro-com/scopebond.git",
|
|
11
|
+
"directory": "packages/mcp"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/avouro-com/scopebond/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"scopebond",
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"ai-agents",
|
|
21
|
+
"policy",
|
|
22
|
+
"proxy"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"scopebond-mcp": "dist/cli.js"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@scopebond/policy-schema": "^0.3.0",
|
|
44
|
+
"@scopebond/verify": "^0.2.0",
|
|
45
|
+
"@scopebond/gateway": "^0.5.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.json",
|
|
52
|
+
"test": "tsc -p tsconfig.json && node --test test/*.test.mjs"
|
|
53
|
+
}
|
|
54
|
+
}
|