@veilio-inc/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/LICENSE ADDED
@@ -0,0 +1,248 @@
1
+ # Veilio Community License
2
+
3
+ _Version 1.0 · Effective 2026-08-08_
4
+
5
+ **Copyright © 2026 Veilio**
6
+
7
+ > **Plain-language summary (non-binding; the numbered terms below control).**
8
+ > Use Veilio for anything you like — personally, or inside your company, including
9
+ > to make money. Read it, fork it, change it, self-host it, ship products with it.
10
+ > The one thing you may not do without written permission is sell Veilio itself:
11
+ > reselling it, white-labeling it, or running it as a hosted service for other
12
+ > people. Contributions are welcome. For a commercial or redistribution license,
13
+ > email `hello@veilio.dev`.
14
+
15
+ ---
16
+
17
+ ## 1. Project Model
18
+
19
+ This project follows a **source-available and community-driven development model** with a separate commercial Cloud Edition. The source is public and contributions are welcome, but this is deliberately **not an OSI-approved open-source license**: the commercial restrictions in Section 5 go beyond what that definition permits.
20
+
21
+ The **Community Core** is publicly available and intended to be freely used, inspected, modified, forked, and improved by the community. Contributions from the community are welcome and are an important part of the project's development.
22
+
23
+ The **Cloud Edition** is a separate commercial offering operated by Veilio. It provides hosted and managed functionality and may include additional proprietary features, infrastructure, services, and support.
24
+
25
+ The Software may be used for personal purposes as well as for internal commercial purposes. Organizations may deploy and use the Software within their own businesses without requiring a commercial license.
26
+
27
+ However, the Software may not be commercially redistributed, resold, white-labeled, or offered as a third-party hosted service without prior written permission from Veilio.
28
+
29
+ The purpose of this model is to keep the core technology open and community-driven while allowing the project owner to maintain and commercially operate the official Cloud Edition.
30
+
31
+ ---
32
+
33
+ ## 2. Definitions
34
+
35
+ For the purposes of this License:
36
+
37
+ **"Software"** means the source code, binaries, documentation, configuration, and other materials distributed as part of this project.
38
+
39
+ **"Community Core"** means the publicly available portion of the Software developed and distributed under this License.
40
+
41
+ **"Modified Version"** means any work based on, derived from, or incorporating substantial portions of the Software.
42
+
43
+ **"Cloud Edition"** means the hosted, managed, or subscription-based version of the Software operated and commercially provided by Veilio, including any proprietary services, infrastructure, features, or components associated with it.
44
+
45
+ **"Commercial Distribution"** means selling, licensing, renting, leasing, sublicensing, or otherwise providing the Software or a Modified Version to third parties in exchange for payment or other commercial consideration.
46
+
47
+ **"Hosted Service"** means making the Software or a Modified Version available to third parties over a network, including as a SaaS, PaaS, managed service, hosted application, or similar commercial offering.
48
+
49
+ **"Competing Product"** means a commercially offered product or service whose primary purpose and core functionality substantially overlap with the Software or Cloud Edition.
50
+
51
+ ---
52
+
53
+ ## 3. Permissions
54
+
55
+ Subject to the restrictions in this License, you are granted a worldwide, royalty-free, non-exclusive license to:
56
+
57
+ * use the Software for personal purposes;
58
+ * use the Software for internal commercial purposes;
59
+ * inspect and study the source code;
60
+ * modify the Software;
61
+ * create forks and derivative works;
62
+ * submit contributions, patches, bug fixes, and improvements to the project;
63
+ * use modified versions for personal purposes or internal commercial operations;
64
+ * share the Software and Modified Versions for non-commercial purposes.
65
+
66
+ These permissions are intended to enable community development, experimentation, self-hosting, internal business use, and collaboration.
67
+
68
+ ---
69
+
70
+ ## 4. Internal Commercial Use
71
+
72
+ Commercial use of the Software is permitted when the Software is used as an internal tool or component of your own business activities.
73
+
74
+ For example, an organization may deploy the Software on its own infrastructure and use it to:
75
+
76
+ * operate internal business processes;
77
+ * support its employees;
78
+ * develop its own products;
79
+ * provide its own services;
80
+ * manage its own operations; or
81
+ * otherwise conduct its own commercial activities.
82
+
83
+ The fact that an organization generates revenue through its business does not, by itself, constitute a violation of this License.
84
+
85
+ The restriction applies to **commercializing the Software itself**, rather than using the Software as part of your own business.
86
+
87
+ ---
88
+
89
+ ## 5. Commercial Restrictions
90
+
91
+ Without prior written permission from Veilio, you may not:
92
+
93
+ ### 5.1 Sell or Resell the Software
94
+
95
+ Sell, license, rent, lease, sublicense, or otherwise commercially distribute the Software or a Modified Version as a standalone product.
96
+
97
+ ### 5.2 Offer the Software as a Hosted Service
98
+
99
+ Operate the Software or a Modified Version as a commercial SaaS, PaaS, hosted application, managed service, or similar service for third parties.
100
+
101
+ ### 5.3 Create a Competing Commercial Product
102
+
103
+ Use the Software or a Modified Version as the basis for a commercially offered product or service that substantially competes with the Cloud Edition.
104
+
105
+ ### 5.4 White-Label or Rebrand the Software
106
+
107
+ Repackage, white-label, rebrand, or otherwise present the Software or a Modified Version as your own commercial software product.
108
+
109
+ ### 5.5 Commercially Redistribute Modified Versions
110
+
111
+ Commercially distribute a Modified Version where the primary value or functionality being sold is provided by the Software.
112
+
113
+ Requests for written permission may be sent to `hello@veilio.dev`.
114
+
115
+ ---
116
+
117
+ ## 6. Cloud Edition
118
+
119
+ The Cloud Edition is the official commercial hosted offering of the project.
120
+
121
+ The Cloud Edition may be provided through paid subscriptions and may include:
122
+
123
+ * managed hosting;
124
+ * automatic updates;
125
+ * backups;
126
+ * infrastructure and scalability;
127
+ * monitoring;
128
+ * enterprise functionality;
129
+ * technical support;
130
+ * proprietary features;
131
+ * other hosted or managed services.
132
+
133
+ The Community Core and Cloud Edition may share common code, concepts, or functionality. However, access to the Community Core does not grant any right to commercially operate a competing hosted version of the Cloud Edition.
134
+
135
+ The Cloud Edition may be governed by separate Terms of Service, subscription agreements, privacy policies, and commercial licenses.
136
+
137
+ ---
138
+
139
+ ## 7. Forks and Modified Versions
140
+
141
+ You are permitted to create forks and Modified Versions of the Software for:
142
+
143
+ * personal use;
144
+ * internal business use;
145
+ * research;
146
+ * education;
147
+ * development;
148
+ * experimentation; and
149
+ * other purposes permitted by this License.
150
+
151
+ Forks and Modified Versions must retain applicable copyright notices and a copy of this License.
152
+
153
+ Creating a fork does not grant permission to commercially distribute that fork, offer it as a commercial Hosted Service, or use it to create a Competing Product.
154
+
155
+ ---
156
+
157
+ ## 8. Contributions
158
+
159
+ Contributions to the Community Core are welcome.
160
+
161
+ By submitting a contribution, you represent that you have the necessary rights to submit that contribution and agree that it may be incorporated into the project and distributed under this License.
162
+
163
+ Unless otherwise agreed in writing, contributions will be made available under the same licensing terms as the Software.
164
+
165
+ Contributors retain ownership of their original contributions to the extent permitted by applicable law.
166
+
167
+ ---
168
+
169
+ ## 9. Redistribution
170
+
171
+ You may redistribute the Software and Modified Versions for non-commercial purposes, provided that:
172
+
173
+ * applicable copyright notices are retained;
174
+ * the original project is appropriately credited;
175
+ * a copy of this License is included;
176
+ * recipients are informed of the applicable licensing terms; and
177
+ * the redistribution does not imply endorsement by Veilio.
178
+
179
+ Commercial redistribution requires prior written permission from Veilio.
180
+
181
+ ---
182
+
183
+ ## 10. Attribution
184
+
185
+ Redistributions of the Software or Modified Versions must retain:
186
+
187
+ * applicable copyright notices;
188
+ * notices identifying the original project; and
189
+ * a copy of this License.
190
+
191
+ You may add your own copyright notices for your modifications, provided that they do not imply ownership of the original Software.
192
+
193
+ ---
194
+
195
+ ## 11. Trademarks
196
+
197
+ This License does not grant permission to use the project's name, logo, trademarks, service marks, domain names, or branding except as reasonably necessary to identify the original Software.
198
+
199
+ You may not use the project's trademarks to imply endorsement, sponsorship, affiliation, or official status without prior written permission.
200
+
201
+ Creating a fork does not grant the right to use the project's trademarks for that fork.
202
+
203
+ ---
204
+
205
+ ## 12. No Warranty
206
+
207
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
208
+
209
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE AUTHORS AND COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
210
+
211
+ ---
212
+
213
+ ## 13. Limitation of Liability
214
+
215
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHORS, COPYRIGHT HOLDERS, CONTRIBUTORS, OR PROJECT OWNERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM OR RELATED TO THE SOFTWARE OR THE USE OR INABILITY TO USE THE SOFTWARE.
216
+
217
+ ---
218
+
219
+ ## 14. Termination
220
+
221
+ Your rights under this License terminate automatically if you materially violate its terms.
222
+
223
+ Upon termination, you must cease the activities that are prohibited by this License.
224
+
225
+ Permissions granted to recipients who are not in violation of this License remain unaffected.
226
+
227
+ ---
228
+
229
+ ## 15. Reservation of Rights
230
+
231
+ All rights not expressly granted by this License are reserved by Veilio.
232
+
233
+ In particular, this License does not grant rights to commercially sell, redistribute, host, white-label, or operate a competing commercial service based on the Software beyond the permissions expressly stated above.
234
+
235
+ ---
236
+
237
+ ## 16. License Versions
238
+
239
+ The project owner may publish future versions of this License.
240
+
241
+ Each version will be identified by a version number. Unless explicitly stated otherwise, versions of the Software already distributed under a particular version of this License remain subject to that version.
242
+
243
+ ---
244
+
245
+ **Project:** Veilio
246
+ **Copyright:** © 2026 Veilio
247
+ **License:** Veilio Community License, Version 1.0
248
+ **Contact:** `hello@veilio.dev`
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @veilio-inc/mcp
2
+
3
+ MCP server that lets a coding agent work on your code **without the real identifiers ever entering its context.**
4
+
5
+ ## Why path-based tools
6
+
7
+ A naive MCP anonymizer takes source code as a tool argument. That is self-defeating: to call it, the agent must already hold the real code — so the identifiers are already in the model's context and nothing was protected.
8
+
9
+ The primary tools here take a **file path**. The server reads the file in its own process and returns only the masked text. The agent learns `__CLS__1.__FN__2()` and never sees `PaymentGateway.chargeCard()`.
10
+
11
+ ```
12
+ tools/call anonymize_file { "path": "src/gateway.ts" }
13
+
14
+ → Source: src/gateway.ts
15
+ Language: TypeScript / JavaScript
16
+ Placeholders in map: 7
17
+ Credentials detected — 1 critical:
18
+ critical line 2:24 Stripe secret key — sk_l…MNOP (31 chars) (redacted, not recoverable)
19
+
20
+ --- masked code ---
21
+ export class __CLS__1 {
22
+ private __VAR__2 = "__REDACTED_STRIPE_KEY_1__"
23
+ async __FN__1(__VAR__4: string, __VAR__1: number) {
24
+ return this.__VAR__3.__FN__2(__VAR__4, __VAR__1)
25
+ }
26
+ }
27
+ ```
28
+
29
+ ## Tools
30
+
31
+ | Tool | Purpose |
32
+ |---|---|
33
+ | `anonymize_file` | Read a file and return only its masked form. **Preferred.** |
34
+ | `anonymize_text` | Mask text the agent already holds (a user paste). Not for file contents. |
35
+ | `restore_text` | Swap placeholders back and strip AI-generated noise. |
36
+ | `scan_secrets` | Detect credentials without modifying anything, and without putting the values in context. |
37
+ | `symbol_map_summary` | Placeholder counts by kind. Returns keys only, never real names. |
38
+
39
+ ## Install
40
+
41
+ ```jsonc
42
+ // Claude Code — .mcp.json
43
+ {
44
+ "mcpServers": {
45
+ "veilio": {
46
+ "command": "npx",
47
+ "args": ["-y", "@veilio-inc/mcp", "--root", "."]
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ `--root <dir>` scopes every path the server will read; `--map <path>` overrides the symbol-map location. Paths outside the root are refused — the server reads files on the agent's behalf, so traversal would make it an arbitrary-file-read primitive.
54
+
55
+ ## Design properties
56
+
57
+ - **Zero runtime dependencies.** JSON-RPC framing is implemented directly. Pulling a transitive tree into the component that reads your source would undercut the product's own claim.
58
+ - **stdout is protocol only.** Diagnostics go to stderr; a stray write to stdout corrupts the stream.
59
+ - **Tool errors, not protocol errors.** Failures come back as `isError` content so the model can correct itself, rather than aborting the call.
60
+ - **Redaction is one-way.** Credentials never enter the symbol map, so `restore_text` cannot bring them back.
61
+
62
+ The symbol map is shared with the `veilio` CLI, so you can mask in an agent and restore from a terminal, or the reverse.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export { FrameReader, handleFrame, handleMessage, SERVER_VERSION } from './server.js';
3
+ export { TOOLS, callTool } from './tools.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAUA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ // stdio transport wiring.
3
+ //
4
+ // stdout carries the JSON-RPC stream and nothing else — a stray console.log
5
+ // here corrupts the protocol and the client drops the connection. Diagnostics
6
+ // go to stderr, which MCP clients surface as server logs.
7
+ import { FrameReader } from './server.js';
8
+ export { FrameReader, handleFrame, handleMessage, SERVER_VERSION } from './server.js';
9
+ export { TOOLS, callTool } from './tools.js';
10
+ function parseCliContext(argv) {
11
+ let cwd = process.cwd();
12
+ let mapPath = null;
13
+ for (let i = 0; i < argv.length; i++) {
14
+ if ((argv[i] === '--root' || argv[i] === '-r') && argv[i + 1] !== undefined) {
15
+ cwd = argv[++i];
16
+ }
17
+ else if ((argv[i] === '--map' || argv[i] === '-m') && argv[i + 1] !== undefined) {
18
+ mapPath = argv[++i];
19
+ }
20
+ }
21
+ return { cwd, mapPath };
22
+ }
23
+ function start() {
24
+ const ctx = parseCliContext(process.argv.slice(2));
25
+ const send = (response) => {
26
+ process.stdout.write(`${JSON.stringify(response)}\n`);
27
+ };
28
+ const reader = new FrameReader(ctx, send);
29
+ process.stdin.setEncoding('utf8');
30
+ process.stdin.on('data', (chunk) => reader.push(chunk));
31
+ process.stdin.on('end', () => process.exit(0));
32
+ process.stderr.write(`veilio-mcp: serving ${ctx.cwd}\n`);
33
+ }
34
+ if (process.argv[1] !== undefined && import.meta.url === `file://${process.argv[1]}`) {
35
+ start();
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,0BAA0B;AAC1B,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAE,WAAW,EAAwB,MAAM,aAAa,CAAA;AAG/D,OAAO,EAAE,W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E,IAAI,CAAC,CAAA;IAEzC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAC1D,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrF,KAAK,EAAE,CAAA;AACT,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { type ToolContext } from './tools.js';
2
+ export declare const SERVER_VERSION = "0.1.0";
3
+ /** Protocol revisions this server implements. If the client asks for one of
4
+ * these we echo it back; otherwise we answer with our newest and let the
5
+ * client decide whether it can proceed. */
6
+ export declare const SUPPORTED_PROTOCOL_VERSIONS: string[];
7
+ export interface JsonRpcRequest {
8
+ jsonrpc: '2.0';
9
+ id?: string | number | null;
10
+ method: string;
11
+ params?: Record<string, unknown>;
12
+ }
13
+ export interface JsonRpcResponse {
14
+ jsonrpc: '2.0';
15
+ id: string | number | null;
16
+ result?: unknown;
17
+ error?: {
18
+ code: number;
19
+ message: string;
20
+ data?: unknown;
21
+ };
22
+ }
23
+ /** Handle one parsed message. Returns null for notifications, which by spec
24
+ * MUST NOT be answered. */
25
+ export declare function handleMessage(message: unknown, ctx: ToolContext): JsonRpcResponse | null;
26
+ /** Parse and handle one newline-delimited frame. */
27
+ export declare function handleFrame(line: string, ctx: ToolContext): JsonRpcResponse | null;
28
+ /** Accumulates stdin chunks and emits one response per complete line. Kept
29
+ * separate from process wiring so it can be driven directly in tests. */
30
+ export declare class FrameReader {
31
+ private readonly ctx;
32
+ private readonly send;
33
+ private buffer;
34
+ constructor(ctx: ToolContext, send: (response: JsonRpcResponse) => void);
35
+ push(chunk: string): void;
36
+ }
37
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC;;4CAE4C;AAC5C,eAAO,MAAM,2BAA2B,UAA6C,CAAA;AAGrF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC1D;AAeD;4BAC4B;AAC5B,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAkExF;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAQlF;AAED;0EAC0E;AAC1E,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,MAAM,CAAK;gBAGA,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI;IAG5D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAW1B"}
package/dist/server.js ADDED
@@ -0,0 +1,121 @@
1
+ // MCP over JSON-RPC 2.0, implemented directly.
2
+ //
3
+ // No SDK dependency. The product's claim is that your source code is handled by
4
+ // auditable, local, dependency-free code; pulling a transitive tree into the
5
+ // component that reads your files to undercut that would be an odd trade for
6
+ // ~150 lines of message plumbing.
7
+ import { PRODUCT_NAME } from '@veilio-inc/engine';
8
+ import { callTool, TOOLS } from './tools.js';
9
+ export const SERVER_VERSION = '0.1.0';
10
+ /** Protocol revisions this server implements. If the client asks for one of
11
+ * these we echo it back; otherwise we answer with our newest and let the
12
+ * client decide whether it can proceed. */
13
+ export const SUPPORTED_PROTOCOL_VERSIONS = ['2025-06-18', '2025-03-26', '2024-11-05'];
14
+ const LATEST_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0];
15
+ // Standard JSON-RPC error codes.
16
+ const PARSE_ERROR = -32700;
17
+ const INVALID_REQUEST = -32600;
18
+ const METHOD_NOT_FOUND = -32601;
19
+ function ok(id, result) {
20
+ return { jsonrpc: '2.0', id, result };
21
+ }
22
+ function fail(id, code, message) {
23
+ return { jsonrpc: '2.0', id, error: { code, message } };
24
+ }
25
+ /** Handle one parsed message. Returns null for notifications, which by spec
26
+ * MUST NOT be answered. */
27
+ export function handleMessage(message, ctx) {
28
+ if (typeof message !== 'object' || message === null || Array.isArray(message)) {
29
+ return fail(null, INVALID_REQUEST, 'request must be a JSON object');
30
+ }
31
+ const req = message;
32
+ if (typeof req.method !== 'string') {
33
+ return fail(req.id ?? null, INVALID_REQUEST, 'missing method');
34
+ }
35
+ // Absent id = notification. Handle the side effect, answer nothing.
36
+ const isNotification = req.id === undefined;
37
+ const id = req.id ?? null;
38
+ const params = req.params ?? {};
39
+ switch (req.method) {
40
+ case 'initialize': {
41
+ const requested = params.protocolVersion;
42
+ const protocolVersion = typeof requested === 'string' && SUPPORTED_PROTOCOL_VERSIONS.includes(requested)
43
+ ? requested
44
+ : LATEST_PROTOCOL_VERSION;
45
+ return ok(id, {
46
+ protocolVersion,
47
+ capabilities: { tools: { listChanged: false } },
48
+ serverInfo: { name: `${PRODUCT_NAME} MCP`, version: SERVER_VERSION },
49
+ instructions: `Use anonymize_file before reasoning about proprietary source: it reads the file ` +
50
+ `itself and returns only masked code, so real identifiers never enter your context. ` +
51
+ `Use scan_secrets to check a file or diff for credentials without seeing their values.`,
52
+ });
53
+ }
54
+ case 'notifications/initialized':
55
+ case 'notifications/cancelled':
56
+ return null;
57
+ case 'ping':
58
+ return ok(id, {});
59
+ case 'tools/list':
60
+ return ok(id, {
61
+ tools: TOOLS.map((t) => ({
62
+ name: t.name,
63
+ title: t.title,
64
+ description: t.description,
65
+ inputSchema: t.inputSchema,
66
+ })),
67
+ });
68
+ case 'tools/call': {
69
+ const name = typeof params.name === 'string' ? params.name : '';
70
+ const rawArgs = params.arguments;
71
+ const args = typeof rawArgs === 'object' && rawArgs !== null && !Array.isArray(rawArgs)
72
+ ? rawArgs
73
+ : {};
74
+ const result = callTool(name, args, ctx);
75
+ return ok(id, {
76
+ content: [{ type: 'text', text: result.text }],
77
+ isError: result.isError === true,
78
+ });
79
+ }
80
+ default:
81
+ if (isNotification)
82
+ return null;
83
+ return fail(id, METHOD_NOT_FOUND, `unknown method "${req.method}"`);
84
+ }
85
+ }
86
+ /** Parse and handle one newline-delimited frame. */
87
+ export function handleFrame(line, ctx) {
88
+ let parsed;
89
+ try {
90
+ parsed = JSON.parse(line);
91
+ }
92
+ catch {
93
+ return fail(null, PARSE_ERROR, 'invalid JSON');
94
+ }
95
+ return handleMessage(parsed, ctx);
96
+ }
97
+ /** Accumulates stdin chunks and emits one response per complete line. Kept
98
+ * separate from process wiring so it can be driven directly in tests. */
99
+ export class FrameReader {
100
+ ctx;
101
+ send;
102
+ buffer = '';
103
+ constructor(ctx, send) {
104
+ this.ctx = ctx;
105
+ this.send = send;
106
+ }
107
+ push(chunk) {
108
+ this.buffer += chunk;
109
+ let index;
110
+ while ((index = this.buffer.indexOf('\n')) !== -1) {
111
+ const line = this.buffer.slice(0, index).trim();
112
+ this.buffer = this.buffer.slice(index + 1);
113
+ if (line.length === 0)
114
+ continue;
115
+ const response = handleFrame(line, this.ctx);
116
+ if (response !== null)
117
+ this.send(response);
118
+ }
119
+ }
120
+ }
121
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAA;AAE9D,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAA;AAErC;;4CAE4C;AAC5C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;AACrF,MAAM,uBAAuB,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAA;AAgB9D,iCAAiC;AACjC,MAAM,WAAW,GAAG,CAAC,KAAK,CAAA;AAC1B,MAAM,eAAe,GAAG,CAAC,KAAK,CAAA;AAC9B,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAA;AAE/B,SAAS,EAAE,CAAC,EAA0B,EAAE,MAAe;IACrD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAA;AACvC,CAAC;AAED,SAAS,IAAI,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AAE,SAAQ;YAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;YAC5C,IAAI,QAAQ,KAAK,IAAI;gBAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ export interface ToolContext {
2
+ /** Root the server is allowed to read from. */
3
+ cwd: string;
4
+ /** Override for the symbol-map location; null uses the project store. */
5
+ mapPath: string | null;
6
+ }
7
+ export interface ToolResult {
8
+ text: string;
9
+ isError?: boolean;
10
+ }
11
+ export interface ToolDefinition {
12
+ name: string;
13
+ title: string;
14
+ description: string;
15
+ inputSchema: Record<string, unknown>;
16
+ handler: (args: Record<string, unknown>, ctx: ToolContext) => ToolResult;
17
+ }
18
+ export declare const TOOLS: ToolDefinition[];
19
+ export declare const TOOLS_BY_NAME: Map<string, ToolDefinition>;
20
+ /** Run a tool, converting expected failures into an error result rather than a
21
+ * protocol-level fault — MCP clients surface tool errors to the model so it can
22
+ * correct itself, whereas a JSON-RPC error usually aborts the call. */
23
+ export declare function callTool(name: string, args: Record<string, unknown>, ctx: ToolContext): ToolResult;
24
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAA;IACX,yEAAyE;IACzE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,UAAU,CAAA;CACzE;AAiKD,eAAO,MAAM,KAAK,EAAE,cAAc,EAyIjC,CAAA;AAED,eAAO,MAAM,aAAa,6BAAyC,CAAA;AAEnE;;wEAEwE;AACxE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,WAAW,GACf,UAAU,CASZ"}
package/dist/tools.js ADDED
@@ -0,0 +1,302 @@
1
+ // Tool definitions and handlers.
2
+ //
3
+ // THE POINT OF THE PATH-BASED TOOLS
4
+ //
5
+ // A naive MCP anonymizer would take source code as a tool argument. That is
6
+ // self-defeating: to call it, the agent must already hold the real code, which
7
+ // means the real identifiers are already in the model's context. Nothing was
8
+ // protected.
9
+ //
10
+ // So the primary tools take a FILE PATH. The server reads the file itself, in
11
+ // this process, and returns only the masked text. The agent learns
12
+ // `__CLS__1.__FN__2()` and never sees `PaymentGateway.chargeCard()`. That is the
13
+ // only arrangement where an MCP anonymizer actually anonymizes anything.
14
+ //
15
+ // `anonymize_text` exists for the case where the agent legitimately already has
16
+ // the text (a user pasted it into chat). Its description says so plainly, so the
17
+ // model does not reach for it out of convenience and quietly defeat the purpose.
18
+ import { readFileSync } from 'node:fs';
19
+ import { isAbsolute, relative, resolve } from 'node:path';
20
+ import { anonymize, detectSecrets, isPlaceholder, restore, summarizeSecrets, withAiPreamble, BIN_NAME, LANGUAGES, LANGUAGE_LABELS, PRODUCT_NAME, } from '@veilio-inc/engine';
21
+ import { loadMap, resolveMapPath, saveMap } from '@veilio-inc/cli/store';
22
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
23
+ class ToolError extends Error {
24
+ }
25
+ function str(args, key, required = false) {
26
+ const value = args[key];
27
+ if (value === undefined || value === null) {
28
+ if (required)
29
+ throw new ToolError(`missing required argument "${key}"`);
30
+ return undefined;
31
+ }
32
+ if (typeof value !== 'string')
33
+ throw new ToolError(`argument "${key}" must be a string`);
34
+ return value;
35
+ }
36
+ /** Resolve a caller-supplied path and refuse anything outside `cwd`.
37
+ * The server reads files on the agent's behalf, so path traversal here would
38
+ * turn it into an arbitrary-file-read primitive. */
39
+ function safeResolve(path, cwd) {
40
+ const abs = isAbsolute(path) ? path : resolve(cwd, path);
41
+ const rel = relative(cwd, abs);
42
+ if (rel.startsWith('..') || isAbsolute(rel)) {
43
+ throw new ToolError(`path "${path}" is outside the project root`);
44
+ }
45
+ return abs;
46
+ }
47
+ function readTarget(args, ctx) {
48
+ const path = str(args, 'path');
49
+ const text = str(args, 'text');
50
+ if (path !== undefined && text !== undefined) {
51
+ throw new ToolError('pass either "path" or "text", not both');
52
+ }
53
+ if (path !== undefined) {
54
+ const abs = safeResolve(path, ctx.cwd);
55
+ try {
56
+ return { text: readFileSync(abs, 'utf8'), label: path };
57
+ }
58
+ catch {
59
+ throw new ToolError(`cannot read "${path}"`);
60
+ }
61
+ }
62
+ if (text !== undefined)
63
+ return { text, label: 'inline text' };
64
+ throw new ToolError('pass either "path" or "text"');
65
+ }
66
+ function findingLines(findings) {
67
+ return findings
68
+ .map((f) => ` ${f.severity.padEnd(8)} line ${f.line}:${f.column} ${f.label} — ${f.preview}` +
69
+ (f.redacted ? ' (redacted, not recoverable)' : ' (left in place)'))
70
+ .join('\n');
71
+ }
72
+ function secretSummary(findings) {
73
+ if (findings.length === 0)
74
+ return 'No credentials detected.';
75
+ const s = summarizeSecrets(findings);
76
+ const parts = [];
77
+ if (s.critical)
78
+ parts.push(`${s.critical} critical`);
79
+ if (s.high)
80
+ parts.push(`${s.high} high`);
81
+ if (s.medium)
82
+ parts.push(`${s.medium} advisory`);
83
+ return `Credentials detected — ${parts.join(', ')}:\n${findingLines(findings)}`;
84
+ }
85
+ /** Tell the caller what did not survive the round trip.
86
+ *
87
+ * Worth more here than anywhere else in the product: over MCP the caller is the
88
+ * model, and the model is usually the thing that broke the placeholder. Told
89
+ * which token it mangled, it can go back and fix its own reply — a correction
90
+ * loop no human-facing panel can close.
91
+ *
92
+ * `unresolved` leads because it is always wrong: the restored text now carries
93
+ * a token that means nothing. `missing` is reported as information, since a
94
+ * reply about one function legitimately omits the rest of the file. Silence
95
+ * when both are empty keeps a clean restore from growing a paragraph nobody
96
+ * needs to read. */
97
+ function restoreReportLines(report) {
98
+ const parts = [];
99
+ if (report.unresolved.length > 0) {
100
+ parts.push(`WARNING: ${report.unresolved.length} placeholder-shaped token(s) match no map entry — ` +
101
+ `they were invented or altered somewhere in the reply and are still in the output: ` +
102
+ `${report.unresolved.join(', ')}. Replace them with the correct placeholders and restore again.`);
103
+ }
104
+ if (report.missing.length > 0) {
105
+ parts.push(`${report.missing.length} placeholder(s) never appeared in the text: ` +
106
+ `${report.missing.join(', ')}. Expected if the text only covered part of the source; ` +
107
+ `if it covered all of it, those names came back renamed and are not recoverable from it.`);
108
+ }
109
+ return parts.length > 0 ? `\n\n${parts.join('\n\n')}` : '';
110
+ }
111
+ const LANGUAGE_ENUM = ['auto', ...LANGUAGES];
112
+ const LANGUAGE_PROP = {
113
+ type: 'string',
114
+ enum: LANGUAGE_ENUM,
115
+ description: `Source language. "auto" (default) detects it. Supported: ${LANGUAGES.map((l) => LANGUAGE_LABELS[l]).join(', ')}.`,
116
+ };
117
+ function runAnonymize(source, label, args, ctx) {
118
+ const mapPath = resolveMapPath(ctx.mapPath, ctx.cwd);
119
+ const existingMap = loadMap(mapPath);
120
+ const language = (str(args, 'language') ?? 'auto');
121
+ const result = anonymize(source, { existingMap, language, secrets: 'redact' });
122
+ saveMap(mapPath, result.map);
123
+ const body = args.preamble === true ? withAiPreamble(result.anonymized, result.map) : result.anonymized;
124
+ // The model reading this is about to reason over the masked text, and these
125
+ // two lines are the only place it can learn what the masking did NOT cover.
126
+ // The engine puts both on every result precisely so this server does not have
127
+ // to decide for itself; dropping them here would leave an agent believing the
128
+ // output is clean when a name is sitting in a comment inside it.
129
+ const caveats = [];
130
+ if (result.languageFallback) {
131
+ caveats.push(`WARNING: no language marker matched. Masked as ${LANGUAGE_LABELS[result.language]}, ` +
132
+ `which may be wrong for this file — pass "language" explicitly to be sure.`);
133
+ }
134
+ if (result.comments.total > 0) {
135
+ const { total, inline, characters } = result.comments;
136
+ caveats.push(`Comment prose is NOT masked: ${total} comment${total === 1 ? '' : 's'} ` +
137
+ `(${inline === 0 ? 'above the code' : `${inline} inside the body`}), ` +
138
+ `${characters} characters, left exactly as written. Names, customers and ticket ` +
139
+ `numbers in them are still real. Treat them as unmasked when quoting or forwarding.`);
140
+ }
141
+ const notes = [
142
+ `Source: ${label}`,
143
+ `Language: ${LANGUAGE_LABELS[result.language]}`,
144
+ `Placeholders in map: ${Object.keys(result.map).length}`,
145
+ secretSummary(result.secrets),
146
+ ...caveats,
147
+ ].join('\n');
148
+ return {
149
+ text: `${notes}\n\n--- masked code ---\n${body}`,
150
+ };
151
+ }
152
+ // ─── Tools ───────────────────────────────────────────────────────────────────
153
+ export const TOOLS = [
154
+ {
155
+ name: 'anonymize_file',
156
+ title: 'Anonymize a file',
157
+ description: `Read a file from disk and return it with every proprietary identifier replaced by a ` +
158
+ `placeholder (__CLS__1, __FN__2, …) and every credential irreversibly redacted. ` +
159
+ `PREFER THIS over anonymize_text: ${PRODUCT_NAME} reads the file itself, so the real ` +
160
+ `identifiers never enter your context — you only ever see the masked form. Use it before ` +
161
+ `reasoning about, quoting, or forwarding proprietary source. The symbol map is stored ` +
162
+ `locally so restore_text can reverse it later.`,
163
+ inputSchema: {
164
+ type: 'object',
165
+ properties: {
166
+ path: { type: 'string', description: 'File path, relative to the project root.' },
167
+ language: LANGUAGE_PROP,
168
+ preamble: {
169
+ type: 'boolean',
170
+ description: 'Prepend a note explaining the placeholders, for forwarding to another model.',
171
+ },
172
+ },
173
+ required: ['path'],
174
+ additionalProperties: false,
175
+ },
176
+ handler: (args, ctx) => {
177
+ const path = str(args, 'path', true);
178
+ const abs = safeResolve(path, ctx.cwd);
179
+ let source;
180
+ try {
181
+ source = readFileSync(abs, 'utf8');
182
+ }
183
+ catch {
184
+ throw new ToolError(`cannot read "${path}"`);
185
+ }
186
+ return runAnonymize(source, path, args, ctx);
187
+ },
188
+ },
189
+ {
190
+ name: 'anonymize_text',
191
+ title: 'Anonymize text you already have',
192
+ description: `Mask identifiers and redact credentials in text passed as an argument. Only use this for ` +
193
+ `text you ALREADY hold — something the user pasted into the conversation. If the content ` +
194
+ `is in a file, use anonymize_file instead: passing file contents through this tool means ` +
195
+ `the real identifiers are already in your context, which defeats the purpose.`,
196
+ inputSchema: {
197
+ type: 'object',
198
+ properties: {
199
+ text: { type: 'string', description: 'The code to mask.' },
200
+ language: LANGUAGE_PROP,
201
+ preamble: { type: 'boolean', description: 'Prepend the explanatory note.' },
202
+ },
203
+ required: ['text'],
204
+ additionalProperties: false,
205
+ },
206
+ handler: (args, ctx) => runAnonymize(str(args, 'text', true), 'inline text', args, ctx),
207
+ },
208
+ {
209
+ name: 'restore_text',
210
+ title: 'Restore real identifiers',
211
+ description: `Swap placeholders back to the real identifiers using the stored symbol map, and strip ` +
212
+ `AI-generated noise (JSDoc, TODO comments, narration). Use this on a reply that came back ` +
213
+ `containing placeholders. Note that irreversibly redacted credentials stay redacted — ` +
214
+ `that is deliberate.`,
215
+ inputSchema: {
216
+ type: 'object',
217
+ properties: {
218
+ text: { type: 'string', description: 'Text containing placeholders.' },
219
+ },
220
+ required: ['text'],
221
+ additionalProperties: false,
222
+ },
223
+ handler: (args, ctx) => {
224
+ const text = str(args, 'text', true);
225
+ const map = loadMap(resolveMapPath(ctx.mapPath, ctx.cwd));
226
+ if (Object.keys(map).length === 0) {
227
+ throw new ToolError(`no symbol map yet — run anonymize_file (or "${BIN_NAME} scrub") first`);
228
+ }
229
+ const result = restore(text, map);
230
+ return {
231
+ text: `Restored ${result.report.resolved.length} of ${Object.keys(map).length} placeholders; ` +
232
+ `stripped ${result.strippedCount} AI artifact(s).` +
233
+ `${restoreReportLines(result.report)}\n\n--- restored ---\n${result.restored}`,
234
+ };
235
+ },
236
+ },
237
+ {
238
+ name: 'scan_secrets',
239
+ title: 'Scan for credentials',
240
+ description: `Detect credentials — API keys, tokens, private keys, connection-string passwords, ` +
241
+ `emails, private IPs — without modifying anything and WITHOUT putting the values in your ` +
242
+ `context (findings carry truncated previews only). Run this on a file before reading it, ` +
243
+ `or on a diff before committing.`,
244
+ inputSchema: {
245
+ type: 'object',
246
+ properties: {
247
+ path: { type: 'string', description: 'File to scan, relative to the project root.' },
248
+ text: { type: 'string', description: 'Text to scan, if not reading a file.' },
249
+ },
250
+ additionalProperties: false,
251
+ },
252
+ handler: (args, ctx) => {
253
+ const { text, label } = readTarget(args, ctx);
254
+ const findings = detectSecrets(text);
255
+ return { text: `Scanned ${label}.\n${secretSummary(findings)}` };
256
+ },
257
+ },
258
+ {
259
+ name: 'symbol_map_summary',
260
+ title: 'Summarize the symbol map',
261
+ description: `Report how many placeholders exist and which kinds. Deliberately returns placeholder ` +
262
+ `KEYS only, never the real names — so you can reason about coverage without ` +
263
+ `de-anonymizing anything.`,
264
+ inputSchema: { type: 'object', properties: {}, additionalProperties: false },
265
+ handler: (_args, ctx) => {
266
+ const mapPath = resolveMapPath(ctx.mapPath, ctx.cwd);
267
+ const map = loadMap(mapPath);
268
+ const keys = Object.keys(map);
269
+ if (keys.length === 0)
270
+ return { text: 'No symbol map yet.' };
271
+ const byBase = new Map();
272
+ for (const key of keys) {
273
+ // Whether a key is a placeholder is the engine's question, so it is
274
+ // asked rather than re-encoded here — a local copy of the pattern goes
275
+ // stale the first time the engine mints a role it does not describe,
276
+ // and mis-grouping is silent. Stripping the trailing counter to get the
277
+ // role is presentation, and stays here.
278
+ const base = isPlaceholder(key) ? key.replace(/\d+$/, '') : key;
279
+ byBase.set(base, (byBase.get(base) ?? 0) + 1);
280
+ }
281
+ const breakdown = [...byBase].map(([base, n]) => ` ${base}* × ${n}`).join('\n');
282
+ return { text: `${keys.length} placeholders at ${mapPath}:\n${breakdown}` };
283
+ },
284
+ },
285
+ ];
286
+ export const TOOLS_BY_NAME = new Map(TOOLS.map((t) => [t.name, t]));
287
+ /** Run a tool, converting expected failures into an error result rather than a
288
+ * protocol-level fault — MCP clients surface tool errors to the model so it can
289
+ * correct itself, whereas a JSON-RPC error usually aborts the call. */
290
+ export function callTool(name, args, ctx) {
291
+ const tool = TOOLS_BY_NAME.get(name);
292
+ if (!tool)
293
+ return { text: `Unknown tool "${name}".`, isError: true };
294
+ try {
295
+ return tool.handler(args, ctx);
296
+ }
297
+ catch (err) {
298
+ const message = err instanceof Error ? err.message : String(err);
299
+ return { text: `${PRODUCT_NAME}: ${message}`, isError: true };
300
+ }
301
+ }
302
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,oCAAoC;AACpC,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,aAAa;AACb,EAAE;AACF,8EAA8E;AAC9E,mEAAmE;AACnE,iFAAiF;AACjF,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,GAGb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAsBxE,gFAAgF;AAEhF,MAAM,SAAU,SAA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EAAE,IAAI,EAAE,CAAA;IAC/D,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@veilio-inc/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server exposing the anonymizer to coding agents, so a model can work on masked code without the real identifiers ever entering its context.",
5
+ "type": "module",
6
+ "bin": {
7
+ "veilio-mcp": "dist/index.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=24"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "model-context-protocol",
22
+ "anonymizer",
23
+ "llm",
24
+ "privacy",
25
+ "secret-scanning",
26
+ "veilio"
27
+ ],
28
+ "license": "SEE LICENSE IN LICENSE",
29
+ "dependencies": {
30
+ "@veilio-inc/engine": "^1.4.0",
31
+ "@veilio-inc/cli": "^0.1.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "clean": "rm -rf dist",
36
+ "prepublishOnly": "npm run clean && npm run typecheck && npm run build && npm run test",
37
+ "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
38
+ "test": "vitest run",
39
+ "test:coverage": "vitest run --coverage"
40
+ },
41
+ "devDependencies": {
42
+ "typescript": "^5.4.0",
43
+ "vitest": "^4.1.10",
44
+ "@vitest/coverage-v8": "^4.1.10"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/veilio-inc/veilio.git",
49
+ "directory": "packages/mcp"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/veilio-inc/veilio/issues"
53
+ },
54
+ "homepage": "https://github.com/veilio-inc/veilio/tree/main/packages/mcp#readme",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }