@forestadmin/mcp-server 1.3.0 → 1.5.0
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/forest-oauth-provider.d.ts +1 -1
- package/dist/forest-oauth-provider.js +4 -2
- package/dist/server.js +15 -4
- package/dist/tools/create.d.ts +4 -0
- package/dist/tools/create.js +51 -0
- package/dist/tools/delete.d.ts +4 -0
- package/dist/tools/delete.js +47 -0
- package/dist/tools/describe-collection.d.ts +2 -2
- package/dist/tools/describe-collection.js +78 -67
- package/dist/tools/list-related.d.ts +2 -2
- package/dist/tools/list-related.js +58 -101
- package/dist/tools/list.d.ts +1 -1
- package/dist/tools/list.js +47 -86
- package/dist/tools/update.d.ts +4 -0
- package/dist/tools/update.js +55 -0
- package/dist/utils/activity-logs-creator.d.ts +4 -4
- package/dist/utils/activity-logs-creator.js +16 -12
- package/dist/utils/agent-caller.d.ts +2 -2
- package/dist/utils/sse-error-logger.d.ts +1 -1
- package/dist/utils/tool-with-logging.d.ts +2 -2
- package/dist/utils/tool-with-logging.js +2 -1
- package/dist/utils/with-activity-log.d.ts +31 -0
- package/dist/utils/with-activity-log.js +83 -0
- package/package.json +2 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Logger } from '../server';
|
|
2
|
+
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
3
|
+
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { ActivityLogAction } from './activity-logs-creator';
|
|
5
|
+
interface ActivityLogContext {
|
|
6
|
+
collectionName?: string;
|
|
7
|
+
recordId?: string | number;
|
|
8
|
+
recordIds?: string[] | number[];
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
interface WithActivityLogOptions<T> {
|
|
12
|
+
forestServerUrl: string;
|
|
13
|
+
request: RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
14
|
+
action: ActivityLogAction;
|
|
15
|
+
context?: ActivityLogContext;
|
|
16
|
+
logger: Logger;
|
|
17
|
+
operation: () => Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Optional function to enhance error messages before logging and throwing.
|
|
20
|
+
* Receives the parsed error message and the original error.
|
|
21
|
+
* Should return the enhanced error message to use.
|
|
22
|
+
*/
|
|
23
|
+
errorEnhancer?: (parsedMessage: string, originalError: unknown) => Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Wraps an operation with activity log lifecycle management.
|
|
27
|
+
* Creates a pending activity log, executes the operation, and marks it as succeeded or failed.
|
|
28
|
+
*/
|
|
29
|
+
export default function withActivityLog<T>(options: WithActivityLogOptions<T>): Promise<T>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=with-activity-log.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = withActivityLog;
|
|
40
|
+
const activity_logs_creator_1 = __importStar(require("./activity-logs-creator"));
|
|
41
|
+
const error_parser_1 = __importDefault(require("./error-parser"));
|
|
42
|
+
/**
|
|
43
|
+
* Wraps an operation with activity log lifecycle management.
|
|
44
|
+
* Creates a pending activity log, executes the operation, and marks it as succeeded or failed.
|
|
45
|
+
*/
|
|
46
|
+
async function withActivityLog(options) {
|
|
47
|
+
const { forestServerUrl, request, action, context, logger, operation, errorEnhancer } = options;
|
|
48
|
+
// We want to create the activity log before executing the operation
|
|
49
|
+
// If activity log creation fails, we must prevent the execution of the operation
|
|
50
|
+
const activityLog = await (0, activity_logs_creator_1.default)(forestServerUrl, request, action, context);
|
|
51
|
+
try {
|
|
52
|
+
const result = await operation();
|
|
53
|
+
(0, activity_logs_creator_1.markActivityLogAsSucceeded)({
|
|
54
|
+
forestServerUrl,
|
|
55
|
+
request,
|
|
56
|
+
activityLog,
|
|
57
|
+
logger,
|
|
58
|
+
});
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const errorDetail = (0, error_parser_1.default)(error);
|
|
63
|
+
let errorMessage = errorDetail || (error instanceof Error ? error.message : String(error));
|
|
64
|
+
// Apply error enhancer if provided (e.g., to add helpful context about available fields)
|
|
65
|
+
if (errorEnhancer) {
|
|
66
|
+
try {
|
|
67
|
+
errorMessage = await errorEnhancer(errorMessage, error);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// If enhancement fails, use the original parsed message
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
(0, activity_logs_creator_1.markActivityLogAsFailed)({
|
|
74
|
+
forestServerUrl,
|
|
75
|
+
request,
|
|
76
|
+
activityLog,
|
|
77
|
+
errorMessage,
|
|
78
|
+
logger,
|
|
79
|
+
});
|
|
80
|
+
throw new Error(errorMessage);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0aC1hY3Rpdml0eS1sb2cuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2l0aC1hY3Rpdml0eS1sb2cudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFxQ0Esa0NBeUNDO0FBMUVELGlGQUlpQztBQUNqQyxrRUFBNkM7QUF3QjdDOzs7R0FHRztBQUNZLEtBQUssVUFBVSxlQUFlLENBQUksT0FBa0M7SUFDakYsTUFBTSxFQUFFLGVBQWUsRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLGFBQWEsRUFBRSxHQUFHLE9BQU8sQ0FBQztJQUVoRyxvRUFBb0U7SUFDcEUsaUZBQWlGO0lBQ2pGLE1BQU0sV0FBVyxHQUFHLE1BQU0sSUFBQSwrQkFBd0IsRUFBQyxlQUFlLEVBQUUsT0FB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-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Model Context Protocol server for Forest Admin with OAuth authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@types/express": "^5.0.0",
|
|
44
44
|
"@types/node": "^18.11.18",
|
|
45
45
|
"@types/supertest": "^6.0.2",
|
|
46
|
+
"superagent": "^10.2.3",
|
|
46
47
|
"supertest": "^7.1.3",
|
|
47
48
|
"typescript": "^5.0.0"
|
|
48
49
|
}
|