anonyma 1.0.0 → 1.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/CHANGELOG.md +273 -144
- package/README.md +427 -143
- package/dist/ai/index.cjs +522 -0
- package/dist/ai/index.cjs.map +1 -0
- package/dist/ai/index.d.cts +322 -0
- package/dist/ai/index.d.ts +322 -0
- package/dist/ai/index.js +505 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/audit/index.cjs +359 -0
- package/dist/audit/index.cjs.map +1 -0
- package/dist/audit/index.d.cts +287 -0
- package/dist/audit/index.d.ts +287 -0
- package/dist/audit/index.js +340 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/chunk-26IHMQHL.cjs +662 -0
- package/dist/chunk-26IHMQHL.cjs.map +1 -0
- package/dist/chunk-2F2GWGTB.js +174 -0
- package/dist/chunk-2F2GWGTB.js.map +1 -0
- package/dist/chunk-2NNMJ55L.cjs +45 -0
- package/dist/chunk-2NNMJ55L.cjs.map +1 -0
- package/dist/chunk-2YG7R4KJ.cjs +114 -0
- package/dist/chunk-2YG7R4KJ.cjs.map +1 -0
- package/dist/chunk-2ZZHLCEJ.js +237 -0
- package/dist/chunk-2ZZHLCEJ.js.map +1 -0
- package/dist/chunk-3CY6ATKS.cjs +308 -0
- package/dist/chunk-3CY6ATKS.cjs.map +1 -0
- package/dist/chunk-3D5ZCJ7R.js +268 -0
- package/dist/chunk-3D5ZCJ7R.js.map +1 -0
- package/dist/chunk-6LDAIJBL.js +103 -0
- package/dist/chunk-6LDAIJBL.js.map +1 -0
- package/dist/chunk-7HK2V5Q4.js +111 -0
- package/dist/chunk-7HK2V5Q4.js.map +1 -0
- package/dist/chunk-AAP472NG.js +177 -0
- package/dist/chunk-AAP472NG.js.map +1 -0
- package/dist/chunk-AP4JIUNW.js +42 -0
- package/dist/chunk-AP4JIUNW.js.map +1 -0
- package/dist/chunk-BBJPQPGP.js +457 -0
- package/dist/chunk-BBJPQPGP.js.map +1 -0
- package/dist/chunk-CRXRJZEV.cjs +82 -0
- package/dist/chunk-CRXRJZEV.cjs.map +1 -0
- package/dist/chunk-E3PICZYI.js +20 -0
- package/dist/chunk-E3PICZYI.js.map +1 -0
- package/dist/chunk-F7O2FA3F.cjs +1255 -0
- package/dist/chunk-F7O2FA3F.cjs.map +1 -0
- package/dist/chunk-FB56NAAH.cjs +243 -0
- package/dist/chunk-FB56NAAH.cjs.map +1 -0
- package/dist/chunk-G4AN7FND.js +1063 -0
- package/dist/chunk-G4AN7FND.js.map +1 -0
- package/dist/chunk-GS3FRH4K.js +294 -0
- package/dist/chunk-GS3FRH4K.js.map +1 -0
- package/dist/chunk-GYMG5OI3.cjs +186 -0
- package/dist/chunk-GYMG5OI3.cjs.map +1 -0
- package/dist/chunk-IHEIYZPL.cjs +301 -0
- package/dist/chunk-IHEIYZPL.cjs.map +1 -0
- package/dist/chunk-IJAMLYOT.cjs +1087 -0
- package/dist/chunk-IJAMLYOT.cjs.map +1 -0
- package/dist/chunk-ISL5B4LU.cjs +181 -0
- package/dist/chunk-ISL5B4LU.cjs.map +1 -0
- package/dist/chunk-JKW36IPT.js +179 -0
- package/dist/chunk-JKW36IPT.js.map +1 -0
- package/dist/chunk-KOCQBDI4.cjs +179 -0
- package/dist/chunk-KOCQBDI4.cjs.map +1 -0
- package/dist/chunk-OGNLB2KA.js +79 -0
- package/dist/chunk-OGNLB2KA.js.map +1 -0
- package/dist/chunk-PKHZ7CVI.js +28 -0
- package/dist/chunk-PKHZ7CVI.js.map +1 -0
- package/dist/chunk-QYD4F6T7.cjs +114 -0
- package/dist/chunk-QYD4F6T7.cjs.map +1 -0
- package/dist/chunk-RCW5IPPR.js +1288 -0
- package/dist/chunk-RCW5IPPR.js.map +1 -0
- package/dist/chunk-RMMKYHUN.cjs +35 -0
- package/dist/chunk-RMMKYHUN.cjs.map +1 -0
- package/dist/chunk-S4BJ2ADB.cjs +22 -0
- package/dist/chunk-S4BJ2ADB.cjs.map +1 -0
- package/dist/chunk-S7NH6CHY.cjs +462 -0
- package/dist/chunk-S7NH6CHY.cjs.map +1 -0
- package/dist/chunk-SIHPDZXA.js +176 -0
- package/dist/chunk-SIHPDZXA.js.map +1 -0
- package/dist/chunk-TW7PM3UJ.cjs +30 -0
- package/dist/chunk-TW7PM3UJ.cjs.map +1 -0
- package/dist/chunk-UA3EOFBS.cjs +1322 -0
- package/dist/chunk-UA3EOFBS.cjs.map +1 -0
- package/dist/chunk-VE4CCW7W.js +32 -0
- package/dist/chunk-VE4CCW7W.js.map +1 -0
- package/dist/chunk-W6RBCHYF.js +651 -0
- package/dist/chunk-W6RBCHYF.js.map +1 -0
- package/dist/chunk-WLJN7GIS.cjs +189 -0
- package/dist/chunk-WLJN7GIS.cjs.map +1 -0
- package/dist/chunk-YMLR375Z.js +1244 -0
- package/dist/chunk-YMLR375Z.js.map +1 -0
- package/dist/compliance/index.cjs +88 -0
- package/dist/compliance/index.cjs.map +1 -0
- package/dist/compliance/index.d.cts +277 -0
- package/dist/compliance/index.d.ts +277 -0
- package/dist/compliance/index.js +47 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/crypto.cjs +12 -136
- package/dist/crypto.cjs.map +1 -1
- package/dist/crypto.d.cts +4 -3
- package/dist/crypto.d.ts +4 -3
- package/dist/crypto.js +3 -137
- package/dist/crypto.js.map +1 -1
- package/dist/detectors/index.cjs +146 -1483
- package/dist/detectors/index.cjs.map +1 -1
- package/dist/detectors/index.d.cts +1 -1
- package/dist/detectors/index.d.ts +1 -1
- package/dist/detectors/index.js +3 -1449
- package/dist/detectors/index.js.map +1 -1
- package/dist/engine/index.cjs +441 -0
- package/dist/engine/index.cjs.map +1 -0
- package/dist/engine/index.d.cts +728 -0
- package/dist/engine/index.d.ts +728 -0
- package/dist/engine/index.js +189 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/hash-2PSYNDMM.cjs +14 -0
- package/dist/hash-2PSYNDMM.cjs.map +1 -0
- package/dist/hash-CELLDNKN.js +5 -0
- package/dist/hash-CELLDNKN.js.map +1 -0
- package/dist/index.cjs +153 -2816
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -11
- package/dist/index.d.ts +93 -11
- package/dist/index.js +13 -2791
- package/dist/index.js.map +1 -1
- package/dist/json-CKDvlRtl.d.ts +147 -0
- package/dist/json-s8ny-RCo.d.cts +147 -0
- package/dist/mcp/index.cjs +751 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +226 -0
- package/dist/mcp/index.d.ts +226 -0
- package/dist/mcp/index.js +744 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/middleware/express.cjs +93 -0
- package/dist/middleware/express.cjs.map +1 -0
- package/dist/middleware/express.d.cts +90 -0
- package/dist/middleware/express.d.ts +90 -0
- package/dist/middleware/express.js +91 -0
- package/dist/middleware/express.js.map +1 -0
- package/dist/middleware/hono.cjs +58 -0
- package/dist/middleware/hono.cjs.map +1 -0
- package/dist/middleware/hono.d.cts +75 -0
- package/dist/middleware/hono.d.ts +75 -0
- package/dist/middleware/hono.js +56 -0
- package/dist/middleware/hono.js.map +1 -0
- package/dist/middleware/index.cjs +24 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +106 -0
- package/dist/middleware/index.d.ts +106 -0
- package/dist/middleware/index.js +15 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/schemas.cjs +5 -5
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +20 -10
- package/dist/schemas.d.ts +20 -10
- package/dist/schemas.js +5 -5
- package/dist/schemas.js.map +1 -1
- package/dist/session-BdRftyZ5.d.cts +102 -0
- package/dist/session-Cs2zlNQp.d.ts +102 -0
- package/dist/stream.cjs +13 -2262
- package/dist/stream.cjs.map +1 -1
- package/dist/stream.d.cts +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/stream.js +6 -2255
- package/dist/stream.js.map +1 -1
- package/dist/types--tPm_AjY.d.ts +199 -0
- package/dist/types-0BJH_wqc.d.cts +199 -0
- package/dist/types-CPUhjvl8.d.cts +629 -0
- package/dist/types-Dtht33aq.d.ts +629 -0
- package/dist/{types-D-9HzVuy.d.cts → types-EJTj_BKY.d.cts} +38 -7
- package/dist/{types-D-9HzVuy.d.ts → types-EJTj_BKY.d.ts} +38 -7
- package/dist/types-Zt_bZvwS.d.cts +182 -0
- package/dist/types-Zt_bZvwS.d.ts +182 -0
- package/dist/validators.cjs +39 -181
- package/dist/validators.cjs.map +1 -1
- package/dist/validators.js +1 -174
- package/dist/validators.js.map +1 -1
- package/dist/vault/index.cjs +688 -0
- package/dist/vault/index.cjs.map +1 -0
- package/dist/vault/index.d.cts +385 -0
- package/dist/vault/index.d.ts +385 -0
- package/dist/vault/index.js +669 -0
- package/dist/vault/index.js.map +1 -0
- package/package.json +128 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/definitions.ts","../../src/mcp/schema.ts","../../src/mcp/server.ts"],"names":["BUILTIN_CATEGORIES","PRESET_REGISTRY","AnonymaError","webCrypto","toHex","createSessionTokenizer","compilePipeline","summarizeSpans","result","sanitizeJson","checkPolicy","isRegulationId","REGULATIONS"],"mappings":";;;;;;;;;;;;;;;;;;;AA2EO,IAAM,qBAAA,GAA2C,OAAO,MAAA,CAAO;AAAA,EACpE,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAC;AAED,IAAM,IAAA,GAAO;AAAA,EACX,YAAA,EAAc,IAAA;AAAA,EACd,eAAA,EAAiB,KAAA;AAAA,EACjB,cAAA,EAAgB,IAAA;AAAA,EAChB,aAAA,EAAe;AACjB,CAAA;AAEA,IAAM,QAAA,GAAuB,EAAE,IAAA,EAAM,QAAA,EAAU,MAAMA,oCAAA,EAAmB;AACxE,IAAM,UAAA,GAAyB;AAAA,EAC7B,IAAA,EAAM,OAAA;AAAA,EACN,WAAA,EACE,6FAAA;AAAA,EACF,KAAA,EAAO,QAAA;AAAA,EACP,QAAA,EAAU,CA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A,CAAM,CAAA,EAAG,OAAO,CAAC,CAAA;AACtC,MAAA,MAAA,GAAS,MAAA,CAAO,KAAA,CAAM,OAAA,GAAU,CAAC,CAAA;AACjC,MAAA,OAAA,GAAU,MAAA,CAAO,QAAQ,IAAI,CAAA;AAAA,IAC/B;AAAA,EACF;AACA,EAAA,MAAM,OAAA,CAAQ,MAAA,GAAS,OAAA,CAAQ,MAAA,EAAQ,CAAA;AACzC","file":"index.cjs","sourcesContent":["/**\n * @module mcp/definitions\n * @description Model Context Protocol declarations for anonyma: the tools,\n * resources and resource templates a server exposes, with JSON Schema\n * (draft 2020-12) for every tool input and output. The declarations are plain\n * data, so they can also be registered with any MCP server framework.\n */\n\nimport { BUILTIN_CATEGORIES } from \"../engine/builtin.js\";\n\n/**\n * The subset of JSON Schema used by the declarations.\n */\nexport interface JsonSchema {\n readonly type?: \"object\" | \"array\" | \"string\" | \"number\" | \"integer\" | \"boolean\";\n readonly description?: string;\n readonly properties?: Readonly<Record<string, JsonSchema>>;\n readonly required?: readonly string[];\n readonly additionalProperties?: boolean;\n readonly items?: JsonSchema;\n readonly enum?: readonly string[];\n readonly minimum?: number;\n readonly maximum?: number;\n readonly minLength?: number;\n readonly maxLength?: number;\n readonly minItems?: number;\n readonly maxItems?: number;\n}\n\n/**\n * An MCP tool declaration.\n */\nexport interface McpTool {\n /** Unique tool name. */\n readonly name: string;\n /** Human-readable name. */\n readonly title: string;\n /** What the tool does, written for a model. */\n readonly description: string;\n /** JSON Schema of the `arguments` object. */\n readonly inputSchema: JsonSchema & { readonly type: \"object\" };\n /** JSON Schema of `structuredContent` in the result. */\n readonly outputSchema: JsonSchema & { readonly type: \"object\" };\n /** Behaviour hints for clients. */\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n };\n}\n\n/**\n * An MCP resource declaration.\n */\nexport interface McpResource {\n readonly uri: string;\n readonly name: string;\n readonly title: string;\n readonly description: string;\n readonly mimeType: \"application/json\";\n}\n\n/**\n * An MCP resource template declaration.\n */\nexport interface McpResourceTemplate {\n readonly uriTemplate: string;\n readonly name: string;\n readonly title: string;\n readonly description: string;\n readonly mimeType: \"application/json\";\n}\n\n/** Protocol revisions the server implements, newest first. */\nexport const MCP_PROTOCOL_VERSIONS: readonly string[] = Object.freeze([\n \"2025-06-18\",\n \"2025-03-26\",\n \"2024-11-05\",\n]);\n\nconst PURE = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nconst CATEGORY: JsonSchema = { type: \"string\", enum: BUILTIN_CATEGORIES };\nconst CATEGORIES: JsonSchema = {\n type: \"array\",\n description:\n \"Categories to detect. Leave it out for the categories of the preset, or for all categories.\",\n items: CATEGORY,\n minItems: 1,\n maxItems: BUILTIN_CATEGORIES.length,\n};\nconst PRESET: JsonSchema = {\n type: \"string\",\n description: \"Compliance preset that selects categories and strategies.\",\n enum: [\"gdpr\", \"lgpd\", \"pipeda\", \"hipaa\", \"ccpa\", \"pci-dss\", \"sox\", \"ferpa\"],\n};\nconst TEXT: JsonSchema = {\n type: \"string\",\n description: \"The text to process.\",\n maxLength: 1_000_000,\n};\nconst MIN_CONFIDENCE: JsonSchema = {\n type: \"number\",\n description: \"Ignore detections below this confidence (0 to 1).\",\n minimum: 0,\n maximum: 1,\n};\nconst FIELDS: JsonSchema = {\n type: \"array\",\n description: \"What was replaced where. Contains no replaced text.\",\n items: {\n type: \"object\",\n properties: {\n path: { type: \"string\", description: \"JSON Pointer of the field; empty for plain text.\" },\n category: { type: \"string\" },\n detector: { type: \"string\" },\n rule: { type: \"string\" },\n count: { type: \"integer\", minimum: 0 },\n },\n required: [\"path\", \"category\", \"detector\", \"rule\", \"count\"],\n additionalProperties: false,\n },\n};\n\n/**\n * The strategies a model may request. Strategies that need key material or a\n * token vault are not offered through this parameter.\n */\nconst STRATEGY: JsonSchema = {\n type: \"object\",\n description:\n \"How detected values are replaced. Defaults to the preset's strategy, or to redaction.\",\n properties: {\n strategy: {\n type: \"string\",\n enum: [\"redact\", \"mask\", \"pseudonymize\", \"generalize\", \"synthesize\"],\n },\n label: {\n type: \"string\",\n description: \"redact: the replacement label.\",\n minLength: 1,\n maxLength: 64,\n },\n maskChar: {\n type: \"string\",\n description: \"mask: the masking character.\",\n minLength: 1,\n maxLength: 1,\n },\n keepLeading: {\n type: \"integer\",\n description: \"mask: leading characters left visible.\",\n minimum: 0,\n },\n keepTrailing: {\n type: \"integer\",\n description: \"mask: trailing characters left visible.\",\n minimum: 0,\n },\n bucketSize: {\n type: \"integer\",\n description: \"generalize: width of the numeric range.\",\n minimum: 1,\n },\n },\n required: [\"strategy\"],\n additionalProperties: false,\n};\n\nconst DETECT: McpTool = {\n name: \"anonyma_detect\",\n title: \"Detect personal data\",\n description:\n \"Find personal data (email addresses, phone numbers, government identifiers, payment cards, IP addresses and more) \" +\n \"in a text. Returns the position, category and confidence of every detection, never the detected text itself. \" +\n \"Use it to decide whether text is safe to store, log or send elsewhere.\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: TEXT,\n categories: CATEGORIES,\n preset: PRESET,\n minConfidence: MIN_CONFIDENCE,\n },\n required: [\"text\"],\n additionalProperties: false,\n },\n outputSchema: {\n type: \"object\",\n properties: {\n found: { type: \"boolean\" },\n count: { type: \"integer\", minimum: 0 },\n spans: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n start: { type: \"integer\", minimum: 0 },\n end: { type: \"integer\", minimum: 0 },\n category: { type: \"string\" },\n confidence: { type: \"number\", minimum: 0, maximum: 1 },\n detector: { type: \"string\" },\n },\n required: [\"start\", \"end\", \"category\", \"confidence\", \"detector\"],\n additionalProperties: false,\n },\n },\n },\n required: [\"found\", \"count\", \"spans\"],\n additionalProperties: false,\n },\n annotations: PURE,\n};\n\nconst ANONYMIZE: McpTool = {\n name: \"anonyma_anonymize\",\n title: \"Anonymize text or JSON\",\n description:\n \"Replace personal data in a text, or in every string of a JSON value, irreversibly. The structure of JSON \" +\n \"(keys, nesting, array lengths, non-string values) is preserved. Provide exactly one of `text` and `json`. \" +\n \"Use it before writing data to logs, tickets, prompts or files.\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: TEXT,\n json: {\n description:\n \"A JSON object or array. Its string values, its keys and its integers of 12 or more digits are anonymized.\",\n },\n preset: PRESET,\n categories: CATEGORIES,\n strategy: STRATEGY,\n minConfidence: MIN_CONFIDENCE,\n },\n additionalProperties: false,\n },\n outputSchema: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"The anonymized text, when `text` was given.\" },\n json: { description: \"The anonymized JSON value, when `json` was given.\" },\n replaced: { type: \"integer\", minimum: 0 },\n fields: FIELDS,\n },\n required: [\"replaced\", \"fields\"],\n additionalProperties: false,\n },\n annotations: PURE,\n};\n\nconst TOKENIZE: McpTool = {\n name: \"anonyma_tokenize\",\n title: \"Replace personal data with tokens\",\n description:\n \"Replace personal data in a text with placeholder tokens such as [EMAIL_0001]. Equal values get equal tokens \" +\n \"within a session, so the text stays meaningful. The original values stay on the server. Pass the returned \" +\n \"`session` to later calls to keep using the same tokens.\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: TEXT,\n session: {\n type: \"string\",\n description: \"Session returned by an earlier call.\",\n minLength: 8,\n maxLength: 64,\n },\n categories: CATEGORIES,\n preset: PRESET,\n minConfidence: MIN_CONFIDENCE,\n },\n required: [\"text\"],\n additionalProperties: false,\n },\n outputSchema: {\n type: \"object\",\n properties: {\n text: { type: \"string\" },\n session: { type: \"string\" },\n replaced: { type: \"integer\", minimum: 0 },\n fields: FIELDS,\n },\n required: [\"text\", \"session\", \"replaced\", \"fields\"],\n additionalProperties: false,\n },\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n};\n\nconst DETOKENIZE: McpTool = {\n name: \"anonyma_detokenize\",\n title: \"Restore tokens to original values\",\n description:\n \"Replace the tokens of a session with the original values. This reveals personal data to the caller and is \" +\n \"only available when the server operator has enabled it.\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: TEXT,\n session: {\n type: \"string\",\n description: \"Session returned by anonyma_tokenize.\",\n minLength: 8,\n maxLength: 64,\n },\n },\n required: [\"text\", \"session\"],\n additionalProperties: false,\n },\n outputSchema: {\n type: \"object\",\n properties: {\n text: { type: \"string\" },\n restored: { type: \"integer\", minimum: 0 },\n unresolved: { type: \"array\", items: { type: \"string\" } },\n },\n required: [\"text\", \"restored\", \"unresolved\"],\n additionalProperties: false,\n },\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n};\n\nconst CHECK_POLICY: McpTool = {\n name: \"anonyma_check_policy\",\n title: \"Check an anonymization policy\",\n description:\n \"Validate an anonyma policy document and check it against the regulations it extends (GDPR, LGPD, PIPEDA, \" +\n \"CCPA, HIPAA, PCI DSS). Returns every problem with a JSON Pointer and, for compliance problems, the provision \" +\n \"that is violated.\",\n inputSchema: {\n type: \"object\",\n properties: { policy: { type: \"object\", description: \"The policy document.\" } },\n required: [\"policy\"],\n additionalProperties: false,\n },\n outputSchema: {\n type: \"object\",\n properties: {\n valid: { type: \"boolean\" },\n issues: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n severity: { type: \"string\", enum: [\"error\", \"warning\"] },\n path: { type: \"string\" },\n code: { type: \"string\" },\n message: { type: \"string\" },\n citation: { type: \"string\" },\n },\n required: [\"severity\", \"path\", \"code\", \"message\"],\n additionalProperties: false,\n },\n },\n },\n required: [\"valid\", \"issues\"],\n additionalProperties: false,\n },\n annotations: PURE,\n};\n\n/**\n * Every tool declaration. `anonyma_detokenize` is only served when the server\n * operator enables it.\n *\n * @example\n * ```ts\n * import { MCP_TOOLS } from \"anonyma/mcp\";\n *\n * for (const tool of MCP_TOOLS) console.log(tool.name, JSON.stringify(tool.inputSchema));\n * ```\n */\nexport const MCP_TOOLS: readonly McpTool[] = Object.freeze([\n DETECT,\n ANONYMIZE,\n TOKENIZE,\n DETOKENIZE,\n CHECK_POLICY,\n]);\n\n/**\n * Every static resource declaration.\n *\n * @example\n * ```ts\n * import { MCP_RESOURCES } from \"anonyma/mcp\";\n *\n * MCP_RESOURCES.map((resource) => resource.uri);\n * // [\"anonyma://categories\", \"anonyma://strategies\", \"anonyma://presets\", \"anonyma://audit/head\"]\n * ```\n */\nexport const MCP_RESOURCES: readonly McpResource[] = Object.freeze([\n {\n uri: \"anonyma://categories\",\n name: \"categories\",\n title: \"Detectable categories\",\n description: \"The categories of personal data the server can detect.\",\n mimeType: \"application/json\",\n },\n {\n uri: \"anonyma://strategies\",\n name: \"strategies\",\n title: \"Anonymization strategies\",\n description: \"The strategies a tool call may request, and what each does to a value.\",\n mimeType: \"application/json\",\n },\n {\n uri: \"anonyma://presets\",\n name: \"presets\",\n title: \"Compliance presets\",\n description: \"The compliance presets with their categories and strategies.\",\n mimeType: \"application/json\",\n },\n {\n uri: \"anonyma://audit/head\",\n name: \"audit-head\",\n title: \"Audit chain head\",\n description: \"Sequence number and hash of the most recent audit record of this server.\",\n mimeType: \"application/json\",\n },\n]);\n\n/**\n * Every resource template declaration.\n *\n * @example\n * ```ts\n * import { MCP_RESOURCE_TEMPLATES } from \"anonyma/mcp\";\n *\n * MCP_RESOURCE_TEMPLATES[0]?.uriTemplate; // \"anonyma://regulations/{id}\"\n * ```\n */\nexport const MCP_RESOURCE_TEMPLATES: readonly McpResourceTemplate[] = Object.freeze([\n {\n uriTemplate: \"anonyma://regulations/{id}\",\n name: \"regulation\",\n title: \"Regulation profile\",\n description:\n \"For one regulation (gdpr, lgpd, pipeda, ccpa, hipaa, pci-dss): the categories in scope with the provisions \" +\n \"that bring them into scope, the protection required, and the data elements that cannot be detected.\",\n mimeType: \"application/json\",\n },\n]);\n","/**\n * @module mcp/schema\n * @description A validator for the subset of JSON Schema that the tool\n * declarations use, so that tool arguments are checked against exactly the\n * schema that is advertised to clients.\n * @internal\n */\n\nimport type { JsonSchema } from \"./definitions.js\";\n\nfunction typeOf(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n if (typeof value === \"number\") return Number.isInteger(value) ? \"integer\" : \"number\";\n return typeof value;\n}\n\n/**\n * Validate `value` against `schema`.\n *\n * @returns One message per violation, each prefixed with a JSON Pointer; empty when valid.\n * @internal\n */\nexport function validate(schema: JsonSchema, value: unknown, path = \"\"): string[] {\n const errors: string[] = [];\n const at = path === \"\" ? \"/\" : path;\n const actual = typeOf(value);\n\n if (\n schema.type !== undefined &&\n actual !== schema.type &&\n !(schema.type === \"number\" && actual === \"integer\")\n ) {\n return [`${at}: expected ${schema.type}, got ${actual}`];\n }\n if (schema.enum !== undefined && !(typeof value === \"string\" && schema.enum.includes(value))) {\n errors.push(`${at}: must be one of ${schema.enum.join(\", \")}`);\n }\n if (typeof value === \"string\") {\n if (schema.minLength !== undefined && value.length < schema.minLength) {\n errors.push(`${at}: must have at least ${String(schema.minLength)} characters`);\n }\n if (schema.maxLength !== undefined && value.length > schema.maxLength) {\n errors.push(`${at}: must have at most ${String(schema.maxLength)} characters`);\n }\n }\n if (typeof value === \"number\") {\n if (schema.minimum !== undefined && value < schema.minimum) {\n errors.push(`${at}: must be at least ${String(schema.minimum)}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n errors.push(`${at}: must be at most ${String(schema.maximum)}`);\n }\n }\n if (Array.isArray(value)) {\n if (schema.minItems !== undefined && value.length < schema.minItems) {\n errors.push(`${at}: must have at least ${String(schema.minItems)} item(s)`);\n }\n if (schema.maxItems !== undefined && value.length > schema.maxItems) {\n // The items of an oversized array are not looked at: one message, not one per item.\n return [...errors, `${at}: must have at most ${String(schema.maxItems)} items`];\n }\n if (schema.items !== undefined) {\n for (const [index, item] of (value as unknown[]).entries()) {\n errors.push(...validate(schema.items, item, `${path}/${String(index)}`));\n }\n }\n }\n if (actual === \"object\" && schema.type === \"object\") {\n const record = value as Record<string, unknown>;\n const properties = schema.properties ?? {};\n for (const name of schema.required ?? []) {\n if (!Object.hasOwn(record, name)) errors.push(`${path}/${name}: is required`);\n }\n for (const [name, member] of Object.entries(record)) {\n const propertySchema = Object.hasOwn(properties, name) ? properties[name] : undefined;\n if (propertySchema !== undefined) {\n errors.push(...validate(propertySchema, member, `${path}/${name}`));\n } else if (schema.additionalProperties === false) {\n errors.push(`${path}/${name}: is not a known parameter`);\n }\n }\n }\n return errors;\n}\n","/**\n * @module mcp/server\n * @description A dependency-free Model Context Protocol server for anonyma.\n * It is transport-agnostic: {@link McpServer.handle} takes one JSON-RPC\n * message and returns the response, and {@link serveStdio} connects it to a\n * newline-delimited stream such as standard input and output.\n *\n * Privacy properties\n * - Original values behind tokens are kept in server memory, per session, and\n * are never part of a tool result unless the operator enables\n * `anonyma_detokenize`.\n * - `anonyma_detect` reports positions and categories, not the detected text.\n * - Strategies that need key material are not selectable by the model.\n * - With an audit logger, every tool call is recorded without its content.\n */\n\nimport { AnonymaError } from \"../errors.js\";\nimport { sanitizeJson } from \"../ai/json.js\";\nimport { summarizeSpans } from \"../audit/fields.js\";\nimport type { AuditLogger, AuditOperation } from \"../audit/types.js\";\nimport { REGULATIONS, isRegulationId } from \"../compliance/regulations.js\";\nimport { checkPolicy } from \"../compliance/policy.js\";\nimport { BUILTIN_CATEGORIES } from \"../engine/builtin.js\";\nimport { compilePipeline } from \"../engine/compile.js\";\nimport type { PipelineSpec, StrategySpec } from \"../engine/types.js\";\nimport { toHex } from \"../internal/encoding.js\";\nimport { webCrypto } from \"../internal/webcrypto.js\";\nimport { PRESET_REGISTRY } from \"../presets.js\";\nimport { createSessionTokenizer } from \"../vault/session.js\";\nimport type { SessionTokenizer } from \"../vault/session.js\";\nimport {\n MCP_PROTOCOL_VERSIONS,\n MCP_RESOURCES,\n MCP_RESOURCE_TEMPLATES,\n MCP_TOOLS,\n} from \"./definitions.js\";\nimport type { McpTool } from \"./definitions.js\";\nimport { validate } from \"./schema.js\";\n\n/** JSON-RPC 2.0 error codes used by the server. */\nconst PARSE_ERROR = -32700;\nconst INVALID_REQUEST = -32600;\nconst METHOD_NOT_FOUND = -32601;\nconst INVALID_PARAMS = -32602;\nconst INTERNAL_ERROR = -32603;\nconst RESOURCE_NOT_FOUND = -32002;\n\n/**\n * A JSON-RPC 2.0 response.\n */\nexport type JsonRpcResponse =\n | { readonly jsonrpc: \"2.0\"; readonly id: string | number | null; readonly result: unknown }\n | {\n readonly jsonrpc: \"2.0\";\n readonly id: string | number | null;\n readonly error: { readonly code: number; readonly message: string };\n };\n\n/**\n * Options accepted by {@link createMcpServer}.\n */\nexport interface McpServerOptions {\n /**\n * Serve `anonyma_detokenize`, which returns original values to the caller.\n * Defaults to `false`: tokens can then only be resolved outside the model's reach.\n */\n readonly allowDetokenize?: boolean;\n /** Records every tool call, without content. */\n readonly audit?: AuditLogger;\n /** Largest number of tokenization sessions kept; the least recently used is dropped. Defaults to `256`. */\n readonly maxSessions?: number;\n /**\n * Largest `json` argument of `anonyma_anonymize`, in characters of its\n * serialised form. Defaults to 1,000,000, the limit of the `text` argument.\n */\n readonly maxJsonLength?: number;\n /** Name and version reported to clients. */\n readonly serverInfo?: { readonly name: string; readonly version: string };\n}\n\n/**\n * A Model Context Protocol server.\n */\nexport interface McpServer {\n /**\n * Handle one JSON-RPC message.\n *\n * @param message - The parsed message, or an array of messages (a batch).\n * @returns The response, one response per request of a batch, or `undefined`\n * when nothing has to be answered.\n */\n readonly handle: (\n message: unknown,\n ) => Promise<JsonRpcResponse | readonly JsonRpcResponse[] | undefined>;\n /**\n * Handle one line of a newline-delimited transport.\n *\n * @param line - One JSON-RPC message as JSON text.\n * @returns The response as JSON text without a line break, or `undefined` for a notification.\n */\n readonly handleLine: (line: string) => Promise<string | undefined>;\n}\n\ntype Args = Record<string, unknown>;\ninterface ToolOutcome {\n readonly structured: Record<string, unknown>;\n readonly operation: AuditOperation;\n readonly fields: ReturnType<typeof summarizeSpans>;\n}\n\n/** How many problems an \"Invalid arguments\" message lists. */\nconst MAX_PROBLEMS = 10;\n\nconst invalidRequest: JsonRpcResponse = Object.freeze({\n jsonrpc: \"2.0\",\n id: null,\n error: Object.freeze({ code: INVALID_REQUEST, message: \"Invalid request.\" }),\n});\n\nclass RpcError extends Error {\n public constructor(\n public readonly code: number,\n message: string,\n ) {\n super(message);\n }\n}\n\nconst STRATEGY_NOTES: Readonly<Record<string, string>> = {\n redact: \"Replaces the value with a label. Nothing of the value remains.\",\n mask: \"Replaces characters with a mask character; keepLeading/keepTrailing leave characters visible.\",\n pseudonymize: \"Replaces the value with a random identifier.\",\n generalize: \"Replaces a number with a range; other values are redacted.\",\n synthesize: \"Replaces the value with a made-up value of the same kind.\",\n};\n\n/**\n * Create an MCP server.\n *\n * @param options - Server options.\n * @returns The {@link McpServer}.\n *\n * @example\n * ```ts\n * // anonyma-mcp.mjs — register with: claude mcp add anonyma -- node anonyma-mcp.mjs\n * import { createMcpServer, serveStdio } from \"anonyma/mcp\";\n *\n * await serveStdio(createMcpServer(), {\n * input: process.stdin,\n * write: (line) => void process.stdout.write(line),\n * });\n * ```\n */\nexport function createMcpServer(options: McpServerOptions = {}): McpServer {\n const { allowDetokenize = false, audit, maxSessions = 256, maxJsonLength = 1_000_000 } = options;\n const serverInfo = options.serverInfo ?? { name: \"anonyma\", version: \"1.1.0\" };\n const tools = MCP_TOOLS.filter((tool) => allowDetokenize || tool.name !== \"anonyma_detokenize\");\n const sessions = new Map<string, SessionTokenizer>();\n\n /**\n * Build the pipeline spec of a call. An explicit strategy applies to every\n * category, so it replaces the per-category rules of a preset.\n */\n function specOf(args: Args, forced?: StrategySpec): PipelineSpec {\n const preset = args[\"preset\"] as NonNullable<PipelineSpec[\"preset\"]> | undefined;\n const strategy = forced ?? (args[\"strategy\"] as StrategySpec | undefined);\n const categories =\n (args[\"categories\"] as PipelineSpec[\"categories\"]) ??\n (strategy !== undefined && preset !== undefined\n ? PRESET_REGISTRY[preset].categories\n : undefined);\n return {\n ...(strategy === undefined && preset !== undefined ? { preset } : {}),\n ...(categories !== undefined ? { categories } : {}),\n ...(args[\"minConfidence\"] !== undefined\n ? { minConfidence: args[\"minConfidence\"] as number }\n : {}),\n ...(strategy !== undefined ? { defaultStrategy: strategy } : {}),\n };\n }\n\n async function sessionFor(id: unknown): Promise<{ id: string; session: SessionTokenizer }> {\n if (typeof id === \"string\") {\n const existing = sessions.get(id);\n if (existing === undefined)\n throw new AnonymaError(\"Unknown or expired session.\", \"MCP_UNKNOWN_SESSION\");\n // Re-insert so that the map's order reflects recent use.\n sessions.delete(id);\n sessions.set(id, existing);\n return { id, session: existing };\n }\n const crypto = await webCrypto();\n const fresh = toHex(crypto.getRandomValues(new Uint8Array(16)));\n // A random tag in every token: text that merely looks like a token is never\n // replaced by a stored value when the session is detokenized.\n const tag = toHex(crypto.getRandomValues(new Uint8Array(4)));\n const session = createSessionTokenizer({ tag });\n sessions.set(fresh, session);\n while (sessions.size > maxSessions) {\n const oldest = sessions.keys().next();\n /* v8 ignore next -- the map is not empty here */\n if (oldest.done === true) break;\n sessions.delete(oldest.value);\n }\n return { id: fresh, session };\n }\n\n async function runTool(tool: McpTool, args: Args): Promise<ToolOutcome> {\n switch (tool.name) {\n case \"anonyma_detect\": {\n const pipeline = compilePipeline(specOf(args));\n const spans = pipeline.scan(args[\"text\"] as string);\n return {\n structured: {\n found: spans.length > 0,\n count: spans.length,\n spans: spans.map(({ start, end, category, confidence, detector }) => ({\n start,\n end,\n category,\n confidence,\n detector,\n })),\n },\n operation: \"detect\",\n fields: summarizeSpans(spans, { rule: \"detect\" }),\n };\n }\n case \"anonyma_anonymize\": {\n const hasText = typeof args[\"text\"] === \"string\";\n const json = args[\"json\"];\n if (hasText === (json !== undefined)) {\n throw new AnonymaError(\n \"Provide exactly one of `text` and `json`.\",\n \"MCP_INVALID_ARGUMENTS\",\n );\n }\n const spec = specOf(args);\n const pipeline = compilePipeline(spec);\n const rule = (spec.defaultStrategy ?? { strategy: spec.preset ?? \"redact\" }).strategy;\n if (hasText) {\n const result = pipeline.transform(args[\"text\"] as string);\n const fields = summarizeSpans(result.spans, { rule });\n return {\n structured: { text: result.text, replaced: result.spans.length, fields },\n operation: \"anonymize\",\n fields,\n };\n }\n if (typeof json !== \"object\" || json === null) {\n throw new AnonymaError(\"`json` must be an object or an array.\", \"MCP_INVALID_ARGUMENTS\");\n }\n if (JSON.stringify(json).length > maxJsonLength) {\n throw new AnonymaError(\n `\\`json\\` is larger than ${String(maxJsonLength)} characters.`,\n \"MCP_INVALID_ARGUMENTS\",\n );\n }\n const result = sanitizeJson(json, { pipeline, ruleName: () => rule });\n return {\n structured: { json: result.value, replaced: result.replaced, fields: result.fields },\n operation: \"anonymize\",\n fields: [...result.fields],\n };\n }\n case \"anonyma_tokenize\": {\n const { id, session } = await sessionFor(args[\"session\"]);\n const pipeline = compilePipeline(specOf(args, { strategy: \"tokenize\" }), {\n tokenization: session,\n });\n const result = pipeline.transform(args[\"text\"] as string);\n const fields = summarizeSpans(result.spans, { rule: \"tokenize\" });\n return {\n structured: { text: result.text, session: id, replaced: result.spans.length, fields },\n operation: \"tokenize\",\n fields,\n };\n }\n case \"anonyma_detokenize\": {\n const { session } = await sessionFor(args[\"session\"]);\n const result = session.restore(args[\"text\"] as string);\n return {\n structured: {\n text: result.text,\n restored: result.restored,\n unresolved: [...result.unresolved],\n },\n operation: \"detokenize\",\n fields: [],\n };\n }\n default: {\n const { policy, issues } = checkPolicy(args[\"policy\"]);\n return {\n structured: {\n valid: policy !== undefined,\n issues: issues.map(({ severity, path, code, message, reference }) => ({\n severity,\n path,\n code,\n message,\n ...(reference !== undefined ? { citation: reference.citation } : {}),\n })),\n },\n operation: \"policy-load\",\n fields: [],\n };\n }\n }\n }\n\n async function callTool(params: unknown): Promise<unknown> {\n const { name, arguments: args = {} } = (params ?? {}) as {\n name?: unknown;\n arguments?: unknown;\n };\n const tool = tools.find((candidate) => candidate.name === name);\n if (tool === undefined) throw new RpcError(INVALID_PARAMS, \"Unknown tool.\");\n\n const problems = validate(tool.inputSchema, args);\n if (problems.length > 0) {\n const shown = problems.slice(0, MAX_PROBLEMS).join(\"; \");\n const more = problems.length - MAX_PROBLEMS;\n return {\n content: [\n {\n type: \"text\",\n text: `Invalid arguments: ${shown}${more > 0 ? `; and ${String(more)} more` : \"\"}`,\n },\n ],\n isError: true,\n };\n }\n try {\n const outcome = await runTool(tool, args as Args);\n if (audit !== undefined) {\n await audit.record({\n operation: outcome.operation,\n actor: \"mcp\",\n source: tool.name,\n fields: outcome.fields,\n });\n }\n return {\n content: [{ type: \"text\", text: JSON.stringify(outcome.structured) }],\n structuredContent: outcome.structured,\n };\n } catch (error) {\n if (!(error instanceof AnonymaError)) throw error;\n return { content: [{ type: \"text\", text: error.message }], isError: true };\n }\n }\n\n function readResource(params: unknown): unknown {\n const uri = (params as { uri?: unknown } | null | undefined)?.uri;\n const json = (value: unknown): unknown => ({\n contents: [{ uri, mimeType: \"application/json\", text: JSON.stringify(value) }],\n });\n if (uri === \"anonyma://categories\") return json({ categories: BUILTIN_CATEGORIES });\n if (uri === \"anonyma://strategies\") return json({ strategies: STRATEGY_NOTES });\n if (uri === \"anonyma://presets\") {\n return json({\n presets: Object.values(PRESET_REGISTRY).map(\n ({ name, description, categories, defaultStrategy, rules }) => ({\n name,\n description,\n categories,\n defaultStrategy,\n rules: rules ?? [],\n }),\n ),\n });\n }\n if (uri === \"anonyma://audit/head\")\n return json(audit === undefined ? { enabled: false } : { enabled: true, ...audit.head() });\n if (typeof uri === \"string\" && uri.startsWith(\"anonyma://regulations/\")) {\n const id = uri.slice(\"anonyma://regulations/\".length);\n if (isRegulationId(id)) return json(REGULATIONS[id]);\n }\n throw new RpcError(RESOURCE_NOT_FOUND, \"Resource not found.\");\n }\n\n async function dispatch(method: string, params: unknown): Promise<unknown> {\n switch (method) {\n case \"initialize\": {\n const requested = (params as { protocolVersion?: unknown } | null | undefined)\n ?.protocolVersion;\n return {\n protocolVersion:\n typeof requested === \"string\" && MCP_PROTOCOL_VERSIONS.includes(requested)\n ? requested\n : MCP_PROTOCOL_VERSIONS[0],\n capabilities: {\n tools: { listChanged: false },\n resources: { subscribe: false, listChanged: false },\n },\n serverInfo: { name: serverInfo.name, title: \"anonyma\", version: serverInfo.version },\n instructions:\n \"Use anonyma_anonymize before writing text or JSON that may contain personal data to logs, files, \" +\n \"tickets or other tools. Use anonyma_tokenize when the data must stay meaningful for further work.\",\n };\n }\n case \"ping\":\n return {};\n case \"tools/list\":\n return { tools };\n case \"tools/call\":\n return callTool(params);\n case \"resources/list\":\n return { resources: MCP_RESOURCES };\n case \"resources/templates/list\":\n return { resourceTemplates: MCP_RESOURCE_TEMPLATES };\n case \"resources/read\":\n return readResource(params);\n default:\n throw new RpcError(METHOD_NOT_FOUND, \"Method not found.\");\n }\n }\n\n async function handle(\n message: unknown,\n ): Promise<JsonRpcResponse | JsonRpcResponse[] | undefined> {\n if (Array.isArray(message)) {\n // A JSON-RPC batch, which protocol revisions before 2025-06-18 allow.\n if (message.length === 0) return invalidRequest;\n const responses: JsonRpcResponse[] = [];\n for (const entry of message as unknown[]) {\n const response = await handleOne(entry);\n if (response !== undefined) responses.push(response);\n }\n return responses.length > 0 ? responses : undefined;\n }\n return handleOne(message);\n }\n\n async function handleOne(message: unknown): Promise<JsonRpcResponse | undefined> {\n if (typeof message !== \"object\" || message === null || Array.isArray(message)) {\n return invalidRequest;\n }\n const { jsonrpc, id, method, params } = message as Record<string, unknown>;\n const isNotification = id === undefined;\n // An id such as 1e999 parses to Infinity, which cannot be sent back.\n const responseId =\n typeof id === \"string\" || (typeof id === \"number\" && Number.isFinite(id)) ? id : null;\n if (\n jsonrpc !== \"2.0\" ||\n typeof method !== \"string\" ||\n (!isNotification && responseId === null)\n ) {\n // A response sent by the client, or a malformed message.\n if (method === undefined && (message as Record<string, unknown>)[\"jsonrpc\"] === \"2.0\")\n return undefined;\n return {\n jsonrpc: \"2.0\",\n id: responseId,\n error: { code: INVALID_REQUEST, message: \"Invalid request.\" },\n };\n }\n if (isNotification) return undefined;\n\n try {\n return { jsonrpc: \"2.0\", id: responseId, result: await dispatch(method, params) };\n } catch (error) {\n const known = error instanceof RpcError;\n return {\n jsonrpc: \"2.0\",\n id: responseId,\n error: {\n code: known ? error.code : INTERNAL_ERROR,\n message: known ? error.message : \"Internal error.\",\n },\n };\n }\n }\n\n async function handleLine(line: string): Promise<string | undefined> {\n let message: unknown;\n try {\n message = JSON.parse(line);\n } catch {\n return JSON.stringify({\n jsonrpc: \"2.0\",\n id: null,\n error: { code: PARSE_ERROR, message: \"Parse error.\" },\n });\n }\n const response = await handle(message);\n return response === undefined ? undefined : JSON.stringify(response);\n }\n\n return Object.freeze({ handle, handleLine });\n}\n\n/**\n * Serve an MCP server over a newline-delimited JSON transport, such as\n * standard input and output. Resolves when the input ends.\n *\n * @param server - The server.\n * @param io - `input` yields text or bytes in arbitrary chunks; `write`\n * receives each response as one line including its line feed.\n *\n * @example\n * ```ts\n * await serveStdio(createMcpServer(), {\n * input: process.stdin,\n * write: (line) => void process.stdout.write(line),\n * });\n * ```\n */\nexport async function serveStdio(\n server: McpServer,\n io: {\n readonly input: AsyncIterable<string | Uint8Array>;\n readonly write: (line: string) => void | Promise<void>;\n },\n): Promise<void> {\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n async function consume(line: string): Promise<void> {\n if (line.trim() === \"\") return;\n const response = await server.handleLine(line);\n if (response !== undefined) await io.write(`${response}\\n`);\n }\n\n for await (const chunk of io.input) {\n buffer += typeof chunk === \"string\" ? chunk : decoder.decode(chunk, { stream: true });\n let newline = buffer.indexOf(\"\\n\");\n while (newline >= 0) {\n await consume(buffer.slice(0, newline));\n buffer = buffer.slice(newline + 1);\n newline = buffer.indexOf(\"\\n\");\n }\n }\n await consume(buffer + decoder.decode());\n}\n"]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { a as AuditLogger } from '../types-Zt_bZvwS.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module mcp/definitions
|
|
5
|
+
* @description Model Context Protocol declarations for anonyma: the tools,
|
|
6
|
+
* resources and resource templates a server exposes, with JSON Schema
|
|
7
|
+
* (draft 2020-12) for every tool input and output. The declarations are plain
|
|
8
|
+
* data, so they can also be registered with any MCP server framework.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The subset of JSON Schema used by the declarations.
|
|
12
|
+
*/
|
|
13
|
+
interface JsonSchema {
|
|
14
|
+
readonly type?: "object" | "array" | "string" | "number" | "integer" | "boolean";
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
17
|
+
readonly required?: readonly string[];
|
|
18
|
+
readonly additionalProperties?: boolean;
|
|
19
|
+
readonly items?: JsonSchema;
|
|
20
|
+
readonly enum?: readonly string[];
|
|
21
|
+
readonly minimum?: number;
|
|
22
|
+
readonly maximum?: number;
|
|
23
|
+
readonly minLength?: number;
|
|
24
|
+
readonly maxLength?: number;
|
|
25
|
+
readonly minItems?: number;
|
|
26
|
+
readonly maxItems?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An MCP tool declaration.
|
|
30
|
+
*/
|
|
31
|
+
interface McpTool {
|
|
32
|
+
/** Unique tool name. */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Human-readable name. */
|
|
35
|
+
readonly title: string;
|
|
36
|
+
/** What the tool does, written for a model. */
|
|
37
|
+
readonly description: string;
|
|
38
|
+
/** JSON Schema of the `arguments` object. */
|
|
39
|
+
readonly inputSchema: JsonSchema & {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
};
|
|
42
|
+
/** JSON Schema of `structuredContent` in the result. */
|
|
43
|
+
readonly outputSchema: JsonSchema & {
|
|
44
|
+
readonly type: "object";
|
|
45
|
+
};
|
|
46
|
+
/** Behaviour hints for clients. */
|
|
47
|
+
readonly annotations: {
|
|
48
|
+
readonly readOnlyHint: boolean;
|
|
49
|
+
readonly destructiveHint: boolean;
|
|
50
|
+
readonly idempotentHint: boolean;
|
|
51
|
+
readonly openWorldHint: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* An MCP resource declaration.
|
|
56
|
+
*/
|
|
57
|
+
interface McpResource {
|
|
58
|
+
readonly uri: string;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly title: string;
|
|
61
|
+
readonly description: string;
|
|
62
|
+
readonly mimeType: "application/json";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* An MCP resource template declaration.
|
|
66
|
+
*/
|
|
67
|
+
interface McpResourceTemplate {
|
|
68
|
+
readonly uriTemplate: string;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly title: string;
|
|
71
|
+
readonly description: string;
|
|
72
|
+
readonly mimeType: "application/json";
|
|
73
|
+
}
|
|
74
|
+
/** Protocol revisions the server implements, newest first. */
|
|
75
|
+
declare const MCP_PROTOCOL_VERSIONS: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Every tool declaration. `anonyma_detokenize` is only served when the server
|
|
78
|
+
* operator enables it.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { MCP_TOOLS } from "anonyma/mcp";
|
|
83
|
+
*
|
|
84
|
+
* for (const tool of MCP_TOOLS) console.log(tool.name, JSON.stringify(tool.inputSchema));
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare const MCP_TOOLS: readonly McpTool[];
|
|
88
|
+
/**
|
|
89
|
+
* Every static resource declaration.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { MCP_RESOURCES } from "anonyma/mcp";
|
|
94
|
+
*
|
|
95
|
+
* MCP_RESOURCES.map((resource) => resource.uri);
|
|
96
|
+
* // ["anonyma://categories", "anonyma://strategies", "anonyma://presets", "anonyma://audit/head"]
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare const MCP_RESOURCES: readonly McpResource[];
|
|
100
|
+
/**
|
|
101
|
+
* Every resource template declaration.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { MCP_RESOURCE_TEMPLATES } from "anonyma/mcp";
|
|
106
|
+
*
|
|
107
|
+
* MCP_RESOURCE_TEMPLATES[0]?.uriTemplate; // "anonyma://regulations/{id}"
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare const MCP_RESOURCE_TEMPLATES: readonly McpResourceTemplate[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @module mcp/server
|
|
114
|
+
* @description A dependency-free Model Context Protocol server for anonyma.
|
|
115
|
+
* It is transport-agnostic: {@link McpServer.handle} takes one JSON-RPC
|
|
116
|
+
* message and returns the response, and {@link serveStdio} connects it to a
|
|
117
|
+
* newline-delimited stream such as standard input and output.
|
|
118
|
+
*
|
|
119
|
+
* Privacy properties
|
|
120
|
+
* - Original values behind tokens are kept in server memory, per session, and
|
|
121
|
+
* are never part of a tool result unless the operator enables
|
|
122
|
+
* `anonyma_detokenize`.
|
|
123
|
+
* - `anonyma_detect` reports positions and categories, not the detected text.
|
|
124
|
+
* - Strategies that need key material are not selectable by the model.
|
|
125
|
+
* - With an audit logger, every tool call is recorded without its content.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A JSON-RPC 2.0 response.
|
|
130
|
+
*/
|
|
131
|
+
type JsonRpcResponse = {
|
|
132
|
+
readonly jsonrpc: "2.0";
|
|
133
|
+
readonly id: string | number | null;
|
|
134
|
+
readonly result: unknown;
|
|
135
|
+
} | {
|
|
136
|
+
readonly jsonrpc: "2.0";
|
|
137
|
+
readonly id: string | number | null;
|
|
138
|
+
readonly error: {
|
|
139
|
+
readonly code: number;
|
|
140
|
+
readonly message: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Options accepted by {@link createMcpServer}.
|
|
145
|
+
*/
|
|
146
|
+
interface McpServerOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Serve `anonyma_detokenize`, which returns original values to the caller.
|
|
149
|
+
* Defaults to `false`: tokens can then only be resolved outside the model's reach.
|
|
150
|
+
*/
|
|
151
|
+
readonly allowDetokenize?: boolean;
|
|
152
|
+
/** Records every tool call, without content. */
|
|
153
|
+
readonly audit?: AuditLogger;
|
|
154
|
+
/** Largest number of tokenization sessions kept; the least recently used is dropped. Defaults to `256`. */
|
|
155
|
+
readonly maxSessions?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Largest `json` argument of `anonyma_anonymize`, in characters of its
|
|
158
|
+
* serialised form. Defaults to 1,000,000, the limit of the `text` argument.
|
|
159
|
+
*/
|
|
160
|
+
readonly maxJsonLength?: number;
|
|
161
|
+
/** Name and version reported to clients. */
|
|
162
|
+
readonly serverInfo?: {
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly version: string;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A Model Context Protocol server.
|
|
169
|
+
*/
|
|
170
|
+
interface McpServer {
|
|
171
|
+
/**
|
|
172
|
+
* Handle one JSON-RPC message.
|
|
173
|
+
*
|
|
174
|
+
* @param message - The parsed message, or an array of messages (a batch).
|
|
175
|
+
* @returns The response, one response per request of a batch, or `undefined`
|
|
176
|
+
* when nothing has to be answered.
|
|
177
|
+
*/
|
|
178
|
+
readonly handle: (message: unknown) => Promise<JsonRpcResponse | readonly JsonRpcResponse[] | undefined>;
|
|
179
|
+
/**
|
|
180
|
+
* Handle one line of a newline-delimited transport.
|
|
181
|
+
*
|
|
182
|
+
* @param line - One JSON-RPC message as JSON text.
|
|
183
|
+
* @returns The response as JSON text without a line break, or `undefined` for a notification.
|
|
184
|
+
*/
|
|
185
|
+
readonly handleLine: (line: string) => Promise<string | undefined>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create an MCP server.
|
|
189
|
+
*
|
|
190
|
+
* @param options - Server options.
|
|
191
|
+
* @returns The {@link McpServer}.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* // anonyma-mcp.mjs — register with: claude mcp add anonyma -- node anonyma-mcp.mjs
|
|
196
|
+
* import { createMcpServer, serveStdio } from "anonyma/mcp";
|
|
197
|
+
*
|
|
198
|
+
* await serveStdio(createMcpServer(), {
|
|
199
|
+
* input: process.stdin,
|
|
200
|
+
* write: (line) => void process.stdout.write(line),
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
205
|
+
/**
|
|
206
|
+
* Serve an MCP server over a newline-delimited JSON transport, such as
|
|
207
|
+
* standard input and output. Resolves when the input ends.
|
|
208
|
+
*
|
|
209
|
+
* @param server - The server.
|
|
210
|
+
* @param io - `input` yields text or bytes in arbitrary chunks; `write`
|
|
211
|
+
* receives each response as one line including its line feed.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* await serveStdio(createMcpServer(), {
|
|
216
|
+
* input: process.stdin,
|
|
217
|
+
* write: (line) => void process.stdout.write(line),
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
declare function serveStdio(server: McpServer, io: {
|
|
222
|
+
readonly input: AsyncIterable<string | Uint8Array>;
|
|
223
|
+
readonly write: (line: string) => void | Promise<void>;
|
|
224
|
+
}): Promise<void>;
|
|
225
|
+
|
|
226
|
+
export { type JsonRpcResponse, type JsonSchema, MCP_PROTOCOL_VERSIONS, MCP_RESOURCES, MCP_RESOURCE_TEMPLATES, MCP_TOOLS, type McpResource, type McpResourceTemplate, type McpServer, type McpServerOptions, type McpTool, createMcpServer, serveStdio };
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { a as AuditLogger } from '../types-Zt_bZvwS.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module mcp/definitions
|
|
5
|
+
* @description Model Context Protocol declarations for anonyma: the tools,
|
|
6
|
+
* resources and resource templates a server exposes, with JSON Schema
|
|
7
|
+
* (draft 2020-12) for every tool input and output. The declarations are plain
|
|
8
|
+
* data, so they can also be registered with any MCP server framework.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The subset of JSON Schema used by the declarations.
|
|
12
|
+
*/
|
|
13
|
+
interface JsonSchema {
|
|
14
|
+
readonly type?: "object" | "array" | "string" | "number" | "integer" | "boolean";
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
17
|
+
readonly required?: readonly string[];
|
|
18
|
+
readonly additionalProperties?: boolean;
|
|
19
|
+
readonly items?: JsonSchema;
|
|
20
|
+
readonly enum?: readonly string[];
|
|
21
|
+
readonly minimum?: number;
|
|
22
|
+
readonly maximum?: number;
|
|
23
|
+
readonly minLength?: number;
|
|
24
|
+
readonly maxLength?: number;
|
|
25
|
+
readonly minItems?: number;
|
|
26
|
+
readonly maxItems?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An MCP tool declaration.
|
|
30
|
+
*/
|
|
31
|
+
interface McpTool {
|
|
32
|
+
/** Unique tool name. */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Human-readable name. */
|
|
35
|
+
readonly title: string;
|
|
36
|
+
/** What the tool does, written for a model. */
|
|
37
|
+
readonly description: string;
|
|
38
|
+
/** JSON Schema of the `arguments` object. */
|
|
39
|
+
readonly inputSchema: JsonSchema & {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
};
|
|
42
|
+
/** JSON Schema of `structuredContent` in the result. */
|
|
43
|
+
readonly outputSchema: JsonSchema & {
|
|
44
|
+
readonly type: "object";
|
|
45
|
+
};
|
|
46
|
+
/** Behaviour hints for clients. */
|
|
47
|
+
readonly annotations: {
|
|
48
|
+
readonly readOnlyHint: boolean;
|
|
49
|
+
readonly destructiveHint: boolean;
|
|
50
|
+
readonly idempotentHint: boolean;
|
|
51
|
+
readonly openWorldHint: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* An MCP resource declaration.
|
|
56
|
+
*/
|
|
57
|
+
interface McpResource {
|
|
58
|
+
readonly uri: string;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly title: string;
|
|
61
|
+
readonly description: string;
|
|
62
|
+
readonly mimeType: "application/json";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* An MCP resource template declaration.
|
|
66
|
+
*/
|
|
67
|
+
interface McpResourceTemplate {
|
|
68
|
+
readonly uriTemplate: string;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly title: string;
|
|
71
|
+
readonly description: string;
|
|
72
|
+
readonly mimeType: "application/json";
|
|
73
|
+
}
|
|
74
|
+
/** Protocol revisions the server implements, newest first. */
|
|
75
|
+
declare const MCP_PROTOCOL_VERSIONS: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Every tool declaration. `anonyma_detokenize` is only served when the server
|
|
78
|
+
* operator enables it.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { MCP_TOOLS } from "anonyma/mcp";
|
|
83
|
+
*
|
|
84
|
+
* for (const tool of MCP_TOOLS) console.log(tool.name, JSON.stringify(tool.inputSchema));
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare const MCP_TOOLS: readonly McpTool[];
|
|
88
|
+
/**
|
|
89
|
+
* Every static resource declaration.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { MCP_RESOURCES } from "anonyma/mcp";
|
|
94
|
+
*
|
|
95
|
+
* MCP_RESOURCES.map((resource) => resource.uri);
|
|
96
|
+
* // ["anonyma://categories", "anonyma://strategies", "anonyma://presets", "anonyma://audit/head"]
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare const MCP_RESOURCES: readonly McpResource[];
|
|
100
|
+
/**
|
|
101
|
+
* Every resource template declaration.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { MCP_RESOURCE_TEMPLATES } from "anonyma/mcp";
|
|
106
|
+
*
|
|
107
|
+
* MCP_RESOURCE_TEMPLATES[0]?.uriTemplate; // "anonyma://regulations/{id}"
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare const MCP_RESOURCE_TEMPLATES: readonly McpResourceTemplate[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @module mcp/server
|
|
114
|
+
* @description A dependency-free Model Context Protocol server for anonyma.
|
|
115
|
+
* It is transport-agnostic: {@link McpServer.handle} takes one JSON-RPC
|
|
116
|
+
* message and returns the response, and {@link serveStdio} connects it to a
|
|
117
|
+
* newline-delimited stream such as standard input and output.
|
|
118
|
+
*
|
|
119
|
+
* Privacy properties
|
|
120
|
+
* - Original values behind tokens are kept in server memory, per session, and
|
|
121
|
+
* are never part of a tool result unless the operator enables
|
|
122
|
+
* `anonyma_detokenize`.
|
|
123
|
+
* - `anonyma_detect` reports positions and categories, not the detected text.
|
|
124
|
+
* - Strategies that need key material are not selectable by the model.
|
|
125
|
+
* - With an audit logger, every tool call is recorded without its content.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A JSON-RPC 2.0 response.
|
|
130
|
+
*/
|
|
131
|
+
type JsonRpcResponse = {
|
|
132
|
+
readonly jsonrpc: "2.0";
|
|
133
|
+
readonly id: string | number | null;
|
|
134
|
+
readonly result: unknown;
|
|
135
|
+
} | {
|
|
136
|
+
readonly jsonrpc: "2.0";
|
|
137
|
+
readonly id: string | number | null;
|
|
138
|
+
readonly error: {
|
|
139
|
+
readonly code: number;
|
|
140
|
+
readonly message: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Options accepted by {@link createMcpServer}.
|
|
145
|
+
*/
|
|
146
|
+
interface McpServerOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Serve `anonyma_detokenize`, which returns original values to the caller.
|
|
149
|
+
* Defaults to `false`: tokens can then only be resolved outside the model's reach.
|
|
150
|
+
*/
|
|
151
|
+
readonly allowDetokenize?: boolean;
|
|
152
|
+
/** Records every tool call, without content. */
|
|
153
|
+
readonly audit?: AuditLogger;
|
|
154
|
+
/** Largest number of tokenization sessions kept; the least recently used is dropped. Defaults to `256`. */
|
|
155
|
+
readonly maxSessions?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Largest `json` argument of `anonyma_anonymize`, in characters of its
|
|
158
|
+
* serialised form. Defaults to 1,000,000, the limit of the `text` argument.
|
|
159
|
+
*/
|
|
160
|
+
readonly maxJsonLength?: number;
|
|
161
|
+
/** Name and version reported to clients. */
|
|
162
|
+
readonly serverInfo?: {
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly version: string;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A Model Context Protocol server.
|
|
169
|
+
*/
|
|
170
|
+
interface McpServer {
|
|
171
|
+
/**
|
|
172
|
+
* Handle one JSON-RPC message.
|
|
173
|
+
*
|
|
174
|
+
* @param message - The parsed message, or an array of messages (a batch).
|
|
175
|
+
* @returns The response, one response per request of a batch, or `undefined`
|
|
176
|
+
* when nothing has to be answered.
|
|
177
|
+
*/
|
|
178
|
+
readonly handle: (message: unknown) => Promise<JsonRpcResponse | readonly JsonRpcResponse[] | undefined>;
|
|
179
|
+
/**
|
|
180
|
+
* Handle one line of a newline-delimited transport.
|
|
181
|
+
*
|
|
182
|
+
* @param line - One JSON-RPC message as JSON text.
|
|
183
|
+
* @returns The response as JSON text without a line break, or `undefined` for a notification.
|
|
184
|
+
*/
|
|
185
|
+
readonly handleLine: (line: string) => Promise<string | undefined>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create an MCP server.
|
|
189
|
+
*
|
|
190
|
+
* @param options - Server options.
|
|
191
|
+
* @returns The {@link McpServer}.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* // anonyma-mcp.mjs — register with: claude mcp add anonyma -- node anonyma-mcp.mjs
|
|
196
|
+
* import { createMcpServer, serveStdio } from "anonyma/mcp";
|
|
197
|
+
*
|
|
198
|
+
* await serveStdio(createMcpServer(), {
|
|
199
|
+
* input: process.stdin,
|
|
200
|
+
* write: (line) => void process.stdout.write(line),
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
205
|
+
/**
|
|
206
|
+
* Serve an MCP server over a newline-delimited JSON transport, such as
|
|
207
|
+
* standard input and output. Resolves when the input ends.
|
|
208
|
+
*
|
|
209
|
+
* @param server - The server.
|
|
210
|
+
* @param io - `input` yields text or bytes in arbitrary chunks; `write`
|
|
211
|
+
* receives each response as one line including its line feed.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* await serveStdio(createMcpServer(), {
|
|
216
|
+
* input: process.stdin,
|
|
217
|
+
* write: (line) => void process.stdout.write(line),
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
declare function serveStdio(server: McpServer, io: {
|
|
222
|
+
readonly input: AsyncIterable<string | Uint8Array>;
|
|
223
|
+
readonly write: (line: string) => void | Promise<void>;
|
|
224
|
+
}): Promise<void>;
|
|
225
|
+
|
|
226
|
+
export { type JsonRpcResponse, type JsonSchema, MCP_PROTOCOL_VERSIONS, MCP_RESOURCES, MCP_RESOURCE_TEMPLATES, MCP_TOOLS, type McpResource, type McpResourceTemplate, type McpServer, type McpServerOptions, type McpTool, createMcpServer, serveStdio };
|