insureforge-mcp 0.1.3 → 0.1.5
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/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -3
- package/dist/tools/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -6
- package/src/services/api-client.ts +5 -34
- package/src/tools/index.ts +12 -60
- package/src/types/index.ts +1 -14
package/dist/tools/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare const toolDefinitions: {
|
|
|
81
81
|
};
|
|
82
82
|
readonly export_document: {
|
|
83
83
|
readonly name: "export_document";
|
|
84
|
-
readonly description: "Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters.
|
|
84
|
+
readonly description: "Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Returns a download URL that the user can click to download the document.";
|
|
85
85
|
readonly inputSchema: {
|
|
86
86
|
readonly type: "object";
|
|
87
87
|
readonly properties: {
|
|
@@ -91,7 +91,7 @@ export declare const toolDefinitions: {
|
|
|
91
91
|
};
|
|
92
92
|
readonly exporterName: {
|
|
93
93
|
readonly type: "string";
|
|
94
|
-
readonly description: "
|
|
94
|
+
readonly description: "Exporter name (use English name from list_exporters, e.g., \"product_liability_quotation\", \"application_report\", \"raw_json\")";
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
readonly required: readonly ["jobId", "exporterName"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAqBhE"}
|
package/dist/tools/index.js
CHANGED
|
@@ -77,7 +77,7 @@ export const toolDefinitions = {
|
|
|
77
77
|
},
|
|
78
78
|
export_document: {
|
|
79
79
|
name: 'export_document',
|
|
80
|
-
description: 'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters.
|
|
80
|
+
description: 'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Returns a download URL that the user can click to download the document.',
|
|
81
81
|
inputSchema: {
|
|
82
82
|
type: 'object',
|
|
83
83
|
properties: {
|
|
@@ -87,7 +87,7 @@ export const toolDefinitions = {
|
|
|
87
87
|
},
|
|
88
88
|
exporterName: {
|
|
89
89
|
type: 'string',
|
|
90
|
-
description: '
|
|
90
|
+
description: 'Exporter name (use English name from list_exporters, e.g., "product_liability_quotation", "application_report", "raw_json")',
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
required: ['jobId', 'exporterName'],
|
|
@@ -186,6 +186,7 @@ export class ToolHandlers {
|
|
|
186
186
|
}
|
|
187
187
|
async listExporters(_input) {
|
|
188
188
|
const result = await this.client.listExporters();
|
|
189
|
+
const exporterNames = result.exporters.map((e) => e.name).join(', ');
|
|
189
190
|
return {
|
|
190
191
|
content: [
|
|
191
192
|
{
|
|
@@ -197,7 +198,7 @@ export class ToolHandlers {
|
|
|
197
198
|
displayName: e.display_name,
|
|
198
199
|
format: e.format,
|
|
199
200
|
})),
|
|
200
|
-
message: `Found ${result.exporters.length} available exporter(s). Use
|
|
201
|
+
message: `Found ${result.exporters.length} available exporter(s). IMPORTANT: Use the "name" field (not "displayName") with export_document. Available names: ${exporterNames}`,
|
|
201
202
|
}, null, 2),
|
|
202
203
|
},
|
|
203
204
|
],
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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AAE,IAAI;wBACb,QAAQ,EAAE,KAAK,CAAC,YAAY;wBAC5B,WAAW;wBACX,OAAO,EAAE,4DAA4D,WAAW,EAAE;qBACnF,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
listExportersInput,
|
|
24
24
|
toolDefinitions,
|
|
25
25
|
ToolHandlers,
|
|
26
|
-
uploadFilesInput,
|
|
27
26
|
} from './tools/index.js';
|
|
28
27
|
|
|
29
28
|
// Configuration from environment
|
|
@@ -71,11 +70,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
71
70
|
|
|
72
71
|
try {
|
|
73
72
|
switch (name) {
|
|
74
|
-
case 'upload_files': {
|
|
75
|
-
const input = uploadFilesInput.parse(args);
|
|
76
|
-
return await handlers.uploadFiles(input);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
73
|
case 'create_extraction': {
|
|
80
74
|
const input = createExtractionInput.parse(args);
|
|
81
75
|
return await handlers.createExtraction(input);
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* HTTP client for InsureForge API
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import * as fs from 'fs';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
|
|
8
5
|
import type {
|
|
9
6
|
ApiError,
|
|
10
7
|
ExportersResponse,
|
|
@@ -12,7 +9,6 @@ import type {
|
|
|
12
9
|
InsureForgeConfig,
|
|
13
10
|
JobResponse,
|
|
14
11
|
JobResultResponse,
|
|
15
|
-
UploadResponse,
|
|
16
12
|
} from '../types/index.js';
|
|
17
13
|
|
|
18
14
|
export class InsureForgeApiClient {
|
|
@@ -29,18 +25,14 @@ export class InsureForgeApiClient {
|
|
|
29
25
|
endpoint: string,
|
|
30
26
|
options?: {
|
|
31
27
|
body?: unknown;
|
|
32
|
-
formData?: FormData;
|
|
33
28
|
}
|
|
34
29
|
): Promise<T> {
|
|
35
30
|
const url = `${this.baseUrl}${endpoint}`;
|
|
36
31
|
|
|
37
32
|
const headers: Record<string, string> = {};
|
|
38
|
-
let body: string |
|
|
33
|
+
let body: string | undefined;
|
|
39
34
|
|
|
40
|
-
if (options?.
|
|
41
|
-
body = options.formData;
|
|
42
|
-
// Don't set Content-Type for FormData, let fetch handle it
|
|
43
|
-
} else if (options?.body) {
|
|
35
|
+
if (options?.body) {
|
|
44
36
|
headers['Content-Type'] = 'application/json';
|
|
45
37
|
body = JSON.stringify(options.body);
|
|
46
38
|
}
|
|
@@ -68,32 +60,11 @@ export class InsureForgeApiClient {
|
|
|
68
60
|
}
|
|
69
61
|
|
|
70
62
|
/**
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
async uploadFiles(filePaths: string[]): Promise<UploadResponse> {
|
|
74
|
-
const formData = new FormData();
|
|
75
|
-
|
|
76
|
-
for (const filePath of filePaths) {
|
|
77
|
-
const absolutePath = path.resolve(filePath);
|
|
78
|
-
if (!fs.existsSync(absolutePath)) {
|
|
79
|
-
throw new Error(`File not found: ${absolutePath}`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const fileBuffer = fs.readFileSync(absolutePath);
|
|
83
|
-
const fileName = path.basename(absolutePath);
|
|
84
|
-
const blob = new Blob([fileBuffer]);
|
|
85
|
-
formData.append('files', blob, fileName);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return this.request<UploadResponse>('POST', '/api/v1/upload', { formData });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Create an extraction job
|
|
63
|
+
* Create an extraction job with file objectKeys or URLs
|
|
93
64
|
*/
|
|
94
|
-
async createExtraction(
|
|
65
|
+
async createExtraction(files: string[]): Promise<ExtractResponse> {
|
|
95
66
|
return this.request<ExtractResponse>('POST', '/api/v1/extract', {
|
|
96
|
-
body: {
|
|
67
|
+
body: { files },
|
|
97
68
|
});
|
|
98
69
|
}
|
|
99
70
|
|
package/src/tools/index.ts
CHANGED
|
@@ -7,41 +7,20 @@ import type { InsureForgeApiClient } from '../services/api-client.js';
|
|
|
7
7
|
|
|
8
8
|
// Tool definitions for MCP
|
|
9
9
|
export const toolDefinitions = {
|
|
10
|
-
upload_files: {
|
|
11
|
-
name: 'upload_files',
|
|
12
|
-
description:
|
|
13
|
-
'Upload insurance documents (DOCX, PDF, MSG, images) for data extraction. Returns a group ID that can be used to create an extraction job.',
|
|
14
|
-
inputSchema: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
filePaths: {
|
|
18
|
-
type: 'array',
|
|
19
|
-
items: { type: 'string' },
|
|
20
|
-
description: 'Array of absolute file paths to upload',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
required: ['filePaths'],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
10
|
create_extraction: {
|
|
28
11
|
name: 'create_extraction',
|
|
29
12
|
description:
|
|
30
|
-
'Create an extraction job to process
|
|
13
|
+
'Create an extraction job to process insurance documents. Accepts file objectKeys (from ragent-oss) or download URLs. The extraction runs asynchronously. Use check_status to monitor progress.',
|
|
31
14
|
inputSchema: {
|
|
32
15
|
type: 'object',
|
|
33
16
|
properties: {
|
|
34
|
-
|
|
35
|
-
type: 'string',
|
|
36
|
-
description: 'Upload group ID from upload_files',
|
|
37
|
-
},
|
|
38
|
-
fileIds: {
|
|
17
|
+
files: {
|
|
39
18
|
type: 'array',
|
|
40
19
|
items: { type: 'string' },
|
|
41
|
-
description: '
|
|
20
|
+
description: 'Array of file objectKeys or download URLs to process',
|
|
42
21
|
},
|
|
43
22
|
},
|
|
44
|
-
required: ['
|
|
23
|
+
required: ['files'],
|
|
45
24
|
},
|
|
46
25
|
},
|
|
47
26
|
|
|
@@ -90,7 +69,7 @@ export const toolDefinitions = {
|
|
|
90
69
|
export_document: {
|
|
91
70
|
name: 'export_document',
|
|
92
71
|
description:
|
|
93
|
-
'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters.
|
|
72
|
+
'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Returns a download URL that the user can click to download the document.',
|
|
94
73
|
inputSchema: {
|
|
95
74
|
type: 'object',
|
|
96
75
|
properties: {
|
|
@@ -100,7 +79,8 @@ export const toolDefinitions = {
|
|
|
100
79
|
},
|
|
101
80
|
exporterName: {
|
|
102
81
|
type: 'string',
|
|
103
|
-
description:
|
|
82
|
+
description:
|
|
83
|
+
'Exporter name (use English name from list_exporters, e.g., "product_liability_quotation", "application_report", "raw_json")',
|
|
104
84
|
},
|
|
105
85
|
},
|
|
106
86
|
required: ['jobId', 'exporterName'],
|
|
@@ -109,13 +89,8 @@ export const toolDefinitions = {
|
|
|
109
89
|
} as const;
|
|
110
90
|
|
|
111
91
|
// Input schemas for validation
|
|
112
|
-
export const uploadFilesInput = z.object({
|
|
113
|
-
filePaths: z.array(z.string()),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
92
|
export const createExtractionInput = z.object({
|
|
117
|
-
|
|
118
|
-
fileIds: z.array(z.string()).optional(),
|
|
93
|
+
files: z.array(z.string()).min(1),
|
|
119
94
|
});
|
|
120
95
|
|
|
121
96
|
export const checkStatusInput = z.object({
|
|
@@ -137,33 +112,8 @@ export const exportDocumentInput = z.object({
|
|
|
137
112
|
export class ToolHandlers {
|
|
138
113
|
constructor(private client: InsureForgeApiClient) {}
|
|
139
114
|
|
|
140
|
-
async uploadFiles(input: z.infer<typeof uploadFilesInput>) {
|
|
141
|
-
const result = await this.client.uploadFiles(input.filePaths);
|
|
142
|
-
return {
|
|
143
|
-
content: [
|
|
144
|
-
{
|
|
145
|
-
type: 'text' as const,
|
|
146
|
-
text: JSON.stringify(
|
|
147
|
-
{
|
|
148
|
-
success: true,
|
|
149
|
-
groupId: result.groupId,
|
|
150
|
-
uploadedFiles: result.files.map((f) => ({
|
|
151
|
-
id: f.fileId,
|
|
152
|
-
name: f.fileName,
|
|
153
|
-
size: f.fileSize,
|
|
154
|
-
})),
|
|
155
|
-
message: `Successfully uploaded ${result.files.length} file(s). Use groupId "${result.groupId}" to create an extraction job.`,
|
|
156
|
-
},
|
|
157
|
-
null,
|
|
158
|
-
2
|
|
159
|
-
),
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
115
|
async createExtraction(input: z.infer<typeof createExtractionInput>) {
|
|
166
|
-
const result = await this.client.createExtraction(input.
|
|
116
|
+
const result = await this.client.createExtraction(input.files);
|
|
167
117
|
return {
|
|
168
118
|
content: [
|
|
169
119
|
{
|
|
@@ -195,6 +145,7 @@ export class ToolHandlers {
|
|
|
195
145
|
status: result.status,
|
|
196
146
|
progress: result.progress,
|
|
197
147
|
error: result.error,
|
|
148
|
+
outputKeys: result.outputKeys,
|
|
198
149
|
createdAt: result.createdAt,
|
|
199
150
|
completedAt: result.completedAt,
|
|
200
151
|
},
|
|
@@ -220,6 +171,7 @@ export class ToolHandlers {
|
|
|
220
171
|
|
|
221
172
|
async listExporters(_input: z.infer<typeof listExportersInput>) {
|
|
222
173
|
const result = await this.client.listExporters();
|
|
174
|
+
const exporterNames = result.exporters.map((e) => e.name).join(', ');
|
|
223
175
|
return {
|
|
224
176
|
content: [
|
|
225
177
|
{
|
|
@@ -232,7 +184,7 @@ export class ToolHandlers {
|
|
|
232
184
|
displayName: e.display_name,
|
|
233
185
|
format: e.format,
|
|
234
186
|
})),
|
|
235
|
-
message: `Found ${result.exporters.length} available exporter(s). Use
|
|
187
|
+
message: `Found ${result.exporters.length} available exporter(s). IMPORTANT: Use the "name" field (not "displayName") with export_document. Available names: ${exporterNames}`,
|
|
236
188
|
},
|
|
237
189
|
null,
|
|
238
190
|
2
|
package/src/types/index.ts
CHANGED
|
@@ -2,19 +2,6 @@
|
|
|
2
2
|
* Type definitions for InsureForge MCP Server
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export interface FileInfo {
|
|
6
|
-
fileId: string;
|
|
7
|
-
fileName: string;
|
|
8
|
-
fileSize: number;
|
|
9
|
-
contentType: string | null;
|
|
10
|
-
uploadedAt: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface UploadResponse {
|
|
14
|
-
groupId: string;
|
|
15
|
-
files: FileInfo[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
5
|
export interface ExtractResponse {
|
|
19
6
|
jobId: string;
|
|
20
7
|
status: JobStatus;
|
|
@@ -33,10 +20,10 @@ export interface JobProgress {
|
|
|
33
20
|
|
|
34
21
|
export interface JobResponse {
|
|
35
22
|
jobId: string;
|
|
36
|
-
groupId: string;
|
|
37
23
|
status: JobStatus;
|
|
38
24
|
progress: JobProgress | null;
|
|
39
25
|
error: string | null;
|
|
26
|
+
outputKeys: Record<string, string> | null;
|
|
40
27
|
createdAt: string;
|
|
41
28
|
completedAt: string | null;
|
|
42
29
|
}
|