@type-crafter/mcp 0.6.0 → 1.0.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/README.md +114 -208
- package/dist/docs/RULES_COMPOSITION.md +343 -0
- package/dist/docs/RULES_NULLABLE.md +293 -0
- package/dist/docs/RULES_PATTERNS.md +516 -0
- package/dist/docs/RULES_REFERENCES.md +302 -0
- package/dist/docs/RULES_STRUCTURE.md +248 -0
- package/dist/docs/RULES_TYPES.md +291 -0
- package/dist/docs/WRITING_GUIDE.md +179 -0
- package/dist/index.js +321 -345
- package/package.json +3 -5
- package/src/GUIDE.md +0 -459
- package/src/SPEC_RULES.md +0 -1755
package/README.md
CHANGED
|
@@ -1,162 +1,134 @@
|
|
|
1
1
|
# Type Crafter MCP Server
|
|
2
2
|
|
|
3
|
-
An MCP (Model Context Protocol) server
|
|
3
|
+
An MCP (Model Context Protocol) server that helps AI assistants write correct Type Crafter YAML specifications.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@type-crafter/mcp-server)
|
|
6
6
|
[](https://opensource.org/licenses/ISC)
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## What This MCP Does
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This MCP server helps LLMs:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
1. **Learn** the correct YAML specification format
|
|
13
|
+
2. **Validate** YAML specs before generation
|
|
14
|
+
3. **Avoid** common mistakes like `nullable: true` (which doesn't exist)
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
Type generation is handled by the `type-crafter` CLI in your project.
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
## Tools
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
- `specFilePath` (required): Path to the YAML specification file
|
|
20
|
-
- `outputDirectory` (required): Directory where generated types will be written
|
|
21
|
-
- `typesWriterMode` (optional): `SingleFile` or `Files` (default: `SingleFile`)
|
|
22
|
-
- `groupedTypesWriterMode` (optional): `FolderWithFiles` or `SingleFile` (default: `SingleFile`)
|
|
20
|
+
### 1. `get-writing-guide`
|
|
23
21
|
|
|
24
|
-
**
|
|
22
|
+
**CALL THIS FIRST** - Returns the writing guide and a sessionId.
|
|
25
23
|
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"groupedTypesWriterMode": "FolderWithFiles"
|
|
33
|
-
}
|
|
24
|
+
```
|
|
25
|
+
Returns:
|
|
26
|
+
- sessionId (pass to other tools)
|
|
27
|
+
- Quick start guide
|
|
28
|
+
- Common mistakes to avoid
|
|
29
|
+
- Quick reference table
|
|
34
30
|
```
|
|
35
31
|
|
|
36
|
-
### 2. `
|
|
32
|
+
### 2. `get-rules-section`
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
Get detailed rules for a specific topic.
|
|
39
35
|
|
|
40
36
|
**Parameters:**
|
|
41
37
|
|
|
42
|
-
- `
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 3. `list-languages`
|
|
53
|
-
|
|
54
|
-
List all supported target languages for type generation.
|
|
38
|
+
- `sessionId` (optional): Session ID from get-writing-guide
|
|
39
|
+
- `section` (required): One of:
|
|
40
|
+
- `structure` - Root structure, info section, types vs groupedTypes
|
|
41
|
+
- `types` - Objects, enums, primitives, arrays
|
|
42
|
+
- `nullable` - How `required` array controls nullability
|
|
43
|
+
- `references` - $ref syntax, top-file vs non-top-file rules
|
|
44
|
+
- `composition` - oneOf (unions), allOf (intersections)
|
|
45
|
+
- `patterns` - Common patterns with full examples
|
|
55
46
|
|
|
56
|
-
|
|
47
|
+
### 3. `validate-spec`
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Get detailed information about a YAML specification file including version, title, and all defined types.
|
|
49
|
+
Validate a YAML spec file for correctness.
|
|
61
50
|
|
|
62
51
|
**Parameters:**
|
|
63
52
|
|
|
53
|
+
- `sessionId` (optional): Session ID from get-writing-guide
|
|
64
54
|
- `specFilePath` (required): Path to the YAML specification file
|
|
65
55
|
|
|
66
|
-
**
|
|
56
|
+
**Checks:**
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
```
|
|
58
|
+
- Structure (info, types, groupedTypes)
|
|
59
|
+
- Common mistakes (nullable, optional, wrong paths)
|
|
60
|
+
- Top-file vs non-top-file reference rules
|
|
73
61
|
|
|
74
|
-
###
|
|
75
|
-
|
|
76
|
-
Get comprehensive rules and guidelines for writing Type Crafter YAML specification files. This tool provides LLMs with detailed information about the YAML spec format, type mappings, nullable types, references, composition, best practices, and common patterns.
|
|
62
|
+
### 4. `get-spec-info`
|
|
77
63
|
|
|
78
|
-
|
|
64
|
+
Get information about an existing spec file.
|
|
79
65
|
|
|
80
|
-
**
|
|
66
|
+
**Parameters:**
|
|
81
67
|
|
|
82
|
-
-
|
|
83
|
-
- You want to understand the Type Crafter spec format
|
|
84
|
-
- You need guidance on type mappings and nullable types
|
|
85
|
-
- You want to learn about references, composition, and best practices
|
|
68
|
+
- `specFilePath` (required): Path to the YAML specification file
|
|
86
69
|
|
|
87
|
-
**Returns:**
|
|
70
|
+
**Returns:**
|
|
88
71
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
- Type definitions (objects, enums, arrays, nested objects)
|
|
93
|
-
- References (local, external, cyclic)
|
|
94
|
-
- Composition (oneOf unions, allOf intersections)
|
|
95
|
-
- Best practices and common patterns
|
|
96
|
-
- Complete examples with YAML and TypeScript side-by-side
|
|
72
|
+
- Version and title
|
|
73
|
+
- List of all types
|
|
74
|
+
- List of all grouped types
|
|
97
75
|
|
|
98
|
-
|
|
76
|
+
### 5. `list-languages`
|
|
99
77
|
|
|
100
|
-
|
|
101
|
-
- `type-crafter` CLI installed globally or locally
|
|
78
|
+
List supported languages for the type-crafter CLI.
|
|
102
79
|
|
|
103
|
-
|
|
80
|
+
## Recommended Workflow
|
|
104
81
|
|
|
105
|
-
```bash
|
|
106
|
-
npm install -g type-crafter
|
|
107
82
|
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
83
|
+
1. Call get-writing-guide
|
|
84
|
+
↓
|
|
85
|
+
2. Write YAML spec (following the guide)
|
|
86
|
+
↓
|
|
87
|
+
3. Call validate-spec
|
|
88
|
+
↓
|
|
89
|
+
4. Fix any issues (use get-rules-section for details)
|
|
90
|
+
↓
|
|
91
|
+
5. Run type-crafter CLI in your project
|
|
117
92
|
```
|
|
118
93
|
|
|
119
|
-
|
|
94
|
+
## Session Enforcement
|
|
120
95
|
|
|
121
|
-
|
|
122
|
-
npm install @type-crafter/mcp-server
|
|
123
|
-
```
|
|
96
|
+
The MCP uses sessions to encourage reading the guide first:
|
|
124
97
|
|
|
125
|
-
|
|
98
|
+
- `get-writing-guide` returns a `sessionId`
|
|
99
|
+
- Pass `sessionId` to other tools
|
|
100
|
+
- If validation fails with common mistakes AND no sessionId → suggests reading the guide
|
|
101
|
+
- Sessions expire after 30 minutes
|
|
126
102
|
|
|
127
|
-
|
|
103
|
+
## Installation
|
|
128
104
|
|
|
129
|
-
|
|
130
|
-
git clone https://github.com/sinha-sahil/type-crafter.git
|
|
131
|
-
cd type-crafter/mcp-server
|
|
132
|
-
```
|
|
105
|
+
### Prerequisites
|
|
133
106
|
|
|
134
|
-
|
|
107
|
+
- Node.js >= 18.0.0
|
|
108
|
+
- `type-crafter` CLI installed in your project
|
|
135
109
|
|
|
136
110
|
```bash
|
|
137
|
-
npm install
|
|
111
|
+
npm install -g type-crafter
|
|
112
|
+
# or locally
|
|
113
|
+
npm install type-crafter
|
|
138
114
|
```
|
|
139
115
|
|
|
140
|
-
|
|
116
|
+
### Install MCP Server
|
|
141
117
|
|
|
142
118
|
```bash
|
|
143
|
-
npm
|
|
119
|
+
npm install -g @type-crafter/mcp-server
|
|
144
120
|
```
|
|
145
121
|
|
|
146
122
|
## Configuration
|
|
147
123
|
|
|
148
|
-
###
|
|
149
|
-
|
|
150
|
-
After installing globally via npm:
|
|
124
|
+
### Claude Desktop
|
|
151
125
|
|
|
152
|
-
Edit your Claude Desktop
|
|
126
|
+
Edit your Claude Desktop config:
|
|
153
127
|
|
|
154
128
|
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
155
129
|
|
|
156
130
|
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
157
131
|
|
|
158
|
-
**For global installation:**
|
|
159
|
-
|
|
160
132
|
```json
|
|
161
133
|
{
|
|
162
134
|
"mcpServers": {
|
|
@@ -167,28 +139,14 @@ Edit your Claude Desktop configuration file:
|
|
|
167
139
|
}
|
|
168
140
|
```
|
|
169
141
|
|
|
170
|
-
|
|
142
|
+
### From Source
|
|
171
143
|
|
|
172
144
|
```json
|
|
173
145
|
{
|
|
174
146
|
"mcpServers": {
|
|
175
147
|
"type-crafter": {
|
|
176
148
|
"command": "node",
|
|
177
|
-
"args": ["/
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**For project-local npm installation:**
|
|
184
|
-
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"mcpServers": {
|
|
188
|
-
"type-crafter": {
|
|
189
|
-
"command": "npx",
|
|
190
|
-
"args": ["type-crafter-mcp"],
|
|
191
|
-
"cwd": "/path/to/your/project"
|
|
149
|
+
"args": ["/path/to/type-crafter/mcp/dist/index.js"]
|
|
192
150
|
}
|
|
193
151
|
}
|
|
194
152
|
}
|
|
@@ -196,128 +154,76 @@ Edit your Claude Desktop configuration file:
|
|
|
196
154
|
|
|
197
155
|
## Usage Examples
|
|
198
156
|
|
|
199
|
-
|
|
157
|
+
### Learning the Format
|
|
200
158
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
Show me the rules for writing Type Crafter YAML specification files
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
2. **Generate TypeScript types:**
|
|
159
|
+
```
|
|
160
|
+
User: "I need to create types for a user API"
|
|
208
161
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
162
|
+
LLM: [Calls get-writing-guide]
|
|
163
|
+
LLM: "I've read the Type Crafter guide. Here's what I learned..."
|
|
164
|
+
LLM: [Creates YAML following the rules]
|
|
165
|
+
LLM: [Calls validate-spec to verify]
|
|
166
|
+
```
|
|
212
167
|
|
|
213
|
-
|
|
168
|
+
### Validating Existing Spec
|
|
214
169
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
```
|
|
170
|
+
```
|
|
171
|
+
User: "Check if my types.yaml is valid"
|
|
218
172
|
|
|
219
|
-
|
|
173
|
+
LLM: [Calls validate-spec with the file path]
|
|
174
|
+
LLM: "Found 2 issues:
|
|
175
|
+
1. Line 15: 'nullable: true' doesn't exist - use required array
|
|
176
|
+
2. Line 23: Wrong path format..."
|
|
177
|
+
```
|
|
220
178
|
|
|
221
|
-
|
|
222
|
-
Show me information about the types defined in my spec.yaml
|
|
223
|
-
```
|
|
179
|
+
### Deep Dive on Rules
|
|
224
180
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
What languages does Type Crafter support?
|
|
228
|
-
```
|
|
181
|
+
```
|
|
182
|
+
User: "How do I make a field nullable?"
|
|
229
183
|
|
|
230
|
-
|
|
184
|
+
LLM: [Calls get-rules-section with section: "nullable"]
|
|
185
|
+
LLM: "In Type Crafter, nullability is controlled by the required array..."
|
|
186
|
+
```
|
|
231
187
|
|
|
232
|
-
|
|
188
|
+
## YAML Quick Reference
|
|
233
189
|
|
|
234
190
|
```yaml
|
|
235
191
|
info:
|
|
236
|
-
version:
|
|
237
|
-
title:
|
|
192
|
+
version: '1.0.0'
|
|
193
|
+
title: 'My Types'
|
|
238
194
|
|
|
239
195
|
types:
|
|
240
|
-
|
|
196
|
+
User:
|
|
241
197
|
type: object
|
|
198
|
+
required:
|
|
199
|
+
- id # Required → string
|
|
200
|
+
- email # Required → string
|
|
242
201
|
properties:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
groupedTypes:
|
|
247
|
-
GroupName:
|
|
248
|
-
TypeInGroup:
|
|
249
|
-
type: object
|
|
250
|
-
properties:
|
|
251
|
-
id:
|
|
252
|
-
type: string
|
|
202
|
+
id: { type: string }
|
|
203
|
+
email: { type: string }
|
|
204
|
+
name: { type: string } # Not in required → string | null
|
|
253
205
|
```
|
|
254
206
|
|
|
255
|
-
|
|
207
|
+
**Key Rules:**
|
|
256
208
|
|
|
257
|
-
|
|
209
|
+
- `nullable: true` does NOT exist - use `required` array
|
|
210
|
+
- `optional: true` does NOT exist - use `required` array
|
|
211
|
+
- Arrays cannot be top-level types
|
|
212
|
+
- Paths are from project root, not relative to current file
|
|
258
213
|
|
|
259
|
-
|
|
214
|
+
## Development
|
|
260
215
|
|
|
261
216
|
```bash
|
|
217
|
+
# Build
|
|
262
218
|
npm run build
|
|
263
|
-
```
|
|
264
219
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
```bash
|
|
220
|
+
# Watch mode
|
|
268
221
|
npm run dev
|
|
269
|
-
```
|
|
270
222
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
```bash
|
|
223
|
+
# Lint
|
|
274
224
|
npm run lint
|
|
275
|
-
npm run lint:fix
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
## Testing the Package Locally
|
|
279
|
-
|
|
280
|
-
Before publishing or to test the installed package:
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
# Create a tarball
|
|
284
|
-
npm pack
|
|
285
|
-
|
|
286
|
-
# Install globally from tarball
|
|
287
|
-
npm install -g ./type-crafter-mcp-server-0.1.0.tgz
|
|
288
|
-
|
|
289
|
-
# Test it
|
|
290
|
-
type-crafter-mcp
|
|
291
225
|
```
|
|
292
226
|
|
|
293
|
-
See [PUBLISHING.md](./PUBLISHING.md) for detailed publishing instructions.
|
|
294
|
-
|
|
295
|
-
## Troubleshooting
|
|
296
|
-
|
|
297
|
-
### Server not connecting
|
|
298
|
-
|
|
299
|
-
- **Global installation:** Ensure `type-crafter-mcp` is in your PATH
|
|
300
|
-
- **Local installation:** Verify the path in your configuration is correct
|
|
301
|
-
- Check that the server was built successfully (`npm run build`)
|
|
302
|
-
- Restart Claude Desktop after modifying the configuration
|
|
303
|
-
- Check Node.js version (requires >= 18.0.0)
|
|
304
|
-
|
|
305
|
-
### Type generation errors
|
|
306
|
-
|
|
307
|
-
- Ensure `type-crafter` CLI is installed: `npm install -g type-crafter`
|
|
308
|
-
- Validate your YAML specification using the `validate-spec` tool
|
|
309
|
-
- Check that all file paths are absolute or relative to your working directory
|
|
310
|
-
- Ensure the output directory exists or the server has permissions to create it
|
|
311
|
-
|
|
312
|
-
### Permission denied error
|
|
313
|
-
|
|
314
|
-
- For global installation, you may need sudo: `sudo npm install -g @type-crafter/mcp-server`
|
|
315
|
-
- Or configure npm to install global packages in your home directory
|
|
316
|
-
|
|
317
|
-
## Contributing
|
|
318
|
-
|
|
319
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
320
|
-
|
|
321
227
|
## License
|
|
322
228
|
|
|
323
|
-
ISC
|
|
229
|
+
ISC
|