Skip to content

Commit c73e8ce

Browse files
authored
fix: logging error (#9)
* fix: logging error * fix: logging error
1 parent bd7038f commit c73e8ce

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish Package
33
on:
44
push:
55
tags:
6-
- "*"
6+
- '*'
77

88
jobs:
99
publish:
@@ -18,14 +18,10 @@ jobs:
1818
node-version: '20.x'
1919
registry-url: 'https://registry.npmjs.org'
2020

21-
- name: Install dependencies
22-
run: npm ci
23-
24-
- name: Build
25-
run: npm run build
26-
2721
- name: Publish to NPM
28-
run: npm publish
22+
run: |
23+
npm install
24+
npm run publish
2925
env:
3026
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3127

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ npx -y @vectorize-io/vectorize-mcp-server@latest
3737
}
3838
}
3939
```
40+
4041
## Tools
4142

4243
### Retrieve documents
@@ -78,8 +79,9 @@ Generate a Private Deep Research from your pipeline (see official [API](https://
7879
"query": "Generate a financial status report about the company",
7980
"webSearch": true
8081
}
81-
}
82+
}
8283
```
84+
8385
## Development
8486

8587
```bash

src/index.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ import {
99
} from '@modelcontextprotocol/sdk/types.js';
1010

1111
import dotenv from 'dotenv';
12-
import { Configuration, ExtractionApi, FilesApi, PipelinesApi } from '@vectorize-io/vectorize-client';
12+
import {
13+
Configuration,
14+
ExtractionApi,
15+
FilesApi,
16+
PipelinesApi,
17+
} from '@vectorize-io/vectorize-client';
1318

1419
dotenv.config();
1520

1621
const RETRIEVAL_TOOL: Tool = {
1722
name: 'retrieve',
18-
description: 'Retrieve documents from a Vectorize pipeline.',
23+
description: 'Retrieve documents from the configured pipeline.',
1924
inputSchema: {
2025
type: 'object',
2126
properties: {
@@ -26,16 +31,16 @@ const RETRIEVAL_TOOL: Tool = {
2631
k: {
2732
type: 'number',
2833
description: 'The number of documents to retrieve.',
34+
default: 4,
2935
},
3036
},
31-
required: ['question', 'k']
37+
required: ['question'],
3238
},
3339
};
3440

35-
3641
const DEEP_RESEARCH_TOOL: Tool = {
3742
name: 'deep-research',
38-
description: 'Generate a deep research on a Vectorize pipeline.',
43+
description: 'Generate a deep research on the configured pipeline.',
3944
inputSchema: {
4045
type: 'object',
4146
properties: {
@@ -48,7 +53,7 @@ const DEEP_RESEARCH_TOOL: Tool = {
4853
description: 'Whether to perform a web search.',
4954
},
5055
},
51-
required: ['query', 'webSearch']
56+
required: ['query', 'webSearch'],
5257
},
5358
};
5459

@@ -66,7 +71,6 @@ const EXTRACTION_TOOL: Tool = {
6671
type: 'string',
6772
description: 'Document content type.',
6873
},
69-
7074
},
7175
required: ['base64Document', 'contentType'],
7276
},
@@ -125,7 +129,6 @@ async function performRetrieval(
125129
};
126130
}
127131

128-
129132
async function performExtraction(
130133
orgId: string,
131134
base64Document: string,
@@ -135,17 +138,17 @@ async function performExtraction(
135138
const startResponse = await filesApi.startFileUpload({
136139
organization: orgId,
137140
startFileUploadRequest: {
138-
name: "My File",
139-
contentType
140-
}
141+
name: 'My File',
142+
contentType,
143+
},
141144
});
142145

143146
const fileBuffer = Buffer.from(base64Document, 'base64');
144147
const fetchResponse = await fetch(startResponse.uploadUrl, {
145148
method: 'PUT',
146149
body: fileBuffer,
147150
headers: {
148-
'Content-Type': contentType
151+
'Content-Type': contentType,
149152
},
150153
});
151154
if (!fetchResponse.ok) {
@@ -158,21 +161,21 @@ async function performExtraction(
158161
startExtractionRequest: {
159162
fileId: startResponse.fileId,
160163
chunkSize: 512,
161-
}
162-
})
164+
},
165+
});
163166
const extractionId = response.extractionId;
164167
// eslint-disable-next-line no-constant-condition
165168
while (true) {
166169
const result = await extractionApi.getExtractionResult({
167170
organization: orgId,
168171
extractionId: extractionId,
169-
})
172+
});
170173
if (result.ready) {
171174
if (result.data?.success) {
172175
return {
173176
content: [{ type: 'text', text: JSON.stringify(result.data) }],
174177
isError: false,
175-
}
178+
};
176179
} else {
177180
throw new Error(`Extraction failed: ${result.data?.error}`);
178181
}
@@ -182,8 +185,6 @@ async function performExtraction(
182185
}
183186
}
184187

185-
186-
187188
async function performDeepResearch(
188189
orgId: string,
189190
pipelineId: string,
@@ -196,34 +197,33 @@ async function performDeepResearch(
196197
pipeline: pipelineId,
197198
startDeepResearchRequest: {
198199
query,
199-
webSearch
200-
}
200+
webSearch,
201+
},
201202
});
202203
const researchId = response.researchId;
203204
// eslint-disable-next-line no-constant-condition
204205
while (true) {
205206
const result = await pipelinesApi.getDeepResearchResult({
206207
organization: orgId,
207208
pipeline: pipelineId,
208-
researchId: researchId
209-
})
209+
researchId: researchId,
210+
});
210211
if (result.ready) {
211212
if (result.data?.success) {
212213
return {
213214
content: [{ type: 'text', text: result.data.markdown }],
214215
isError: false,
215-
}
216+
};
216217
} else {
217218
throw new Error(`Deep research failed: ${result.data?.error}`);
218219
}
219-
break
220+
break;
220221
} else {
221222
await new Promise((resolve) => setTimeout(resolve, 1000));
222223
}
223224
}
224225
}
225226

226-
227227
server.setRequestHandler(CallToolRequestSchema, async (request) => {
228228
try {
229229
const { name, arguments: args } = request.params;
@@ -279,7 +279,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
279279
},
280280
});
281281
return {
282-
content: [{ type: 'text', text: JSON.stringify({ error: errorMessage }) }],
282+
content: [
283+
{ type: 'text', text: JSON.stringify({ error: errorMessage }) },
284+
],
283285
isError: true,
284286
};
285287
}
@@ -300,8 +302,6 @@ async function runServer() {
300302
level: 'info',
301303
data: `Configuration: Organization ID: ${VECTORIZE_ORG_ID} with Pipeline ID: ${VECTORIZE_PIPELINE_ID}`,
302304
});
303-
304-
console.info('Vectorize MCP Server running');
305305
}
306306

307307
runServer().catch((error) => {

0 commit comments

Comments
 (0)