@docrouter/mcp 0.1.0 → 0.1.2
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/CLAUDE.md +129 -0
- package/README.md +365 -8
- package/dist/CLAUDE.md +129 -0
- package/dist/index.js +83 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code when using DocRouter MCP tools.
|
|
4
|
+
|
|
5
|
+
## Working with DocRouter MCP Tools
|
|
6
|
+
|
|
7
|
+
### CRITICAL: Always Call Help Tools First
|
|
8
|
+
|
|
9
|
+
Before creating or modifying DocRouter resources, **ALWAYS** follow this workflow:
|
|
10
|
+
|
|
11
|
+
1. **Call help tools FIRST**:
|
|
12
|
+
- `mcp__docrouter__help_schemas()` - Before creating/modifying schemas
|
|
13
|
+
- `mcp__docrouter__help_prompts()` - Before creating/modifying prompts
|
|
14
|
+
- `mcp__docrouter__help_forms()` - Before creating/modifying forms
|
|
15
|
+
- `mcp__docrouter__help()` - For general API guidance
|
|
16
|
+
|
|
17
|
+
2. **Validate before creating**:
|
|
18
|
+
- `mcp__docrouter__validate_schema(schema)` - ALWAYS validate schemas before creating them
|
|
19
|
+
- `mcp__docrouter__validate_form(form)` - ALWAYS validate forms before creating them
|
|
20
|
+
- Check the validation response for errors and fix any issues
|
|
21
|
+
|
|
22
|
+
3. **Then create the resource**:
|
|
23
|
+
- Only after help and validation, create the resource
|
|
24
|
+
|
|
25
|
+
### Schema Creation Rules
|
|
26
|
+
|
|
27
|
+
**CRITICAL**: OpenAI's strict mode requires:
|
|
28
|
+
|
|
29
|
+
- **ALL properties in an object MUST be in the `required` array** (even optional fields)
|
|
30
|
+
- Use `additionalProperties: false` for strict validation
|
|
31
|
+
- All nested objects must follow the same rules
|
|
32
|
+
- Never create a schema without validating it first
|
|
33
|
+
|
|
34
|
+
**Wrong** (will fail):
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"properties": {
|
|
38
|
+
"personal_info": {
|
|
39
|
+
"properties": {
|
|
40
|
+
"name": {"type": "string"},
|
|
41
|
+
"phone": {"type": "string"}
|
|
42
|
+
},
|
|
43
|
+
"required": ["name"] // ❌ Missing "phone" in required
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Correct**:
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"properties": {
|
|
53
|
+
"personal_info": {
|
|
54
|
+
"properties": {
|
|
55
|
+
"name": {"type": "string"},
|
|
56
|
+
"phone": {"type": "string"}
|
|
57
|
+
},
|
|
58
|
+
"required": ["name", "phone"] // ✅ ALL properties listed
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Mandatory Workflow for Schema Creation
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
1. mcp__docrouter__help_schemas() // Read the documentation
|
|
68
|
+
2. mcp__docrouter__validate_schema() // Validate your schema
|
|
69
|
+
3. Fix any validation errors
|
|
70
|
+
4. mcp__docrouter__create_schema() // Only if validation passes
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Mandatory Workflow for Form Creation
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
1. mcp__docrouter__help_forms() // Read the documentation
|
|
77
|
+
2. mcp__docrouter__validate_form() // Validate your form
|
|
78
|
+
3. Fix any validation errors
|
|
79
|
+
4. mcp__docrouter__create_form() // Only if validation passes
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Form Creation Rules
|
|
83
|
+
|
|
84
|
+
**CRITICAL**: Form.io forms in DocRouter require:
|
|
85
|
+
|
|
86
|
+
- **`json_formio` array** - Must contain array of Form.io component definitions
|
|
87
|
+
- **Unique field keys** - Each input field must have a unique `key` property
|
|
88
|
+
- **Valid component types** - Use standard Form.io types (textfield, email, number, select, etc.)
|
|
89
|
+
- **Proper nested structures** - Panels, columns, and fieldsets must have `components` arrays
|
|
90
|
+
- **Field mappings (optional)** - If using `json_formio_mapping`, ensure all references are valid
|
|
91
|
+
|
|
92
|
+
**Wrong** (will fail):
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"json_formio": [
|
|
96
|
+
{
|
|
97
|
+
"type": "textfield",
|
|
98
|
+
"label": "Name"
|
|
99
|
+
// ❌ Missing "key" field
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Correct**:
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"json_formio": [
|
|
109
|
+
{
|
|
110
|
+
"type": "textfield",
|
|
111
|
+
"key": "candidate_name",
|
|
112
|
+
"label": "Candidate Name",
|
|
113
|
+
"input": true,
|
|
114
|
+
"validate": {
|
|
115
|
+
"required": true
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Never Skip Validation
|
|
123
|
+
|
|
124
|
+
**NEVER** call `create_schema`, `create_prompt`, or `create_form` without:
|
|
125
|
+
1. Reading the help documentation first
|
|
126
|
+
2. Validating the schema/form/structure first
|
|
127
|
+
3. Confirming validation succeeded
|
|
128
|
+
|
|
129
|
+
This prevents wasted time and ensures resources are created correctly on the first attempt.
|
package/README.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
A TypeScript-based Model Context Protocol (MCP) server for DocRouter API integration.
|
|
4
4
|
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install the package
|
|
9
|
+
npm install @docrouter/mcp
|
|
10
|
+
|
|
11
|
+
# Configure with your DocRouter credentials
|
|
12
|
+
export DOCROUTER_ORG_ID="your-org-id"
|
|
13
|
+
export DOCROUTER_ORG_API_TOKEN="your-token"
|
|
14
|
+
|
|
15
|
+
# Use in your MCP client configuration
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Publishing Quick Reference
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Build and test
|
|
22
|
+
npm run build && npm test
|
|
23
|
+
|
|
24
|
+
# Update version and publish
|
|
25
|
+
npm version patch && npm publish
|
|
26
|
+
|
|
27
|
+
# Check published package
|
|
28
|
+
npm view @docrouter/mcp
|
|
29
|
+
```
|
|
30
|
+
|
|
5
31
|
## Overview
|
|
6
32
|
|
|
7
33
|
This MCP server provides AI applications with access to DocRouter's document processing capabilities, including:
|
|
@@ -14,7 +40,25 @@ This MCP server provides AI applications with access to DocRouter's document pro
|
|
|
14
40
|
|
|
15
41
|
## Installation
|
|
16
42
|
|
|
43
|
+
### For Users
|
|
44
|
+
|
|
45
|
+
Install the published package:
|
|
46
|
+
|
|
17
47
|
```bash
|
|
48
|
+
# Install locally
|
|
49
|
+
npm install @docrouter/mcp
|
|
50
|
+
|
|
51
|
+
# Or install globally
|
|
52
|
+
npm install -g @docrouter/mcp
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### For Developers
|
|
56
|
+
|
|
57
|
+
Clone and install dependencies:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone <repository-url>
|
|
61
|
+
cd docrouter-mcp
|
|
18
62
|
npm install
|
|
19
63
|
```
|
|
20
64
|
|
|
@@ -114,17 +158,36 @@ const guide = await docrouter_document_analysis_guide("document-id");
|
|
|
114
158
|
|
|
115
159
|
## Integration with AI Applications
|
|
116
160
|
|
|
117
|
-
###
|
|
161
|
+
### Prerequisites
|
|
118
162
|
|
|
119
|
-
|
|
163
|
+
Before configuring MCP integration, ensure you have:
|
|
164
|
+
|
|
165
|
+
1. **Installed the package**:
|
|
166
|
+
```bash
|
|
167
|
+
npm install @docrouter/mcp
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
2. **DocRouter credentials**:
|
|
171
|
+
- `DOCROUTER_ORG_ID` - Your DocRouter organization ID
|
|
172
|
+
- `DOCROUTER_ORG_API_TOKEN` - Your DocRouter organization API token
|
|
173
|
+
- `DOCROUTER_API_URL` - DocRouter API URL (optional, defaults to production)
|
|
174
|
+
|
|
175
|
+
### Configuration Files
|
|
176
|
+
|
|
177
|
+
The MCP server can be configured using different configuration files depending on your AI application:
|
|
178
|
+
|
|
179
|
+
#### For Cursor IDE
|
|
180
|
+
|
|
181
|
+
Create `.mcp.json` in your project root:
|
|
120
182
|
|
|
121
183
|
```json
|
|
122
184
|
{
|
|
123
185
|
"mcpServers": {
|
|
124
186
|
"docrouter": {
|
|
125
187
|
"command": "node",
|
|
126
|
-
"args": ["/
|
|
188
|
+
"args": ["node_modules/@docrouter/mcp/dist/index.js"],
|
|
127
189
|
"env": {
|
|
190
|
+
"DOCROUTER_API_URL": "https://app.docrouter.ai/fastapi",
|
|
128
191
|
"DOCROUTER_ORG_ID": "your-org-id",
|
|
129
192
|
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
130
193
|
}
|
|
@@ -133,17 +196,18 @@ Add to your `claude_desktop_config.json`:
|
|
|
133
196
|
}
|
|
134
197
|
```
|
|
135
198
|
|
|
136
|
-
|
|
199
|
+
#### For Claude Desktop
|
|
137
200
|
|
|
138
|
-
|
|
201
|
+
Add to your `claude_desktop_config.json`:
|
|
139
202
|
|
|
140
203
|
```json
|
|
141
204
|
{
|
|
142
205
|
"mcpServers": {
|
|
143
206
|
"docrouter": {
|
|
144
207
|
"command": "node",
|
|
145
|
-
"args": ["/
|
|
208
|
+
"args": ["node_modules/@docrouter/mcp/dist/index.js"],
|
|
146
209
|
"env": {
|
|
210
|
+
"DOCROUTER_API_URL": "https://app.docrouter.ai/fastapi",
|
|
147
211
|
"DOCROUTER_ORG_ID": "your-org-id",
|
|
148
212
|
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
149
213
|
}
|
|
@@ -152,7 +216,7 @@ Create `.cursor/mcp.json` in your project root:
|
|
|
152
216
|
}
|
|
153
217
|
```
|
|
154
218
|
|
|
155
|
-
|
|
219
|
+
#### For Claude Code
|
|
156
220
|
|
|
157
221
|
Create a `.mcp.conf` file in your project root:
|
|
158
222
|
|
|
@@ -161,8 +225,9 @@ Create a `.mcp.conf` file in your project root:
|
|
|
161
225
|
"mcpServers": {
|
|
162
226
|
"docrouter": {
|
|
163
227
|
"command": "node",
|
|
164
|
-
"args": ["/
|
|
228
|
+
"args": ["node_modules/@docrouter/mcp/dist/index.js"],
|
|
165
229
|
"env": {
|
|
230
|
+
"DOCROUTER_API_URL": "https://app.docrouter.ai/fastapi",
|
|
166
231
|
"DOCROUTER_ORG_ID": "your-org-id",
|
|
167
232
|
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
168
233
|
}
|
|
@@ -171,6 +236,152 @@ Create a `.mcp.conf` file in your project root:
|
|
|
171
236
|
}
|
|
172
237
|
```
|
|
173
238
|
|
|
239
|
+
### Using Global Installation
|
|
240
|
+
|
|
241
|
+
If you installed the package globally, you can use the binary directly:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"mcpServers": {
|
|
246
|
+
"docrouter": {
|
|
247
|
+
"command": "docrouter-mcp",
|
|
248
|
+
"env": {
|
|
249
|
+
"DOCROUTER_API_URL": "https://app.docrouter.ai/fastapi",
|
|
250
|
+
"DOCROUTER_ORG_ID": "your-org-id",
|
|
251
|
+
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Step-by-Step Setup Guide
|
|
259
|
+
|
|
260
|
+
#### 1. Install the Package
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# In your project directory
|
|
264
|
+
npm install @docrouter/mcp
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### 2. Create Configuration File
|
|
268
|
+
|
|
269
|
+
For **Cursor IDE**, create `.mcp.json` in your project root:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Create the configuration file
|
|
273
|
+
touch .mcp.json
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### 3. Add Configuration Content
|
|
277
|
+
|
|
278
|
+
Copy the appropriate configuration from above and replace:
|
|
279
|
+
- `your-org-id` with your actual DocRouter organization ID
|
|
280
|
+
- `your-token` with your actual DocRouter API token
|
|
281
|
+
- `https://app.docrouter.ai/fastapi` with your API URL (if different)
|
|
282
|
+
|
|
283
|
+
#### 4. Verify Installation
|
|
284
|
+
|
|
285
|
+
Check that the package files exist:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Verify the main file exists
|
|
289
|
+
ls -la node_modules/@docrouter/mcp/dist/index.js
|
|
290
|
+
|
|
291
|
+
# Check package contents
|
|
292
|
+
ls -la node_modules/@docrouter/mcp/dist/
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### 5. Test the Configuration
|
|
296
|
+
|
|
297
|
+
You can test the MCP server manually:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Set environment variables
|
|
301
|
+
export DOCROUTER_ORG_ID="your-org-id"
|
|
302
|
+
export DOCROUTER_ORG_API_TOKEN="your-token"
|
|
303
|
+
|
|
304
|
+
# Run the server directly
|
|
305
|
+
node node_modules/@docrouter/mcp/dist/index.js
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Troubleshooting MCP Connection
|
|
309
|
+
|
|
310
|
+
#### Common Issues and Solutions
|
|
311
|
+
|
|
312
|
+
**1. "MCP server not connecting"**
|
|
313
|
+
|
|
314
|
+
- ✅ **Check file paths**: Ensure `node_modules/@docrouter/mcp/dist/index.js` exists
|
|
315
|
+
- ✅ **Verify package installation**: Run `npm list @docrouter/mcp`
|
|
316
|
+
- ✅ **Check configuration syntax**: Validate your JSON configuration
|
|
317
|
+
- ✅ **Test manually**: Run the server directly to check for errors
|
|
318
|
+
|
|
319
|
+
**2. "Command not found"**
|
|
320
|
+
|
|
321
|
+
- ✅ **Use absolute paths**: Use full paths instead of relative ones
|
|
322
|
+
- ✅ **Check Node.js**: Ensure Node.js is in your PATH
|
|
323
|
+
- ✅ **Verify permissions**: Ensure the file is executable
|
|
324
|
+
|
|
325
|
+
**3. "Environment variables not set"**
|
|
326
|
+
|
|
327
|
+
- ✅ **Check variable names**: Use exact names: `DOCROUTER_ORG_ID`, `DOCROUTER_ORG_API_TOKEN`
|
|
328
|
+
- ✅ **Verify values**: Ensure credentials are correct and not expired
|
|
329
|
+
- ✅ **Test API access**: Verify your credentials work with DocRouter API
|
|
330
|
+
|
|
331
|
+
**4. "Permission denied"**
|
|
332
|
+
|
|
333
|
+
- ✅ **Check file permissions**: Ensure the file is readable
|
|
334
|
+
- ✅ **Run as correct user**: Don't use sudo for MCP servers
|
|
335
|
+
- ✅ **Check directory permissions**: Ensure access to the project directory
|
|
336
|
+
|
|
337
|
+
#### Debug Configuration
|
|
338
|
+
|
|
339
|
+
Add debug logging to your configuration:
|
|
340
|
+
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"mcpServers": {
|
|
344
|
+
"docrouter": {
|
|
345
|
+
"command": "node",
|
|
346
|
+
"args": ["node_modules/@docrouter/mcp/dist/index.js"],
|
|
347
|
+
"env": {
|
|
348
|
+
"DOCROUTER_API_URL": "https://app.docrouter.ai/fastapi",
|
|
349
|
+
"DOCROUTER_ORG_ID": "your-org-id",
|
|
350
|
+
"DOCROUTER_ORG_API_TOKEN": "your-token",
|
|
351
|
+
"DEBUG": "mcp:*"
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
#### Example Working Configuration
|
|
359
|
+
|
|
360
|
+
Here's a complete example for Cursor IDE:
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"mcpServers": {
|
|
365
|
+
"docrouter": {
|
|
366
|
+
"command": "node",
|
|
367
|
+
"args": ["node_modules/@docrouter/mcp/dist/index.js"],
|
|
368
|
+
"env": {
|
|
369
|
+
"DOCROUTER_API_URL": "http://localhost:8000",
|
|
370
|
+
"DOCROUTER_ORG_ID": "679c9a914cfaaaa3640811ed",
|
|
371
|
+
"DOCROUTER_ORG_API_TOKEN": "LK8RyD5OKn8taDQCbozI5payDk2xXqnW2SXXPZgMp88"
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Security Notes
|
|
379
|
+
|
|
380
|
+
- 🔒 **Never commit credentials**: Add `.mcp.json` to `.gitignore` if it contains real credentials
|
|
381
|
+
- 🔒 **Use environment variables**: Consider using system environment variables instead of hardcoded values
|
|
382
|
+
- 🔒 **Rotate tokens regularly**: Update your API tokens periodically
|
|
383
|
+
- 🔒 **Limit token permissions**: Use tokens with minimal required permissions
|
|
384
|
+
|
|
174
385
|
## Development
|
|
175
386
|
|
|
176
387
|
### Prerequisites
|
|
@@ -178,12 +389,15 @@ Create a `.mcp.conf` file in your project root:
|
|
|
178
389
|
- Node.js 18+
|
|
179
390
|
- TypeScript 5+
|
|
180
391
|
- Access to DocRouter API
|
|
392
|
+
- npm account with publish permissions
|
|
181
393
|
|
|
182
394
|
### Scripts
|
|
183
395
|
|
|
184
396
|
- `npm run build` - Build the project
|
|
185
397
|
- `npm run dev` - Build in watch mode
|
|
186
398
|
- `npm run start:dev` - Run in development mode
|
|
399
|
+
- `npm test` - Run test suite
|
|
400
|
+
- `npm run test:watch` - Run tests in watch mode
|
|
187
401
|
- `npm run lint` - Run ESLint
|
|
188
402
|
- `npm run type-check` - Run TypeScript type checking
|
|
189
403
|
|
|
@@ -192,12 +406,155 @@ Create a `.mcp.conf` file in your project root:
|
|
|
192
406
|
```
|
|
193
407
|
src/
|
|
194
408
|
├── index.ts # Main MCP server implementation
|
|
409
|
+
tests/
|
|
410
|
+
├── mcp-functionality.test.ts # MCP functionality tests
|
|
411
|
+
├── mcp-server.test.ts # Server integration tests
|
|
412
|
+
├── setup.ts # Test setup configuration
|
|
195
413
|
package.json # Package configuration
|
|
196
414
|
tsconfig.json # TypeScript configuration
|
|
197
415
|
tsup.config.ts # Build configuration
|
|
416
|
+
jest.config.js # Jest test configuration
|
|
198
417
|
README.md # This file
|
|
199
418
|
```
|
|
200
419
|
|
|
420
|
+
## Publishing
|
|
421
|
+
|
|
422
|
+
### Prerequisites for Publishing
|
|
423
|
+
|
|
424
|
+
1. **npm Account**: Ensure you have an npm account and are logged in
|
|
425
|
+
2. **Organization Access**: You need publish permissions for the `@docrouter` organization
|
|
426
|
+
3. **Clean Working Directory**: All changes should be committed
|
|
427
|
+
|
|
428
|
+
### Publishing Steps
|
|
429
|
+
|
|
430
|
+
#### 1. Login to npm
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
npm login
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Verify you're logged in:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
npm whoami
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
#### 2. Prepare for Publishing
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# Build the project
|
|
446
|
+
npm run build
|
|
447
|
+
|
|
448
|
+
# Run tests to ensure everything works
|
|
449
|
+
npm test
|
|
450
|
+
|
|
451
|
+
# Check what will be published
|
|
452
|
+
npm pack --dry-run
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
#### 3. Version Management
|
|
456
|
+
|
|
457
|
+
Update the version number in `package.json`:
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
# For bug fixes
|
|
461
|
+
npm version patch
|
|
462
|
+
|
|
463
|
+
# For new features (backward compatible)
|
|
464
|
+
npm version minor
|
|
465
|
+
|
|
466
|
+
# For breaking changes
|
|
467
|
+
npm version major
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
Or manually edit the version in `package.json`.
|
|
471
|
+
|
|
472
|
+
#### 4. Publish the Package
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
npm publish
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
#### 5. Verify Publication
|
|
479
|
+
|
|
480
|
+
Check that your package is available:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
# View package info
|
|
484
|
+
npm view @docrouter/mcp
|
|
485
|
+
|
|
486
|
+
# Test installation
|
|
487
|
+
npm install @docrouter/mcp
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Package Configuration
|
|
491
|
+
|
|
492
|
+
The package is configured as a scoped package with the following key settings:
|
|
493
|
+
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
"name": "@docrouter/mcp",
|
|
497
|
+
"publishConfig": {
|
|
498
|
+
"access": "public"
|
|
499
|
+
},
|
|
500
|
+
"files": [
|
|
501
|
+
"dist",
|
|
502
|
+
"README.md"
|
|
503
|
+
]
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### What Gets Published
|
|
508
|
+
|
|
509
|
+
The following files are included in the published package:
|
|
510
|
+
|
|
511
|
+
- `dist/` - Built JavaScript files (CommonJS + ES Modules)
|
|
512
|
+
- `dist/docs/knowledge_base/` - Bundled knowledge base files
|
|
513
|
+
- `README.md` - Documentation
|
|
514
|
+
- `package.json` - Package metadata
|
|
515
|
+
|
|
516
|
+
### Updating the Package
|
|
517
|
+
|
|
518
|
+
To publish updates:
|
|
519
|
+
|
|
520
|
+
1. Make your changes
|
|
521
|
+
2. Update the version: `npm version patch|minor|major`
|
|
522
|
+
3. Build and test: `npm run build && npm test`
|
|
523
|
+
4. Publish: `npm publish`
|
|
524
|
+
|
|
525
|
+
### Troubleshooting
|
|
526
|
+
|
|
527
|
+
#### Package Already Exists
|
|
528
|
+
If you get an error that the package already exists:
|
|
529
|
+
- Check the version number - it must be unique
|
|
530
|
+
- Use `npm version patch` to increment the version
|
|
531
|
+
|
|
532
|
+
#### Permission Denied
|
|
533
|
+
If you get permission errors:
|
|
534
|
+
- Ensure you're logged in: `npm whoami`
|
|
535
|
+
- Check you have publish permissions for `@docrouter` organization
|
|
536
|
+
- Contact the organization admin if needed
|
|
537
|
+
|
|
538
|
+
#### Build Errors
|
|
539
|
+
If the build fails:
|
|
540
|
+
- Check TypeScript errors: `npm run type-check`
|
|
541
|
+
- Ensure all dependencies are installed: `npm install`
|
|
542
|
+
- Check the `tsup.config.ts` configuration
|
|
543
|
+
|
|
544
|
+
### Unpublishing (Emergency Only)
|
|
545
|
+
|
|
546
|
+
⚠️ **Warning**: Only unpublish within 72 hours and if absolutely necessary.
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
# Unpublish a specific version
|
|
550
|
+
npm unpublish @docrouter/mcp@0.1.0
|
|
551
|
+
|
|
552
|
+
# Unpublish entire package (use with caution)
|
|
553
|
+
npm unpublish @docrouter/mcp --force
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Note**: Unpublishing blocks republishing the same version for 24 hours.
|
|
557
|
+
|
|
201
558
|
## Error Handling
|
|
202
559
|
|
|
203
560
|
The server includes comprehensive error handling and will return structured error responses for debugging. All errors are logged to stderr to avoid interfering with MCP communication.
|
package/dist/CLAUDE.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code when using DocRouter MCP tools.
|
|
4
|
+
|
|
5
|
+
## Working with DocRouter MCP Tools
|
|
6
|
+
|
|
7
|
+
### CRITICAL: Always Call Help Tools First
|
|
8
|
+
|
|
9
|
+
Before creating or modifying DocRouter resources, **ALWAYS** follow this workflow:
|
|
10
|
+
|
|
11
|
+
1. **Call help tools FIRST**:
|
|
12
|
+
- `mcp__docrouter__help_schemas()` - Before creating/modifying schemas
|
|
13
|
+
- `mcp__docrouter__help_prompts()` - Before creating/modifying prompts
|
|
14
|
+
- `mcp__docrouter__help_forms()` - Before creating/modifying forms
|
|
15
|
+
- `mcp__docrouter__help()` - For general API guidance
|
|
16
|
+
|
|
17
|
+
2. **Validate before creating**:
|
|
18
|
+
- `mcp__docrouter__validate_schema(schema)` - ALWAYS validate schemas before creating them
|
|
19
|
+
- `mcp__docrouter__validate_form(form)` - ALWAYS validate forms before creating them
|
|
20
|
+
- Check the validation response for errors and fix any issues
|
|
21
|
+
|
|
22
|
+
3. **Then create the resource**:
|
|
23
|
+
- Only after help and validation, create the resource
|
|
24
|
+
|
|
25
|
+
### Schema Creation Rules
|
|
26
|
+
|
|
27
|
+
**CRITICAL**: OpenAI's strict mode requires:
|
|
28
|
+
|
|
29
|
+
- **ALL properties in an object MUST be in the `required` array** (even optional fields)
|
|
30
|
+
- Use `additionalProperties: false` for strict validation
|
|
31
|
+
- All nested objects must follow the same rules
|
|
32
|
+
- Never create a schema without validating it first
|
|
33
|
+
|
|
34
|
+
**Wrong** (will fail):
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"properties": {
|
|
38
|
+
"personal_info": {
|
|
39
|
+
"properties": {
|
|
40
|
+
"name": {"type": "string"},
|
|
41
|
+
"phone": {"type": "string"}
|
|
42
|
+
},
|
|
43
|
+
"required": ["name"] // ❌ Missing "phone" in required
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Correct**:
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"properties": {
|
|
53
|
+
"personal_info": {
|
|
54
|
+
"properties": {
|
|
55
|
+
"name": {"type": "string"},
|
|
56
|
+
"phone": {"type": "string"}
|
|
57
|
+
},
|
|
58
|
+
"required": ["name", "phone"] // ✅ ALL properties listed
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Mandatory Workflow for Schema Creation
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
1. mcp__docrouter__help_schemas() // Read the documentation
|
|
68
|
+
2. mcp__docrouter__validate_schema() // Validate your schema
|
|
69
|
+
3. Fix any validation errors
|
|
70
|
+
4. mcp__docrouter__create_schema() // Only if validation passes
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Mandatory Workflow for Form Creation
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
1. mcp__docrouter__help_forms() // Read the documentation
|
|
77
|
+
2. mcp__docrouter__validate_form() // Validate your form
|
|
78
|
+
3. Fix any validation errors
|
|
79
|
+
4. mcp__docrouter__create_form() // Only if validation passes
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Form Creation Rules
|
|
83
|
+
|
|
84
|
+
**CRITICAL**: Form.io forms in DocRouter require:
|
|
85
|
+
|
|
86
|
+
- **`json_formio` array** - Must contain array of Form.io component definitions
|
|
87
|
+
- **Unique field keys** - Each input field must have a unique `key` property
|
|
88
|
+
- **Valid component types** - Use standard Form.io types (textfield, email, number, select, etc.)
|
|
89
|
+
- **Proper nested structures** - Panels, columns, and fieldsets must have `components` arrays
|
|
90
|
+
- **Field mappings (optional)** - If using `json_formio_mapping`, ensure all references are valid
|
|
91
|
+
|
|
92
|
+
**Wrong** (will fail):
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"json_formio": [
|
|
96
|
+
{
|
|
97
|
+
"type": "textfield",
|
|
98
|
+
"label": "Name"
|
|
99
|
+
// ❌ Missing "key" field
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Correct**:
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"json_formio": [
|
|
109
|
+
{
|
|
110
|
+
"type": "textfield",
|
|
111
|
+
"key": "candidate_name",
|
|
112
|
+
"label": "Candidate Name",
|
|
113
|
+
"input": true,
|
|
114
|
+
"validate": {
|
|
115
|
+
"required": true
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Never Skip Validation
|
|
123
|
+
|
|
124
|
+
**NEVER** call `create_schema`, `create_prompt`, or `create_form` without:
|
|
125
|
+
1. Reading the help documentation first
|
|
126
|
+
2. Validating the schema/form/structure first
|
|
127
|
+
3. Confirming validation succeeded
|
|
128
|
+
|
|
129
|
+
This prevents wasted time and ensures resources are created correctly on the first attempt.
|