@clampd/mcp-proxy 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/Dockerfile +32 -0
- package/README.md +103 -0
- package/dist/dashboard.d.ts +64 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +516 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/fleet.d.ts +52 -0
- package/dist/fleet.d.ts.map +1 -0
- package/dist/fleet.js +274 -0
- package/dist/fleet.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +173 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor.d.ts +92 -0
- package/dist/interceptor.d.ts.map +1 -0
- package/dist/interceptor.js +274 -0
- package/dist/interceptor.js.map +1 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +15 -0
- package/dist/logger.js.map +1 -0
- package/dist/mock-server.d.ts +14 -0
- package/dist/mock-server.d.ts.map +1 -0
- package/dist/mock-server.js +128 -0
- package/dist/mock-server.js.map +1 -0
- package/dist/proxy.d.ts +59 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +578 -0
- package/dist/proxy.js.map +1 -0
- package/fleet.example.json +38 -0
- package/package.json +44 -0
- package/src/dashboard.ts +602 -0
- package/src/fleet.ts +329 -0
- package/src/index.ts +187 -0
- package/src/interceptor.ts +427 -0
- package/src/logger.ts +17 -0
- package/src/mock-server.ts +240 -0
- package/src/proxy.ts +752 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway communication — classifies tool calls, scans input/output,
|
|
3
|
+
* and validates responses through ag-gateway.
|
|
4
|
+
*
|
|
5
|
+
* This is the security boundary: every MCP tool call passes through here
|
|
6
|
+
* before reaching the upstream server.
|
|
7
|
+
*/
|
|
8
|
+
import { createHmac, createHash } from "node:crypto";
|
|
9
|
+
import { log } from "./logger.js";
|
|
10
|
+
// ── Tool descriptor hashing ──────────────────────────────────────────
|
|
11
|
+
/** Compute SHA-256 hex hash of a tool descriptor for rug-pull detection. */
|
|
12
|
+
export function computeToolDescriptorHash(tool) {
|
|
13
|
+
const canonical = JSON.stringify({
|
|
14
|
+
name: tool.name,
|
|
15
|
+
description: tool.description ?? "",
|
|
16
|
+
inputSchema: tool.inputSchema ?? {},
|
|
17
|
+
});
|
|
18
|
+
return createHash("sha256").update(canonical).digest("hex");
|
|
19
|
+
}
|
|
20
|
+
/** Build a lookup map of tool name → descriptor hash. */
|
|
21
|
+
export function buildDescriptorMap(tools) {
|
|
22
|
+
const map = new Map();
|
|
23
|
+
for (const tool of tools) {
|
|
24
|
+
map.set(tool.name, computeToolDescriptorHash(tool));
|
|
25
|
+
}
|
|
26
|
+
return map;
|
|
27
|
+
}
|
|
28
|
+
// ── JWT generation ────────────────────────────────────────────────────
|
|
29
|
+
function makeAgentJwt(agentId, secret) {
|
|
30
|
+
if (!secret) {
|
|
31
|
+
throw new Error("No JWT signing secret available. " +
|
|
32
|
+
"Set JWT_SECRET env var or pass --secret flag.");
|
|
33
|
+
}
|
|
34
|
+
// Derive signing key: ags_ prefixed secrets get SHA-256 hashed
|
|
35
|
+
// to match the credential_hash stored server-side in Redis.
|
|
36
|
+
const signingKey = secret.startsWith("ags_")
|
|
37
|
+
? createHash("sha256").update(secret).digest("hex")
|
|
38
|
+
: secret;
|
|
39
|
+
const header = { alg: "HS256", typ: "JWT" };
|
|
40
|
+
const payload = {
|
|
41
|
+
sub: agentId,
|
|
42
|
+
iat: Math.floor(Date.now() / 1000),
|
|
43
|
+
exp: Math.floor(Date.now() / 1000) + 300, // 5 minutes
|
|
44
|
+
iss: "clampd-mcp-proxy",
|
|
45
|
+
};
|
|
46
|
+
const encode = (obj) => Buffer.from(JSON.stringify(obj)).toString("base64url");
|
|
47
|
+
const headerB64 = encode(header);
|
|
48
|
+
const payloadB64 = encode(payload);
|
|
49
|
+
const signature = createHmac("sha256", signingKey)
|
|
50
|
+
.update(`${headerB64}.${payloadB64}`)
|
|
51
|
+
.digest("base64url");
|
|
52
|
+
return `${headerB64}.${payloadB64}.${signature}`;
|
|
53
|
+
}
|
|
54
|
+
// ── Shared helpers ───────────────────────────────────────────────────
|
|
55
|
+
function makeHeaders(apiKey, agentId, secret, authorizedTools) {
|
|
56
|
+
const jwt = makeAgentJwt(agentId, secret);
|
|
57
|
+
const h = {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
"X-AG-Key": apiKey,
|
|
60
|
+
"Authorization": `Bearer ${jwt}`,
|
|
61
|
+
};
|
|
62
|
+
if (authorizedTools && authorizedTools.length > 0) {
|
|
63
|
+
h["X-AG-Authorized-Tools"] = authorizedTools.join(",");
|
|
64
|
+
}
|
|
65
|
+
return h;
|
|
66
|
+
}
|
|
67
|
+
function baseUrl(gatewayUrl) {
|
|
68
|
+
return gatewayUrl.replace(/\/$/, "");
|
|
69
|
+
}
|
|
70
|
+
// ── Gateway classify ─────────────────────────────────────────────────
|
|
71
|
+
export async function classifyToolCall(gatewayUrl, apiKey, secret, agentId, toolName, params, dryRun = false, toolDescriptorHash, authorizedTools, toolDescription, toolParamsSchema) {
|
|
72
|
+
const endpoint = dryRun ? "/v1/verify" : "/v1/proxy";
|
|
73
|
+
const url = `${baseUrl(gatewayUrl)}${endpoint}`;
|
|
74
|
+
// MCP proxy handles upstream forwarding itself — use evaluate-only
|
|
75
|
+
// mode (empty target_url) so the gateway runs stages 1-6 and returns
|
|
76
|
+
// the allow/deny verdict without attempting to forward to mcp://.
|
|
77
|
+
const body = {
|
|
78
|
+
tool: toolName,
|
|
79
|
+
params,
|
|
80
|
+
target_url: "",
|
|
81
|
+
};
|
|
82
|
+
if (!dryRun) {
|
|
83
|
+
body.prompt_context = `MCP tool call: ${toolName}`;
|
|
84
|
+
}
|
|
85
|
+
if (toolDescriptorHash) {
|
|
86
|
+
body.tool_descriptor_hash = toolDescriptorHash;
|
|
87
|
+
}
|
|
88
|
+
if (toolDescription) {
|
|
89
|
+
body.tool_description = toolDescription;
|
|
90
|
+
}
|
|
91
|
+
if (toolParamsSchema) {
|
|
92
|
+
body.tool_params_schema = toolParamsSchema;
|
|
93
|
+
}
|
|
94
|
+
log("debug", `POST ${url} — tool=${toolName}`);
|
|
95
|
+
const resp = await fetch(url, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: makeHeaders(apiKey, agentId, secret, authorizedTools),
|
|
98
|
+
body: JSON.stringify(body),
|
|
99
|
+
signal: AbortSignal.timeout(5_000),
|
|
100
|
+
});
|
|
101
|
+
if (!resp.ok) {
|
|
102
|
+
const text = await resp.text().catch(() => `HTTP ${resp.status}`);
|
|
103
|
+
throw new Error(`Gateway returned ${resp.status}: ${text}`);
|
|
104
|
+
}
|
|
105
|
+
const json = (await resp.json());
|
|
106
|
+
return {
|
|
107
|
+
allowed: json.allowed,
|
|
108
|
+
risk_score: json.risk_score ?? 0,
|
|
109
|
+
matched_rules: json.matched_rules ?? [],
|
|
110
|
+
denial_reason: json.denial_reason,
|
|
111
|
+
scope_granted: json.scope_granted,
|
|
112
|
+
request_id: json.request_id,
|
|
113
|
+
scope_token: json.scope_token,
|
|
114
|
+
latency_ms: json.latency_ms ?? 0,
|
|
115
|
+
degraded_stages: json.degraded_stages ?? [],
|
|
116
|
+
session_flags: json.session_flags ?? [],
|
|
117
|
+
action: json.action,
|
|
118
|
+
reasoning: json.reasoning,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// ── Input scanning ───────────────────────────────────────────────────
|
|
122
|
+
export async function scanInput(gatewayUrl, apiKey, secret, agentId, text) {
|
|
123
|
+
const url = `${baseUrl(gatewayUrl)}/v1/scan-input`;
|
|
124
|
+
log("debug", `POST ${url} — scan-input (${text.length} chars)`);
|
|
125
|
+
const resp = await fetch(url, {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: makeHeaders(apiKey, agentId, secret),
|
|
128
|
+
body: JSON.stringify({ text }),
|
|
129
|
+
signal: AbortSignal.timeout(5_000),
|
|
130
|
+
});
|
|
131
|
+
if (!resp.ok) {
|
|
132
|
+
const body = await resp.text().catch(() => `HTTP ${resp.status}`);
|
|
133
|
+
throw new Error(`scan-input returned ${resp.status}: ${body}`);
|
|
134
|
+
}
|
|
135
|
+
const json = (await resp.json());
|
|
136
|
+
return {
|
|
137
|
+
allowed: json.allowed,
|
|
138
|
+
risk_score: json.risk_score ?? 0,
|
|
139
|
+
matched_rules: json.matched_rules ?? [],
|
|
140
|
+
denial_reason: json.denial_reason,
|
|
141
|
+
latency_ms: json.latency_ms ?? 0,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ── Output scanning ──────────────────────────────────────────────────
|
|
145
|
+
export async function scanOutput(gatewayUrl, apiKey, secret, agentId, text, requestId) {
|
|
146
|
+
const url = `${baseUrl(gatewayUrl)}/v1/scan-output`;
|
|
147
|
+
log("debug", `POST ${url} — scan-output (${text.length} chars)`);
|
|
148
|
+
const body = { text };
|
|
149
|
+
if (requestId)
|
|
150
|
+
body.request_id = requestId;
|
|
151
|
+
const resp = await fetch(url, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: makeHeaders(apiKey, agentId, secret),
|
|
154
|
+
body: JSON.stringify(body),
|
|
155
|
+
signal: AbortSignal.timeout(5_000),
|
|
156
|
+
});
|
|
157
|
+
if (!resp.ok) {
|
|
158
|
+
const respBody = await resp.text().catch(() => `HTTP ${resp.status}`);
|
|
159
|
+
throw new Error(`scan-output returned ${resp.status}: ${respBody}`);
|
|
160
|
+
}
|
|
161
|
+
const json = (await resp.json());
|
|
162
|
+
return {
|
|
163
|
+
allowed: json.allowed,
|
|
164
|
+
risk_score: json.risk_score ?? 0,
|
|
165
|
+
matched_rules: json.matched_rules ?? [],
|
|
166
|
+
denial_reason: json.denial_reason,
|
|
167
|
+
latency_ms: json.latency_ms ?? 0,
|
|
168
|
+
pii_found: json.pii_found,
|
|
169
|
+
secrets_found: json.secrets_found,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// ── Response inspection ──────────────────────────────────────────────
|
|
173
|
+
export async function inspectResponse(gatewayUrl, apiKey, secret, agentId, toolName, responseData, requestId, scopeToken) {
|
|
174
|
+
const url = `${baseUrl(gatewayUrl)}/v1/inspect`;
|
|
175
|
+
log("debug", `POST ${url} — inspect response for ${toolName}`);
|
|
176
|
+
const body = {
|
|
177
|
+
tool: toolName,
|
|
178
|
+
response_data: responseData,
|
|
179
|
+
};
|
|
180
|
+
if (requestId)
|
|
181
|
+
body.request_id = requestId;
|
|
182
|
+
if (scopeToken)
|
|
183
|
+
body.scope_token = scopeToken;
|
|
184
|
+
const resp = await fetch(url, {
|
|
185
|
+
method: "POST",
|
|
186
|
+
headers: makeHeaders(apiKey, agentId, secret),
|
|
187
|
+
body: JSON.stringify(body),
|
|
188
|
+
signal: AbortSignal.timeout(5_000),
|
|
189
|
+
});
|
|
190
|
+
if (!resp.ok) {
|
|
191
|
+
const respBody = await resp.text().catch(() => `HTTP ${resp.status}`);
|
|
192
|
+
throw new Error(`inspect returned ${resp.status}: ${respBody}`);
|
|
193
|
+
}
|
|
194
|
+
const json = (await resp.json());
|
|
195
|
+
return {
|
|
196
|
+
allowed: json.allowed,
|
|
197
|
+
risk_score: json.risk_score ?? 0,
|
|
198
|
+
matched_rules: json.matched_rules ?? [],
|
|
199
|
+
denial_reason: json.denial_reason,
|
|
200
|
+
latency_ms: json.latency_ms ?? 0,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Register discovered tools with the gateway at startup.
|
|
205
|
+
*
|
|
206
|
+
* Sends a lightweight `/v1/proxy` call (evaluate-only, target_url="") for
|
|
207
|
+
* each tool with benign empty params. This triggers the shadow event pipeline
|
|
208
|
+
* in ag-gateway, which ag-control picks up to auto-capture tool descriptors
|
|
209
|
+
* into the `tool_descriptors` table. If the org has `auto_trust` enabled,
|
|
210
|
+
* tools are auto-approved and their scopes synced to Redis — preventing
|
|
211
|
+
* `tool_not_registered` (422) errors on subsequent real calls.
|
|
212
|
+
*
|
|
213
|
+
* Requests run in parallel with a concurrency cap to avoid overwhelming
|
|
214
|
+
* the gateway. Registration is idempotent (safe to re-run on restart).
|
|
215
|
+
*/
|
|
216
|
+
export async function registerTools(gatewayUrl, apiKey, secret, agentId, tools, descriptorMap) {
|
|
217
|
+
const url = `${baseUrl(gatewayUrl)}/v1/proxy`;
|
|
218
|
+
const toolNames = tools.map((t) => t.name);
|
|
219
|
+
const result = { registered: 0, failed: 0, errors: [] };
|
|
220
|
+
// Process in batches of 5 to avoid overwhelming the gateway
|
|
221
|
+
const BATCH_SIZE = 5;
|
|
222
|
+
for (let i = 0; i < tools.length; i += BATCH_SIZE) {
|
|
223
|
+
const batch = tools.slice(i, i + BATCH_SIZE);
|
|
224
|
+
const promises = batch.map(async (tool) => {
|
|
225
|
+
const body = {
|
|
226
|
+
tool: tool.name,
|
|
227
|
+
params: {},
|
|
228
|
+
target_url: "",
|
|
229
|
+
prompt_context: `MCP startup registration: ${tool.name}`,
|
|
230
|
+
};
|
|
231
|
+
const hash = descriptorMap.get(tool.name);
|
|
232
|
+
if (hash) {
|
|
233
|
+
body.tool_descriptor_hash = hash;
|
|
234
|
+
}
|
|
235
|
+
if (tool.description) {
|
|
236
|
+
body.tool_description = tool.description;
|
|
237
|
+
}
|
|
238
|
+
if (tool.inputSchema) {
|
|
239
|
+
body.tool_params_schema = JSON.stringify(tool.inputSchema);
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const resp = await fetch(url, {
|
|
243
|
+
method: "POST",
|
|
244
|
+
headers: makeHeaders(apiKey, agentId, secret, toolNames),
|
|
245
|
+
body: JSON.stringify(body),
|
|
246
|
+
signal: AbortSignal.timeout(10_000),
|
|
247
|
+
});
|
|
248
|
+
if (!resp.ok) {
|
|
249
|
+
const text = await resp.text().catch(() => `HTTP ${resp.status}`);
|
|
250
|
+
// 422 tool_not_registered is expected when auto_trust is off —
|
|
251
|
+
// the shadow event was still emitted, so discovery still works.
|
|
252
|
+
if (resp.status === 422) {
|
|
253
|
+
result.registered++;
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
result.failed++;
|
|
257
|
+
result.errors.push({ tool: tool.name, error: `${resp.status}: ${text}` });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
result.registered++;
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
result.failed++;
|
|
264
|
+
result.errors.push({
|
|
265
|
+
tool: tool.name,
|
|
266
|
+
error: err instanceof Error ? err.message : String(err),
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
await Promise.all(promises);
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../src/interceptor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAwDlC,wEAAwE;AAExE,4EAA4E;AAC5E,MAAM,UAAU,yBAAyB,CAAC,IAAa;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;QACnC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;KACpC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,kBAAkB,CAAC,KAAgB;IACjD,MAAM,GAAG,GAAG,IAAI,GAAG,EA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EAAE,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;oBAClE,+DAA+D;oBAC/D,gEAAgE;oBAChE,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;wBACxB,MAAM,CAAC,UAAU,EAAE,CAAC;wBACpB,OAAO;oBACT,CAAC;oBACD,MAAM,CAAC,MAAM,EAAE,CAAC;oBAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;oBAC1E,OAAO;gBACT,CAAC;gBAED,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,CAAC;YAAC,OAAO,GAAY,EAAE,CAAC;gBACtB,MAAM,CAAC,MAAM,EAAE,CAAC;gBAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;oBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBACxD,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal logger that writes to stderr (to avoid corrupting MCP stdio streams).
|
|
3
|
+
*/
|
|
4
|
+
export declare function setVerbose(v: boolean): void;
|
|
5
|
+
export declare function log(level: "info" | "warn" | "error" | "debug", msg: string): void;
|
|
6
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAE3C;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAMjF"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal logger that writes to stderr (to avoid corrupting MCP stdio streams).
|
|
3
|
+
*/
|
|
4
|
+
let verbose = false;
|
|
5
|
+
export function setVerbose(v) {
|
|
6
|
+
verbose = v;
|
|
7
|
+
}
|
|
8
|
+
export function log(level, msg) {
|
|
9
|
+
if (level === "debug" && !verbose)
|
|
10
|
+
return;
|
|
11
|
+
const ts = new Date().toISOString();
|
|
12
|
+
const prefix = `[${ts}] [clampd-mcp-proxy] [${level}]`;
|
|
13
|
+
process.stderr.write(`${prefix} ${msg}\n`);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,MAAM,UAAU,UAAU,CAAC,CAAU;IACnC,OAAO,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,KAA0C,EAAE,GAAW;IACzE,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,OAAO;QAAE,OAAO;IAE1C,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,EAAE,yBAAyB,KAAK,GAAG,CAAC;IACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Mock MCP server with role-specific tool sets.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node mock-server.js analyst → data analysis tools
|
|
7
|
+
* node mock-server.js devops → infrastructure tools
|
|
8
|
+
* node mock-server.js dbadmin → database tools
|
|
9
|
+
* node mock-server.js all → every tool (default)
|
|
10
|
+
*
|
|
11
|
+
* Runs over stdio so the MCP proxy can spawn it as an upstream.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=mock-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../src/mock-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Mock MCP server with role-specific tool sets.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* node mock-server.js analyst → data analysis tools
|
|
7
|
+
* node mock-server.js devops → infrastructure tools
|
|
8
|
+
* node mock-server.js dbadmin → database tools
|
|
9
|
+
* node mock-server.js all → every tool (default)
|
|
10
|
+
*
|
|
11
|
+
* Runs over stdio so the MCP proxy can spawn it as an upstream.
|
|
12
|
+
*/
|
|
13
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
const role = process.argv[2] ?? "all";
|
|
17
|
+
const server = new McpServer({
|
|
18
|
+
name: `clampd-mock-${role}`,
|
|
19
|
+
version: "1.0.0",
|
|
20
|
+
});
|
|
21
|
+
// ── Database tools ──────────────────────────────────────────────
|
|
22
|
+
const dbTools = () => {
|
|
23
|
+
server.tool("database_query", "Execute a SQL query against the database", { query: z.string().describe("SQL query to execute") }, async ({ query }) => ({
|
|
24
|
+
content: [{ type: "text", text: `[mock] Query result for: ${query}\n\n| id | name | email |\n|----|------|-------|\n| 1 | Alice | alice@example.com |\n| 2 | Bob | bob@example.com |` }],
|
|
25
|
+
}));
|
|
26
|
+
server.tool("database_schema", "Get database schema information", { table: z.string().optional().describe("Table name (omit for all tables)") }, async ({ table }) => ({
|
|
27
|
+
content: [{ type: "text", text: `[mock] Schema for ${table ?? "all tables"}:\n\nusers (id INT PK, name VARCHAR, email VARCHAR, ssn VARCHAR)\norders (id INT PK, user_id INT FK, total DECIMAL)\npayments (id INT PK, card_number VARCHAR, cvv VARCHAR)` }],
|
|
28
|
+
}));
|
|
29
|
+
server.tool("database_mutate", "Execute a write/mutation query (INSERT, UPDATE, DELETE)", { query: z.string().describe("SQL mutation to execute") }, async ({ query }) => ({
|
|
30
|
+
content: [{ type: "text", text: `[mock] Mutation executed: ${query}\nRows affected: 1` }],
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
// ── Shell / Infrastructure tools ────────────────────────────────
|
|
34
|
+
const shellTools = () => {
|
|
35
|
+
server.tool("shell_exec", "Execute a shell command on the server", { command: z.string().describe("Shell command to execute") }, async ({ command }) => ({
|
|
36
|
+
content: [{ type: "text", text: `[mock] $ ${command}\nCommand output simulated. Exit code: 0` }],
|
|
37
|
+
}));
|
|
38
|
+
server.tool("process_list", "List running processes", { filter: z.string().optional().describe("Process name filter") }, async ({ filter }) => ({
|
|
39
|
+
content: [{ type: "text", text: `[mock] PID CMD\n1 systemd\n142 nginx\n203 postgres\n${filter ? `(filtered by: ${filter})` : ""}` }],
|
|
40
|
+
}));
|
|
41
|
+
server.tool("docker_exec", "Execute a command inside a Docker container", {
|
|
42
|
+
container: z.string().describe("Container name or ID"),
|
|
43
|
+
command: z.string().describe("Command to execute"),
|
|
44
|
+
}, async ({ container, command }) => ({
|
|
45
|
+
content: [{ type: "text", text: `[mock] docker exec ${container} ${command}\nOutput simulated.` }],
|
|
46
|
+
}));
|
|
47
|
+
server.tool("kubernetes_apply", "Apply a Kubernetes manifest", { manifest: z.string().describe("YAML manifest content") }, async ({ manifest }) => ({
|
|
48
|
+
content: [{ type: "text", text: `[mock] kubectl apply -f -\n${manifest.substring(0, 100)}...\nresource/configured` }],
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
// ── Filesystem tools ────────────────────────────────────────────
|
|
52
|
+
const fsTools = () => {
|
|
53
|
+
server.tool("filesystem_read", "Read contents of a file", { path: z.string().describe("File path to read") }, async ({ path }) => ({
|
|
54
|
+
content: [{ type: "text", text: `[mock] Contents of ${path}:\nSample file content here.` }],
|
|
55
|
+
}));
|
|
56
|
+
server.tool("filesystem_write", "Write content to a file", {
|
|
57
|
+
path: z.string().describe("File path to write"),
|
|
58
|
+
content: z.string().describe("Content to write"),
|
|
59
|
+
}, async ({ path, content }) => ({
|
|
60
|
+
content: [{ type: "text", text: `[mock] Wrote ${content.length} bytes to ${path}` }],
|
|
61
|
+
}));
|
|
62
|
+
server.tool("filesystem_list", "List files in a directory", { path: z.string().describe("Directory path") }, async ({ path }) => ({
|
|
63
|
+
content: [{ type: "text", text: `[mock] ${path}/\n config.yml\n data.csv\n README.md\n .env\n credentials.json` }],
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
// ── Network / HTTP tools ────────────────────────────────────────
|
|
67
|
+
const netTools = () => {
|
|
68
|
+
server.tool("http_fetch", "Make an HTTP request to a URL", {
|
|
69
|
+
url: z.string().describe("URL to fetch"),
|
|
70
|
+
method: z.string().optional().describe("HTTP method (GET, POST, etc.)"),
|
|
71
|
+
}, async ({ url, method }) => ({
|
|
72
|
+
content: [{ type: "text", text: `[mock] ${method ?? "GET"} ${url}\nStatus: 200 OK\nBody: {"status": "ok"}` }],
|
|
73
|
+
}));
|
|
74
|
+
server.tool("network_scan", "Scan a network range for open ports", {
|
|
75
|
+
target: z.string().describe("IP or CIDR range to scan"),
|
|
76
|
+
ports: z.string().optional().describe("Port range (e.g., 1-1024)"),
|
|
77
|
+
}, async ({ target, ports }) => ({
|
|
78
|
+
content: [{ type: "text", text: `[mock] Scanning ${target} ports ${ports ?? "1-1024"}\n22/tcp open ssh\n80/tcp open http\n443/tcp open https` }],
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
// ── Email / Communication tools ─────────────────────────────────
|
|
82
|
+
const emailTools = () => {
|
|
83
|
+
server.tool("email_send", "Send an email message", {
|
|
84
|
+
to: z.string().describe("Recipient email address"),
|
|
85
|
+
subject: z.string().describe("Email subject"),
|
|
86
|
+
body: z.string().describe("Email body content"),
|
|
87
|
+
}, async ({ to, subject }) => ({
|
|
88
|
+
content: [{ type: "text", text: `[mock] Email sent to ${to}\nSubject: ${subject}\nStatus: delivered` }],
|
|
89
|
+
}));
|
|
90
|
+
server.tool("email_search", "Search emails by query", { query: z.string().describe("Search query") }, async ({ query }) => ({
|
|
91
|
+
content: [{ type: "text", text: `[mock] Search results for "${query}":\n1. Meeting notes - from boss@company.com\n2. Invoice #1234 - from billing@vendor.com` }],
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
// ── LLM / AI tools ──────────────────────────────────────────────
|
|
95
|
+
const llmTools = () => {
|
|
96
|
+
server.tool("llm_prompt", "Send a prompt to an LLM and get a response", {
|
|
97
|
+
prompt: z.string().describe("The prompt to send"),
|
|
98
|
+
model: z.string().optional().describe("Model to use"),
|
|
99
|
+
}, async ({ prompt, model }) => ({
|
|
100
|
+
content: [{ type: "text", text: `[mock] ${model ?? "default"} response to: "${prompt.substring(0, 80)}..."\n\nThis is a simulated LLM response.` }],
|
|
101
|
+
}));
|
|
102
|
+
server.tool("llm_embed", "Generate embeddings for text", { text: z.string().describe("Text to embed") }, async ({ text }) => ({
|
|
103
|
+
content: [{ type: "text", text: `[mock] Embedding for "${text.substring(0, 50)}...":\n[0.0234, -0.1456, 0.8901, ...] (1536 dimensions)` }],
|
|
104
|
+
}));
|
|
105
|
+
};
|
|
106
|
+
// ── Auth / Secrets tools ────────────────────────────────────────
|
|
107
|
+
const authTools = () => {
|
|
108
|
+
server.tool("secret_read", "Read a secret from the vault", { key: z.string().describe("Secret key name") }, async ({ key }) => ({
|
|
109
|
+
content: [{ type: "text", text: `[mock] Secret "${key}": ****redacted****` }],
|
|
110
|
+
}));
|
|
111
|
+
server.tool("credential_rotate", "Rotate a credential or API key", { service: z.string().describe("Service name") }, async ({ service }) => ({
|
|
112
|
+
content: [{ type: "text", text: `[mock] Rotated credential for ${service}. New key: ak_****new****` }],
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
// ── Register tools by role ──────────────────────────────────────
|
|
116
|
+
const roleMap = {
|
|
117
|
+
analyst: [dbTools, netTools, llmTools, emailTools],
|
|
118
|
+
devops: [shellTools, fsTools, netTools, authTools],
|
|
119
|
+
dbadmin: [dbTools, fsTools, authTools],
|
|
120
|
+
all: [dbTools, shellTools, fsTools, netTools, emailTools, llmTools, authTools],
|
|
121
|
+
};
|
|
122
|
+
const register = roleMap[role] ?? roleMap.all;
|
|
123
|
+
for (const fn of register)
|
|
124
|
+
fn();
|
|
125
|
+
// ── Start ───────────────────────────────────────────────────────
|
|
126
|
+
const transport = new StdioServerTransport();
|
|
127
|
+
await server.connect(transport);
|
|
128
|
+
//# sourceMappingURL=mock-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-server.js","sourceRoot":"","sources":["../src/mock-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;AAEtC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,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MAAM,OAAO,GAAmC;IAC9C,OAAO,EAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC;IACnD,MAAM,EAAI,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;IACpD,OAAO,EAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC;IACvC,GAAG,EAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC;CACpF,CAAC;AAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC;AAC9C,KAAK,MAAM,EAAE,IAAI,QAAQ;IAAE,EAAE,EAAE,CAAC;AAEhC,mEAAmE;AACnE,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/proxy.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core proxy logic: spawns the upstream MCP server, creates an SSE transport
|
|
3
|
+
* for downstream clients (Claude Desktop), and intercepts all tool calls
|
|
4
|
+
* through the Clampd gateway.
|
|
5
|
+
*
|
|
6
|
+
* Security features:
|
|
7
|
+
* - Tool descriptor hashing (rug-pull detection)
|
|
8
|
+
* - Input scanning (prompt injection, PII, secrets)
|
|
9
|
+
* - Output scanning (PII/secrets leak prevention)
|
|
10
|
+
* - Response inspection (scope token validation)
|
|
11
|
+
* - Full audit trail via shadow events
|
|
12
|
+
*
|
|
13
|
+
* Architecture:
|
|
14
|
+
*
|
|
15
|
+
* Claude Desktop ──SSE──► Clampd MCP Proxy ──stdio──► Upstream MCP Server
|
|
16
|
+
* │
|
|
17
|
+
* ag-gateway
|
|
18
|
+
* (/v1/proxy, /v1/scan-input,
|
|
19
|
+
* /v1/scan-output, /v1/inspect)
|
|
20
|
+
*/
|
|
21
|
+
import { type ProxyEvent, type SessionStats } from "./dashboard.js";
|
|
22
|
+
export interface ProxyOptions {
|
|
23
|
+
/** Shell command to spawn the upstream MCP server */
|
|
24
|
+
upstreamCommand: string;
|
|
25
|
+
/** Clampd gateway base URL */
|
|
26
|
+
gatewayUrl: string;
|
|
27
|
+
/** API key for gateway authentication */
|
|
28
|
+
apiKey: string;
|
|
29
|
+
/** Agent UUID registered with Clampd */
|
|
30
|
+
agentId: string;
|
|
31
|
+
/** Port for the SSE + dashboard server */
|
|
32
|
+
port: number;
|
|
33
|
+
/** JWT signing secret */
|
|
34
|
+
secret?: string;
|
|
35
|
+
/** Dry-run mode: /v1/verify instead of /v1/proxy */
|
|
36
|
+
dryRun: boolean;
|
|
37
|
+
/** Enable debug logging */
|
|
38
|
+
verbose: boolean;
|
|
39
|
+
/** Enable input scanning before tool classification */
|
|
40
|
+
scanInputEnabled: boolean;
|
|
41
|
+
/** Enable output scanning after tool execution */
|
|
42
|
+
scanOutputEnabled: boolean;
|
|
43
|
+
/** Enable response inspection (scope token validation) */
|
|
44
|
+
checkResponse: boolean;
|
|
45
|
+
/** Show demo attack panel in dashboard */
|
|
46
|
+
demoPanel?: boolean;
|
|
47
|
+
/** Agent display name (for fleet mode) */
|
|
48
|
+
agentName?: string;
|
|
49
|
+
/** Callback for fleet event aggregation */
|
|
50
|
+
onEvent?: (event: ProxyEvent & {
|
|
51
|
+
agentName?: string;
|
|
52
|
+
}) => void;
|
|
53
|
+
}
|
|
54
|
+
/** Export event log for fleet dashboard access */
|
|
55
|
+
export declare function getEventLog(): ProxyEvent[];
|
|
56
|
+
/** Export session stats for fleet dashboard access */
|
|
57
|
+
export declare function getSessionStats(): SessionStats;
|
|
58
|
+
export declare function startProxy(opts: ProxyOptions): Promise<void>;
|
|
59
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../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