@type-crafter/mcp 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -68
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -6,7 +6,32 @@ import path from 'path';
|
|
|
6
6
|
import { parse as parseYaml } from 'yaml';
|
|
7
7
|
import { exec } from 'child_process';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
|
+
import { z } from 'zod';
|
|
9
10
|
const execAsync = promisify(exec);
|
|
11
|
+
// Zod schemas for all tools
|
|
12
|
+
const generateTypesSchema = z.object({
|
|
13
|
+
language: z
|
|
14
|
+
.enum(['typescript', 'typescript-with-decoders'])
|
|
15
|
+
.describe('Target language for type generation'),
|
|
16
|
+
specFilePath: z.string().describe('Path to the YAML specification file'),
|
|
17
|
+
outputDirectory: z.string().describe('Directory where generated types will be written'),
|
|
18
|
+
typesWriterMode: z
|
|
19
|
+
.enum(['SingleFile', 'Files'])
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Writer mode for types: SingleFile or Files'),
|
|
22
|
+
groupedTypesWriterMode: z
|
|
23
|
+
.enum(['FolderWithFiles', 'SingleFile'])
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Writer mode for grouped types: FolderWithFiles or SingleFile'),
|
|
26
|
+
});
|
|
27
|
+
const validateSpecSchema = z.object({
|
|
28
|
+
specFilePath: z.string().describe('Path to the YAML specification file to validate'),
|
|
29
|
+
});
|
|
30
|
+
const listLanguagesSchema = z.object({});
|
|
31
|
+
const getSpecInfoSchema = z.object({
|
|
32
|
+
specFilePath: z.string().describe('Path to the YAML specification file'),
|
|
33
|
+
});
|
|
34
|
+
const getSpecRulesSchema = z.object({});
|
|
10
35
|
// Type guards
|
|
11
36
|
function isRecord(value) {
|
|
12
37
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -67,74 +92,10 @@ const server = new McpServer({
|
|
|
67
92
|
tools: {},
|
|
68
93
|
},
|
|
69
94
|
});
|
|
70
|
-
// Schema definitions for all tools
|
|
71
|
-
const generateTypesSchema = {
|
|
72
|
-
type: 'object',
|
|
73
|
-
properties: {
|
|
74
|
-
language: {
|
|
75
|
-
type: 'string',
|
|
76
|
-
description: 'Target language for type generation',
|
|
77
|
-
enum: ['typescript', 'typescript-with-decoders'],
|
|
78
|
-
},
|
|
79
|
-
specFilePath: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
description: 'Path to the YAML specification file',
|
|
82
|
-
},
|
|
83
|
-
outputDirectory: {
|
|
84
|
-
type: 'string',
|
|
85
|
-
description: 'Directory where generated types will be written',
|
|
86
|
-
},
|
|
87
|
-
typesWriterMode: {
|
|
88
|
-
type: 'string',
|
|
89
|
-
description: 'Writer mode for types: SingleFile or Files',
|
|
90
|
-
enum: ['SingleFile', 'Files'],
|
|
91
|
-
},
|
|
92
|
-
groupedTypesWriterMode: {
|
|
93
|
-
type: 'string',
|
|
94
|
-
description: 'Writer mode for grouped types: FolderWithFiles or SingleFile',
|
|
95
|
-
enum: ['FolderWithFiles', 'SingleFile'],
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
required: ['language', 'specFilePath', 'outputDirectory'],
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
};
|
|
101
|
-
const validateSpecSchema = {
|
|
102
|
-
type: 'object',
|
|
103
|
-
properties: {
|
|
104
|
-
specFilePath: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
description: 'Path to the YAML specification file to validate',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
required: ['specFilePath'],
|
|
110
|
-
additionalProperties: false,
|
|
111
|
-
};
|
|
112
|
-
const listLanguagesSchema = {
|
|
113
|
-
type: 'object',
|
|
114
|
-
properties: {},
|
|
115
|
-
additionalProperties: false,
|
|
116
|
-
};
|
|
117
|
-
const getSpecInfoSchema = {
|
|
118
|
-
type: 'object',
|
|
119
|
-
properties: {
|
|
120
|
-
specFilePath: {
|
|
121
|
-
type: 'string',
|
|
122
|
-
description: 'Path to the YAML specification file',
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
required: ['specFilePath'],
|
|
126
|
-
additionalProperties: false,
|
|
127
|
-
};
|
|
128
|
-
const getSpecRulesSchema = {
|
|
129
|
-
type: 'object',
|
|
130
|
-
properties: {},
|
|
131
|
-
additionalProperties: false,
|
|
132
|
-
};
|
|
133
95
|
// Register generate-types tool
|
|
134
96
|
server.registerTool('generate-types', {
|
|
135
97
|
description: 'Generate type definitions from a YAML specification file. Supports TypeScript and TypeScript with decoders. ' +
|
|
136
98
|
'The YAML spec should follow the Type Crafter format with info, types, and/or groupedTypes sections.',
|
|
137
|
-
// @ts-expect-error - MCP SDK schema type mismatch
|
|
138
99
|
inputSchema: generateTypesSchema,
|
|
139
100
|
}, async (args) => {
|
|
140
101
|
if (!isGenerateTypesArgs(args)) {
|
|
@@ -221,7 +182,6 @@ server.registerTool('generate-types', {
|
|
|
221
182
|
server.registerTool('validate-spec', {
|
|
222
183
|
description: 'Validate a YAML specification file without generating types. ' +
|
|
223
184
|
'Checks if the spec file is valid and can be processed by Type Crafter.',
|
|
224
|
-
// @ts-expect-error - MCP SDK schema type mismatch
|
|
225
185
|
inputSchema: validateSpecSchema,
|
|
226
186
|
}, async (args) => {
|
|
227
187
|
if (!isSpecFilePathArgs(args)) {
|
|
@@ -283,7 +243,6 @@ server.registerTool('validate-spec', {
|
|
|
283
243
|
// Register list-languages tool
|
|
284
244
|
server.registerTool('list-languages', {
|
|
285
245
|
description: 'List all supported target languages for type generation',
|
|
286
|
-
// @ts-expect-error - MCP SDK schema type mismatch
|
|
287
246
|
inputSchema: listLanguagesSchema,
|
|
288
247
|
}, async () => {
|
|
289
248
|
return {
|
|
@@ -299,7 +258,6 @@ server.registerTool('list-languages', {
|
|
|
299
258
|
server.registerTool('get-spec-info', {
|
|
300
259
|
description: 'Get information about a YAML specification file including version, title, ' +
|
|
301
260
|
'and counts of types and grouped types defined in the spec.',
|
|
302
|
-
// @ts-expect-error - MCP SDK schema type mismatch
|
|
303
261
|
inputSchema: getSpecInfoSchema,
|
|
304
262
|
}, async (args) => {
|
|
305
263
|
if (!isSpecFilePathArgs(args)) {
|
|
@@ -391,7 +349,6 @@ server.registerTool('get-spec-rules', {
|
|
|
391
349
|
description: 'Get comprehensive rules and guidelines for writing Type Crafter YAML specification files. ' +
|
|
392
350
|
'This provides LLMs with detailed information about the YAML spec format, type mappings, nullable types, ' +
|
|
393
351
|
'references, composition, best practices, and common patterns. Use this before creating or modifying spec files.',
|
|
394
|
-
// @ts-expect-error - MCP SDK schema type mismatch
|
|
395
352
|
inputSchema: getSpecRulesSchema,
|
|
396
353
|
}, async () => {
|
|
397
354
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@type-crafter/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MCP server for Type Crafter - generate types from YAML specifications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -61,14 +61,15 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
64
|
-
"yaml": "^2.
|
|
64
|
+
"yaml": "^2.8.2",
|
|
65
|
+
"zod": "3.25.76"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@types/node": "^
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
69
|
-
"@typescript-eslint/parser": "^
|
|
70
|
-
"eslint": "^
|
|
68
|
+
"@types/node": "^25.0.3",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
70
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
71
|
+
"eslint": "^9.39.2",
|
|
71
72
|
"prettier": "^3.7.4",
|
|
72
|
-
"typescript": "^5.
|
|
73
|
+
"typescript": "^5.9.3"
|
|
73
74
|
}
|
|
74
75
|
}
|