crowdcode-mcp 0.1.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-URCCBSON.js +193 -0
- package/dist/chunk-URCCBSON.js.map +1 -0
- package/dist/chunk-ZOKWC7AU.js +18 -0
- package/dist/chunk-ZOKWC7AU.js.map +1 -0
- package/dist/cli.js +93 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/server-EAUTUSVT.js +362 -0
- package/dist/server-EAUTUSVT.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// src/canonical/pystrip.ts
|
|
2
|
+
var PY_SPACE = "\\t\\n\\x0b\\x0c\\r\\x1c\\x1d\\x1e\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
3
|
+
var LEADING = new RegExp(`^[${PY_SPACE}]+`);
|
|
4
|
+
var TRAILING = new RegExp(`[${PY_SPACE}]+$`);
|
|
5
|
+
function pyStrip(value) {
|
|
6
|
+
return value.replace(LEADING, "").replace(TRAILING, "");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/canonical/identity.ts
|
|
10
|
+
import { createHash } from "crypto";
|
|
11
|
+
var PAYMENT_PROVIDERS = /* @__PURE__ */ new Set([
|
|
12
|
+
"stripe",
|
|
13
|
+
"stripe_payment_link",
|
|
14
|
+
"mppx",
|
|
15
|
+
"x402",
|
|
16
|
+
"manual"
|
|
17
|
+
]);
|
|
18
|
+
var PAYMENT_PROVIDER_ALIASES = {
|
|
19
|
+
link: "stripe_payment_link",
|
|
20
|
+
stripe_link: "stripe_payment_link",
|
|
21
|
+
payment_link: "stripe_payment_link",
|
|
22
|
+
mpp: "mppx"
|
|
23
|
+
};
|
|
24
|
+
function cleanOptional(value) {
|
|
25
|
+
if (value === null || value === void 0) return null;
|
|
26
|
+
const cleaned = pyStrip(value);
|
|
27
|
+
return cleaned === "" ? null : cleaned;
|
|
28
|
+
}
|
|
29
|
+
function normalizePaymentProvider(value) {
|
|
30
|
+
const cleaned = cleanOptional(value);
|
|
31
|
+
if (cleaned === null) return null;
|
|
32
|
+
let provider = cleaned.toLowerCase().replaceAll("-", "_");
|
|
33
|
+
provider = PAYMENT_PROVIDER_ALIASES[provider] ?? provider;
|
|
34
|
+
if (!PAYMENT_PROVIDERS.has(provider)) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
"payment_provider must be one of: " + [...PAYMENT_PROVIDERS].sort().join(", ")
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return provider;
|
|
40
|
+
}
|
|
41
|
+
var URL_RE = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)([^?#]*)(?:\?[^#]*)?(?:#.*)?$/;
|
|
42
|
+
function normalizeApiEndpoint(value) {
|
|
43
|
+
const cleaned = cleanOptional(value);
|
|
44
|
+
if (cleaned === null) return null;
|
|
45
|
+
const candidate = cleaned.includes("://") ? cleaned : `https://${cleaned}`;
|
|
46
|
+
const match = URL_RE.exec(candidate);
|
|
47
|
+
if (!match) {
|
|
48
|
+
throw new Error("api_endpoint must include a host");
|
|
49
|
+
}
|
|
50
|
+
const scheme = (match[1] ?? "https").toLowerCase();
|
|
51
|
+
const authority = match[2] ?? "";
|
|
52
|
+
const rawPath = match[3] ?? "";
|
|
53
|
+
if (authority === "") {
|
|
54
|
+
throw new Error("api_endpoint must include a host");
|
|
55
|
+
}
|
|
56
|
+
const atIndex = authority.lastIndexOf("@");
|
|
57
|
+
const hostPort = atIndex === -1 ? authority : authority.slice(atIndex + 1);
|
|
58
|
+
let host = hostPort;
|
|
59
|
+
let port = null;
|
|
60
|
+
const colonIndex = hostPort.lastIndexOf(":");
|
|
61
|
+
if (colonIndex !== -1) {
|
|
62
|
+
host = hostPort.slice(0, colonIndex);
|
|
63
|
+
const portStr = hostPort.slice(colonIndex + 1);
|
|
64
|
+
if (portStr !== "") {
|
|
65
|
+
if (!/^\d+$/.test(portStr)) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Port could not be cast to integer value as '${portStr}'`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const parsed = Number.parseInt(portStr, 10);
|
|
71
|
+
if (parsed > 65535) {
|
|
72
|
+
throw new Error("Port out of range 0-65535");
|
|
73
|
+
}
|
|
74
|
+
port = String(parsed);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
host = host.toLowerCase();
|
|
78
|
+
if (host === "") {
|
|
79
|
+
throw new Error("api_endpoint must include a host");
|
|
80
|
+
}
|
|
81
|
+
const netloc = port === null ? host : `${host}:${port}`;
|
|
82
|
+
const path = rawPath.replace(/\/+$/, "") || "/";
|
|
83
|
+
return `${scheme}://${netloc}${path}`;
|
|
84
|
+
}
|
|
85
|
+
function generateServiceId(apiEndpoint, paymentProvider, paymentTargetRef) {
|
|
86
|
+
const material = [
|
|
87
|
+
normalizeApiEndpoint(apiEndpoint) ?? "",
|
|
88
|
+
paymentProvider,
|
|
89
|
+
pyStrip(paymentTargetRef)
|
|
90
|
+
].join("|");
|
|
91
|
+
return "svc_" + createHash("sha256").update(material, "utf8").digest("hex").slice(0, 20);
|
|
92
|
+
}
|
|
93
|
+
function buildIdentity(args) {
|
|
94
|
+
return {
|
|
95
|
+
service_id: cleanOptional(args.service_id),
|
|
96
|
+
service_name: cleanOptional(args.service_name),
|
|
97
|
+
api_endpoint: normalizeApiEndpoint(args.api_endpoint),
|
|
98
|
+
payment_provider: normalizePaymentProvider(args.payment_provider),
|
|
99
|
+
payment_target_ref: cleanOptional(args.payment_target_ref),
|
|
100
|
+
directory_slug: cleanOptional(args.directory_slug)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function hasStrongIdentity(identity) {
|
|
104
|
+
return Boolean(
|
|
105
|
+
identity.api_endpoint && identity.payment_provider && identity.payment_target_ref
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/canonical/json.ts
|
|
110
|
+
var SHORT_ESCAPES = {
|
|
111
|
+
8: "\\b",
|
|
112
|
+
9: "\\t",
|
|
113
|
+
10: "\\n",
|
|
114
|
+
12: "\\f",
|
|
115
|
+
13: "\\r"
|
|
116
|
+
};
|
|
117
|
+
function encodeString(value) {
|
|
118
|
+
let out = '"';
|
|
119
|
+
for (let i = 0; i < value.length; i++) {
|
|
120
|
+
const code = value.charCodeAt(i);
|
|
121
|
+
const short = SHORT_ESCAPES[code];
|
|
122
|
+
if (code === 34) {
|
|
123
|
+
out += '\\"';
|
|
124
|
+
} else if (code === 92) {
|
|
125
|
+
out += "\\\\";
|
|
126
|
+
} else if (short !== void 0) {
|
|
127
|
+
out += short;
|
|
128
|
+
} else if (code < 32 || code > 126) {
|
|
129
|
+
out += "\\u" + code.toString(16).padStart(4, "0");
|
|
130
|
+
} else {
|
|
131
|
+
out += value[i];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return out + '"';
|
|
135
|
+
}
|
|
136
|
+
function pythonCanonicalJson(obj) {
|
|
137
|
+
const parts = Object.keys(obj).sort().map((key) => {
|
|
138
|
+
const value = obj[key] ?? null;
|
|
139
|
+
let encoded;
|
|
140
|
+
if (value === null) {
|
|
141
|
+
encoded = "null";
|
|
142
|
+
} else if (typeof value === "number") {
|
|
143
|
+
if (!Number.isInteger(value)) {
|
|
144
|
+
throw new Error(`non-integer number in canonical payload: ${key}`);
|
|
145
|
+
}
|
|
146
|
+
encoded = String(value);
|
|
147
|
+
} else {
|
|
148
|
+
encoded = encodeString(value);
|
|
149
|
+
}
|
|
150
|
+
return `${encodeString(key)}:${encoded}`;
|
|
151
|
+
});
|
|
152
|
+
return `{${parts.join(",")}}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/canonical/payload.ts
|
|
156
|
+
import { createHash as createHash2 } from "crypto";
|
|
157
|
+
var PAYLOAD_TYPE = "crowdcode.review.v1";
|
|
158
|
+
function reasonHash(reason) {
|
|
159
|
+
return "sha256:" + createHash2("sha256").update(pyStrip(reason), "utf8").digest("hex");
|
|
160
|
+
}
|
|
161
|
+
function canonicalReviewPayload(args) {
|
|
162
|
+
const { identity, rating, reason, paymentReference } = args;
|
|
163
|
+
if (!Number.isInteger(rating)) {
|
|
164
|
+
throw new Error("rating must be an integer");
|
|
165
|
+
}
|
|
166
|
+
return pythonCanonicalJson({
|
|
167
|
+
type: PAYLOAD_TYPE,
|
|
168
|
+
service_id: identity.service_id,
|
|
169
|
+
api_endpoint: identity.api_endpoint,
|
|
170
|
+
payment_provider: identity.payment_provider,
|
|
171
|
+
payment_target_ref: identity.payment_target_ref,
|
|
172
|
+
directory_slug: identity.directory_slug,
|
|
173
|
+
payment_reference: pyStrip(paymentReference),
|
|
174
|
+
rating,
|
|
175
|
+
reason_hash: reasonHash(reason)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
pyStrip,
|
|
181
|
+
PAYMENT_PROVIDERS,
|
|
182
|
+
cleanOptional,
|
|
183
|
+
normalizePaymentProvider,
|
|
184
|
+
normalizeApiEndpoint,
|
|
185
|
+
generateServiceId,
|
|
186
|
+
buildIdentity,
|
|
187
|
+
hasStrongIdentity,
|
|
188
|
+
pythonCanonicalJson,
|
|
189
|
+
PAYLOAD_TYPE,
|
|
190
|
+
reasonHash,
|
|
191
|
+
canonicalReviewPayload
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=chunk-URCCBSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/canonical/pystrip.ts","../src/canonical/identity.ts","../src/canonical/json.ts","../src/canonical/payload.ts"],"sourcesContent":["/**\n * Python `str.strip()` equivalent.\n *\n * Python strips every character for which `str.isspace()` is true. That set\n * is a superset of JS `String.prototype.trim()`'s White_Space set — notably\n * U+001C..U+001F (file/group/record/unit separators) are Python-space but\n * not JS-space. The canonical payload spec (spec/CANONICAL_PAYLOAD.md)\n * requires Python semantics.\n */\n\nconst PY_SPACE =\n \"\\\\t\\\\n\\\\x0b\\\\x0c\\\\r\\\\x1c\\\\x1d\\\\x1e\\\\x1f \\\\x85\\\\xa0\\\\u1680\\\\u2000-\\\\u200a\\\\u2028\\\\u2029\\\\u202f\\\\u205f\\\\u3000\";\n\nconst LEADING = new RegExp(`^[${PY_SPACE}]+`);\nconst TRAILING = new RegExp(`[${PY_SPACE}]+$`);\n\nexport function pyStrip(value: string): string {\n return value.replace(LEADING, \"\").replace(TRAILING, \"\");\n}\n","/**\n * Byte-for-byte port of src/crowdcode/identity.py (normative source).\n * Conformance is enforced against spec/review-payload-vectors.json; any\n * behavior difference from the Python implementation is a bug here.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { pyStrip } from \"./pystrip.js\";\n\nexport const PAYMENT_PROVIDERS = new Set([\n \"stripe\",\n \"stripe_payment_link\",\n \"mppx\",\n \"x402\",\n \"manual\",\n]);\n\nconst PAYMENT_PROVIDER_ALIASES: Record<string, string> = {\n link: \"stripe_payment_link\",\n stripe_link: \"stripe_payment_link\",\n payment_link: \"stripe_payment_link\",\n mpp: \"mppx\",\n};\n\nexport interface ServiceIdentity {\n service_id: string | null;\n service_name: string | null;\n api_endpoint: string | null;\n payment_provider: string | null;\n payment_target_ref: string | null;\n directory_slug: string | null;\n}\n\nexport function cleanOptional(value: string | null | undefined): string | null {\n if (value === null || value === undefined) return null;\n const cleaned = pyStrip(value);\n return cleaned === \"\" ? null : cleaned;\n}\n\nexport function normalizePaymentProvider(\n value: string | null | undefined,\n): string | null {\n const cleaned = cleanOptional(value);\n if (cleaned === null) return null;\n let provider = cleaned.toLowerCase().replaceAll(\"-\", \"_\");\n provider = PAYMENT_PROVIDER_ALIASES[provider] ?? provider;\n if (!PAYMENT_PROVIDERS.has(provider)) {\n throw new Error(\n \"payment_provider must be one of: \" +\n [...PAYMENT_PROVIDERS].sort().join(\", \"),\n );\n }\n return provider;\n}\n\n// Mirrors Python urlsplit for the subset of URLs the backend accepts.\n// Deliberately NOT the WHATWG URL class: `new URL` drops default ports and\n// percent-normalizes paths, which Python's urlsplit does not.\nconst URL_RE = /^([A-Za-z][A-Za-z0-9+.-]*):\\/\\/([^/?#]*)([^?#]*)(?:\\?[^#]*)?(?:#.*)?$/;\n\nexport function normalizeApiEndpoint(\n value: string | null | undefined,\n): string | null {\n const cleaned = cleanOptional(value);\n if (cleaned === null) return null;\n\n const candidate = cleaned.includes(\"://\") ? cleaned : `https://${cleaned}`;\n const match = URL_RE.exec(candidate);\n if (!match) {\n throw new Error(\"api_endpoint must include a host\");\n }\n const scheme = (match[1] ?? \"https\").toLowerCase();\n const authority = match[2] ?? \"\";\n const rawPath = match[3] ?? \"\";\n\n if (authority === \"\") {\n throw new Error(\"api_endpoint must include a host\");\n }\n\n // Userinfo is dropped, exactly like the Python code (it rebuilds netloc\n // from parsed.hostname + parsed.port only).\n const atIndex = authority.lastIndexOf(\"@\");\n const hostPort = atIndex === -1 ? authority : authority.slice(atIndex + 1);\n\n let host = hostPort;\n let port: string | null = null;\n const colonIndex = hostPort.lastIndexOf(\":\");\n if (colonIndex !== -1) {\n host = hostPort.slice(0, colonIndex);\n const portStr = hostPort.slice(colonIndex + 1);\n if (portStr !== \"\") {\n if (!/^\\d+$/.test(portStr)) {\n throw new Error(\n `Port could not be cast to integer value as '${portStr}'`,\n );\n }\n const parsed = Number.parseInt(portStr, 10);\n if (parsed > 65535) {\n throw new Error(\"Port out of range 0-65535\");\n }\n port = String(parsed);\n }\n }\n\n host = host.toLowerCase();\n if (host === \"\") {\n throw new Error(\"api_endpoint must include a host\");\n }\n\n const netloc = port === null ? host : `${host}:${port}`;\n const path = rawPath.replace(/\\/+$/, \"\") || \"/\";\n return `${scheme}://${netloc}${path}`;\n}\n\nexport function generateServiceId(\n apiEndpoint: string,\n paymentProvider: string,\n paymentTargetRef: string,\n): string {\n const material = [\n normalizeApiEndpoint(apiEndpoint) ?? \"\",\n paymentProvider,\n pyStrip(paymentTargetRef),\n ].join(\"|\");\n return (\n \"svc_\" +\n createHash(\"sha256\").update(material, \"utf8\").digest(\"hex\").slice(0, 20)\n );\n}\n\nexport function buildIdentity(args: {\n service_id?: string | null;\n service_name?: string | null;\n api_endpoint?: string | null;\n payment_provider?: string | null;\n payment_target_ref?: string | null;\n directory_slug?: string | null;\n}): ServiceIdentity {\n return {\n service_id: cleanOptional(args.service_id),\n service_name: cleanOptional(args.service_name),\n api_endpoint: normalizeApiEndpoint(args.api_endpoint),\n payment_provider: normalizePaymentProvider(args.payment_provider),\n payment_target_ref: cleanOptional(args.payment_target_ref),\n directory_slug: cleanOptional(args.directory_slug),\n };\n}\n\nexport function hasStrongIdentity(identity: ServiceIdentity): boolean {\n return Boolean(\n identity.api_endpoint &&\n identity.payment_provider &&\n identity.payment_target_ref,\n );\n}\n","/**\n * Serialize exactly like Python\n * `json.dumps(obj, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=True)`.\n *\n * JS JSON.stringify cannot be used: it does not escape non-ASCII characters,\n * and Python additionally escapes U+007F. Hand-rolled per\n * spec/CANONICAL_PAYLOAD.md.\n */\n\nconst SHORT_ESCAPES: Record<number, string> = {\n 0x08: \"\\\\b\",\n 0x09: \"\\\\t\",\n 0x0a: \"\\\\n\",\n 0x0c: \"\\\\f\",\n 0x0d: \"\\\\r\",\n};\n\nfunction encodeString(value: string): string {\n let out = '\"';\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n const short = SHORT_ESCAPES[code];\n if (code === 0x22) {\n out += '\\\\\"';\n } else if (code === 0x5c) {\n out += \"\\\\\\\\\";\n } else if (short !== undefined) {\n out += short;\n } else if (code < 0x20 || code > 0x7e) {\n // ensure_ascii: everything outside printable ASCII becomes \\uxxxx\n // (lowercase hex). Iterating UTF-16 code units makes astral characters\n // come out as escaped surrogate pairs, matching CPython.\n out += \"\\\\u\" + code.toString(16).padStart(4, \"0\");\n } else {\n out += value[i];\n }\n }\n return out + '\"';\n}\n\nexport function pythonCanonicalJson(\n obj: Record<string, string | number | null>,\n): string {\n const parts = Object.keys(obj)\n .sort()\n .map((key) => {\n const value = obj[key] ?? null;\n let encoded: string;\n if (value === null) {\n encoded = \"null\";\n } else if (typeof value === \"number\") {\n if (!Number.isInteger(value)) {\n throw new Error(`non-integer number in canonical payload: ${key}`);\n }\n encoded = String(value);\n } else {\n encoded = encodeString(value);\n }\n return `${encodeString(key)}:${encoded}`;\n });\n return `{${parts.join(\",\")}}`;\n}\n","/**\n * Local construction of the crowdcode.review.v1 signing payload.\n * Byte-for-byte port of src/crowdcode/payments.py:canonical_review_payload;\n * conformance enforced against spec/review-payload-vectors.json.\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { ServiceIdentity } from \"./identity.js\";\nimport { pythonCanonicalJson } from \"./json.js\";\nimport { pyStrip } from \"./pystrip.js\";\n\nexport const PAYLOAD_TYPE = \"crowdcode.review.v1\";\n\nexport function reasonHash(reason: string): string {\n return (\n \"sha256:\" +\n createHash(\"sha256\").update(pyStrip(reason), \"utf8\").digest(\"hex\")\n );\n}\n\nexport function canonicalReviewPayload(args: {\n identity: Pick<\n ServiceIdentity,\n | \"service_id\"\n | \"api_endpoint\"\n | \"payment_provider\"\n | \"payment_target_ref\"\n | \"directory_slug\"\n >;\n rating: number;\n reason: string;\n paymentReference: string;\n}): string {\n const { identity, rating, reason, paymentReference } = args;\n if (!Number.isInteger(rating)) {\n throw new Error(\"rating must be an integer\");\n }\n return pythonCanonicalJson({\n type: PAYLOAD_TYPE,\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n payment_reference: pyStrip(paymentReference),\n rating,\n reason_hash: reasonHash(reason),\n });\n}\n"],"mappings":";AAUA,IAAM,WACJ;AAEF,IAAM,UAAU,IAAI,OAAO,KAAK,QAAQ,IAAI;AAC5C,IAAM,WAAW,IAAI,OAAO,IAAI,QAAQ,KAAK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IAC9B;AACA,WAAO,GAAG,aAAa,GAAG,CAAC,IAAI,OAAO;AAAA,EACxC,CAAC;AACH,SAAO,IAAI,MAAM,KAAK,GAAG,CAAC;AAC5B;;;ACvDA,SAAS,cAAAA,mBAAkB;AAKpB,IAAM,eAAe;AAErB,SAAS,WAAW,QAAwB;AACjD,SACE,YACAC,YAAW,QAAQ,EAAE,OAAO,QAAQ,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK;AAErE;AAEO,SAAS,uBAAuB,MAY5B;AACT,QAAM,EAAE,UAAU,QAAQ,QAAQ,iBAAiB,IAAI;AACvD,MAAI,CAAC,OAAO,UAAU,MAAM,GAAG;AAC7B,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,SAAO,oBAAoB;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,SAAS;AAAA,IACrB,cAAc,SAAS;AAAA,IACvB,kBAAkB,SAAS;AAAA,IAC3B,oBAAoB,SAAS;AAAA,IAC7B,gBAAgB,SAAS;AAAA,IACzB,mBAAmB,QAAQ,gBAAgB;AAAA,IAC3C;AAAA,IACA,aAAa,WAAW,MAAM;AAAA,EAChC,CAAC;AACH;","names":["createHash","createHash"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes"]);
|
|
5
|
+
function getConfig(env = process.env) {
|
|
6
|
+
return {
|
|
7
|
+
backendUrl: env.CROWDCODE_BACKEND_URL ?? "https://crowdcode-backend.onrender.com/mcp",
|
|
8
|
+
cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), ".cache", "crowdcode-mcp"),
|
|
9
|
+
disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? "").toLowerCase()),
|
|
10
|
+
// Generous default: the free-tier Render backend cold-starts slowly.
|
|
11
|
+
upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 6e4)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
getConfig
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-ZOKWC7AU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport interface Config {\n backendUrl: string;\n cacheDir: string;\n disableModel: boolean;\n upstreamTimeoutMs: number;\n}\n\nconst TRUTHY = new Set([\"1\", \"true\", \"yes\"]);\n\nexport function getConfig(env: NodeJS.ProcessEnv = process.env): Config {\n return {\n backendUrl:\n env.CROWDCODE_BACKEND_URL ?? \"https://crowdcode-backend.onrender.com/mcp\",\n cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), \".cache\", \"crowdcode-mcp\"),\n disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? \"\").toLowerCase()),\n // Generous default: the free-tier Render backend cold-starts slowly.\n upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 60_000),\n };\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,YAAY;AASrB,IAAM,SAAS,oBAAI,IAAI,CAAC,KAAK,QAAQ,KAAK,CAAC;AAEpC,SAAS,UAAU,MAAyB,QAAQ,KAAa;AACtE,SAAO;AAAA,IACL,YACE,IAAI,yBAAyB;AAAA,IAC/B,UAAU,IAAI,uBAAuB,KAAK,QAAQ,GAAG,UAAU,eAAe;AAAA,IAC9E,cAAc,OAAO,KAAK,IAAI,2BAA2B,IAAI,YAAY,CAAC;AAAA;AAAA,IAE1E,mBAAmB,OAAO,IAAI,iCAAiC,GAAM;AAAA,EACvE;AACF;","names":[]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getConfig
|
|
4
|
+
} from "./chunk-ZOKWC7AU.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
import { rm, stat } from "fs/promises";
|
|
8
|
+
function routeStdoutToStderr() {
|
|
9
|
+
console.log = (...args) => console.error(...args);
|
|
10
|
+
console.info = (...args) => console.error(...args);
|
|
11
|
+
}
|
|
12
|
+
async function readStdin() {
|
|
13
|
+
const chunks = [];
|
|
14
|
+
for await (const chunk of process.stdin) {
|
|
15
|
+
chunks.push(chunk);
|
|
16
|
+
}
|
|
17
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
18
|
+
}
|
|
19
|
+
async function runCheck(argText) {
|
|
20
|
+
const config = getConfig();
|
|
21
|
+
const text = argText ?? await readStdin();
|
|
22
|
+
if (!text.trim()) {
|
|
23
|
+
console.error('usage: crowdcode-mcp check "some text" (or pipe via stdin)');
|
|
24
|
+
process.exit(2);
|
|
25
|
+
}
|
|
26
|
+
const { RedactionEngine } = await import("@crowdcode/redaction");
|
|
27
|
+
const engine = await RedactionEngine.create({
|
|
28
|
+
cacheDir: config.cacheDir,
|
|
29
|
+
enableModel: !config.disableModel
|
|
30
|
+
});
|
|
31
|
+
if (!config.disableModel) {
|
|
32
|
+
console.error(
|
|
33
|
+
"loading PII model (downloads ~15 MB to " + config.cacheDir + " on first run; deterministic recognizers work without it) ..."
|
|
34
|
+
);
|
|
35
|
+
await engine.waitForModel();
|
|
36
|
+
}
|
|
37
|
+
const result = await engine.redact(text);
|
|
38
|
+
const revealed = await engine.reveal(result.text);
|
|
39
|
+
console.error("");
|
|
40
|
+
console.error("input: " + JSON.stringify(text));
|
|
41
|
+
console.error("redacted: " + JSON.stringify(result.text));
|
|
42
|
+
console.error("revealed: " + JSON.stringify(revealed) + " (local round-trip)");
|
|
43
|
+
console.error("");
|
|
44
|
+
console.error(
|
|
45
|
+
`entities removed: ${result.entitiesRemoved} model active: ${result.modelActive}`
|
|
46
|
+
);
|
|
47
|
+
console.error(
|
|
48
|
+
"only the redacted form would ever be sent to the CrowdCode backend."
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
async function runClearCache() {
|
|
52
|
+
const config = getConfig();
|
|
53
|
+
try {
|
|
54
|
+
await stat(config.cacheDir);
|
|
55
|
+
} catch {
|
|
56
|
+
console.error(`nothing to clear (${config.cacheDir} does not exist)`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await rm(config.cacheDir, { recursive: true, force: true });
|
|
60
|
+
console.error(`cleared ${config.cacheDir}`);
|
|
61
|
+
}
|
|
62
|
+
async function main() {
|
|
63
|
+
const [, , command, ...rest] = process.argv;
|
|
64
|
+
switch (command) {
|
|
65
|
+
case void 0:
|
|
66
|
+
case "serve": {
|
|
67
|
+
routeStdoutToStderr();
|
|
68
|
+
const { startServer } = await import("./server-EAUTUSVT.js");
|
|
69
|
+
await startServer();
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "check":
|
|
73
|
+
await runCheck(rest.length > 0 ? rest.join(" ") : void 0);
|
|
74
|
+
break;
|
|
75
|
+
case "clear-cache":
|
|
76
|
+
await runClearCache();
|
|
77
|
+
break;
|
|
78
|
+
case "--help":
|
|
79
|
+
case "-h":
|
|
80
|
+
console.error(
|
|
81
|
+
"usage: crowdcode-mcp [serve|check <text>|clear-cache]\n serve start the stdio MCP server (default)\n check demo the local redaction pipeline on sample text\n clear-cache delete the downloaded model cache"
|
|
82
|
+
);
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
console.error(`unknown command: ${command} (try --help)`);
|
|
86
|
+
process.exit(2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
main().catch((err) => {
|
|
90
|
+
console.error("crowdcode-mcp fatal:", err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * crowdcode-mcp — CrowdCode MCP client with local-first PII redaction.\n *\n * Subcommands:\n * (none) | serve start the stdio MCP server (default)\n * check [text] show what the redaction pipeline does to sample text\n * clear-cache delete the downloaded model cache\n */\n\nimport { rm, stat } from \"node:fs/promises\";\nimport { getConfig } from \"./config.js\";\n\n// stdout carries the MCP protocol in serve mode; anything that would print\n// there (transformers download progress, stray library logs) corrupts it.\n// Patch before any heavy import happens.\nfunction routeStdoutToStderr(): void {\n console.log = (...args: unknown[]) => console.error(...args);\n console.info = (...args: unknown[]) => console.error(...args);\n}\n\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\nasync function runCheck(argText: string | undefined): Promise<void> {\n const config = getConfig();\n const text = argText ?? (await readStdin());\n if (!text.trim()) {\n console.error('usage: crowdcode-mcp check \"some text\" (or pipe via stdin)');\n process.exit(2);\n }\n\n const { RedactionEngine } = await import(\"@crowdcode/redaction\");\n const engine = await RedactionEngine.create({\n cacheDir: config.cacheDir,\n enableModel: !config.disableModel,\n });\n\n if (!config.disableModel) {\n console.error(\n \"loading PII model (downloads ~15 MB to \" +\n config.cacheDir +\n \" on first run; deterministic recognizers work without it) ...\",\n );\n await engine.waitForModel();\n }\n\n const result = await engine.redact(text);\n const revealed = await engine.reveal(result.text);\n\n console.error(\"\");\n console.error(\"input: \" + JSON.stringify(text));\n console.error(\"redacted: \" + JSON.stringify(result.text));\n console.error(\"revealed: \" + JSON.stringify(revealed) + \" (local round-trip)\");\n console.error(\"\");\n console.error(\n `entities removed: ${result.entitiesRemoved} model active: ${result.modelActive}`,\n );\n console.error(\n \"only the redacted form would ever be sent to the CrowdCode backend.\",\n );\n}\n\nasync function runClearCache(): Promise<void> {\n const config = getConfig();\n try {\n await stat(config.cacheDir);\n } catch {\n console.error(`nothing to clear (${config.cacheDir} does not exist)`);\n return;\n }\n await rm(config.cacheDir, { recursive: true, force: true });\n console.error(`cleared ${config.cacheDir}`);\n}\n\nasync function main(): Promise<void> {\n const [, , command, ...rest] = process.argv;\n switch (command) {\n case undefined:\n case \"serve\": {\n routeStdoutToStderr();\n const { startServer } = await import(\"./server.js\");\n await startServer();\n break;\n }\n case \"check\":\n await runCheck(rest.length > 0 ? rest.join(\" \") : undefined);\n break;\n case \"clear-cache\":\n await runClearCache();\n break;\n case \"--help\":\n case \"-h\":\n console.error(\n \"usage: crowdcode-mcp [serve|check <text>|clear-cache]\\n\" +\n \" serve start the stdio MCP server (default)\\n\" +\n \" check demo the local redaction pipeline on sample text\\n\" +\n \" clear-cache delete the downloaded model cache\",\n );\n break;\n default:\n console.error(`unknown command: ${command} (try --help)`);\n process.exit(2);\n }\n}\n\nmain().catch((err) => {\n console.error(\"crowdcode-mcp fatal:\", err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAUA,SAAS,IAAI,YAAY;AAMzB,SAAS,sBAA4B;AACnC,UAAQ,MAAM,IAAI,SAAoB,QAAQ,MAAM,GAAG,IAAI;AAC3D,UAAQ,OAAO,IAAI,SAAoB,QAAQ,MAAM,GAAG,IAAI;AAC9D;AAEA,eAAe,YAA6B;AAC1C,QAAM,SAAmB,CAAC;AAC1B,mBAAiB,SAAS,QAAQ,OAAO;AACvC,WAAO,KAAK,KAAe;AAAA,EAC7B;AACA,SAAO,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM;AAC9C;AAEA,eAAe,SAAS,SAA4C;AAClE,QAAM,SAAS,UAAU;AACzB,QAAM,OAAO,WAAY,MAAM,UAAU;AACzC,MAAI,CAAC,KAAK,KAAK,GAAG;AAChB,YAAQ,MAAM,4DAA4D;AAC1E,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,sBAAsB;AAC/D,QAAM,SAAS,MAAM,gBAAgB,OAAO;AAAA,IAC1C,UAAU,OAAO;AAA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YAAM,cAAc;AACpB;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,cAAQ;AAAA,QACN;AAAA,MAIF;AACA;AAAA,IACF;AACE,cAAQ,MAAM,oBAAoB,OAAO,eAAe;AACxD,cAAQ,KAAK,CAAC;AAAA,EAClB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,wBAAwB,GAAG;AACzC,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PAYLOAD_TYPE,
|
|
3
|
+
PAYMENT_PROVIDERS,
|
|
4
|
+
buildIdentity,
|
|
5
|
+
canonicalReviewPayload,
|
|
6
|
+
cleanOptional,
|
|
7
|
+
generateServiceId,
|
|
8
|
+
hasStrongIdentity,
|
|
9
|
+
normalizeApiEndpoint,
|
|
10
|
+
normalizePaymentProvider,
|
|
11
|
+
pyStrip,
|
|
12
|
+
pythonCanonicalJson,
|
|
13
|
+
reasonHash
|
|
14
|
+
} from "./chunk-URCCBSON.js";
|
|
15
|
+
export {
|
|
16
|
+
PAYLOAD_TYPE,
|
|
17
|
+
PAYMENT_PROVIDERS,
|
|
18
|
+
buildIdentity,
|
|
19
|
+
canonicalReviewPayload,
|
|
20
|
+
cleanOptional,
|
|
21
|
+
generateServiceId,
|
|
22
|
+
hasStrongIdentity,
|
|
23
|
+
normalizeApiEndpoint,
|
|
24
|
+
normalizePaymentProvider,
|
|
25
|
+
pyStrip,
|
|
26
|
+
pythonCanonicalJson,
|
|
27
|
+
reasonHash
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfig
|
|
3
|
+
} from "./chunk-ZOKWC7AU.js";
|
|
4
|
+
import {
|
|
5
|
+
buildIdentity,
|
|
6
|
+
canonicalReviewPayload
|
|
7
|
+
} from "./chunk-URCCBSON.js";
|
|
8
|
+
|
|
9
|
+
// src/server.ts
|
|
10
|
+
import { RedactionEngine } from "@crowdcode/redaction";
|
|
11
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
|
|
14
|
+
// src/attestation.ts
|
|
15
|
+
function withRedactionAttestation(payload, info) {
|
|
16
|
+
return {
|
|
17
|
+
...payload,
|
|
18
|
+
_redaction: {
|
|
19
|
+
entities_removed: info.entitiesRemoved,
|
|
20
|
+
model_active: info.modelActive
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function toToolResult(payload) {
|
|
25
|
+
return { content: [{ type: "text", text: JSON.stringify(payload) }] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/redaction/policy.ts
|
|
29
|
+
var REDACTION_POLICY = {
|
|
30
|
+
request_service: ["service_description", "task_context"],
|
|
31
|
+
review_service: ["reason", "task_context"]
|
|
32
|
+
};
|
|
33
|
+
async function redactArgs(engine, tool, args) {
|
|
34
|
+
const fields = REDACTION_POLICY[tool] ?? [];
|
|
35
|
+
const out = { ...args };
|
|
36
|
+
let entitiesRemoved = 0;
|
|
37
|
+
let modelActive = engine.modelActive;
|
|
38
|
+
for (const field of fields) {
|
|
39
|
+
const value = out[field];
|
|
40
|
+
if (typeof value !== "string" || value === "") continue;
|
|
41
|
+
const result = await engine.redact(value);
|
|
42
|
+
out[field] = result.text;
|
|
43
|
+
entitiesRemoved += result.entitiesRemoved;
|
|
44
|
+
modelActive = result.modelActive;
|
|
45
|
+
}
|
|
46
|
+
return { args: out, entitiesRemoved, modelActive };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/schemas.ts
|
|
50
|
+
import { z } from "zod";
|
|
51
|
+
var identityShape = {
|
|
52
|
+
service_id: z.string().nullish().describe("Canonical service id (svc_...)"),
|
|
53
|
+
api_endpoint: z.string().nullish().describe("Service API endpoint URL"),
|
|
54
|
+
payment_provider: z.string().nullish().describe("One of: stripe, stripe_payment_link, mppx, x402, manual"),
|
|
55
|
+
payment_target_ref: z.string().nullish().describe("Payment recipient reference (wallet address, account id, ...)"),
|
|
56
|
+
directory_slug: z.string().nullish().describe("Directory slug if known")
|
|
57
|
+
};
|
|
58
|
+
var requestServiceShape = {
|
|
59
|
+
service_description: z.string().describe(
|
|
60
|
+
"Specific, reusable service capability with clear inputs and outputs. Do not include secrets, credentials, or private user data \u2014 free text is additionally redacted locally before it leaves this machine."
|
|
61
|
+
),
|
|
62
|
+
task_context: z.string().nullish().describe("Optional context about the task that needed this service")
|
|
63
|
+
};
|
|
64
|
+
var getServiceScoreShape = { ...identityShape };
|
|
65
|
+
var signingPayloadShape = {
|
|
66
|
+
rating: z.number().int().describe("Rating 1-5"),
|
|
67
|
+
reason: z.string().describe("Review text (redacted locally before hashing)"),
|
|
68
|
+
payment_reference: z.string().describe("Payment reference for this review"),
|
|
69
|
+
...identityShape
|
|
70
|
+
};
|
|
71
|
+
var reviewServiceShape = {
|
|
72
|
+
rating: z.number().int().describe("Rating 1-5"),
|
|
73
|
+
reason: z.string().describe("Review text (redacted locally before sending)"),
|
|
74
|
+
payment_reference: z.string().describe("Unique payment reference"),
|
|
75
|
+
service_id: identityShape.service_id,
|
|
76
|
+
task_context: z.string().nullish(),
|
|
77
|
+
service_name: z.string().nullish(),
|
|
78
|
+
api_endpoint: identityShape.api_endpoint,
|
|
79
|
+
payment_provider: identityShape.payment_provider,
|
|
80
|
+
payment_target_ref: identityShape.payment_target_ref,
|
|
81
|
+
directory_slug: identityShape.directory_slug,
|
|
82
|
+
payment_proof: z.string().nullish(),
|
|
83
|
+
payment_challenge: z.string().nullish(),
|
|
84
|
+
reviewer_wallet: z.string().nullish(),
|
|
85
|
+
review_signature: z.string().nullish(),
|
|
86
|
+
signature_scheme: z.string().default("eip191")
|
|
87
|
+
};
|
|
88
|
+
var MIRRORED_REMOTE_TOOLS = [
|
|
89
|
+
"request_service",
|
|
90
|
+
"get_service_score",
|
|
91
|
+
"review_service"
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
// src/tools/signing-payload.ts
|
|
95
|
+
function orNull(value) {
|
|
96
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
97
|
+
}
|
|
98
|
+
async function getReviewSigningPayload(deps, args) {
|
|
99
|
+
let identity;
|
|
100
|
+
try {
|
|
101
|
+
identity = buildIdentity(args);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return { ok: false, reason: err.message };
|
|
104
|
+
}
|
|
105
|
+
const redacted = await deps.redact(args.reason);
|
|
106
|
+
let score;
|
|
107
|
+
try {
|
|
108
|
+
score = await deps.upstream.call("get_service_score", {
|
|
109
|
+
service_id: identity.service_id,
|
|
110
|
+
api_endpoint: identity.api_endpoint,
|
|
111
|
+
payment_provider: identity.payment_provider,
|
|
112
|
+
payment_target_ref: identity.payment_target_ref,
|
|
113
|
+
directory_slug: identity.directory_slug
|
|
114
|
+
});
|
|
115
|
+
} catch (err) {
|
|
116
|
+
return {
|
|
117
|
+
ok: false,
|
|
118
|
+
reason: `could not reach the CrowdCode backend to resolve the service: ${err.message}`
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
let effective = identity;
|
|
122
|
+
if (score.found === true) {
|
|
123
|
+
try {
|
|
124
|
+
effective = buildIdentity({
|
|
125
|
+
service_id: orNull(score.service_id),
|
|
126
|
+
service_name: orNull(score.service_name),
|
|
127
|
+
api_endpoint: identity.api_endpoint ?? orNull(score.canonical_endpoint),
|
|
128
|
+
payment_provider: identity.payment_provider ?? orNull(score.payment_provider),
|
|
129
|
+
payment_target_ref: identity.payment_target_ref ?? orNull(score.payment_target_ref),
|
|
130
|
+
directory_slug: identity.directory_slug ?? orNull(score.directory_slug)
|
|
131
|
+
});
|
|
132
|
+
} catch (err) {
|
|
133
|
+
return { ok: false, reason: err.message };
|
|
134
|
+
}
|
|
135
|
+
} else if (typeof score.reason === "string" && score.reason !== "service not found") {
|
|
136
|
+
return { ok: false, reason: score.reason };
|
|
137
|
+
}
|
|
138
|
+
const message = canonicalReviewPayload({
|
|
139
|
+
identity: effective,
|
|
140
|
+
rating: args.rating,
|
|
141
|
+
reason: redacted.text,
|
|
142
|
+
paymentReference: args.payment_reference
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
ok: true,
|
|
146
|
+
signature_scheme: "eip191",
|
|
147
|
+
message,
|
|
148
|
+
reason: redacted.text,
|
|
149
|
+
identity: {
|
|
150
|
+
service_id: effective.service_id,
|
|
151
|
+
api_endpoint: effective.api_endpoint,
|
|
152
|
+
payment_provider: effective.payment_provider,
|
|
153
|
+
payment_target_ref: effective.payment_target_ref,
|
|
154
|
+
directory_slug: effective.directory_slug
|
|
155
|
+
},
|
|
156
|
+
instructions: "Sign `message` with the reviewer wallet (EIP-191 personal_sign). Then call review_service in this same session, passing this exact `reason` string and every field of `identity` verbatim, plus the same rating and payment_reference.",
|
|
157
|
+
_redaction: {
|
|
158
|
+
entities_removed: redacted.entitiesRemoved,
|
|
159
|
+
model_active: redacted.modelActive
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/upstream.ts
|
|
165
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
166
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
167
|
+
var UpstreamError = class extends Error {
|
|
168
|
+
};
|
|
169
|
+
var UpstreamClient = class {
|
|
170
|
+
constructor(baseUrl, timeoutMs) {
|
|
171
|
+
this.baseUrl = baseUrl;
|
|
172
|
+
this.timeoutMs = timeoutMs;
|
|
173
|
+
}
|
|
174
|
+
baseUrl;
|
|
175
|
+
timeoutMs;
|
|
176
|
+
client = null;
|
|
177
|
+
async connect() {
|
|
178
|
+
if (this.client !== null) return this.client;
|
|
179
|
+
const client = new Client({ name: "crowdcode-mcp-local", version: "0.1.0" });
|
|
180
|
+
const transport = new StreamableHTTPClientTransport(new URL(this.baseUrl));
|
|
181
|
+
await client.connect(transport);
|
|
182
|
+
this.client = client;
|
|
183
|
+
return client;
|
|
184
|
+
}
|
|
185
|
+
async reset() {
|
|
186
|
+
const client = this.client;
|
|
187
|
+
this.client = null;
|
|
188
|
+
if (client !== null) {
|
|
189
|
+
try {
|
|
190
|
+
await client.close();
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async call(name, args) {
|
|
196
|
+
try {
|
|
197
|
+
return await this.callOnce(name, args);
|
|
198
|
+
} catch (err) {
|
|
199
|
+
if (err instanceof UpstreamError) throw err;
|
|
200
|
+
await this.reset();
|
|
201
|
+
return this.callOnce(name, args);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async callOnce(name, args) {
|
|
205
|
+
const client = await this.connect();
|
|
206
|
+
const result = await client.callTool({ name, arguments: args }, void 0, {
|
|
207
|
+
timeout: this.timeoutMs
|
|
208
|
+
});
|
|
209
|
+
if (result.isError) {
|
|
210
|
+
throw new UpstreamError(
|
|
211
|
+
`backend tool ${name} failed: ${firstText(result.content)}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const structured = result.structuredContent;
|
|
215
|
+
if (structured !== void 0 && isRecord(structured)) {
|
|
216
|
+
return structured;
|
|
217
|
+
}
|
|
218
|
+
const text = firstText(result.content);
|
|
219
|
+
try {
|
|
220
|
+
const parsed = JSON.parse(text);
|
|
221
|
+
if (isRecord(parsed)) return parsed;
|
|
222
|
+
} catch {
|
|
223
|
+
}
|
|
224
|
+
throw new UpstreamError(
|
|
225
|
+
`backend tool ${name} returned an unparseable result: ${text.slice(0, 200)}`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
async listToolNames() {
|
|
229
|
+
const client = await this.connect();
|
|
230
|
+
const { tools } = await client.listTools();
|
|
231
|
+
return tools.map((tool) => tool.name);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function isRecord(value) {
|
|
235
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
236
|
+
}
|
|
237
|
+
function firstText(content) {
|
|
238
|
+
if (Array.isArray(content)) {
|
|
239
|
+
for (const item of content) {
|
|
240
|
+
if (isRecord(item) && item.type === "text" && typeof item.text === "string") {
|
|
241
|
+
return item.text;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return "";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/server.ts
|
|
249
|
+
function errorPayload(tool, err) {
|
|
250
|
+
const message = err instanceof UpstreamError ? err.message : `could not reach the CrowdCode backend: ${err.message}`;
|
|
251
|
+
if (tool === "get_service_score") {
|
|
252
|
+
return {
|
|
253
|
+
found: false,
|
|
254
|
+
avg_rating: null,
|
|
255
|
+
num_reviews: 0,
|
|
256
|
+
recent_reviews: [],
|
|
257
|
+
reason: message
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return { accepted: false, reason: message };
|
|
261
|
+
}
|
|
262
|
+
function createToolHandlers(deps) {
|
|
263
|
+
const { engine, upstream } = deps;
|
|
264
|
+
async function forwardWithRedaction(tool, args) {
|
|
265
|
+
const redacted = await redactArgs(engine, tool, args);
|
|
266
|
+
try {
|
|
267
|
+
const result = await upstream.call(tool, redacted.args);
|
|
268
|
+
return toToolResult(
|
|
269
|
+
withRedactionAttestation(result, {
|
|
270
|
+
entitiesRemoved: redacted.entitiesRemoved,
|
|
271
|
+
modelActive: redacted.modelActive
|
|
272
|
+
})
|
|
273
|
+
);
|
|
274
|
+
} catch (err) {
|
|
275
|
+
return toToolResult(errorPayload(tool, err));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
request_service: (args) => forwardWithRedaction("request_service", args),
|
|
280
|
+
get_service_score: async (args) => {
|
|
281
|
+
try {
|
|
282
|
+
return toToolResult(await upstream.call("get_service_score", args));
|
|
283
|
+
} catch (err) {
|
|
284
|
+
return toToolResult(errorPayload("get_service_score", err));
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
get_review_signing_payload: async (args) => toToolResult(
|
|
288
|
+
await getReviewSigningPayload(
|
|
289
|
+
{ redact: (text) => engine.redact(text), upstream },
|
|
290
|
+
args
|
|
291
|
+
)
|
|
292
|
+
),
|
|
293
|
+
review_service: (args) => forwardWithRedaction("review_service", args)
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function buildServer(deps) {
|
|
297
|
+
const server = new McpServer({ name: "crowdcode", version: "0.1.0" });
|
|
298
|
+
const handlers = createToolHandlers(deps);
|
|
299
|
+
server.registerTool(
|
|
300
|
+
"request_service",
|
|
301
|
+
{
|
|
302
|
+
description: "Capture an unmet, reusable service request for future directory coverage. Use only when no fitting paid or external service exists. Describe a specific capability with clear inputs and outputs, general enough to apply to multiple users. Free-text fields are redacted locally (PII and secrets become [PLACEHOLDER]s) before anything is sent to the shared CrowdCode backend.",
|
|
303
|
+
inputSchema: requestServiceShape
|
|
304
|
+
},
|
|
305
|
+
(args) => handlers.request_service(args)
|
|
306
|
+
);
|
|
307
|
+
server.registerTool(
|
|
308
|
+
"get_service_score",
|
|
309
|
+
{
|
|
310
|
+
description: "Return the average rating, review count, and recent reviews for a service, identified by service_id, api_endpoint, payment target, or directory_slug. Check this before paying for a service.",
|
|
311
|
+
inputSchema: getServiceScoreShape
|
|
312
|
+
},
|
|
313
|
+
(args) => handlers.get_service_score(args)
|
|
314
|
+
);
|
|
315
|
+
server.registerTool(
|
|
316
|
+
"get_review_signing_payload",
|
|
317
|
+
{
|
|
318
|
+
description: "Build the exact EIP-191 message to sign before submitting an mppx or x402 review. Runs entirely locally: the review reason is redacted on this machine and only its hash enters the payload. Sign the returned `message` with the reviewer wallet, then call review_service with the returned `reason` and `identity` fields passed through verbatim, in this same session.",
|
|
319
|
+
inputSchema: signingPayloadShape
|
|
320
|
+
},
|
|
321
|
+
(args) => handlers.get_review_signing_payload(args)
|
|
322
|
+
);
|
|
323
|
+
server.registerTool(
|
|
324
|
+
"review_service",
|
|
325
|
+
{
|
|
326
|
+
description: "Submit a review for a service you paid for. Requires the payment reference; mppx/x402 reviews additionally require payment_proof, reviewer_wallet, and review_signature over the message from get_review_signing_payload. Free-text fields are redacted locally before submission \u2014 pass the exact `reason` returned by get_review_signing_payload when submitting a signed review.",
|
|
327
|
+
inputSchema: reviewServiceShape
|
|
328
|
+
},
|
|
329
|
+
(args) => handlers.review_service(args)
|
|
330
|
+
);
|
|
331
|
+
return server;
|
|
332
|
+
}
|
|
333
|
+
async function warnOnToolDrift(upstream) {
|
|
334
|
+
try {
|
|
335
|
+
const remote = new Set(await upstream.listToolNames());
|
|
336
|
+
const missing = MIRRORED_REMOTE_TOOLS.filter((name) => !remote.has(name));
|
|
337
|
+
if (missing.length > 0) {
|
|
338
|
+
process.stderr.write(
|
|
339
|
+
`crowdcode-mcp: backend no longer advertises: ${missing.join(", ")} \u2014 update the crowdcode-mcp package.
|
|
340
|
+
`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
} catch {
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async function startServer() {
|
|
347
|
+
const config = getConfig();
|
|
348
|
+
const engine = await RedactionEngine.create({
|
|
349
|
+
cacheDir: config.cacheDir,
|
|
350
|
+
enableModel: !config.disableModel
|
|
351
|
+
});
|
|
352
|
+
const upstream = new UpstreamClient(config.backendUrl, config.upstreamTimeoutMs);
|
|
353
|
+
const server = buildServer({ engine, upstream });
|
|
354
|
+
await server.connect(new StdioServerTransport());
|
|
355
|
+
void warnOnToolDrift(upstream);
|
|
356
|
+
}
|
|
357
|
+
export {
|
|
358
|
+
buildServer,
|
|
359
|
+
createToolHandlers,
|
|
360
|
+
startServer
|
|
361
|
+
};
|
|
362
|
+
//# sourceMappingURL=server-EAUTUSVT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/attestation.ts","../src/redaction/policy.ts","../src/schemas.ts","../src/tools/signing-payload.ts","../src/upstream.ts"],"sourcesContent":["/**\n * The stdio MCP server. Advertises the same tools as the CrowdCode backend;\n * free-text arguments are redacted locally (Rampart + secret recognizers)\n * before forwarding over streamable-HTTP, and get_review_signing_payload is\n * served entirely locally so raw review text never leaves this machine at\n * signing time.\n */\n\nimport { RedactionEngine } from \"@crowdcode/redaction\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { toToolResult, withRedactionAttestation } from \"./attestation.js\";\nimport { getConfig } from \"./config.js\";\nimport { redactArgs } from \"./redaction/policy.js\";\nimport {\n MIRRORED_REMOTE_TOOLS,\n getServiceScoreShape,\n requestServiceShape,\n reviewServiceShape,\n signingPayloadShape,\n} from \"./schemas.js\";\nimport {\n getReviewSigningPayload,\n type SigningPayloadArgs,\n} from \"./tools/signing-payload.js\";\nimport { UpstreamClient, UpstreamError, type Upstream } from \"./upstream.js\";\n\nexport interface ServerDeps {\n engine: RedactionEngine;\n upstream: Upstream;\n}\n\ntype ToolResult = ReturnType<typeof toToolResult>;\n\nfunction errorPayload(\n tool: string,\n err: unknown,\n): Record<string, unknown> {\n const message =\n err instanceof UpstreamError\n ? err.message\n : `could not reach the CrowdCode backend: ${(err as Error).message}`;\n if (tool === \"get_service_score\") {\n return {\n found: false,\n avg_rating: null,\n num_reviews: 0,\n recent_reviews: [],\n reason: message,\n };\n }\n return { accepted: false, reason: message };\n}\n\nexport function createToolHandlers(deps: ServerDeps) {\n const { engine, upstream } = deps;\n\n async function forwardWithRedaction(\n tool: string,\n args: Record<string, unknown>,\n ): Promise<ToolResult> {\n const redacted = await redactArgs(engine, tool, args);\n try {\n const result = await upstream.call(tool, redacted.args);\n return toToolResult(\n withRedactionAttestation(result, {\n entitiesRemoved: redacted.entitiesRemoved,\n modelActive: redacted.modelActive,\n }),\n );\n } catch (err) {\n return toToolResult(errorPayload(tool, err));\n }\n }\n\n return {\n request_service: (args: Record<string, unknown>) =>\n forwardWithRedaction(\"request_service\", args),\n\n get_service_score: async (\n args: Record<string, unknown>,\n ): Promise<ToolResult> => {\n try {\n return toToolResult(await upstream.call(\"get_service_score\", args));\n } catch (err) {\n return toToolResult(errorPayload(\"get_service_score\", err));\n }\n },\n\n get_review_signing_payload: async (\n args: SigningPayloadArgs,\n ): Promise<ToolResult> =>\n toToolResult(\n await getReviewSigningPayload(\n { redact: (text) => engine.redact(text), upstream },\n args,\n ),\n ),\n\n review_service: (args: Record<string, unknown>) =>\n forwardWithRedaction(\"review_service\", args),\n };\n}\n\nexport function buildServer(deps: ServerDeps): McpServer {\n const server = new McpServer({ name: \"crowdcode\", version: \"0.1.0\" });\n const handlers = createToolHandlers(deps);\n\n server.registerTool(\n \"request_service\",\n {\n description:\n \"Capture an unmet, reusable service request for future directory \" +\n \"coverage. Use only when no fitting paid or external service exists. \" +\n \"Describe a specific capability with clear inputs and outputs, general \" +\n \"enough to apply to multiple users. Free-text fields are redacted \" +\n \"locally (PII and secrets become [PLACEHOLDER]s) before anything is \" +\n \"sent to the shared CrowdCode backend.\",\n inputSchema: requestServiceShape,\n },\n (args) => handlers.request_service(args),\n );\n\n server.registerTool(\n \"get_service_score\",\n {\n description:\n \"Return the average rating, review count, and recent reviews for a \" +\n \"service, identified by service_id, api_endpoint, payment target, or \" +\n \"directory_slug. Check this before paying for a service.\",\n inputSchema: getServiceScoreShape,\n },\n (args) => handlers.get_service_score(args),\n );\n\n server.registerTool(\n \"get_review_signing_payload\",\n {\n description:\n \"Build the exact EIP-191 message to sign before submitting an mppx or \" +\n \"x402 review. Runs entirely locally: the review reason is redacted on \" +\n \"this machine and only its hash enters the payload. Sign the returned \" +\n \"`message` with the reviewer wallet, then call review_service with the \" +\n \"returned `reason` and `identity` fields passed through verbatim, in \" +\n \"this same session.\",\n inputSchema: signingPayloadShape,\n },\n (args) => handlers.get_review_signing_payload(args as SigningPayloadArgs),\n );\n\n server.registerTool(\n \"review_service\",\n {\n description:\n \"Submit a review for a service you paid for. Requires the payment \" +\n \"reference; mppx/x402 reviews additionally require payment_proof, \" +\n \"reviewer_wallet, and review_signature over the message from \" +\n \"get_review_signing_payload. Free-text fields are redacted locally \" +\n \"before submission — pass the exact `reason` returned by \" +\n \"get_review_signing_payload when submitting a signed review.\",\n inputSchema: reviewServiceShape,\n },\n (args) => handlers.review_service(args),\n );\n\n return server;\n}\n\nasync function warnOnToolDrift(upstream: Upstream): Promise<void> {\n try {\n const remote = new Set(await upstream.listToolNames());\n const missing = MIRRORED_REMOTE_TOOLS.filter((name) => !remote.has(name));\n if (missing.length > 0) {\n process.stderr.write(\n `crowdcode-mcp: backend no longer advertises: ${missing.join(\", \")} — ` +\n \"update the crowdcode-mcp package.\\n\",\n );\n }\n } catch {\n // Backend unreachable at startup (cold start); tool calls will retry.\n }\n}\n\nexport async function startServer(): Promise<void> {\n const config = getConfig();\n const engine = await RedactionEngine.create({\n cacheDir: config.cacheDir,\n enableModel: !config.disableModel,\n });\n const upstream = new UpstreamClient(config.backendUrl, config.upstreamTimeoutMs);\n const server = buildServer({ engine, upstream });\n await server.connect(new StdioServerTransport());\n void warnOnToolDrift(upstream);\n}\n","export interface RedactionInfo {\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\n/** Attach the local-redaction attestation so agents (and users reading\n * transcripts) can see that redaction ran and at what coverage level. */\nexport function withRedactionAttestation(\n payload: Record<string, unknown>,\n info: RedactionInfo,\n): Record<string, unknown> {\n return {\n ...payload,\n _redaction: {\n entities_removed: info.entitiesRemoved,\n model_active: info.modelActive,\n },\n };\n}\n\nexport function toToolResult(payload: Record<string, unknown>): {\n content: Array<{ type: \"text\"; text: string }>;\n} {\n return { content: [{ type: \"text\", text: JSON.stringify(payload) }] };\n}\n","/**\n * Which tool arguments get redacted before leaving the machine.\n *\n * Only free-text fields are listed. Identity fields (api_endpoint,\n * payment_target_ref, directory_slug, service_id, service_name) and payment\n * material (payment_reference, payment_proof, reviewer_wallet,\n * review_signature) pass through untouched — redacting them would break\n * service resolution and payment verification, and they are minimized\n * server-side instead.\n */\n\nimport type { RedactionEngine } from \"@crowdcode/redaction\";\n\nexport const REDACTION_POLICY: Record<string, readonly string[]> = {\n request_service: [\"service_description\", \"task_context\"],\n review_service: [\"reason\", \"task_context\"],\n};\n\nexport interface RedactedArgs {\n args: Record<string, unknown>;\n entitiesRemoved: number;\n modelActive: boolean;\n}\n\nexport async function redactArgs(\n engine: RedactionEngine,\n tool: string,\n args: Record<string, unknown>,\n): Promise<RedactedArgs> {\n const fields = REDACTION_POLICY[tool] ?? [];\n const out = { ...args };\n let entitiesRemoved = 0;\n let modelActive = engine.modelActive;\n for (const field of fields) {\n const value = out[field];\n if (typeof value !== \"string\" || value === \"\") continue;\n const result = await engine.redact(value);\n out[field] = result.text;\n entitiesRemoved += result.entitiesRemoved;\n modelActive = result.modelActive;\n }\n return { args: out, entitiesRemoved, modelActive };\n}\n","/**\n * Static mirror of the backend tool signatures (src/crowdcode/server.py).\n * A static mirror — not dynamic passthrough — because get_review_signing_payload\n * is overridden locally and the redaction policy is keyed to known parameter\n * names; upstream drift should fail loudly, not silently forward unredacted\n * fields. Names/optionality must match the Python signatures exactly.\n */\n\nimport { z } from \"zod\";\n\nexport const identityShape = {\n service_id: z.string().nullish().describe(\"Canonical service id (svc_...)\"),\n api_endpoint: z.string().nullish().describe(\"Service API endpoint URL\"),\n payment_provider: z\n .string()\n .nullish()\n .describe(\"One of: stripe, stripe_payment_link, mppx, x402, manual\"),\n payment_target_ref: z\n .string()\n .nullish()\n .describe(\"Payment recipient reference (wallet address, account id, ...)\"),\n directory_slug: z.string().nullish().describe(\"Directory slug if known\"),\n};\n\nexport const requestServiceShape = {\n service_description: z\n .string()\n .describe(\n \"Specific, reusable service capability with clear inputs and outputs. \" +\n \"Do not include secrets, credentials, or private user data — free text \" +\n \"is additionally redacted locally before it leaves this machine.\",\n ),\n task_context: z\n .string()\n .nullish()\n .describe(\"Optional context about the task that needed this service\"),\n};\n\nexport const getServiceScoreShape = { ...identityShape };\n\nexport const signingPayloadShape = {\n rating: z.number().int().describe(\"Rating 1-5\"),\n reason: z.string().describe(\"Review text (redacted locally before hashing)\"),\n payment_reference: z.string().describe(\"Payment reference for this review\"),\n ...identityShape,\n};\n\nexport const reviewServiceShape = {\n rating: z.number().int().describe(\"Rating 1-5\"),\n reason: z.string().describe(\"Review text (redacted locally before sending)\"),\n payment_reference: z.string().describe(\"Unique payment reference\"),\n service_id: identityShape.service_id,\n task_context: z.string().nullish(),\n service_name: z.string().nullish(),\n api_endpoint: identityShape.api_endpoint,\n payment_provider: identityShape.payment_provider,\n payment_target_ref: identityShape.payment_target_ref,\n directory_slug: identityShape.directory_slug,\n payment_proof: z.string().nullish(),\n payment_challenge: z.string().nullish(),\n reviewer_wallet: z.string().nullish(),\n review_signature: z.string().nullish(),\n signature_scheme: z.string().default(\"eip191\"),\n};\n\nexport const MIRRORED_REMOTE_TOOLS = [\n \"request_service\",\n \"get_service_score\",\n \"review_service\",\n] as const;\n","/**\n * Local implementation of get_review_signing_payload.\n *\n * This replaces the remote tool so raw review text is never sent at signing\n * time: the reason is redacted locally, hashed locally, and the canonical\n * EIP-191 message is constructed locally (spec/CANONICAL_PAYLOAD.md).\n *\n * The identity-merge logic mirrors the backend exactly\n * (src/crowdcode/server.py review_service effective_identity): the server\n * verifies signatures by REBUILDING the payload from its own resolved\n * identity, so the message signed here must match that reconstruction\n * byte-for-byte. Canonical identity comes from get_service_score when the\n * service exists; otherwise the caller-provided identity is used verbatim,\n * exactly like the old remote signing tool.\n */\n\nimport type { RedactionResult } from \"@crowdcode/redaction\";\nimport { buildIdentity, type ServiceIdentity } from \"../canonical/identity.js\";\nimport { canonicalReviewPayload } from \"../canonical/payload.js\";\nimport type { Upstream } from \"../upstream.js\";\n\nexport interface SigningPayloadArgs {\n rating: number;\n reason: string;\n payment_reference: string;\n service_id?: string | null;\n api_endpoint?: string | null;\n payment_provider?: string | null;\n payment_target_ref?: string | null;\n directory_slug?: string | null;\n}\n\nexport interface SigningDeps {\n redact(text: string): Promise<RedactionResult>;\n upstream: Pick<Upstream, \"call\">;\n}\n\nfunction orNull(value: unknown): string | null {\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\nexport async function getReviewSigningPayload(\n deps: SigningDeps,\n args: SigningPayloadArgs,\n): Promise<Record<string, unknown>> {\n let identity: ServiceIdentity;\n try {\n identity = buildIdentity(args);\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n\n const redacted = await deps.redact(args.reason);\n\n let score: Record<string, unknown>;\n try {\n score = await deps.upstream.call(\"get_service_score\", {\n service_id: identity.service_id,\n api_endpoint: identity.api_endpoint,\n payment_provider: identity.payment_provider,\n payment_target_ref: identity.payment_target_ref,\n directory_slug: identity.directory_slug,\n });\n } catch (err) {\n return {\n ok: false,\n reason: `could not reach the CrowdCode backend to resolve the service: ${\n (err as Error).message\n }`,\n };\n }\n\n let effective = identity;\n if (score.found === true) {\n try {\n // Same merge as the backend: caller-normalized fields win, canonical\n // values fill the gaps, and the result is re-normalized.\n effective = buildIdentity({\n service_id: orNull(score.service_id),\n service_name: orNull(score.service_name),\n api_endpoint: identity.api_endpoint ?? orNull(score.canonical_endpoint),\n payment_provider:\n identity.payment_provider ?? orNull(score.payment_provider),\n payment_target_ref:\n identity.payment_target_ref ?? orNull(score.payment_target_ref),\n directory_slug: identity.directory_slug ?? orNull(score.directory_slug),\n });\n } catch (err) {\n return { ok: false, reason: (err as Error).message };\n }\n } else if (\n typeof score.reason === \"string\" &&\n score.reason !== \"service not found\"\n ) {\n // e.g. \"service identity conflict\" — same failure the remote tool returned.\n return { ok: false, reason: score.reason };\n }\n\n const message = canonicalReviewPayload({\n identity: effective,\n rating: args.rating,\n reason: redacted.text,\n paymentReference: args.payment_reference,\n });\n\n return {\n ok: true,\n signature_scheme: \"eip191\",\n message,\n reason: redacted.text,\n identity: {\n service_id: effective.service_id,\n api_endpoint: effective.api_endpoint,\n payment_provider: effective.payment_provider,\n payment_target_ref: effective.payment_target_ref,\n directory_slug: effective.directory_slug,\n },\n instructions:\n \"Sign `message` with the reviewer wallet (EIP-191 personal_sign). Then \" +\n \"call review_service in this same session, passing this exact `reason` \" +\n \"string and every field of `identity` verbatim, plus the same rating \" +\n \"and payment_reference.\",\n _redaction: {\n entities_removed: redacted.entitiesRemoved,\n model_active: redacted.modelActive,\n },\n };\n}\n","import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\n/** A tool-level failure reported by the backend (not a transport problem). */\nexport class UpstreamError extends Error {}\n\nexport interface Upstream {\n call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>>;\n listToolNames(): Promise<string[]>;\n}\n\nexport class UpstreamClient implements Upstream {\n private client: Client | null = null;\n\n constructor(\n private readonly baseUrl: string,\n private readonly timeoutMs: number,\n ) {}\n\n private async connect(): Promise<Client> {\n if (this.client !== null) return this.client;\n const client = new Client({ name: \"crowdcode-mcp-local\", version: \"0.1.0\" });\n const transport = new StreamableHTTPClientTransport(new URL(this.baseUrl));\n await client.connect(transport);\n this.client = client;\n return client;\n }\n\n private async reset(): Promise<void> {\n const client = this.client;\n this.client = null;\n if (client !== null) {\n try {\n await client.close();\n } catch {\n // already broken\n }\n }\n }\n\n async call(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n try {\n return await this.callOnce(name, args);\n } catch (err) {\n if (err instanceof UpstreamError) throw err;\n // Transport-level failure: reconnect once (absorbs dropped sessions and\n // Render cold starts).\n await this.reset();\n return this.callOnce(name, args);\n }\n }\n\n private async callOnce(\n name: string,\n args: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const client = await this.connect();\n const result = await client.callTool({ name, arguments: args }, undefined, {\n timeout: this.timeoutMs,\n });\n\n if (result.isError) {\n throw new UpstreamError(\n `backend tool ${name} failed: ${firstText(result.content)}`,\n );\n }\n const structured = result.structuredContent;\n if (structured !== undefined && isRecord(structured)) {\n return structured;\n }\n const text = firstText(result.content);\n try {\n const parsed: unknown = JSON.parse(text);\n if (isRecord(parsed)) return parsed;\n } catch {\n // fall through\n }\n throw new UpstreamError(\n `backend tool ${name} returned an unparseable result: ${text.slice(0, 200)}`,\n );\n }\n\n async listToolNames(): Promise<string[]> {\n const client = await this.connect();\n const { tools } = await client.listTools();\n return tools.map((tool) => tool.name);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction firstText(content: unknown): string {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (\n isRecord(item) &&\n item.type === \"text\" &&\n typeof item.text === \"string\"\n ) {\n return item.text;\n }\n }\n }\n return \"\";\n}\n"],"mappings":";;;;;;;;;AAQA,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACH9B,SAAS,yBACd,SACA,MACyB;AACzB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,MACV,kBAAkB,KAAK;AAAA,MACvB,cAAc,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,aAAa,SAE3B;AACA,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,OAAO,EAAE,CAAC,EAAE;AACtE;;;ACXO,IAAM,mBAAsD;AAAA,EACjE,iBAAiB,CAAC,uBAAuB,cAAc;AAAA,EACvD,gBAAgB,CAAC,UAAU,cAAc;AAC3C;AAQA,eAAsB,WACpB,QACA,MACA,MACuB;AACvB,QAAM,SAAS,iBAAiB,IAAI,KAAK,CAAC;AAC1C,QAAM,MAAM,EAAE,GAAG,KAAK;AACtB,MAAI,kBAAkB;AACtB,MAAI,cAAc,OAAO;AACzB,aAAW,SA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;AAChE,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,MAAM,SAAS,cAAc,CAAC;AACrD,UAAM,UAAU,sBAAsB,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC;AACxE,QAAI,QAAQ,SAAS,GAAG;AACtB,cAAQ,OAAO;AAAA,QACb,gDAAgD,QAAQ,KAAK,IAAI,CAAC;AAAA;AAAA,MAEpE;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAEA,eAAsB,cAA6B;AACjD,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,MAAM,gBAAgB,OAAO;AAAA,IAC1C,UAAU,OAAO;AAAA,IACjB,aAAa,CAAC,OAAO;AAAA,EACvB,CAAC;AACD,QAAM,WAAW,IAAI,eAAe,OAAO,YAAY,OAAO,iBAAiB;AAC/E,QAAM,SAAS,YAAY,EAAE,QAAQ,SAAS,CAAC;AAC/C,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAC/C,OAAK,gBAAgB,QAAQ;AAC/B;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crowdcode-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CrowdCode MCP client with local-first PII redaction. Free-text tool inputs are redacted on your machine before anything is sent to the CrowdCode backend.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"crowdcode-mcp": "dist/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@crowdcode/redaction": "^0.1.0",
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
30
|
+
"zod": "^3.24.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.0.0",
|
|
34
|
+
"tsup": "^8.3.0",
|
|
35
|
+
"typescript": "^5.6.0",
|
|
36
|
+
"vitest": "^2.1.0"
|
|
37
|
+
}
|
|
38
|
+
}
|