@docrouter/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/README.md +207 -0
- package/dist/docs/knowledge_base/forms.md +724 -0
- package/dist/docs/knowledge_base/prompts.md +472 -0
- package/dist/docs/knowledge_base/schemas.md +852 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1812 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1809 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# DocRouter MCP Server (TypeScript)
|
|
2
|
+
|
|
3
|
+
A TypeScript-based Model Context Protocol (MCP) server for DocRouter API integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This MCP server provides AI applications with access to DocRouter's document processing capabilities, including:
|
|
8
|
+
|
|
9
|
+
- Document management and retrieval
|
|
10
|
+
- OCR text extraction
|
|
11
|
+
- AI-powered data extraction using prompts
|
|
12
|
+
- Tag and prompt management
|
|
13
|
+
- Search functionality
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
The server can be configured using environment variables or command line arguments:
|
|
24
|
+
|
|
25
|
+
### Environment Variables
|
|
26
|
+
|
|
27
|
+
- `DOCROUTER_API_URL` - DocRouter API base URL (default: https://app.docrouter.ai/fastapi)
|
|
28
|
+
- `DOCROUTER_ORG_ID` - Your DocRouter organization ID (required)
|
|
29
|
+
- `DOCROUTER_ORG_API_TOKEN` - Your DocRouter organization API token (required)
|
|
30
|
+
|
|
31
|
+
### Command Line Arguments
|
|
32
|
+
|
|
33
|
+
- `--url` - DocRouter API base URL
|
|
34
|
+
- `--org-id` - DocRouter organization ID
|
|
35
|
+
- `--org-token` - DocRouter organization API token
|
|
36
|
+
- `--timeout` - Request timeout in milliseconds (default: 30000)
|
|
37
|
+
- `--retries` - Number of retry attempts (default: 3)
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Running the Server
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Using environment variables
|
|
45
|
+
npm start
|
|
46
|
+
|
|
47
|
+
# Using command line arguments
|
|
48
|
+
npm start -- --org-id your-org-id --org-token your-token
|
|
49
|
+
|
|
50
|
+
# Development mode
|
|
51
|
+
npm run start:dev
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Building
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Available Tools
|
|
61
|
+
|
|
62
|
+
### Document Tools
|
|
63
|
+
- `get_docrouter_documents()` - List all documents
|
|
64
|
+
- `get_docrouter_document(documentId)` - Get document by ID
|
|
65
|
+
- `get_docrouter_document_ocr(documentId)` - Get raw OCR text for a document
|
|
66
|
+
- `get_docrouter_document_ocr_metadata(documentId)` - Get OCR metadata for a document
|
|
67
|
+
- `get_docrouter_extraction(documentId, promptRevId)` - Get extraction results
|
|
68
|
+
|
|
69
|
+
### Tag Tools
|
|
70
|
+
- `get_docrouter_tags()` - List all tags
|
|
71
|
+
- `get_docrouter_tag(tagId)` - Get tag by ID
|
|
72
|
+
|
|
73
|
+
### Prompt Tools
|
|
74
|
+
- `get_docrouter_prompts()` - List all prompts
|
|
75
|
+
- `get_docrouter_prompt(promptRevId)` - Get prompt by ID
|
|
76
|
+
|
|
77
|
+
### Search and Extraction Tools
|
|
78
|
+
- `search_docrouter_documents(query, tagIds)` - Search documents by name
|
|
79
|
+
- `search_docrouter_prompts(query)` - Search prompts by name or content
|
|
80
|
+
- `search_docrouter_tags(query)` - Search tags by name or description
|
|
81
|
+
- `run_docrouter_extraction(documentId, promptRevId, force)` - Run AI extraction on a document
|
|
82
|
+
|
|
83
|
+
### Helper Tools
|
|
84
|
+
- `docrouter_help()` - Get help information about using the DocRouter API
|
|
85
|
+
- `docrouter_document_analysis_guide(documentId)` - Generate a guide to analyze a specific document
|
|
86
|
+
|
|
87
|
+
## Example Workflows
|
|
88
|
+
|
|
89
|
+
### 1. Find and Analyze Documents
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Search for invoice documents
|
|
93
|
+
const documents = await search_docrouter_documents("invoice");
|
|
94
|
+
|
|
95
|
+
// Get OCR text for the first document
|
|
96
|
+
const ocrText = await get_docrouter_document_ocr(documents.documents[0].id);
|
|
97
|
+
|
|
98
|
+
// Find available prompts
|
|
99
|
+
const prompts = await get_docrouter_prompts();
|
|
100
|
+
|
|
101
|
+
// Run extraction with a specific prompt
|
|
102
|
+
const extraction = await run_docrouter_extraction(
|
|
103
|
+
documents.documents[0].id,
|
|
104
|
+
prompts.prompts[0].id
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 2. Document Analysis Guide
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Get a step-by-step guide for analyzing a document
|
|
112
|
+
const guide = await docrouter_document_analysis_guide("document-id");
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Integration with AI Applications
|
|
116
|
+
|
|
117
|
+
### Claude Desktop
|
|
118
|
+
|
|
119
|
+
Add to your `claude_desktop_config.json`:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"docrouter": {
|
|
125
|
+
"command": "node",
|
|
126
|
+
"args": ["/path/to/docrouter-mcp/dist/index.js"],
|
|
127
|
+
"env": {
|
|
128
|
+
"DOCROUTER_ORG_ID": "your-org-id",
|
|
129
|
+
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Cursor
|
|
137
|
+
|
|
138
|
+
Create `.cursor/mcp.json` in your project root:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"mcpServers": {
|
|
143
|
+
"docrouter": {
|
|
144
|
+
"command": "node",
|
|
145
|
+
"args": ["/path/to/docrouter-mcp/dist/index.js"],
|
|
146
|
+
"env": {
|
|
147
|
+
"DOCROUTER_ORG_ID": "your-org-id",
|
|
148
|
+
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Claude Code
|
|
156
|
+
|
|
157
|
+
Create a `.mcp.conf` file in your project root:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"mcpServers": {
|
|
162
|
+
"docrouter": {
|
|
163
|
+
"command": "node",
|
|
164
|
+
"args": ["/path/to/docrouter-mcp/dist/index.js"],
|
|
165
|
+
"env": {
|
|
166
|
+
"DOCROUTER_ORG_ID": "your-org-id",
|
|
167
|
+
"DOCROUTER_ORG_API_TOKEN": "your-token"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
### Prerequisites
|
|
177
|
+
|
|
178
|
+
- Node.js 18+
|
|
179
|
+
- TypeScript 5+
|
|
180
|
+
- Access to DocRouter API
|
|
181
|
+
|
|
182
|
+
### Scripts
|
|
183
|
+
|
|
184
|
+
- `npm run build` - Build the project
|
|
185
|
+
- `npm run dev` - Build in watch mode
|
|
186
|
+
- `npm run start:dev` - Run in development mode
|
|
187
|
+
- `npm run lint` - Run ESLint
|
|
188
|
+
- `npm run type-check` - Run TypeScript type checking
|
|
189
|
+
|
|
190
|
+
### Project Structure
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
src/
|
|
194
|
+
├── index.ts # Main MCP server implementation
|
|
195
|
+
package.json # Package configuration
|
|
196
|
+
tsconfig.json # TypeScript configuration
|
|
197
|
+
tsup.config.ts # Build configuration
|
|
198
|
+
README.md # This file
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Error Handling
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT
|