@cplace/mcp-server 1.9.1 → 1.10.6
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/README.md +12 -13
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/app-catalog.js +1 -1
- package/dist/plugins/app-catalog.js.map +1 -1
- package/dist/plugins/application-settings.d.ts.map +1 -1
- package/dist/plugins/application-settings.js +6 -3
- package/dist/plugins/application-settings.js.map +1 -1
- package/dist/plugins/core/widget-specifications/cf.cplace.platform.tableWidget/columns.md +6 -0
- package/dist/plugins/core.d.ts.map +1 -1
- package/dist/plugins/core.js +25 -13
- package/dist/plugins/core.js.map +1 -1
- package/dist/plugins/forms-wizard.js +2 -2
- package/dist/plugins/forms-wizard.js.map +1 -1
- package/dist/plugins/history.d.ts.map +1 -1
- package/dist/plugins/history.js +6 -3
- package/dist/plugins/history.js.map +1 -1
- package/dist/plugins/jobs.js +2 -2
- package/dist/plugins/jobs.js.map +1 -1
- package/dist/plugins/layouts.d.ts.map +1 -1
- package/dist/plugins/layouts.js +17 -8
- package/dist/plugins/layouts.js.map +1 -1
- package/dist/plugins/low-code.d.ts.map +1 -1
- package/dist/plugins/low-code.js +48 -17
- package/dist/plugins/low-code.js.map +1 -1
- package/dist/plugins/project-planning.d.ts.map +1 -1
- package/dist/plugins/project-planning.js +6 -3
- package/dist/plugins/project-planning.js.map +1 -1
- package/dist/plugins/resource-management.d.ts.map +1 -1
- package/dist/plugins/resource-management.js +6 -3
- package/dist/plugins/resource-management.js.map +1 -1
- package/dist/plugins/solution-management.d.ts.map +1 -1
- package/dist/plugins/solution-management.js +6 -3
- package/dist/plugins/solution-management.js.map +1 -1
- package/dist/plugins/types-write.d.ts.map +1 -1
- package/dist/plugins/types-write.js +6 -3
- package/dist/plugins/types-write.js.map +1 -1
- package/dist/plugins/widget-specifications.d.ts.map +1 -1
- package/dist/plugins/widget-specifications.js +2 -2
- package/dist/plugins/widget-specifications.js.map +1 -1
- package/dist/plugins/workspace-admin.d.ts.map +1 -1
- package/dist/plugins/workspace-admin.js +6 -3
- package/dist/plugins/workspace-admin.js.map +1 -1
- package/dist/str-replace-utils.js +1 -1
- package/dist/str-replace-utils.js.map +1 -1
- package/dist/tools/apps-catalog.d.ts +1 -1
- package/dist/tools/apps-catalog.d.ts.map +1 -1
- package/dist/tools/apps-catalog.js +16 -12
- package/dist/tools/apps-catalog.js.map +1 -1
- package/dist/tools/board-widget.d.ts +2 -2
- package/dist/tools/board-widget.d.ts.map +1 -1
- package/dist/tools/board-widget.js +354 -201
- package/dist/tools/board-widget.js.map +1 -1
- package/dist/tools/change-listeners.d.ts +2 -2
- package/dist/tools/change-listeners.d.ts.map +1 -1
- package/dist/tools/change-listeners.js +125 -57
- package/dist/tools/change-listeners.js.map +1 -1
- package/dist/tools/common-schemas.d.ts +1 -1
- package/dist/tools/common-schemas.d.ts.map +1 -1
- package/dist/tools/common-schemas.js +5 -3
- package/dist/tools/common-schemas.js.map +1 -1
- package/dist/tools/csv-export.d.ts +2 -2
- package/dist/tools/csv-export.d.ts.map +1 -1
- package/dist/tools/csv-export.js +29 -24
- package/dist/tools/csv-export.js.map +1 -1
- package/dist/tools/documents.d.ts +2 -2
- package/dist/tools/documents.d.ts.map +1 -1
- package/dist/tools/documents.js +34 -14
- package/dist/tools/documents.js.map +1 -1
- package/dist/tools/expert-settings.d.ts +3 -3
- package/dist/tools/expert-settings.d.ts.map +1 -1
- package/dist/tools/expert-settings.js +97 -38
- package/dist/tools/expert-settings.js.map +1 -1
- package/dist/tools/get-operations.d.ts +2 -2
- package/dist/tools/get-operations.d.ts.map +1 -1
- package/dist/tools/get-operations.js +29 -21
- package/dist/tools/get-operations.js.map +1 -1
- package/dist/tools/job-schedule-trigger.d.ts +2 -2
- package/dist/tools/job-schedule-trigger.d.ts.map +1 -1
- package/dist/tools/job-schedule-trigger.js +19 -10
- package/dist/tools/job-schedule-trigger.js.map +1 -1
- package/dist/tools/job-scripts.d.ts +2 -2
- package/dist/tools/job-scripts.d.ts.map +1 -1
- package/dist/tools/job-scripts.js +119 -55
- package/dist/tools/job-scripts.js.map +1 -1
- package/dist/tools/jobs.d.ts +2 -2
- package/dist/tools/jobs.d.ts.map +1 -1
- package/dist/tools/jobs.js +68 -38
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/layout-richstring-shared.d.ts +24 -1
- package/dist/tools/layout-richstring-shared.d.ts.map +1 -1
- package/dist/tools/layout-richstring-shared.js +99 -1
- package/dist/tools/layout-richstring-shared.js.map +1 -1
- package/dist/tools/layout-richstring-widgets.d.ts +94 -2
- package/dist/tools/layout-richstring-widgets.d.ts.map +1 -1
- package/dist/tools/layout-richstring-widgets.js +247 -25
- package/dist/tools/layout-richstring-widgets.js.map +1 -1
- package/dist/tools/layout.d.ts +5 -4
- package/dist/tools/layout.d.ts.map +1 -1
- package/dist/tools/layout.js +235 -124
- package/dist/tools/layout.js.map +1 -1
- package/dist/tools/linting.d.ts +2 -2
- package/dist/tools/linting.d.ts.map +1 -1
- package/dist/tools/linting.js +5 -5
- package/dist/tools/linting.js.map +1 -1
- package/dist/tools/page-action-simulation.d.ts +18 -0
- package/dist/tools/page-action-simulation.d.ts.map +1 -0
- package/dist/tools/page-action-simulation.js +88 -0
- package/dist/tools/page-action-simulation.js.map +1 -0
- package/dist/tools/page-actions.d.ts +60 -0
- package/dist/tools/page-actions.d.ts.map +1 -0
- package/dist/tools/page-actions.js +284 -0
- package/dist/tools/page-actions.js.map +1 -0
- package/dist/tools/pages.d.ts +3 -3
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +237 -112
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/ppt-export-schemas.d.ts +1 -1
- package/dist/tools/ppt-export-schemas.d.ts.map +1 -1
- package/dist/tools/ppt-export-schemas.js +269 -122
- package/dist/tools/ppt-export-schemas.js.map +1 -1
- package/dist/tools/ppt-export.d.ts +2 -2
- package/dist/tools/ppt-export.d.ts.map +1 -1
- package/dist/tools/ppt-export.js +82 -43
- package/dist/tools/ppt-export.js.map +1 -1
- package/dist/tools/profile-management.d.ts +2 -2
- package/dist/tools/profile-management.d.ts.map +1 -1
- package/dist/tools/profile-management.js +109 -82
- package/dist/tools/profile-management.js.map +1 -1
- package/dist/tools/references.d.ts +2 -2
- package/dist/tools/references.d.ts.map +1 -1
- package/dist/tools/references.js +36 -24
- package/dist/tools/references.js.map +1 -1
- package/dist/tools/resource-planner-widget.d.ts +2 -2
- package/dist/tools/resource-planner-widget.d.ts.map +1 -1
- package/dist/tools/resource-planner-widget.js +334 -138
- package/dist/tools/resource-planner-widget.js.map +1 -1
- package/dist/tools/richstring-marker-resolver.d.ts +16 -0
- package/dist/tools/richstring-marker-resolver.d.ts.map +1 -0
- package/dist/tools/richstring-marker-resolver.js +47 -0
- package/dist/tools/richstring-marker-resolver.js.map +1 -0
- package/dist/tools/richstring-widgets.d.ts +6 -16
- package/dist/tools/richstring-widgets.d.ts.map +1 -1
- package/dist/tools/richstring-widgets.js +184 -129
- package/dist/tools/richstring-widgets.js.map +1 -1
- package/dist/tools/schedule.d.ts +2 -2
- package/dist/tools/schedule.d.ts.map +1 -1
- package/dist/tools/schedule.js +23 -14
- package/dist/tools/schedule.js.map +1 -1
- package/dist/tools/script-logs.d.ts +2 -2
- package/dist/tools/script-logs.d.ts.map +1 -1
- package/dist/tools/script-logs.js +71 -32
- package/dist/tools/script-logs.js.map +1 -1
- package/dist/tools/script.d.ts +2 -2
- package/dist/tools/script.d.ts.map +1 -1
- package/dist/tools/script.js +44 -26
- package/dist/tools/script.js.map +1 -1
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +139 -102
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/solution-packages.d.ts +2 -2
- package/dist/tools/solution-packages.d.ts.map +1 -1
- package/dist/tools/solution-packages.js +149 -61
- package/dist/tools/solution-packages.js.map +1 -1
- package/dist/tools/system.d.ts +2 -2
- package/dist/tools/system.d.ts.map +1 -1
- package/dist/tools/system.js +43 -21
- package/dist/tools/system.js.map +1 -1
- package/dist/tools/type-layouts.d.ts +2 -2
- package/dist/tools/type-layouts.d.ts.map +1 -1
- package/dist/tools/type-layouts.js +67 -31
- package/dist/tools/type-layouts.js.map +1 -1
- package/dist/tools/type-management.d.ts +86 -70
- package/dist/tools/type-management.d.ts.map +1 -1
- package/dist/tools/type-management.js +407 -138
- package/dist/tools/type-management.js.map +1 -1
- package/dist/tools/url-resolution.d.ts +2 -2
- package/dist/tools/url-resolution.d.ts.map +1 -1
- package/dist/tools/url-resolution.js +16 -12
- package/dist/tools/url-resolution.js.map +1 -1
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +24 -14
- package/dist/tools/users.js.map +1 -1
- package/dist/tools/validators.d.ts +2 -2
- package/dist/tools/validators.d.ts.map +1 -1
- package/dist/tools/validators.js +68 -35
- package/dist/tools/validators.js.map +1 -1
- package/dist/tools/version-check.d.ts +2 -2
- package/dist/tools/version-check.d.ts.map +1 -1
- package/dist/tools/version-check.js +36 -30
- package/dist/tools/version-check.js.map +1 -1
- package/dist/tools/version-history.d.ts +2 -2
- package/dist/tools/version-history.d.ts.map +1 -1
- package/dist/tools/version-history.js +72 -41
- package/dist/tools/version-history.js.map +1 -1
- package/dist/tools/widget-simulation.d.ts +5 -6
- package/dist/tools/widget-simulation.d.ts.map +1 -1
- package/dist/tools/widget-simulation.js +60 -42
- package/dist/tools/widget-simulation.js.map +1 -1
- package/dist/tools/widget-tool-helpers.d.ts +17 -1
- package/dist/tools/widget-tool-helpers.d.ts.map +1 -1
- package/dist/tools/widget-tool-helpers.js +41 -6
- package/dist/tools/widget-tool-helpers.js.map +1 -1
- package/dist/tools/widgets.d.ts +2 -2
- package/dist/tools/widgets.d.ts.map +1 -1
- package/dist/tools/widgets.js +62 -43
- package/dist/tools/widgets.js.map +1 -1
- package/dist/tools/wizards.d.ts +2 -2
- package/dist/tools/wizards.d.ts.map +1 -1
- package/dist/tools/wizards.js +378 -182
- package/dist/tools/wizards.js.map +1 -1
- package/dist/tools/workflow-execution.d.ts +2 -2
- package/dist/tools/workflow-execution.d.ts.map +1 -1
- package/dist/tools/workflow-execution.js +27 -19
- package/dist/tools/workflow-execution.js.map +1 -1
- package/dist/tools/workflow-scripts.d.ts +2 -2
- package/dist/tools/workflow-scripts.d.ts.map +1 -1
- package/dist/tools/workflow-scripts.js +168 -81
- package/dist/tools/workflow-scripts.js.map +1 -1
- package/dist/tools/workflow.d.ts +2 -2
- package/dist/tools/workflow.d.ts.map +1 -1
- package/dist/tools/workflow.js +185 -74
- package/dist/tools/workflow.js.map +1 -1
- package/dist/tools/workspace-admin.d.ts +2 -2
- package/dist/tools/workspace-admin.d.ts.map +1 -1
- package/dist/tools/workspace-admin.js +82 -40
- package/dist/tools/workspace-admin.js.map +1 -1
- package/dist/tools/workspace-core.d.ts +2 -2
- package/dist/tools/workspace-core.d.ts.map +1 -1
- package/dist/tools/workspace-core.js +93 -53
- package/dist/tools/workspace-core.js.map +1 -1
- package/dist/utils/dateValidation.js.map +1 -1
- package/package.json +9 -4
package/dist/tools/csv-export.js
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import SearchFilterSchema from
|
|
3
|
-
import { convertSearchFilterToCplaceFormat } from
|
|
4
|
-
import { debugLogWithTag } from
|
|
5
|
-
import { convertPagesToCsv } from
|
|
6
|
-
import { jsonStringToArray, coerceNumber } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import SearchFilterSchema from '../searchSchema.js';
|
|
3
|
+
import { convertSearchFilterToCplaceFormat } from '../searchConversion.js';
|
|
4
|
+
import { debugLogWithTag } from '../logger.js';
|
|
5
|
+
import { convertPagesToCsv } from '../csvUtils.js';
|
|
6
|
+
import { jsonStringToArray, coerceNumber } from './common-schemas.js';
|
|
7
7
|
const TOOL_SEARCH_PAGES_CSV = 'cplace_search_pages_csv';
|
|
8
8
|
export const CSV_EXPORT_TOOL_DEFINITIONS = {
|
|
9
9
|
[TOOL_SEARCH_PAGES_CSV]: {
|
|
10
|
-
description:
|
|
10
|
+
description: 'Same as cplace_search_pages but returns results in CSV format instead of JSON. Only use this tool after first calling cplace_search_pages to establish and validate the search parameters. The CSV result should always be stored as an artifact.\n\nIMPORTANT: Date filter values must use date-only format (YYYY-MM-DD). Datetime formats are not supported. See cplace_search_pages for full details.\n\nNote: Embedded widget tags (`<decoded-widget>`) are stripped from CSV output — only surrounding text is preserved.',
|
|
11
11
|
inputSchema: {
|
|
12
|
-
workspaceId: z.string().optional().describe(
|
|
13
|
-
typeInternalName: z.string().describe(
|
|
14
|
-
searchFilter: jsonStringToArray(z.union([SearchFilterSchema, z.string()])).describe(
|
|
15
|
-
limit: coerceNumber(z.number().min(1).max(1000).default(50)).describe(
|
|
16
|
-
offset: coerceNumber(z.number().min(0).max(10000).default(0)).describe(
|
|
17
|
-
attributes: z.array(z.string()).optional().describe(
|
|
12
|
+
workspaceId: z.string().optional().describe('Same as cplace_search_pages'),
|
|
13
|
+
typeInternalName: z.string().describe('Same as cplace_search_pages'),
|
|
14
|
+
searchFilter: jsonStringToArray(z.union([SearchFilterSchema, z.string()])).describe('Same as cplace_search_pages'),
|
|
15
|
+
limit: coerceNumber(z.number().min(1).max(1000).default(50)).describe('Same as cplace_search_pages'),
|
|
16
|
+
offset: coerceNumber(z.number().min(0).max(10000).default(0)).describe('Same as cplace_search_pages'),
|
|
17
|
+
attributes: z.array(z.string()).optional().describe('Same as cplace_search_pages'),
|
|
18
18
|
},
|
|
19
|
-
annotations: { title:
|
|
20
|
-
}
|
|
19
|
+
annotations: { title: 'Search Pages (CSV Export)' },
|
|
20
|
+
},
|
|
21
21
|
};
|
|
22
22
|
export function registerCsvExportTools(server, client) {
|
|
23
|
-
server.registerTool(TOOL_SEARCH_PAGES_CSV, CSV_EXPORT_TOOL_DEFINITIONS[TOOL_SEARCH_PAGES_CSV], async ({ workspaceId, typeInternalName, searchFilter, limit = 50, offset = 0, attributes
|
|
23
|
+
server.registerTool(TOOL_SEARCH_PAGES_CSV, CSV_EXPORT_TOOL_DEFINITIONS[TOOL_SEARCH_PAGES_CSV], async ({ workspaceId, typeInternalName, searchFilter, limit = 50, offset = 0, attributes }) => {
|
|
24
24
|
debugLogWithTag('CSV_SEARCH', `Starting CSV search with params: workspaceId=${workspaceId || 'none'}, type=${typeInternalName}, filter=${JSON.stringify(searchFilter)}, limit=${limit}, offset=${offset}`);
|
|
25
25
|
try {
|
|
26
26
|
const cplaceFilter = convertSearchFilterToCplaceFormat(searchFilter);
|
|
27
27
|
debugLogWithTag('CSV_SEARCH', `Converted filter: ${JSON.stringify(cplaceFilter)}`);
|
|
28
28
|
if (workspaceId) {
|
|
29
29
|
cplaceFilter.filters.unshift({
|
|
30
|
-
type:
|
|
31
|
-
workspaceIds: [workspaceId]
|
|
30
|
+
type: 'Workspace',
|
|
31
|
+
workspaceIds: [workspaceId],
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
if (typeInternalName) {
|
|
35
35
|
cplaceFilter.filters.unshift({
|
|
36
|
-
type:
|
|
37
|
-
types: [typeInternalName]
|
|
36
|
+
type: 'Type',
|
|
37
|
+
types: [typeInternalName],
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
debugLogWithTag('CSV_SEARCH', `Final cplace filter: ${JSON.stringify(cplaceFilter)}`);
|
|
41
41
|
const result = await client.makeApiRequest('json/search', 'GET', {
|
|
42
42
|
filter: JSON.stringify(cplaceFilter),
|
|
43
43
|
limit,
|
|
44
|
-
offset
|
|
44
|
+
offset,
|
|
45
45
|
});
|
|
46
46
|
const searchResults = result.results || [];
|
|
47
47
|
debugLogWithTag('CSV_SEARCH', `Retrieved ${searchResults.length} results for CSV conversion`);
|
|
48
48
|
const csvContent = await convertPagesToCsv(searchResults, client, attributes);
|
|
49
49
|
return {
|
|
50
|
-
content: [{ type:
|
|
50
|
+
content: [{ type: 'text', text: csvContent }],
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
54
54
|
debugLogWithTag('CSV_SEARCH', `Error during CSV search: ${error instanceof Error ? error.message : String(error)}`);
|
|
55
55
|
return {
|
|
56
|
-
content: [
|
|
57
|
-
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: 'text',
|
|
59
|
+
text: `Error converting or executing CSV search: ${error instanceof Error ? error.message : String(error)}`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
isError: true,
|
|
58
63
|
};
|
|
59
64
|
}
|
|
60
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv-export.js","sourceRoot":"","sources":["../../src/tools/csv-export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,kBAAkB,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGtE,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAGxD,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,CAAC,qBAAqB,CAAC,EAAE;QACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"csv-export.js","sourceRoot":"","sources":["../../src/tools/csv-export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,kBAAkB,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAA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AC/D,CAAC;YAGF,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAE9E,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;aAC9C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CACb,YAAY,EACZ,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrF,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,6CAA6C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAC5G;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { CplaceApiClient } from '../api.js';
|
|
4
4
|
export declare const DOCUMENT_TOOL_DEFINITIONS: {
|
|
5
5
|
readonly cplace_get_document: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAQ5C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAQ5C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CA2B5B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAqE/E"}
|
package/dist/tools/documents.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { debugLogWithTag } from
|
|
3
|
-
import { checkResponseSize } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { debugLogWithTag } from '../logger.js';
|
|
3
|
+
import { checkResponseSize } from '../utils.js';
|
|
4
4
|
const TOOL_GET_DOCUMENT = 'cplace_get_document';
|
|
5
5
|
export const DOCUMENT_TOOL_DEFINITIONS = {
|
|
6
6
|
[TOOL_GET_DOCUMENT]: {
|
|
7
|
-
description:
|
|
7
|
+
description: 'Get document details including fulltext content. Retrieves metadata and extracted text for a document by its UID. Document UIDs are found in page responses (documents array). Supports reading large documents in chunks via fulltextOffset and fulltextMaxLength parameters.',
|
|
8
8
|
inputSchema: {
|
|
9
|
-
documentUID: z
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
documentUID: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe("The unique identifier of the document (e.g., 'document/abc123'). Found in the documents array of page responses. (parameter name is `documentUID`, NOT `uid`)"),
|
|
12
|
+
fulltextOffset: z
|
|
13
|
+
.number()
|
|
14
|
+
.min(0)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Character position to start reading fulltext from (default: 0). Use with fulltextMaxLength to read large documents in chunks.'),
|
|
17
|
+
fulltextMaxLength: z
|
|
18
|
+
.number()
|
|
19
|
+
.min(0)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Maximum number of fulltext characters to return (default: 40000). Set to 0 to exclude fulltext entirely and return metadata only.'),
|
|
12
22
|
},
|
|
13
|
-
annotations: { title:
|
|
14
|
-
}
|
|
23
|
+
annotations: { title: 'Get Document' },
|
|
24
|
+
},
|
|
15
25
|
};
|
|
16
26
|
export function registerDocumentTools(server, client) {
|
|
17
27
|
server.registerTool(TOOL_GET_DOCUMENT, DOCUMENT_TOOL_DEFINITIONS[TOOL_GET_DOCUMENT], async ({ documentUID, fulltextOffset, fulltextMaxLength }) => {
|
|
@@ -38,20 +48,30 @@ export function registerDocumentTools(server, client) {
|
|
|
38
48
|
const sizeCheck = checkResponseSize(result);
|
|
39
49
|
if (sizeCheck.tooLarge) {
|
|
40
50
|
return {
|
|
41
|
-
content: [
|
|
42
|
-
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: `Response too large (${sizeCheck.actualSize} characters, max: 45000). Try reducing fulltextMaxLength (current: ${maxLength}) or set fulltextMaxLength to 0 to retrieve metadata only.`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: true,
|
|
43
58
|
};
|
|
44
59
|
}
|
|
45
60
|
debugLogWithTag('DOCUMENTS', `Successfully retrieved document: ${documentUID}`);
|
|
46
61
|
return {
|
|
47
|
-
content: [{ type:
|
|
62
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
48
63
|
};
|
|
49
64
|
}
|
|
50
65
|
catch (error) {
|
|
51
66
|
debugLogWithTag('DOCUMENTS', `Error getting document: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
67
|
return {
|
|
53
|
-
content: [
|
|
54
|
-
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: 'text',
|
|
71
|
+
text: `Error retrieving document: ${error instanceof Error ? error.message : String(error)}`,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
isError: true,
|
|
55
75
|
};
|
|
56
76
|
}
|
|
57
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAGhD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,CAAC,iBAAiB,CAAC,EAAE;QACnB,WAAW,
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAGhD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,CAAC,iBAAiB,CAAC,EAAE;QACnB,WAAW,EACT,gRAAgR;QAClR,WAAW,EAAE;YACX,WAAW,EAAE,CAAC;iBACX,MAAM,EAAE;iBACR,QAAQ,CACP,+JAA+J,CAChK;YACH,cAAc,EAAE,CAAC;iBACd,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CACP,+HAA+H,CAChI;YACH,iBAAiB,EAAE,CAAC;iBACjB,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CACP,mIAAmI,CACpI;SACJ;QACD,WAAW,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;KACvC;CACO,CAAC;AAEX,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAA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AM,CAAC,CAAC;YAC5C,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACvB,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,uBAAuB,SAAS,CAAC,UAAU,sEAAsE,SAAS,4DAA4D;yBAC7L;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YAED,eAAe,CAAC,WAAW,EAAE,oCAAoC,WAAW,EAAE,CAAC,CAAC;YAEhF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACnE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CACb,WAAW,EACX,2BAA2B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACpF,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAC7F;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { CplaceApiClient } from '../api.js';
|
|
4
4
|
export declare const EXPERT_SETTINGS_TOOL_DEFINITIONS: {
|
|
5
5
|
readonly cplace_get_expert_settings: {
|
|
@@ -22,7 +22,7 @@ export declare const EXPERT_SETTINGS_TOOL_DEFINITIONS: {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
readonly cplace_edit_expert_settings: {
|
|
25
|
-
readonly description: "Surgically edit a single expert settings field using str_replace. Finds and replaces exact text within the specified field (LESS, SCSS, CSS, or JavaScript). More token-efficient than full replacement for small changes in large stylesheets or scripts. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.";
|
|
25
|
+
readonly description: "Surgically edit a single expert settings field using str_replace. Finds and replaces exact text within the specified field (LESS, SCSS, CSS, or JavaScript). More token-efficient than full replacement for small changes in large stylesheets or scripts. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.\n\nIMPORTANT: cplace normalizes HTML/CSS on every save (CSS properties are alphabetized, hex colors become rgb(), whitespace is regularized). After this tool completes, the stored content may differ from what was submitted. The response includes the current stored form — use it (not your original input) when constructing the next old_str.";
|
|
26
26
|
readonly inputSchema: {
|
|
27
27
|
readonly field: z.ZodEnum<["less", "scss", "css", "javascript"]>;
|
|
28
28
|
readonly old_str: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expert-settings.d.ts","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAW5C,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"expert-settings.d.ts","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAW5C,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDnC,CAAC;AAEX,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QA2MrF"}
|
|
@@ -1,36 +1,55 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { debugLogWithTag } from
|
|
3
|
-
import { checkResponseSize } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { debugLogWithTag } from '../logger.js';
|
|
3
|
+
import { checkResponseSize } from '../utils.js';
|
|
4
4
|
import { applyStrReplace } from '../str-replace-utils.js';
|
|
5
5
|
const TOOL_GET_EXPERT_SETTINGS = 'cplace_get_expert_settings';
|
|
6
6
|
const TOOL_UPDATE_EXPERT_SETTINGS = 'cplace_update_expert_settings';
|
|
7
7
|
const TOOL_EDIT_EXPERT_SETTINGS = 'cplace_edit_expert_settings';
|
|
8
8
|
export const EXPERT_SETTINGS_TOOL_DEFINITIONS = {
|
|
9
9
|
[TOOL_GET_EXPERT_SETTINGS]: {
|
|
10
|
-
description:
|
|
10
|
+
description: 'Retrieves all tenant-wide expert settings for theming: LESS variables, SCSS variables, custom CSS, and custom JavaScript. Also returns whether JavaScript editing is enabled on the server. Requires administrator privileges.',
|
|
11
11
|
inputSchema: {},
|
|
12
|
-
annotations: { title:
|
|
12
|
+
annotations: { title: 'Get Expert Settings' },
|
|
13
13
|
},
|
|
14
14
|
[TOOL_UPDATE_EXPERT_SETTINGS]: {
|
|
15
|
-
description:
|
|
15
|
+
description: 'Updates one or more tenant-wide expert settings (LESS, SCSS, CSS, JavaScript). Only provided fields are updated; omitted fields remain unchanged. Send an empty string to clear a setting. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.',
|
|
16
16
|
inputSchema: {
|
|
17
|
-
less: z
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
less: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Custom LESS variables content. Updating triggers async CSS compilation.'),
|
|
21
|
+
scss: z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Custom SCSS variables content. Updating triggers async CSS compilation.'),
|
|
25
|
+
css: z
|
|
26
|
+
.string()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Custom CSS content. Takes effect immediately (no compilation).'),
|
|
29
|
+
javascript: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Custom JavaScript content. Requires server-side JavaScript editing to be enabled. Updates will be rejected if disabled.'),
|
|
21
33
|
},
|
|
22
|
-
annotations: { title:
|
|
34
|
+
annotations: { title: 'Update Expert Settings' },
|
|
23
35
|
},
|
|
24
36
|
[TOOL_EDIT_EXPERT_SETTINGS]: {
|
|
25
|
-
description:
|
|
37
|
+
description: 'Surgically edit a single expert settings field using str_replace. Finds and replaces exact text within the specified field (LESS, SCSS, CSS, or JavaScript). More token-efficient than full replacement for small changes in large stylesheets or scripts. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.\n\nIMPORTANT: cplace normalizes HTML/CSS on every save (CSS properties are alphabetized, hex colors become rgb(), whitespace is regularized). After this tool completes, the stored content may differ from what was submitted. The response includes the current stored form — use it (not your original input) when constructing the next old_str.',
|
|
26
38
|
inputSchema: {
|
|
27
|
-
field: z
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
field: z
|
|
40
|
+
.enum(['less', 'scss', 'css', 'javascript'])
|
|
41
|
+
.describe("The expert settings field to edit. 'javascript' requires server-side JavaScript editing to be enabled."),
|
|
42
|
+
old_str: z
|
|
43
|
+
.string()
|
|
44
|
+
.describe('The exact string to find in the field content. Must match exactly including whitespace and line breaks.'),
|
|
45
|
+
new_str: z.string().describe('The replacement string.'),
|
|
46
|
+
replace_all: z
|
|
47
|
+
.boolean()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('If true, replace all occurrences. If false (default), requires exactly one match.'),
|
|
31
50
|
},
|
|
32
|
-
annotations: { title:
|
|
33
|
-
}
|
|
51
|
+
annotations: { title: 'Edit Expert Settings' },
|
|
52
|
+
},
|
|
34
53
|
};
|
|
35
54
|
export function registerExpertSettingsTools(server, client) {
|
|
36
55
|
server.registerTool(TOOL_GET_EXPERT_SETTINGS, EXPERT_SETTINGS_TOOL_DEFINITIONS[TOOL_GET_EXPERT_SETTINGS], async () => {
|
|
@@ -40,19 +59,24 @@ export function registerExpertSettingsTools(server, client) {
|
|
|
40
59
|
const sizeCheck = checkResponseSize(result);
|
|
41
60
|
if (sizeCheck.tooLarge) {
|
|
42
61
|
return {
|
|
43
|
-
content: [{ type:
|
|
44
|
-
isError: true
|
|
62
|
+
content: [{ type: 'text', text: `Error: ${sizeCheck.suggestion}` }],
|
|
63
|
+
isError: true,
|
|
45
64
|
};
|
|
46
65
|
}
|
|
47
66
|
debugLogWithTag('EXPERT_SETTINGS', 'Successfully retrieved expert settings');
|
|
48
67
|
return {
|
|
49
|
-
content: [{ type:
|
|
68
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
50
69
|
};
|
|
51
70
|
}
|
|
52
71
|
catch (error) {
|
|
53
72
|
return {
|
|
54
|
-
content: [
|
|
55
|
-
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: 'text',
|
|
76
|
+
text: `Error retrieving expert settings: ${error instanceof Error ? error.message : String(error)}`,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
isError: true,
|
|
56
80
|
};
|
|
57
81
|
}
|
|
58
82
|
});
|
|
@@ -69,8 +93,13 @@ export function registerExpertSettingsTools(server, client) {
|
|
|
69
93
|
body.javascript = javascript;
|
|
70
94
|
if (Object.keys(body).length === 0) {
|
|
71
95
|
return {
|
|
72
|
-
content: [
|
|
73
|
-
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: 'text',
|
|
99
|
+
text: 'Error: No fields provided. Supply at least one of: less, scss, css, javascript. Use an empty string to clear a setting.',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
isError: true,
|
|
74
103
|
};
|
|
75
104
|
}
|
|
76
105
|
try {
|
|
@@ -85,13 +114,18 @@ export function registerExpertSettingsTools(server, client) {
|
|
|
85
114
|
}
|
|
86
115
|
debugLogWithTag('EXPERT_SETTINGS', `Successfully updated fields: ${updatedFields.join(', ')}`);
|
|
87
116
|
return {
|
|
88
|
-
content: [{ type:
|
|
117
|
+
content: [{ type: 'text', text: response }],
|
|
89
118
|
};
|
|
90
119
|
}
|
|
91
120
|
catch (error) {
|
|
92
121
|
return {
|
|
93
|
-
content: [
|
|
94
|
-
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'text',
|
|
125
|
+
text: `Error updating expert settings: ${error instanceof Error ? error.message : String(error)}`,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
isError: true,
|
|
95
129
|
};
|
|
96
130
|
}
|
|
97
131
|
});
|
|
@@ -102,26 +136,46 @@ export function registerExpertSettingsTools(server, client) {
|
|
|
102
136
|
const currentContent = settings[field];
|
|
103
137
|
if (currentContent === undefined || currentContent === null) {
|
|
104
138
|
return {
|
|
105
|
-
content: [
|
|
106
|
-
|
|
139
|
+
content: [
|
|
140
|
+
{
|
|
141
|
+
type: 'text',
|
|
142
|
+
text: `Error: Field '${field}' is not available. ${field === 'javascript' ? 'JavaScript editing may be disabled on the server.' : 'The field has no content.'}`,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
isError: true,
|
|
107
146
|
};
|
|
108
147
|
}
|
|
109
148
|
if (currentContent === '') {
|
|
110
149
|
return {
|
|
111
|
-
content: [
|
|
112
|
-
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: `Error: Field '${field}' is empty. Use cplace_update_expert_settings to set initial content.`,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
isError: true,
|
|
113
157
|
};
|
|
114
158
|
}
|
|
115
159
|
const result = applyStrReplace(currentContent, old_str, new_str, replace_all);
|
|
116
160
|
if (!result.success) {
|
|
117
161
|
return {
|
|
118
|
-
content: [{ type:
|
|
119
|
-
isError: true
|
|
162
|
+
content: [{ type: 'text', text: `Error: ${result.error}` }],
|
|
163
|
+
isError: true,
|
|
120
164
|
};
|
|
121
165
|
}
|
|
122
166
|
const patchBody = { [field]: result.newContent };
|
|
123
167
|
const patchResult = await client.makeApiRequest('json/expert-settings', 'PATCH', undefined, patchBody);
|
|
124
|
-
|
|
168
|
+
const reReadSettings = (await client.makeApiRequest('json/expert-settings', 'GET'));
|
|
169
|
+
const storedFieldContent = reReadSettings[field];
|
|
170
|
+
const storedPreview = storedFieldContent
|
|
171
|
+
? storedFieldContent.length > 500
|
|
172
|
+
? storedFieldContent.substring(0, 500) + '...'
|
|
173
|
+
: storedFieldContent
|
|
174
|
+
: null;
|
|
175
|
+
const normalizationNote = storedPreview
|
|
176
|
+
? `\n\nNote: The stored content may differ from what was submitted due to server-side CSS normalization (properties alphabetized, hex→rgb, whitespace regularized). Current stored form (first 500 chars):\n${storedPreview}`
|
|
177
|
+
: '';
|
|
178
|
+
let response = `Successfully edited '${field}'. Replaced ${result.replacementCount} occurrence(s).${normalizationNote}`;
|
|
125
179
|
if (patchResult.lessCompilationJobId) {
|
|
126
180
|
response += `\nLESS compilation job started: ${patchResult.lessCompilationJobId} (use cplace_get_job to check status)`;
|
|
127
181
|
}
|
|
@@ -130,14 +184,19 @@ export function registerExpertSettingsTools(server, client) {
|
|
|
130
184
|
}
|
|
131
185
|
debugLogWithTag('EXPERT_SETTINGS', `Successfully edited '${field}' (${result.replacementCount} replacement(s))`);
|
|
132
186
|
return {
|
|
133
|
-
content: [{ type:
|
|
187
|
+
content: [{ type: 'text', text: response }],
|
|
134
188
|
};
|
|
135
189
|
}
|
|
136
190
|
catch (error) {
|
|
137
191
|
debugLogWithTag('EXPERT_SETTINGS', `Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
138
192
|
return {
|
|
139
|
-
content: [
|
|
140
|
-
|
|
193
|
+
content: [
|
|
194
|
+
{
|
|
195
|
+
type: 'text',
|
|
196
|
+
text: `Error editing expert settings: ${error instanceof Error ? error.message : String(error)}`,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
isError: true,
|
|
141
200
|
};
|
|
142
201
|
}
|
|
143
202
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expert-settings.js","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAC9D,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AACpE,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAGhE,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,CAAC,wBAAwB,CAAC,EAAE;QAC1B,WAAW,
|
|
1
|
+
{"version":3,"file":"expert-settings.js","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAC9D,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AACpE,MAAM,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,CAAC,gBAAgB,kBAAkB,iBAAiB,EAAE,CAAC;YAExH,IAAI,WAAW,CAAC,oBAAoB,EAAE,CAAC;gBACrC,QAAQ,IAAI,mCAAmC,WAAW,CAAC,oBAAoB,uCAAuC,CAAC;YACzH,CAAC;YACD,IAAI,WAAW,CAAC,oBAAoB,EAAE,CAAC;gBACrC,QAAQ,IAAI,mCAAmC,WAAW,CAAC,oBAAoB,uCAAuC,CAAC;YACzH,CAAC;YAED,eAAe,CACb,iBAAiB,EACjB,wBAAwB,KAAK,MAAM,MAAM,CAAC,gBAAgB,kBAAkB,CAC7E,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACrD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CACb,iBAAiB,EACjB,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACjG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { CplaceApiClient } from '../api.js';
|
|
4
4
|
export declare const GET_OPERATIONS_TOOL_DEFINITIONS: {
|
|
5
5
|
readonly cplace_get_by_uid: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-operations.d.ts","sourceRoot":"","sources":["../../src/tools/get-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAQ5C,eAAO,MAAM,+BAA+B;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-operations.d.ts","sourceRoot":"","sources":["../../src/tools/get-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAQ5C,eAAO,MAAM,+BAA+B;;;;;;;;;;CAalC,CAAC;AAEX,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAoEnF"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { debugLogWithTag } from
|
|
3
|
-
import { truncateDocumentSummaries } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { debugLogWithTag } from '../logger.js';
|
|
3
|
+
import { truncateDocumentSummaries } from '../utils.js';
|
|
4
4
|
const TOOL_GET_BY_UID = 'cplace_get_by_uid';
|
|
5
5
|
export const GET_OPERATIONS_TOOL_DEFINITIONS = {
|
|
6
6
|
[TOOL_GET_BY_UID]: {
|
|
7
|
-
description:
|
|
7
|
+
description: 'Get entity by UID. Retrieves detailed information for a page or person by their UID. Entity type is automatically detected from the UID format (page/... or person/...).',
|
|
8
8
|
inputSchema: {
|
|
9
|
-
uid: z
|
|
9
|
+
uid: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe("The unique identifier. For pages: 'page/abc123'. For persons: 'person/user456'. Entity type is auto-detected from the prefix."),
|
|
10
12
|
},
|
|
11
|
-
annotations: { title:
|
|
12
|
-
}
|
|
13
|
+
annotations: { title: 'Get Entity by UID' },
|
|
14
|
+
},
|
|
13
15
|
};
|
|
14
16
|
export function registerGetOperationTools(server, client) {
|
|
15
17
|
server.registerTool(TOOL_GET_BY_UID, GET_OPERATIONS_TOOL_DEFINITIONS[TOOL_GET_BY_UID], async ({ uid }) => {
|
|
@@ -24,38 +26,44 @@ export function registerGetOperationTools(server, client) {
|
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
28
|
return {
|
|
27
|
-
content: [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: `Invalid UID format: '${uid}'. UID must start with 'page/' or 'person/'.`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
isError: true,
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
const endpoints = {
|
|
35
39
|
page: 'json/page',
|
|
36
|
-
person: 'json/person'
|
|
40
|
+
person: 'json/person',
|
|
37
41
|
};
|
|
38
42
|
const paramNames = {
|
|
39
43
|
page: 'pageUID',
|
|
40
|
-
person: 'id'
|
|
44
|
+
person: 'id',
|
|
41
45
|
};
|
|
42
|
-
const result = await client.makeApiRequest(endpoints[entityType], 'GET', {
|
|
46
|
+
const result = await client.makeApiRequest(endpoints[entityType], 'GET', {
|
|
47
|
+
[paramNames[entityType]]: uid,
|
|
48
|
+
});
|
|
43
49
|
if (entityType === 'page' && result.documents && Array.isArray(result.documents)) {
|
|
44
50
|
result.documents = truncateDocumentSummaries(result.documents);
|
|
45
51
|
}
|
|
46
52
|
debugLogWithTag('GET_BY_ID', `Successfully retrieved ${entityType}: ${uid}`);
|
|
47
53
|
return {
|
|
48
|
-
content: [{ type:
|
|
54
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
catch (error) {
|
|
52
58
|
debugLogWithTag('GET_BY_ID', `Error getting entity: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
59
|
return {
|
|
54
|
-
content: [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Error retrieving entity: ${error instanceof Error ? error.message : String(error)}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
isError: true,
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-operations.js","sourceRoot":"","sources":["../../src/tools/get-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAG5C,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,CAAC,eAAe,CAAC,EAAE;QACjB,WAAW,
|
|
1
|
+
{"version":3,"file":"get-operations.js","sourceRoot":"","sources":["../../src/tools/get-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAG5C,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,CAAC,eAAe,CAAC,EAAE;QACjB,WAAW,EACT,0KAA0K;QAC5K,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,QAAQ,CACP,+HAA+H,CAChI;SACJ;QACD,WAAW,EAAE,EAAE,KAAK,EAAE,mBAA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