@getnote/mcp 1.11.0 → 1.11.1
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 +5 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/test/kb-batch.test.mjs +13 -0
package/dist/index.js
CHANGED
|
@@ -1155,11 +1155,15 @@ async function main() {
|
|
|
1155
1155
|
const input = (args ?? {});
|
|
1156
1156
|
try {
|
|
1157
1157
|
const result = await handleTool(name, input, client.withSignal(extra.signal));
|
|
1158
|
+
const batch = result;
|
|
1159
|
+
const rejected = (name === "batch_add_notes_to_topic" || name === "remove_note_from_topic")
|
|
1160
|
+
&& Array.isArray(batch?.failed_note_ids) && batch.failed_note_ids.length > 0;
|
|
1158
1161
|
return {
|
|
1162
|
+
...(rejected ? { isError: true } : {}),
|
|
1159
1163
|
content: [
|
|
1160
1164
|
{
|
|
1161
1165
|
type: "text",
|
|
1162
|
-
text: JSON.stringify(result, null, 2),
|
|
1166
|
+
text: JSON.stringify(rejected ? { ...result, error: true, reason: "knowledge_notes_rejected", retryable: false, message: "Some notes were rejected; inspect failed_note_ids and the actual success count. Do not retry the entire batch." } : result, null, 2),
|
|
1163
1167
|
},
|
|
1164
1168
|
],
|
|
1165
1169
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1187,11 +1187,15 @@ async function main() {
|
|
|
1187
1187
|
|
|
1188
1188
|
try {
|
|
1189
1189
|
const result = await handleTool(name, input, client.withSignal(extra.signal));
|
|
1190
|
+
const batch = result as { failed_note_ids?: unknown[] } | null;
|
|
1191
|
+
const rejected = (name === "batch_add_notes_to_topic" || name === "remove_note_from_topic")
|
|
1192
|
+
&& Array.isArray(batch?.failed_note_ids) && batch.failed_note_ids.length > 0;
|
|
1190
1193
|
return {
|
|
1194
|
+
...(rejected ? { isError: true } : {}),
|
|
1191
1195
|
content: [
|
|
1192
1196
|
{
|
|
1193
1197
|
type: "text" as const,
|
|
1194
|
-
text: JSON.stringify(result, null, 2),
|
|
1198
|
+
text: JSON.stringify(rejected ? { ...result as object, error: true, reason: "knowledge_notes_rejected", retryable: false, message: "Some notes were rejected; inspect failed_note_ids and the actual success count. Do not retry the entire batch." } : result, null, 2),
|
|
1195
1199
|
},
|
|
1196
1200
|
],
|
|
1197
1201
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import test from 'node:test';
|
|
4
|
+
import {Client} from '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
+
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
6
|
+
test('add/remove report partial rejection through actual stdio',async()=>{
|
|
7
|
+
let count=2,failed=[];
|
|
8
|
+
const api=http.createServer(async(req,res)=>{for await(const c of req){};const key=req.url.endsWith('/remove')?'removed_count':'success_count';res.setHeader('Content-Type','application/json');res.end(JSON.stringify({success:true,data:{[key]:count,...(failed===null?{}:{failed_note_ids:failed})}}))});
|
|
9
|
+
await new Promise(r=>api.listen(0,'127.0.0.1',r));
|
|
10
|
+
const client=new Client({name:'test',version:'1'});
|
|
11
|
+
const transport=new StdioClientTransport({command:process.execPath,args:['dist/index.js'],env:{...process.env,GETNOTE_API_KEY:'test',GETNOTE_CLIENT_ID:'test',GETNOTE_API_URL:`http://127.0.0.1:${api.address().port}`},stderr:'pipe'});
|
|
12
|
+
try{await client.connect(transport);for(const name of ['batch_add_notes_to_topic','remove_note_from_topic'])for(const f of [[],['2'],['1','2'],null]){failed=f;count=2-(f?.length??0);const r=await client.callTool({name,arguments:{topic_id:'kb',note_ids:['1','2']}});assert.equal(Boolean(r.isError),Boolean(f?.length));const d=JSON.parse(r.content[0].text);assert.equal(d.success_count??d.removed_count,count);if(f)assert.deepEqual(d.failed_note_ids,f)}}finally{await client.close();api.closeAllConnections();await new Promise(r=>api.close(r))}
|
|
13
|
+
});
|