protect-mcp 0.2.1 → 0.3.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/dist/chunk-3WCA7O4D.mjs +977 -0
- package/dist/cli.js +760 -163
- package/dist/cli.mjs +241 -5
- package/dist/demo-server.d.mts +1 -0
- package/dist/demo-server.d.ts +1 -0
- package/dist/demo-server.js +137 -0
- package/dist/demo-server.mjs +136 -0
- package/dist/index.d.mts +75 -60
- package/dist/index.d.ts +75 -60
- package/dist/index.js +507 -269
- package/dist/index.mjs +3 -123
- package/package.json +4 -4
- package/dist/chunk-ZCKNFULF.mjs +0 -613
package/dist/index.d.mts
CHANGED
|
@@ -115,7 +115,7 @@ interface DecisionLog {
|
|
|
115
115
|
/** Decision: allow or deny */
|
|
116
116
|
decision: 'allow' | 'deny';
|
|
117
117
|
/** Why this decision was made */
|
|
118
|
-
reason_code:
|
|
118
|
+
reason_code: string;
|
|
119
119
|
/** SHA-256 digest of the canonicalized policy file */
|
|
120
120
|
policy_digest: string;
|
|
121
121
|
/** Which policy engine made the decision */
|
|
@@ -154,6 +154,63 @@ interface ProtectConfig {
|
|
|
154
154
|
credentials?: Record<string, CredentialConfig>;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Summary of evidence for tier evaluation.
|
|
159
|
+
*/
|
|
160
|
+
interface EvidenceSummary$1 {
|
|
161
|
+
receipt_count: number;
|
|
162
|
+
epoch_span: number;
|
|
163
|
+
issuer_count: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Thresholds for the 'evidenced' tier.
|
|
167
|
+
*/
|
|
168
|
+
interface EvidenceThresholds {
|
|
169
|
+
min_receipts: number;
|
|
170
|
+
min_epoch_span: number;
|
|
171
|
+
min_issuers: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Evidence store — tracks receipt history per agent.
|
|
175
|
+
*/
|
|
176
|
+
declare class EvidenceStore {
|
|
177
|
+
private agents;
|
|
178
|
+
private filePath;
|
|
179
|
+
private dirty;
|
|
180
|
+
constructor(dir?: string);
|
|
181
|
+
/**
|
|
182
|
+
* Record a receipt observation for an agent.
|
|
183
|
+
*/
|
|
184
|
+
record(agentId: string, issuer: string, timestamp?: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* Get the evidence summary for an agent.
|
|
187
|
+
*/
|
|
188
|
+
getSummary(agentId: string): EvidenceSummary$1;
|
|
189
|
+
/**
|
|
190
|
+
* Check if an agent meets the evidenced tier thresholds.
|
|
191
|
+
*/
|
|
192
|
+
meetsEvidencedThreshold(agentId: string, thresholds?: EvidenceThresholds): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Persist to disk (call periodically or on shutdown).
|
|
195
|
+
*/
|
|
196
|
+
save(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Load from disk.
|
|
199
|
+
*/
|
|
200
|
+
private load;
|
|
201
|
+
/**
|
|
202
|
+
* Get total agent count (for status display).
|
|
203
|
+
*/
|
|
204
|
+
agentCount(): number;
|
|
205
|
+
/**
|
|
206
|
+
* Get all agent summaries (for status display).
|
|
207
|
+
*/
|
|
208
|
+
allSummaries(): Array<{
|
|
209
|
+
agent_id: string;
|
|
210
|
+
summary: EvidenceSummary$1;
|
|
211
|
+
}>;
|
|
212
|
+
}
|
|
213
|
+
|
|
157
214
|
/**
|
|
158
215
|
* @scopeblind/protect-mcp — Trust Tier Admission Evaluator
|
|
159
216
|
*
|
|
@@ -163,8 +220,7 @@ interface ProtectConfig {
|
|
|
163
220
|
*
|
|
164
221
|
* Tiers (ascending): unknown → signed-known → evidenced → privileged
|
|
165
222
|
*
|
|
166
|
-
*
|
|
167
|
-
* Full evidence evaluation (evidenced tier) is stubbed.
|
|
223
|
+
* v2: Real evidence evaluation via EvidenceStore when available.
|
|
168
224
|
*/
|
|
169
225
|
|
|
170
226
|
/**
|
|
@@ -180,7 +236,7 @@ interface ManifestPresentation {
|
|
|
180
236
|
public_key?: string;
|
|
181
237
|
/** Whether the manifest signature was verified */
|
|
182
238
|
signature_valid?: boolean;
|
|
183
|
-
/** Optional evidence summary for tier upgrade */
|
|
239
|
+
/** Optional evidence summary for tier upgrade (inline, without store) */
|
|
184
240
|
evidence_summary?: {
|
|
185
241
|
receipt_count: number;
|
|
186
242
|
epoch_span: number;
|
|
@@ -201,92 +257,51 @@ interface AdmissionResult {
|
|
|
201
257
|
* Maps agent IDs to explicitly assigned tiers.
|
|
202
258
|
*/
|
|
203
259
|
type TierOverrides = Record<string, TrustTier>;
|
|
260
|
+
/**
|
|
261
|
+
* Options for tier evaluation.
|
|
262
|
+
*/
|
|
263
|
+
interface EvaluateTierOptions {
|
|
264
|
+
overrides?: TierOverrides;
|
|
265
|
+
evidenceStore?: EvidenceStore;
|
|
266
|
+
thresholds?: EvidenceThresholds;
|
|
267
|
+
}
|
|
204
268
|
/**
|
|
205
269
|
* Evaluate an agent's trust tier based on their presented credentials.
|
|
206
270
|
*
|
|
207
271
|
* @param manifest - Manifest presentation from the agent (or null if none)
|
|
208
|
-
* @param
|
|
272
|
+
* @param opts - Evaluation options (overrides, evidence store, thresholds)
|
|
209
273
|
* @returns AdmissionResult with assigned tier
|
|
210
274
|
*/
|
|
211
|
-
declare function evaluateTier(manifest: ManifestPresentation | null,
|
|
275
|
+
declare function evaluateTier(manifest: ManifestPresentation | null, opts?: TierOverrides | EvaluateTierOptions): AdmissionResult;
|
|
212
276
|
/**
|
|
213
277
|
* Check if a trust tier meets the minimum required tier.
|
|
214
278
|
*/
|
|
215
279
|
declare function meetsMinTier(actual: TrustTier, required: TrustTier): boolean;
|
|
216
280
|
|
|
217
|
-
/**
|
|
218
|
-
* ProtectGateway — stdio MITM proxy for MCP servers.
|
|
219
|
-
*
|
|
220
|
-
* Sits between an MCP client (stdin/stdout) and a wrapped MCP server (child process).
|
|
221
|
-
* Intercepts `tools/call` requests for policy enforcement and decision logging.
|
|
222
|
-
* Passes through all other JSON-RPC messages transparently.
|
|
223
|
-
*
|
|
224
|
-
* v2 features:
|
|
225
|
-
* - Shadow mode (default): observe + signed receipts, no blocking
|
|
226
|
-
* - Trust-tier gating: evaluate manifest at admission, assign tier
|
|
227
|
-
* - Credential vault: inject secrets, agent never sees raw keys
|
|
228
|
-
* - BYOPE: pluggable policy decision via external HTTP webhook
|
|
229
|
-
* - Signed receipts: every decision produces a signed artifact
|
|
230
|
-
*/
|
|
231
281
|
declare class ProtectGateway {
|
|
232
282
|
private child;
|
|
233
283
|
private config;
|
|
234
284
|
private rateLimitStore;
|
|
235
285
|
private clientReader;
|
|
286
|
+
private logFilePath;
|
|
287
|
+
private evidenceStore;
|
|
288
|
+
private receiptBuffer;
|
|
236
289
|
private currentTier;
|
|
237
290
|
private admissionResult;
|
|
238
291
|
constructor(config: ProtectConfig);
|
|
239
|
-
/**
|
|
240
|
-
* Start the gateway: spawn child process and wire up message relay.
|
|
241
|
-
*/
|
|
242
292
|
start(): Promise<void>;
|
|
243
|
-
/**
|
|
244
|
-
* Set the trust tier for this session.
|
|
245
|
-
* Called at admission (first interaction) or by explicit manifest presentation.
|
|
246
|
-
*/
|
|
247
293
|
setManifest(manifest: ManifestPresentation | null): AdmissionResult;
|
|
248
|
-
/**
|
|
249
|
-
* Handle a message from the MCP client (stdin).
|
|
250
|
-
* Intercept tools/call requests; pass through everything else.
|
|
251
|
-
*/
|
|
252
294
|
private handleClientMessage;
|
|
253
|
-
|
|
254
|
-
* Handle a message from the wrapped MCP server (child stdout).
|
|
255
|
-
* Forward to client (stdout) transparently.
|
|
256
|
-
*/
|
|
295
|
+
private interceptToolCallAsync;
|
|
257
296
|
private handleServerMessage;
|
|
258
|
-
|
|
259
|
-
* Intercept a tools/call request. Returns a JSON-RPC error response if denied, null if allowed.
|
|
260
|
-
*/
|
|
297
|
+
private injectParamsCredentials;
|
|
261
298
|
private interceptToolCall;
|
|
262
|
-
/**
|
|
263
|
-
* Get the applicable rate limit spec based on the agent's tier.
|
|
264
|
-
*/
|
|
265
299
|
private getTierRateLimit;
|
|
266
|
-
/**
|
|
267
|
-
* Emit a structured decision log to stderr.
|
|
268
|
-
* If signing is enabled, also emits a signed artifact.
|
|
269
|
-
*/
|
|
270
300
|
private emitDecisionLog;
|
|
271
|
-
/**
|
|
272
|
-
* Create a JSON-RPC error response.
|
|
273
|
-
*/
|
|
274
301
|
private makeErrorResponse;
|
|
275
|
-
/**
|
|
276
|
-
* Send a message to the child process (wrapped MCP server).
|
|
277
|
-
*/
|
|
278
302
|
private sendToChild;
|
|
279
|
-
/**
|
|
280
|
-
* Send a message to the MCP client (stdout).
|
|
281
|
-
*/
|
|
282
303
|
private sendToClient;
|
|
283
|
-
/**
|
|
284
|
-
* Log a message to stderr (debug output).
|
|
285
|
-
*/
|
|
286
304
|
private log;
|
|
287
|
-
/**
|
|
288
|
-
* Stop the gateway: kill child process and exit.
|
|
289
|
-
*/
|
|
290
305
|
stop(): void;
|
|
291
306
|
}
|
|
292
307
|
|
package/dist/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ interface DecisionLog {
|
|
|
115
115
|
/** Decision: allow or deny */
|
|
116
116
|
decision: 'allow' | 'deny';
|
|
117
117
|
/** Why this decision was made */
|
|
118
|
-
reason_code:
|
|
118
|
+
reason_code: string;
|
|
119
119
|
/** SHA-256 digest of the canonicalized policy file */
|
|
120
120
|
policy_digest: string;
|
|
121
121
|
/** Which policy engine made the decision */
|
|
@@ -154,6 +154,63 @@ interface ProtectConfig {
|
|
|
154
154
|
credentials?: Record<string, CredentialConfig>;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Summary of evidence for tier evaluation.
|
|
159
|
+
*/
|
|
160
|
+
interface EvidenceSummary$1 {
|
|
161
|
+
receipt_count: number;
|
|
162
|
+
epoch_span: number;
|
|
163
|
+
issuer_count: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Thresholds for the 'evidenced' tier.
|
|
167
|
+
*/
|
|
168
|
+
interface EvidenceThresholds {
|
|
169
|
+
min_receipts: number;
|
|
170
|
+
min_epoch_span: number;
|
|
171
|
+
min_issuers: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Evidence store — tracks receipt history per agent.
|
|
175
|
+
*/
|
|
176
|
+
declare class EvidenceStore {
|
|
177
|
+
private agents;
|
|
178
|
+
private filePath;
|
|
179
|
+
private dirty;
|
|
180
|
+
constructor(dir?: string);
|
|
181
|
+
/**
|
|
182
|
+
* Record a receipt observation for an agent.
|
|
183
|
+
*/
|
|
184
|
+
record(agentId: string, issuer: string, timestamp?: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* Get the evidence summary for an agent.
|
|
187
|
+
*/
|
|
188
|
+
getSummary(agentId: string): EvidenceSummary$1;
|
|
189
|
+
/**
|
|
190
|
+
* Check if an agent meets the evidenced tier thresholds.
|
|
191
|
+
*/
|
|
192
|
+
meetsEvidencedThreshold(agentId: string, thresholds?: EvidenceThresholds): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Persist to disk (call periodically or on shutdown).
|
|
195
|
+
*/
|
|
196
|
+
save(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Load from disk.
|
|
199
|
+
*/
|
|
200
|
+
private load;
|
|
201
|
+
/**
|
|
202
|
+
* Get total agent count (for status display).
|
|
203
|
+
*/
|
|
204
|
+
agentCount(): number;
|
|
205
|
+
/**
|
|
206
|
+
* Get all agent summaries (for status display).
|
|
207
|
+
*/
|
|
208
|
+
allSummaries(): Array<{
|
|
209
|
+
agent_id: string;
|
|
210
|
+
summary: EvidenceSummary$1;
|
|
211
|
+
}>;
|
|
212
|
+
}
|
|
213
|
+
|
|
157
214
|
/**
|
|
158
215
|
* @scopeblind/protect-mcp — Trust Tier Admission Evaluator
|
|
159
216
|
*
|
|
@@ -163,8 +220,7 @@ interface ProtectConfig {
|
|
|
163
220
|
*
|
|
164
221
|
* Tiers (ascending): unknown → signed-known → evidenced → privileged
|
|
165
222
|
*
|
|
166
|
-
*
|
|
167
|
-
* Full evidence evaluation (evidenced tier) is stubbed.
|
|
223
|
+
* v2: Real evidence evaluation via EvidenceStore when available.
|
|
168
224
|
*/
|
|
169
225
|
|
|
170
226
|
/**
|
|
@@ -180,7 +236,7 @@ interface ManifestPresentation {
|
|
|
180
236
|
public_key?: string;
|
|
181
237
|
/** Whether the manifest signature was verified */
|
|
182
238
|
signature_valid?: boolean;
|
|
183
|
-
/** Optional evidence summary for tier upgrade */
|
|
239
|
+
/** Optional evidence summary for tier upgrade (inline, without store) */
|
|
184
240
|
evidence_summary?: {
|
|
185
241
|
receipt_count: number;
|
|
186
242
|
epoch_span: number;
|
|
@@ -201,92 +257,51 @@ interface AdmissionResult {
|
|
|
201
257
|
* Maps agent IDs to explicitly assigned tiers.
|
|
202
258
|
*/
|
|
203
259
|
type TierOverrides = Record<string, TrustTier>;
|
|
260
|
+
/**
|
|
261
|
+
* Options for tier evaluation.
|
|
262
|
+
*/
|
|
263
|
+
interface EvaluateTierOptions {
|
|
264
|
+
overrides?: TierOverrides;
|
|
265
|
+
evidenceStore?: EvidenceStore;
|
|
266
|
+
thresholds?: EvidenceThresholds;
|
|
267
|
+
}
|
|
204
268
|
/**
|
|
205
269
|
* Evaluate an agent's trust tier based on their presented credentials.
|
|
206
270
|
*
|
|
207
271
|
* @param manifest - Manifest presentation from the agent (or null if none)
|
|
208
|
-
* @param
|
|
272
|
+
* @param opts - Evaluation options (overrides, evidence store, thresholds)
|
|
209
273
|
* @returns AdmissionResult with assigned tier
|
|
210
274
|
*/
|
|
211
|
-
declare function evaluateTier(manifest: ManifestPresentation | null,
|
|
275
|
+
declare function evaluateTier(manifest: ManifestPresentation | null, opts?: TierOverrides | EvaluateTierOptions): AdmissionResult;
|
|
212
276
|
/**
|
|
213
277
|
* Check if a trust tier meets the minimum required tier.
|
|
214
278
|
*/
|
|
215
279
|
declare function meetsMinTier(actual: TrustTier, required: TrustTier): boolean;
|
|
216
280
|
|
|
217
|
-
/**
|
|
218
|
-
* ProtectGateway — stdio MITM proxy for MCP servers.
|
|
219
|
-
*
|
|
220
|
-
* Sits between an MCP client (stdin/stdout) and a wrapped MCP server (child process).
|
|
221
|
-
* Intercepts `tools/call` requests for policy enforcement and decision logging.
|
|
222
|
-
* Passes through all other JSON-RPC messages transparently.
|
|
223
|
-
*
|
|
224
|
-
* v2 features:
|
|
225
|
-
* - Shadow mode (default): observe + signed receipts, no blocking
|
|
226
|
-
* - Trust-tier gating: evaluate manifest at admission, assign tier
|
|
227
|
-
* - Credential vault: inject secrets, agent never sees raw keys
|
|
228
|
-
* - BYOPE: pluggable policy decision via external HTTP webhook
|
|
229
|
-
* - Signed receipts: every decision produces a signed artifact
|
|
230
|
-
*/
|
|
231
281
|
declare class ProtectGateway {
|
|
232
282
|
private child;
|
|
233
283
|
private config;
|
|
234
284
|
private rateLimitStore;
|
|
235
285
|
private clientReader;
|
|
286
|
+
private logFilePath;
|
|
287
|
+
private evidenceStore;
|
|
288
|
+
private receiptBuffer;
|
|
236
289
|
private currentTier;
|
|
237
290
|
private admissionResult;
|
|
238
291
|
constructor(config: ProtectConfig);
|
|
239
|
-
/**
|
|
240
|
-
* Start the gateway: spawn child process and wire up message relay.
|
|
241
|
-
*/
|
|
242
292
|
start(): Promise<void>;
|
|
243
|
-
/**
|
|
244
|
-
* Set the trust tier for this session.
|
|
245
|
-
* Called at admission (first interaction) or by explicit manifest presentation.
|
|
246
|
-
*/
|
|
247
293
|
setManifest(manifest: ManifestPresentation | null): AdmissionResult;
|
|
248
|
-
/**
|
|
249
|
-
* Handle a message from the MCP client (stdin).
|
|
250
|
-
* Intercept tools/call requests; pass through everything else.
|
|
251
|
-
*/
|
|
252
294
|
private handleClientMessage;
|
|
253
|
-
|
|
254
|
-
* Handle a message from the wrapped MCP server (child stdout).
|
|
255
|
-
* Forward to client (stdout) transparently.
|
|
256
|
-
*/
|
|
295
|
+
private interceptToolCallAsync;
|
|
257
296
|
private handleServerMessage;
|
|
258
|
-
|
|
259
|
-
* Intercept a tools/call request. Returns a JSON-RPC error response if denied, null if allowed.
|
|
260
|
-
*/
|
|
297
|
+
private injectParamsCredentials;
|
|
261
298
|
private interceptToolCall;
|
|
262
|
-
/**
|
|
263
|
-
* Get the applicable rate limit spec based on the agent's tier.
|
|
264
|
-
*/
|
|
265
299
|
private getTierRateLimit;
|
|
266
|
-
/**
|
|
267
|
-
* Emit a structured decision log to stderr.
|
|
268
|
-
* If signing is enabled, also emits a signed artifact.
|
|
269
|
-
*/
|
|
270
300
|
private emitDecisionLog;
|
|
271
|
-
/**
|
|
272
|
-
* Create a JSON-RPC error response.
|
|
273
|
-
*/
|
|
274
301
|
private makeErrorResponse;
|
|
275
|
-
/**
|
|
276
|
-
* Send a message to the child process (wrapped MCP server).
|
|
277
|
-
*/
|
|
278
302
|
private sendToChild;
|
|
279
|
-
/**
|
|
280
|
-
* Send a message to the MCP client (stdout).
|
|
281
|
-
*/
|
|
282
303
|
private sendToClient;
|
|
283
|
-
/**
|
|
284
|
-
* Log a message to stderr (debug output).
|
|
285
|
-
*/
|
|
286
304
|
private log;
|
|
287
|
-
/**
|
|
288
|
-
* Stop the gateway: kill child process and exit.
|
|
289
|
-
*/
|
|
290
305
|
stop(): void;
|
|
291
306
|
}
|
|
292
307
|
|