insureforge-mcp 0.1.2 → 0.1.3
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 +1 -5
- package/dist/index.js.map +1 -1
- package/dist/services/api-client.d.ts +2 -6
- package/dist/services/api-client.d.ts.map +1 -1
- package/dist/services/api-client.js +3 -43
- package/dist/services/api-client.js.map +1 -1
- package/dist/tools/index.d.ts +2 -51
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +5 -63
- 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 +3 -50
- package/src/tools/index.ts +5 -76
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
9
9
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
10
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
11
11
|
import { InsureForgeApiClient } from './services/api-client.js';
|
|
12
|
-
import { checkStatusInput, createExtractionInput,
|
|
12
|
+
import { checkStatusInput, createExtractionInput, exportDocumentInput, getResultInput, listExportersInput, toolDefinitions, ToolHandlers, uploadFilesInput, } from './tools/index.js';
|
|
13
13
|
// Configuration from environment
|
|
14
14
|
const INSUREFORGE_API_URL = process.env.INSUREFORGE_API_URL;
|
|
15
15
|
const INSUREFORGE_TIMEOUT = parseInt(process.env.INSUREFORGE_TIMEOUT || '60000', 10);
|
|
@@ -61,10 +61,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
61
61
|
const input = getResultInput.parse(args);
|
|
62
62
|
return await handlers.getResult(input);
|
|
63
63
|
}
|
|
64
|
-
case 'download_document': {
|
|
65
|
-
const input = downloadDocumentInput.parse(args);
|
|
66
|
-
return await handlers.downloadDocument(input);
|
|
67
|
-
}
|
|
68
64
|
case 'list_exporters': {
|
|
69
65
|
const input = listExportersInput.parse(args);
|
|
70
66
|
return await handlers.listExporters(input);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,iCAAiC;AACjC,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAC5D,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AAErF,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACzB,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;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EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,yBAAyB;IACzB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,iCAAiC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oDAAoD,mBAAmB,EAAE,CAAC,CAAC;QACzF,OAAO,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAC;IACzF,CAAC;IAED,mBAAmB;IACnB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC3D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -23,10 +23,6 @@ export declare class InsureForgeApiClient {
|
|
|
23
23
|
* Get extraction result
|
|
24
24
|
*/
|
|
25
25
|
getJobResult(jobId: string): Promise<JobResultResponse>;
|
|
26
|
-
/**
|
|
27
|
-
* Download result file
|
|
28
|
-
*/
|
|
29
|
-
downloadResult(jobId: string, format?: 'json' | 'docx'): Promise<Buffer>;
|
|
30
26
|
/**
|
|
31
27
|
* Health check
|
|
32
28
|
*/
|
|
@@ -39,8 +35,8 @@ export declare class InsureForgeApiClient {
|
|
|
39
35
|
*/
|
|
40
36
|
listExporters(): Promise<ExportersResponse>;
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
38
|
+
* Get export URL for job result
|
|
43
39
|
*/
|
|
44
|
-
|
|
40
|
+
getExportUrl(jobId: string, exporterName: string): string;
|
|
45
41
|
}
|
|
46
42
|
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/services/api-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAEV,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,iBAAiB;YAKvB,OAAO;IA2CrB;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAkB/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAMrF;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIvD;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI7D;;OAEG;IACG,
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/services/api-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAEV,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,iBAAiB;YAKvB,OAAO;IA2CrB;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAkB/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAMrF;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIvD;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI7D;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAIjE;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAIjD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;CAG1D"}
|
|
@@ -78,29 +78,6 @@ export class InsureForgeApiClient {
|
|
|
78
78
|
async getJobResult(jobId) {
|
|
79
79
|
return this.request('GET', `/api/v1/jobs/${jobId}/result`);
|
|
80
80
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Download result file
|
|
83
|
-
*/
|
|
84
|
-
async downloadResult(jobId, format = 'json') {
|
|
85
|
-
const url = `${this.baseUrl}/api/v1/jobs/${jobId}/download?format=${format}`;
|
|
86
|
-
const controller = new AbortController();
|
|
87
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
88
|
-
try {
|
|
89
|
-
const response = await fetch(url, {
|
|
90
|
-
method: 'GET',
|
|
91
|
-
signal: controller.signal,
|
|
92
|
-
});
|
|
93
|
-
if (!response.ok) {
|
|
94
|
-
const errorData = (await response.json().catch(() => ({})));
|
|
95
|
-
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
96
|
-
}
|
|
97
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
98
|
-
return Buffer.from(arrayBuffer);
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
clearTimeout(timeoutId);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
81
|
/**
|
|
105
82
|
* Health check
|
|
106
83
|
*/
|
|
@@ -114,27 +91,10 @@ export class InsureForgeApiClient {
|
|
|
114
91
|
return this.request('GET', '/api/v1/export/exporters');
|
|
115
92
|
}
|
|
116
93
|
/**
|
|
117
|
-
*
|
|
94
|
+
* Get export URL for job result
|
|
118
95
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const controller = new AbortController();
|
|
122
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
123
|
-
try {
|
|
124
|
-
const response = await fetch(url, {
|
|
125
|
-
method: 'GET',
|
|
126
|
-
signal: controller.signal,
|
|
127
|
-
});
|
|
128
|
-
if (!response.ok) {
|
|
129
|
-
const errorData = (await response.json().catch(() => ({})));
|
|
130
|
-
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
131
|
-
}
|
|
132
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
133
|
-
return Buffer.from(arrayBuffer);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
clearTimeout(timeoutId);
|
|
137
|
-
}
|
|
96
|
+
getExportUrl(jobId, exporterName) {
|
|
97
|
+
return `${this.baseUrl}/api/v1/export/jobs/${jobId}/${exporterName}`;
|
|
138
98
|
}
|
|
139
99
|
}
|
|
140
100
|
//# sourceMappingURL=api-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/services/api-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAY7B,MAAM,OAAO,oBAAoB;IACvB,OAAO,CAAS;IAChB,OAAO,C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initions: {
|
|
|
81
81
|
};
|
|
82
82
|
readonly export_document: {
|
|
83
83
|
readonly name: "export_document";
|
|
84
|
-
readonly description: "
|
|
84
|
+
readonly description: "Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Example exporters: \"product_liability_quotation\" (产品责任保险报价单), \"raw_json\" (原始 JSON 数据). 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: {
|
|
@@ -93,35 +93,8 @@ export declare const toolDefinitions: {
|
|
|
93
93
|
readonly type: "string";
|
|
94
94
|
readonly description: "Name of the exporter to use (e.g., \"product_liability_quotation\", \"raw_json\")";
|
|
95
95
|
};
|
|
96
|
-
readonly outputPath: {
|
|
97
|
-
readonly type: "string";
|
|
98
|
-
readonly description: "Path to save the exported document";
|
|
99
|
-
};
|
|
100
96
|
};
|
|
101
|
-
readonly required: readonly ["jobId", "exporterName"
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
readonly download_document: {
|
|
105
|
-
readonly name: "download_document";
|
|
106
|
-
readonly description: "[DEPRECATED] Use export_document instead. Download the extraction result as a JSON file or generated DOCX document.";
|
|
107
|
-
readonly inputSchema: {
|
|
108
|
-
readonly type: "object";
|
|
109
|
-
readonly properties: {
|
|
110
|
-
readonly jobId: {
|
|
111
|
-
readonly type: "string";
|
|
112
|
-
readonly description: "Job ID from create_extraction";
|
|
113
|
-
};
|
|
114
|
-
readonly format: {
|
|
115
|
-
readonly type: "string";
|
|
116
|
-
readonly enum: readonly ["json", "docx"];
|
|
117
|
-
readonly description: "Output format: json for raw data, docx for generated application form";
|
|
118
|
-
};
|
|
119
|
-
readonly outputPath: {
|
|
120
|
-
readonly type: "string";
|
|
121
|
-
readonly description: "Path to save the downloaded file";
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
readonly required: readonly ["jobId", "format", "outputPath"];
|
|
97
|
+
readonly required: readonly ["jobId", "exporterName"];
|
|
125
98
|
};
|
|
126
99
|
};
|
|
127
100
|
};
|
|
@@ -160,28 +133,12 @@ export declare const listExportersInput: z.ZodObject<{}, "strip", z.ZodTypeAny,
|
|
|
160
133
|
export declare const exportDocumentInput: z.ZodObject<{
|
|
161
134
|
jobId: z.ZodString;
|
|
162
135
|
exporterName: z.ZodString;
|
|
163
|
-
outputPath: z.ZodString;
|
|
164
136
|
}, "strip", z.ZodTypeAny, {
|
|
165
137
|
jobId: string;
|
|
166
138
|
exporterName: string;
|
|
167
|
-
outputPath: string;
|
|
168
139
|
}, {
|
|
169
140
|
jobId: string;
|
|
170
141
|
exporterName: string;
|
|
171
|
-
outputPath: string;
|
|
172
|
-
}>;
|
|
173
|
-
export declare const downloadDocumentInput: z.ZodObject<{
|
|
174
|
-
jobId: z.ZodString;
|
|
175
|
-
format: z.ZodEnum<["json", "docx"]>;
|
|
176
|
-
outputPath: z.ZodString;
|
|
177
|
-
}, "strip", z.ZodTypeAny, {
|
|
178
|
-
jobId: string;
|
|
179
|
-
outputPath: string;
|
|
180
|
-
format: "json" | "docx";
|
|
181
|
-
}, {
|
|
182
|
-
jobId: string;
|
|
183
|
-
outputPath: string;
|
|
184
|
-
format: "json" | "docx";
|
|
185
142
|
}>;
|
|
186
143
|
export declare class ToolHandlers {
|
|
187
144
|
private client;
|
|
@@ -222,11 +179,5 @@ export declare class ToolHandlers {
|
|
|
222
179
|
text: string;
|
|
223
180
|
}[];
|
|
224
181
|
}>;
|
|
225
|
-
downloadDocument(input: z.infer<typeof downloadDocumentInput>): Promise<{
|
|
226
|
-
content: {
|
|
227
|
-
type: "text";
|
|
228
|
-
text: string;
|
|
229
|
-
}[];
|
|
230
|
-
}>;
|
|
231
182
|
}
|
|
232
183
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE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AK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;;;;;;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: '
|
|
80
|
+
description: 'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Example exporters: "product_liability_quotation" (产品责任保险报价单), "raw_json" (原始 JSON 数据). Returns a download URL that the user can click to download the document.',
|
|
81
81
|
inputSchema: {
|
|
82
82
|
type: 'object',
|
|
83
83
|
properties: {
|
|
@@ -89,35 +89,8 @@ export const toolDefinitions = {
|
|
|
89
89
|
type: 'string',
|
|
90
90
|
description: 'Name of the exporter to use (e.g., "product_liability_quotation", "raw_json")',
|
|
91
91
|
},
|
|
92
|
-
outputPath: {
|
|
93
|
-
type: 'string',
|
|
94
|
-
description: 'Path to save the exported document',
|
|
95
|
-
},
|
|
96
92
|
},
|
|
97
|
-
required: ['jobId', 'exporterName'
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
download_document: {
|
|
101
|
-
name: 'download_document',
|
|
102
|
-
description: '[DEPRECATED] Use export_document instead. Download the extraction result as a JSON file or generated DOCX document.',
|
|
103
|
-
inputSchema: {
|
|
104
|
-
type: 'object',
|
|
105
|
-
properties: {
|
|
106
|
-
jobId: {
|
|
107
|
-
type: 'string',
|
|
108
|
-
description: 'Job ID from create_extraction',
|
|
109
|
-
},
|
|
110
|
-
format: {
|
|
111
|
-
type: 'string',
|
|
112
|
-
enum: ['json', 'docx'],
|
|
113
|
-
description: 'Output format: json for raw data, docx for generated application form',
|
|
114
|
-
},
|
|
115
|
-
outputPath: {
|
|
116
|
-
type: 'string',
|
|
117
|
-
description: 'Path to save the downloaded file',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
required: ['jobId', 'format', 'outputPath'],
|
|
93
|
+
required: ['jobId', 'exporterName'],
|
|
121
94
|
},
|
|
122
95
|
},
|
|
123
96
|
};
|
|
@@ -139,12 +112,6 @@ export const listExportersInput = z.object({});
|
|
|
139
112
|
export const exportDocumentInput = z.object({
|
|
140
113
|
jobId: z.string(),
|
|
141
114
|
exporterName: z.string(),
|
|
142
|
-
outputPath: z.string(),
|
|
143
|
-
});
|
|
144
|
-
export const downloadDocumentInput = z.object({
|
|
145
|
-
jobId: z.string(),
|
|
146
|
-
format: z.enum(['json', 'docx']),
|
|
147
|
-
outputPath: z.string(),
|
|
148
115
|
});
|
|
149
116
|
// Tool handlers
|
|
150
117
|
export class ToolHandlers {
|
|
@@ -237,11 +204,7 @@ export class ToolHandlers {
|
|
|
237
204
|
};
|
|
238
205
|
}
|
|
239
206
|
async exportDocument(input) {
|
|
240
|
-
const
|
|
241
|
-
const path = await import('path');
|
|
242
|
-
const buffer = await this.client.exportDocument(input.jobId, input.exporterName);
|
|
243
|
-
const outputPath = path.resolve(input.outputPath);
|
|
244
|
-
fs.writeFileSync(outputPath, buffer);
|
|
207
|
+
const downloadUrl = this.client.getExportUrl(input.jobId, input.exporterName);
|
|
245
208
|
return {
|
|
246
209
|
content: [
|
|
247
210
|
{
|
|
@@ -249,29 +212,8 @@ export class ToolHandlers {
|
|
|
249
212
|
text: JSON.stringify({
|
|
250
213
|
success: true,
|
|
251
214
|
exporter: input.exporterName,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
message: `Successfully exported document using "${input.exporterName}" to ${outputPath}`,
|
|
255
|
-
}, null, 2),
|
|
256
|
-
},
|
|
257
|
-
],
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
async downloadDocument(input) {
|
|
261
|
-
const fs = await import('fs');
|
|
262
|
-
const path = await import('path');
|
|
263
|
-
const buffer = await this.client.downloadResult(input.jobId, input.format);
|
|
264
|
-
const outputPath = path.resolve(input.outputPath);
|
|
265
|
-
fs.writeFileSync(outputPath, buffer);
|
|
266
|
-
return {
|
|
267
|
-
content: [
|
|
268
|
-
{
|
|
269
|
-
type: 'text',
|
|
270
|
-
text: JSON.stringify({
|
|
271
|
-
success: true,
|
|
272
|
-
path: outputPath,
|
|
273
|
-
size: buffer.length,
|
|
274
|
-
message: `Successfully downloaded ${input.format} file to ${outputPath}`,
|
|
215
|
+
downloadUrl,
|
|
216
|
+
message: `Document ready for download. Click the link to download: ${downloadUrl}`,
|
|
275
217
|
}, null, 2),
|
|
276
218
|
},
|
|
277
219
|
],
|
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,CAAC;AAGxB,2BAA2B;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,2IAA2I;QAC7I,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,wCAAwC;iBACtD;aACF;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;IAED,iBAAiB,EAAE;QACjB,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,mIAAmI;QACrI,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,mCAAmC;iBACjD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,+FAA+F;iBAC7G;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IAED,YAAY,EAAE;QACZ,IAA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;aACF;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAA0C;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QAE9E,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,OAAO,EAAE,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
|
@@ -18,7 +18,6 @@ import { InsureForgeApiClient } from './services/api-client.js';
|
|
|
18
18
|
import {
|
|
19
19
|
checkStatusInput,
|
|
20
20
|
createExtractionInput,
|
|
21
|
-
downloadDocumentInput,
|
|
22
21
|
exportDocumentInput,
|
|
23
22
|
getResultInput,
|
|
24
23
|
listExportersInput,
|
|
@@ -92,11 +91,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
92
91
|
return await handlers.getResult(input);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
case 'download_document': {
|
|
96
|
-
const input = downloadDocumentInput.parse(args);
|
|
97
|
-
return await handlers.downloadDocument(input);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
94
|
case 'list_exporters': {
|
|
101
95
|
const input = listExportersInput.parse(args);
|
|
102
96
|
return await handlers.listExporters(input);
|
|
@@ -111,33 +111,6 @@ export class InsureForgeApiClient {
|
|
|
111
111
|
return this.request<JobResultResponse>('GET', `/api/v1/jobs/${jobId}/result`);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
* Download result file
|
|
116
|
-
*/
|
|
117
|
-
async downloadResult(jobId: string, format: 'json' | 'docx' = 'json'): Promise<Buffer> {
|
|
118
|
-
const url = `${this.baseUrl}/api/v1/jobs/${jobId}/download?format=${format}`;
|
|
119
|
-
|
|
120
|
-
const controller = new AbortController();
|
|
121
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const response = await fetch(url, {
|
|
125
|
-
method: 'GET',
|
|
126
|
-
signal: controller.signal,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (!response.ok) {
|
|
130
|
-
const errorData = (await response.json().catch(() => ({}))) as ApiError;
|
|
131
|
-
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
135
|
-
return Buffer.from(arrayBuffer);
|
|
136
|
-
} finally {
|
|
137
|
-
clearTimeout(timeoutId);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
114
|
/**
|
|
142
115
|
* Health check
|
|
143
116
|
*/
|
|
@@ -153,29 +126,9 @@ export class InsureForgeApiClient {
|
|
|
153
126
|
}
|
|
154
127
|
|
|
155
128
|
/**
|
|
156
|
-
*
|
|
129
|
+
* Get export URL for job result
|
|
157
130
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const controller = new AbortController();
|
|
162
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
const response = await fetch(url, {
|
|
166
|
-
method: 'GET',
|
|
167
|
-
signal: controller.signal,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (!response.ok) {
|
|
171
|
-
const errorData = (await response.json().catch(() => ({}))) as ApiError;
|
|
172
|
-
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
176
|
-
return Buffer.from(arrayBuffer);
|
|
177
|
-
} finally {
|
|
178
|
-
clearTimeout(timeoutId);
|
|
179
|
-
}
|
|
131
|
+
getExportUrl(jobId: string, exporterName: string): string {
|
|
132
|
+
return `${this.baseUrl}/api/v1/export/jobs/${jobId}/${exporterName}`;
|
|
180
133
|
}
|
|
181
134
|
}
|
package/src/tools/index.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const toolDefinitions = {
|
|
|
90
90
|
export_document: {
|
|
91
91
|
name: 'export_document',
|
|
92
92
|
description:
|
|
93
|
-
'
|
|
93
|
+
'Get a download link for the extraction result using a specific exporter. Use list_exporters to see available exporters. Example exporters: "product_liability_quotation" (产品责任保险报价单), "raw_json" (原始 JSON 数据). Returns a download URL that the user can click to download the document.',
|
|
94
94
|
inputSchema: {
|
|
95
95
|
type: 'object',
|
|
96
96
|
properties: {
|
|
@@ -102,37 +102,8 @@ export const toolDefinitions = {
|
|
|
102
102
|
type: 'string',
|
|
103
103
|
description: 'Name of the exporter to use (e.g., "product_liability_quotation", "raw_json")',
|
|
104
104
|
},
|
|
105
|
-
outputPath: {
|
|
106
|
-
type: 'string',
|
|
107
|
-
description: 'Path to save the exported document',
|
|
108
|
-
},
|
|
109
105
|
},
|
|
110
|
-
required: ['jobId', 'exporterName'
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
download_document: {
|
|
115
|
-
name: 'download_document',
|
|
116
|
-
description:
|
|
117
|
-
'[DEPRECATED] Use export_document instead. Download the extraction result as a JSON file or generated DOCX document.',
|
|
118
|
-
inputSchema: {
|
|
119
|
-
type: 'object',
|
|
120
|
-
properties: {
|
|
121
|
-
jobId: {
|
|
122
|
-
type: 'string',
|
|
123
|
-
description: 'Job ID from create_extraction',
|
|
124
|
-
},
|
|
125
|
-
format: {
|
|
126
|
-
type: 'string',
|
|
127
|
-
enum: ['json', 'docx'],
|
|
128
|
-
description: 'Output format: json for raw data, docx for generated application form',
|
|
129
|
-
},
|
|
130
|
-
outputPath: {
|
|
131
|
-
type: 'string',
|
|
132
|
-
description: 'Path to save the downloaded file',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
required: ['jobId', 'format', 'outputPath'],
|
|
106
|
+
required: ['jobId', 'exporterName'],
|
|
136
107
|
},
|
|
137
108
|
},
|
|
138
109
|
} as const;
|
|
@@ -160,13 +131,6 @@ export const listExportersInput = z.object({});
|
|
|
160
131
|
export const exportDocumentInput = z.object({
|
|
161
132
|
jobId: z.string(),
|
|
162
133
|
exporterName: z.string(),
|
|
163
|
-
outputPath: z.string(),
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
export const downloadDocumentInput = z.object({
|
|
167
|
-
jobId: z.string(),
|
|
168
|
-
format: z.enum(['json', 'docx']),
|
|
169
|
-
outputPath: z.string(),
|
|
170
134
|
});
|
|
171
135
|
|
|
172
136
|
// Tool handlers
|
|
@@ -279,13 +243,7 @@ export class ToolHandlers {
|
|
|
279
243
|
}
|
|
280
244
|
|
|
281
245
|
async exportDocument(input: z.infer<typeof exportDocumentInput>) {
|
|
282
|
-
const
|
|
283
|
-
const path = await import('path');
|
|
284
|
-
|
|
285
|
-
const buffer = await this.client.exportDocument(input.jobId, input.exporterName);
|
|
286
|
-
const outputPath = path.resolve(input.outputPath);
|
|
287
|
-
|
|
288
|
-
fs.writeFileSync(outputPath, buffer);
|
|
246
|
+
const downloadUrl = this.client.getExportUrl(input.jobId, input.exporterName);
|
|
289
247
|
|
|
290
248
|
return {
|
|
291
249
|
content: [
|
|
@@ -295,37 +253,8 @@ export class ToolHandlers {
|
|
|
295
253
|
{
|
|
296
254
|
success: true,
|
|
297
255
|
exporter: input.exporterName,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
message: `Successfully exported document using "${input.exporterName}" to ${outputPath}`,
|
|
301
|
-
},
|
|
302
|
-
null,
|
|
303
|
-
2
|
|
304
|
-
),
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async downloadDocument(input: z.infer<typeof downloadDocumentInput>) {
|
|
311
|
-
const fs = await import('fs');
|
|
312
|
-
const path = await import('path');
|
|
313
|
-
|
|
314
|
-
const buffer = await this.client.downloadResult(input.jobId, input.format);
|
|
315
|
-
const outputPath = path.resolve(input.outputPath);
|
|
316
|
-
|
|
317
|
-
fs.writeFileSync(outputPath, buffer);
|
|
318
|
-
|
|
319
|
-
return {
|
|
320
|
-
content: [
|
|
321
|
-
{
|
|
322
|
-
type: 'text' as const,
|
|
323
|
-
text: JSON.stringify(
|
|
324
|
-
{
|
|
325
|
-
success: true,
|
|
326
|
-
path: outputPath,
|
|
327
|
-
size: buffer.length,
|
|
328
|
-
message: `Successfully downloaded ${input.format} file to ${outputPath}`,
|
|
256
|
+
downloadUrl,
|
|
257
|
+
message: `Document ready for download. Click the link to download: ${downloadUrl}`,
|
|
329
258
|
},
|
|
330
259
|
null,
|
|
331
260
|
2
|