@adminforth/mcp 1.4.2 → 1.4.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/adminPanelConfirmation.js +2 -1
- package/dist/apiTools.js +2 -1
- package/dist/toolOutput.d.ts +1 -0
- package/dist/toolOutput.js +13 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { MAX_ACTIONS_PER_CONFIRMATION } from './schemas/confirmation.js';
|
|
3
|
+
import { isErrorOutput } from './toolOutput.js';
|
|
3
4
|
import { adminApiPrefix, CONFIRMATION_PAGE_PATH } from './urls.js';
|
|
4
5
|
export const WAIT_FOR_CONFIRMATION_TOOL_NAME = 'wait_for_confirmation';
|
|
5
6
|
const CONFIRMATION_TTL_MS = 10 * 60 * 1000;
|
|
@@ -208,7 +209,7 @@ export class McpAdminPanelConfirmation {
|
|
|
208
209
|
clearTimeout(timer);
|
|
209
210
|
input.abortSignal?.removeEventListener('abort', abort);
|
|
210
211
|
}
|
|
211
|
-
return { output, isError: responseStatus
|
|
212
|
+
return { output, isError: isErrorOutput(responseStatus, output) };
|
|
212
213
|
}
|
|
213
214
|
/** All actions of a group belong to one user and run as one agent, so they can share one verification. */
|
|
214
215
|
openGroup(ids, adminUser) {
|
package/dist/apiTools.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compactInputSchema } from './compactInputSchema.js';
|
|
2
|
+
import { isErrorOutput } from './toolOutput.js';
|
|
2
3
|
import { adminApiPrefix } from './urls.js';
|
|
3
4
|
import { AdminForthDataTypes } from 'adminforth';
|
|
4
5
|
const METHODS_WITHOUT_REQUEST_BODY = new Set(['GET', 'HEAD']);
|
|
@@ -308,7 +309,7 @@ export class AdminForthApiTools {
|
|
|
308
309
|
isError: true,
|
|
309
310
|
};
|
|
310
311
|
}
|
|
311
|
-
const isError = response.status
|
|
312
|
+
const isError = isErrorOutput(response.status, output);
|
|
312
313
|
return {
|
|
313
314
|
output: isError || !override?.project ? output : override.project(output, args, params.arguments ?? {}),
|
|
314
315
|
isError,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isErrorOutput(status: number, output: unknown): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AdminForth core reports a beforeSave hook that returned { ok: false, error: null } with this error.
|
|
2
|
+
// The hook saved the record itself and may point to it with redirectToRecordId; the admin panel treats it as a success.
|
|
3
|
+
const HOOK_ABORT_ERROR = 'Operation aborted by hook';
|
|
4
|
+
export function isErrorOutput(status, output) {
|
|
5
|
+
if (status >= 400)
|
|
6
|
+
return true;
|
|
7
|
+
if (!output || typeof output !== 'object')
|
|
8
|
+
return false;
|
|
9
|
+
const { error, ok } = output;
|
|
10
|
+
if (error === HOOK_ABORT_ERROR)
|
|
11
|
+
return false;
|
|
12
|
+
return 'error' in output || ok === false;
|
|
13
|
+
}
|