@kernlang/mcp 3.1.6

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.
@@ -0,0 +1,205 @@
1
+ import { transpileMCP } from '../transpiler-mcp.js';
2
+ function node(type, props = {}, children = []) {
3
+ return { type, props, children, loc: { line: 1, col: 1, endLine: 1, endCol: 1 } };
4
+ }
5
+ describe('transpileMCP', () => {
6
+ it('should export a function', () => {
7
+ expect(typeof transpileMCP).toBe('function');
8
+ });
9
+ it('should generate basic MCP server code', () => {
10
+ const ast = node('mcp', { name: 'TestServer', version: '1.0' }, [
11
+ node('tool', { name: 'hello' }, [
12
+ node('description', { text: 'Say hello' }),
13
+ node('param', { name: 'name', type: 'string', required: 'true' }),
14
+ ]),
15
+ ]);
16
+ const result = transpileMCP(ast);
17
+ expect(result.code).toContain('McpServer');
18
+ expect(result.code).toContain('StdioServerTransport');
19
+ expect(result.code).toContain('"TestServer"');
20
+ expect(result.code).toContain('"1.0"');
21
+ expect(result.code).toContain('z.string()');
22
+ expect(result.code).toContain('"hello"');
23
+ expect(result.code).toContain('logger.info');
24
+ expect(result.code).toContain('server.tool(');
25
+ });
26
+ it('should generate tool with Zod schema for typed params', () => {
27
+ const ast = node('mcp', { name: 'TypedServer' }, [
28
+ node('tool', { name: 'calculate' }, [
29
+ node('param', { name: 'value', type: 'number', required: 'true' }),
30
+ node('param', { name: 'label', type: 'string', required: 'false' }),
31
+ node('param', { name: 'flag', type: 'boolean' }),
32
+ ]),
33
+ ]);
34
+ const result = transpileMCP(ast);
35
+ expect(result.code).toContain('z.number()');
36
+ expect(result.code).toContain('z.string()');
37
+ expect(result.code).toContain('z.boolean()');
38
+ expect(result.code).toContain('.optional()');
39
+ });
40
+ it('should generate sanitize guard', () => {
41
+ const ast = node('mcp', { name: 'GuardedServer' }, [
42
+ node('tool', { name: 'search' }, [
43
+ node('param', { name: 'query', type: 'string', required: 'true' }),
44
+ node('guard', { type: 'sanitize', param: 'query' }),
45
+ ]),
46
+ ]);
47
+ const result = transpileMCP(ast);
48
+ expect(result.code).toContain('sanitizeValue');
49
+ expect(result.code).toContain('function sanitizeValue');
50
+ });
51
+ it('should generate pathContainment guard', () => {
52
+ const ast = node('mcp', { name: 'FSServer' }, [
53
+ node('tool', { name: 'readFile' }, [
54
+ node('param', { name: 'filePath', type: 'string', required: 'true' }),
55
+ node('guard', { type: 'pathContainment', param: 'filePath', allowlist: '/data,/home' }),
56
+ ]),
57
+ ]);
58
+ const result = transpileMCP(ast);
59
+ expect(result.code).toContain('ensurePathContainment');
60
+ expect(result.code).toContain('ALLOWED_PATHS');
61
+ expect(result.code).toContain('import path');
62
+ });
63
+ it('should auto-inject pathContainment for path-like params', () => {
64
+ const ast = node('mcp', { name: 'AutoGuard' }, [
65
+ node('tool', { name: 'readFile' }, [
66
+ node('param', { name: 'filePath', type: 'string', required: 'true' }),
67
+ ]),
68
+ ]);
69
+ const result = transpileMCP(ast);
70
+ expect(result.code).toContain('ensurePathContainment');
71
+ });
72
+ it('should generate validate guard with min/max/regex', () => {
73
+ const ast = node('mcp', { name: 'ValidatedServer' }, [
74
+ node('tool', { name: 'setCount' }, [
75
+ node('param', { name: 'count', type: 'number', required: 'true' }),
76
+ node('guard', { type: 'validate', param: 'count', min: '1', max: '100' }),
77
+ ]),
78
+ ]);
79
+ const result = transpileMCP(ast);
80
+ expect(result.code).toContain('.min(1)');
81
+ expect(result.code).toContain('.max(100)');
82
+ });
83
+ it('should generate resource handler', () => {
84
+ const ast = node('mcp', { name: 'ResourceServer' }, [
85
+ node('resource', { name: 'docs', uri: 'docs://readme' }, [
86
+ node('description', { text: 'Project documentation' }),
87
+ ]),
88
+ ]);
89
+ const result = transpileMCP(ast);
90
+ expect(result.code).toContain('server.resource(');
91
+ expect(result.code).toContain('"docs"');
92
+ expect(result.code).toContain('"docs://readme"');
93
+ expect(result.code).toContain('resource:read');
94
+ });
95
+ it('should generate ResourceTemplate for URI with variables', () => {
96
+ const ast = node('mcp', { name: 'TemplateServer' }, [
97
+ node('resource', { name: 'userProfile', uri: 'user://{userId}/profile' }),
98
+ ]);
99
+ const result = transpileMCP(ast);
100
+ expect(result.code).toContain('ResourceTemplate');
101
+ expect(result.code).toContain('user://{userId}/profile');
102
+ });
103
+ it('should generate prompt handler', () => {
104
+ const ast = node('mcp', { name: 'PromptServer' }, [
105
+ node('prompt', { name: 'reviewCode' }, [
106
+ node('description', { text: 'Review code for issues' }),
107
+ node('param', { name: 'code', type: 'string', required: 'true' }),
108
+ ]),
109
+ ]);
110
+ const result = transpileMCP(ast);
111
+ expect(result.code).toContain('server.prompt(');
112
+ expect(result.code).toContain('"reviewCode"');
113
+ expect(result.code).toContain('prompt:call');
114
+ });
115
+ it('should auto-inject logging and error handling', () => {
116
+ const ast = node('mcp', { name: 'LoggedServer' }, [
117
+ node('tool', { name: 'action' }),
118
+ ]);
119
+ const result = transpileMCP(ast);
120
+ expect(result.code).toContain('logger.info');
121
+ expect(result.code).toContain('logger.error');
122
+ expect(result.code).toContain('tool:call');
123
+ expect(result.code).toContain('tool:error');
124
+ expect(result.code).toContain('fmtError');
125
+ expect(result.code).toContain('isError: true');
126
+ });
127
+ it('should wrap server in async main with fatal handler', () => {
128
+ const ast = node('mcp', { name: 'MainServer' });
129
+ const result = transpileMCP(ast);
130
+ expect(result.code).toContain('async function main()');
131
+ expect(result.code).toContain('server:start');
132
+ expect(result.code).toContain('server:fatal');
133
+ expect(result.code).toContain('process.exitCode = 1');
134
+ });
135
+ it('should return valid TranspileResult shape', () => {
136
+ const ast = node('mcp', { name: 'ShapeTest' }, [
137
+ node('tool', { name: 'test' }),
138
+ ]);
139
+ const result = transpileMCP(ast);
140
+ expect(result).toHaveProperty('code');
141
+ expect(result).toHaveProperty('sourceMap');
142
+ expect(result).toHaveProperty('irTokenCount');
143
+ expect(result).toHaveProperty('tsTokenCount');
144
+ expect(result).toHaveProperty('tokenReduction');
145
+ expect(result).toHaveProperty('diagnostics');
146
+ expect(typeof result.code).toBe('string');
147
+ expect(Array.isArray(result.sourceMap)).toBe(true);
148
+ });
149
+ it('should handle handler code blocks', () => {
150
+ const ast = node('mcp', { name: 'HandlerServer' }, [
151
+ node('tool', { name: 'greet' }, [
152
+ node('param', { name: 'name', type: 'string', required: 'true' }),
153
+ node('handler', { code: 'return `Hello, ${params.name}!`;' }),
154
+ ]),
155
+ ]);
156
+ const result = transpileMCP(ast);
157
+ expect(result.code).toContain('return `Hello, ${params.name}!`;');
158
+ });
159
+ it('should handle mcp node nested inside document', () => {
160
+ const ast = node('document', {}, [
161
+ node('mcp', { name: 'NestedServer', version: '2.0' }, [
162
+ node('tool', { name: 'ping' }),
163
+ ]),
164
+ ]);
165
+ const result = transpileMCP(ast);
166
+ expect(result.code).toContain('"NestedServer"');
167
+ expect(result.code).toContain('"2.0"');
168
+ expect(result.code).toContain('"ping"');
169
+ });
170
+ it('should emit sanitizeValue for resource params with sanitize guard', () => {
171
+ const ast = node('mcp', { name: 'ResourceGuardServer' }, [
172
+ node('resource', { name: 'search', uri: 'search://results' }, [
173
+ node('param', { name: 'query', type: 'string' }),
174
+ node('guard', { type: 'sanitize', param: 'query' }),
175
+ ]),
176
+ ]);
177
+ const result = transpileMCP(ast);
178
+ expect(result.code).toContain('function sanitizeValue');
179
+ expect(result.code).toContain('sanitizeValue(');
180
+ });
181
+ it('should emit ensurePathContainment for resource with path-like param', () => {
182
+ const ast = node('mcp', { name: 'ResourcePathServer' }, [
183
+ node('resource', { name: 'file', uri: 'file://{filePath}' }, [
184
+ node('param', { name: 'filePath', type: 'string', required: 'true' }),
185
+ ]),
186
+ ]);
187
+ const result = transpileMCP(ast);
188
+ expect(result.code).toContain('ensurePathContainment');
189
+ expect(result.code).toContain('import path');
190
+ expect(result.code).toContain('ALLOWED_PATHS');
191
+ });
192
+ it('should wrap prompt handler in try/catch', () => {
193
+ const ast = node('mcp', { name: 'PromptErrorServer' }, [
194
+ node('prompt', { name: 'review' }, [
195
+ node('description', { text: 'Review code' }),
196
+ node('param', { name: 'code', type: 'string', required: 'true' }),
197
+ ]),
198
+ ]);
199
+ const result = transpileMCP(ast);
200
+ expect(result.code).toContain('prompt:error');
201
+ expect(result.code).toContain('try {');
202
+ expect(result.code).toContain('fmtError(error)');
203
+ });
204
+ });
205
+ //# sourceMappingURL=transpiler-mcp.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpiler-mcp.test.js","sourceRoot":"","sources":["../../src/__tests__/transpiler-mcp.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,SAAS,IAAI,CAAC,IAAY,EAAE,QAAiC,EAAE,EAAE,WAAqB,EAAE;IACtF,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAY,CAAC;AAC9F,CAAC;AAED,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;YAC9D,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;gBAC9B,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;gBAC1C,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;aAClE,CAAC;SACH,CA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AG,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE;YACrD,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBACjC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;gBAC5C,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;aAClE,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @kernlang/mcp — MCP server transpiler
3
+ *
4
+ * Compiles .kern MCP definitions to secure TypeScript MCP servers
5
+ * using @modelcontextprotocol/sdk. Security guards are enforced
6
+ * by construction — validation, logging, and path containment
7
+ * are auto-injected.
8
+ */
9
+ export { transpileMCP, transpileMCPResult } from './transpiler-mcp.js';
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @kernlang/mcp — MCP server transpiler
3
+ *
4
+ * Compiles .kern MCP definitions to secure TypeScript MCP servers
5
+ * using @modelcontextprotocol/sdk. Security guards are enforced
6
+ * by construction — validation, logging, and path containment
7
+ * are auto-injected.
8
+ */
9
+ export { transpileMCP, transpileMCPResult } from './transpiler-mcp.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { IRNode, ResolvedKernConfig, KernConfig, TranspileResult } from '@kernlang/core';
2
+ /** Transpile a KERN IR tree to MCP server TypeScript code string. */
3
+ export declare function transpileMCP(root: IRNode, config?: ResolvedKernConfig): TranspileResult;
4
+ /** Alias for use from CLI where config may not be fully resolved. */
5
+ export declare function transpileMCPResult(root: IRNode, config?: KernConfig | ResolvedKernConfig): TranspileResult;