@cplace/mcp-server 1.10.9 → 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/README.md +14 -2
- package/dist/api.d.ts +11 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +117 -29
- package/dist/api.js.map +1 -1
- package/dist/plugins/low-code.d.ts.map +1 -1
- package/dist/plugins/low-code.js +16 -1
- package/dist/plugins/low-code.js.map +1 -1
- package/dist/searchSchema.d.ts +1 -1
- package/dist/searchSchema.d.ts.map +1 -1
- package/dist/searchSchema.js +143 -86
- package/dist/searchSchema.js.map +1 -1
- package/dist/tools/documents.d.ts +23 -0
- package/dist/tools/documents.d.ts.map +1 -1
- package/dist/tools/documents.js +162 -0
- package/dist/tools/documents.js.map +1 -1
- package/dist/tools/enum-provider-simulation.d.ts +20 -0
- package/dist/tools/enum-provider-simulation.d.ts.map +1 -0
- package/dist/tools/enum-provider-simulation.js +139 -0
- package/dist/tools/enum-provider-simulation.js.map +1 -0
- package/dist/tools/enum-providers.d.ts +45 -0
- package/dist/tools/enum-providers.d.ts.map +1 -0
- package/dist/tools/enum-providers.js +190 -0
- package/dist/tools/enum-providers.js.map +1 -0
- package/dist/tools/layout.d.ts.map +1 -1
- package/dist/tools/layout.js +0 -2
- package/dist/tools/layout.js.map +1 -1
- package/dist/tools/page-action-simulation.d.ts +2 -2
- package/dist/tools/page-action-simulation.d.ts.map +1 -1
- package/dist/tools/page-action-simulation.js +10 -6
- package/dist/tools/page-action-simulation.js.map +1 -1
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +4 -0
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/ppt-export-schemas.d.ts +8 -8
- package/dist/tools/ppt-export.d.ts +8 -8
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +13 -11
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/type-management.d.ts +41 -6
- package/dist/tools/type-management.d.ts.map +1 -1
- package/dist/tools/type-management.js +131 -4
- package/dist/tools/type-management.js.map +1 -1
- package/dist/tools/type-messages.d.ts +42 -0
- package/dist/tools/type-messages.d.ts.map +1 -0
- package/dist/tools/type-messages.js +139 -0
- package/dist/tools/type-messages.js.map +1 -0
- package/dist/tools/widget-simulation.d.ts +2 -2
- package/dist/tools/widget-simulation.d.ts.map +1 -1
- package/dist/tools/widget-simulation.js +9 -5
- package/dist/tools/widget-simulation.js.map +1 -1
- package/dist/utils/fileIO.d.ts +12 -0
- package/dist/utils/fileIO.d.ts.map +1 -0
- package/dist/utils/fileIO.js +38 -0
- package/dist/utils/fileIO.js.map +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +55 -30
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/searchSchema.js
CHANGED
|
@@ -1,66 +1,105 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
const StringFilterSchema = z
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const StringFilterSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
equals: z.string().optional().describe('Exact match for the string value'),
|
|
5
|
+
not_equals: z.string().optional().describe('String does not equal the specified value'),
|
|
6
|
+
contains: z.string().optional().describe('String contains the specified substring'),
|
|
7
|
+
beginsWith: z.string().optional().describe('String starts with the specified prefix'),
|
|
8
|
+
is_empty: z.boolean().optional().describe('Check if the string field is empty'),
|
|
9
|
+
is_not_empty: z.boolean().optional().describe('Check if the string field is not empty'),
|
|
10
|
+
})
|
|
11
|
+
.strict()
|
|
12
|
+
.refine((data) => {
|
|
13
|
+
const definedKeys = Object.keys(data).filter((key) => data[key] !== undefined);
|
|
11
14
|
return definedKeys.length === 1;
|
|
12
15
|
}, {
|
|
13
|
-
message:
|
|
14
|
-
});
|
|
15
|
-
const NumberFilterSchema = z
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
message: 'Invalid string filter. Use exactly one of: equals, not_equals, contains, beginsWith, is_empty, is_not_empty',
|
|
17
|
+
});
|
|
18
|
+
const NumberFilterSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
equals: z.number().optional().describe('Exact numeric match'),
|
|
21
|
+
not_equals: z.number().optional().describe('Number is not equal to the specified value'),
|
|
22
|
+
greater_than: z.number().optional().describe('Number is greater than the specified value'),
|
|
23
|
+
greater_than_or_equal_to: z
|
|
24
|
+
.number()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Number is greater than or equal to the specified value'),
|
|
27
|
+
less_than: z.number().optional().describe('Number is less than the specified value'),
|
|
28
|
+
less_than_or_equal_to: z
|
|
29
|
+
.number()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Number is less than or equal to the specified value'),
|
|
32
|
+
is_empty: z.boolean().optional().describe('Check if the number field is empty'),
|
|
33
|
+
is_not_empty: z.boolean().optional().describe('Check if the number field is not empty'),
|
|
34
|
+
})
|
|
35
|
+
.strict()
|
|
36
|
+
.refine((data) => {
|
|
37
|
+
const definedKeys = Object.keys(data).filter((key) => data[key] !== undefined);
|
|
26
38
|
return definedKeys.length === 1;
|
|
27
39
|
}, {
|
|
28
|
-
message:
|
|
29
|
-
});
|
|
30
|
-
const DateFilterSchema = z
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
message: 'Invalid number filter. Use exactly one of: equals, not_equals, greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to, is_empty, is_not_empty',
|
|
41
|
+
});
|
|
42
|
+
const DateFilterSchema = z
|
|
43
|
+
.object({
|
|
44
|
+
after: z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Date is after the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
48
|
+
before: z
|
|
49
|
+
.string()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Date is before the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
52
|
+
equals: z
|
|
53
|
+
.string()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Date equals the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
56
|
+
not_equals: z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("Date does not equal the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
60
|
+
on_or_after: z
|
|
61
|
+
.string()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("Date is on or after the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
64
|
+
on_or_before: z
|
|
65
|
+
.string()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe("Date is on or before the specified date (YYYY-MM-DD format, e.g., '2024-03-15')"),
|
|
68
|
+
is_empty: z.boolean().optional().describe('Check if the date field is empty'),
|
|
69
|
+
is_not_empty: z.boolean().optional().describe('Check if the date field is not empty'),
|
|
70
|
+
})
|
|
71
|
+
.strict()
|
|
72
|
+
.refine((data) => {
|
|
73
|
+
const definedKeys = Object.keys(data).filter((key) => data[key] !== undefined);
|
|
41
74
|
return definedKeys.length === 1;
|
|
42
75
|
}, {
|
|
43
|
-
message:
|
|
76
|
+
message: 'Invalid date filter. Use exactly one of: equals, not_equals, after, before, on_or_after, on_or_before, is_empty, is_not_empty',
|
|
44
77
|
});
|
|
45
|
-
const ReferenceFilterSchema = z
|
|
78
|
+
const ReferenceFilterSchema = z
|
|
79
|
+
.object({
|
|
46
80
|
equals: z.string().describe("Reference ID in the format 'type/id' for exact match").optional(),
|
|
47
|
-
not_equals: z.string().describe(
|
|
48
|
-
is_empty: z.boolean().optional().describe(
|
|
49
|
-
is_not_empty: z.boolean().optional().describe(
|
|
50
|
-
})
|
|
51
|
-
|
|
81
|
+
not_equals: z.string().describe('Reference ID that the field must NOT equal').optional(),
|
|
82
|
+
is_empty: z.boolean().optional().describe('Check if the reference field is empty'),
|
|
83
|
+
is_not_empty: z.boolean().optional().describe('Check if the reference field is not empty'),
|
|
84
|
+
})
|
|
85
|
+
.strict()
|
|
86
|
+
.refine((data) => {
|
|
87
|
+
const definedKeys = Object.keys(data).filter((key) => data[key] !== undefined);
|
|
52
88
|
return definedKeys.length === 1;
|
|
53
89
|
}, {
|
|
54
|
-
message:
|
|
90
|
+
message: 'Invalid reference filter. Use exactly one of: equals, not_equals, is_empty, is_not_empty',
|
|
55
91
|
});
|
|
56
|
-
const BooleanFilterSchema = z
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
92
|
+
const BooleanFilterSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
equals: z.boolean().optional().describe('Exact boolean match (true or false)'),
|
|
95
|
+
not_equals: z.boolean().optional().describe('Boolean does not equal the specified value'),
|
|
96
|
+
})
|
|
97
|
+
.strict()
|
|
98
|
+
.refine((data) => {
|
|
99
|
+
const definedKeys = Object.keys(data).filter((key) => data[key] !== undefined);
|
|
61
100
|
return definedKeys.length === 1;
|
|
62
101
|
}, {
|
|
63
|
-
message:
|
|
102
|
+
message: 'Invalid boolean filter. Use exactly one of: equals, not_equals',
|
|
64
103
|
});
|
|
65
104
|
const ReferenceOperatorValues = [
|
|
66
105
|
'sessionUser',
|
|
@@ -70,51 +109,67 @@ const ReferenceOperatorValues = [
|
|
|
70
109
|
'connectedTable',
|
|
71
110
|
];
|
|
72
111
|
const RelativeReferenceFilterSchema = z.object({
|
|
73
|
-
attribute: z
|
|
112
|
+
attribute: z
|
|
113
|
+
.string()
|
|
114
|
+
.describe("The reference attribute to filter (e.g., 'cf.cplace.project.task.responsible')"),
|
|
74
115
|
operator: z.string().describe(`Reference operator determining the dynamic value source:
|
|
75
116
|
- "sessionUser": Current logged-in user
|
|
76
117
|
- "sessionUserWithGroups": Current user and their groups
|
|
77
|
-
- "embeddingCustomEntity": The embedding entity itself (requires
|
|
78
|
-
- "parentOfEmbeddingPage": Parent of embedding entity (requires
|
|
79
|
-
- "connectedTable": Selected entity in connected table (requires
|
|
118
|
+
- "embeddingCustomEntity": The embedding entity itself (requires embeddingEntityUID)
|
|
119
|
+
- "parentOfEmbeddingPage": Parent of embedding entity (requires embeddingEntityUID)
|
|
120
|
+
- "connectedTable": Selected entity in connected table (requires connectedTableSelectionUID)
|
|
80
121
|
- "ba_<attr>": Built-in attribute of embedding entity (e.g., "ba_cf.cplace.space")
|
|
81
122
|
- "ca_<attr>": Custom attribute of embedding entity (e.g., "ca_assignedProject")
|
|
82
123
|
- "ctca_<attr>": Custom attribute of connected table selection (e.g., "ctca_selectedTask")`),
|
|
83
124
|
});
|
|
84
125
|
const RelativeDateFilterSchema = z.object({
|
|
85
|
-
attribute: z
|
|
86
|
-
|
|
87
|
-
.describe("
|
|
88
|
-
|
|
126
|
+
attribute: z
|
|
127
|
+
.string()
|
|
128
|
+
.describe("The date attribute to filter (e.g., 'dueDate', 'cf.cplace.modificationDate')"),
|
|
129
|
+
operator: z
|
|
130
|
+
.enum(['equals', 'lessThan', 'lessEquals', 'greaterThan', 'greaterEquals'])
|
|
131
|
+
.describe('Comparison operator for the date'),
|
|
132
|
+
offset: z
|
|
133
|
+
.number()
|
|
134
|
+
.optional()
|
|
135
|
+
.describe("Days to add/subtract from reference date. Negative for past dates. Example: -7 for 'a week ago', 7 for 'a week from now'"),
|
|
89
136
|
relativeToAttribute: z.string().nullable().optional().describe(`Source date reference:
|
|
90
137
|
- null or omitted: Today's date
|
|
91
138
|
- "_lastLogin": User's last login time`),
|
|
92
139
|
});
|
|
93
140
|
const RelativeStringFilterSchema = z.object({
|
|
94
|
-
attribute: z.string().describe(
|
|
95
|
-
sourceAttribute: z
|
|
141
|
+
attribute: z.string().describe('The string attribute to filter'),
|
|
142
|
+
sourceAttribute: z
|
|
143
|
+
.string()
|
|
144
|
+
.describe('Source attribute name from embedding entity to copy value from'),
|
|
96
145
|
});
|
|
97
146
|
const RelativeNumberFilterSchema = z.object({
|
|
98
|
-
attribute: z.string().describe(
|
|
99
|
-
sourceAttribute: z.string().describe(
|
|
100
|
-
operator: z
|
|
101
|
-
.
|
|
102
|
-
|
|
147
|
+
attribute: z.string().describe('The number attribute to filter'),
|
|
148
|
+
sourceAttribute: z.string().describe('Source attribute name from embedding entity'),
|
|
149
|
+
operator: z
|
|
150
|
+
.enum(['equals', 'lessThan', 'lessEquals', 'greaterThan', 'greaterEquals'])
|
|
151
|
+
.optional()
|
|
152
|
+
.describe('Comparison operator (default: equals)'),
|
|
153
|
+
offset: z.number().optional().describe('Value to add to the source value'),
|
|
103
154
|
});
|
|
104
155
|
const RelativeBooleanFilterSchema = z.object({
|
|
105
|
-
attribute: z.string().describe(
|
|
106
|
-
sourceAttribute: z
|
|
156
|
+
attribute: z.string().describe('The boolean attribute to filter'),
|
|
157
|
+
sourceAttribute: z
|
|
158
|
+
.string()
|
|
159
|
+
.describe('Source attribute name from embedding entity to copy value from'),
|
|
107
160
|
});
|
|
108
|
-
const RelativeSpaceFilterSchema = z
|
|
161
|
+
const RelativeSpaceFilterSchema = z
|
|
162
|
+
.object({})
|
|
163
|
+
.describe("Filter to embedding entity's workspace. Requires embeddingEntityUID.");
|
|
109
164
|
const RelativeUidFilterSchema = z.object({
|
|
110
165
|
operator: z.string().describe(`Reference operator for UID matching:
|
|
111
|
-
- "connectedTable": Match UID of connected table selection (requires
|
|
112
|
-
- "embeddingCustomEntity": Match UID of embedding entity (requires
|
|
166
|
+
- "connectedTable": Match UID of connected table selection (requires connectedTableSelectionUID)
|
|
167
|
+
- "embeddingCustomEntity": Match UID of embedding entity (requires embeddingEntityUID)
|
|
113
168
|
- Other reference operators also supported`),
|
|
114
169
|
});
|
|
115
170
|
const RelativeBuiltinReferenceFilterSchema = z.object({
|
|
116
171
|
attribute: z.string().describe("Built-in reference attribute (e.g., 'cf.cplace.space')"),
|
|
117
|
-
operator: z.string().describe(
|
|
172
|
+
operator: z.string().describe('Reference operator (same options as relativeReference)'),
|
|
118
173
|
});
|
|
119
174
|
const RelativeReferenceAttributeFilterSchema = z.object({
|
|
120
175
|
relativeReference: RelativeReferenceFilterSchema,
|
|
@@ -145,9 +200,11 @@ const StringAttributeFilterSchema = z.object({
|
|
|
145
200
|
string: StringFilterSchema,
|
|
146
201
|
});
|
|
147
202
|
const NameAttributeFilterSchema = z.object({
|
|
148
|
-
name: z
|
|
149
|
-
|
|
150
|
-
|
|
203
|
+
name: z
|
|
204
|
+
.object({
|
|
205
|
+
equals: z.string(),
|
|
206
|
+
})
|
|
207
|
+
.describe('Filter by page name'),
|
|
151
208
|
});
|
|
152
209
|
const NumberAttributeFilterSchema = z.object({
|
|
153
210
|
attribute: z.string(),
|
|
@@ -182,25 +239,25 @@ const BaseFilterConditionSchema = z.union([
|
|
|
182
239
|
RelativeBuiltinReferenceAttributeFilterSchema,
|
|
183
240
|
]);
|
|
184
241
|
const AndFilterSchema = z.object({
|
|
185
|
-
and: z
|
|
242
|
+
and: z
|
|
243
|
+
.array(z.union([
|
|
186
244
|
BaseFilterConditionSchema,
|
|
187
245
|
z.object({
|
|
188
246
|
or: z.array(BaseFilterConditionSchema).min(1),
|
|
189
|
-
})
|
|
190
|
-
]))
|
|
247
|
+
}),
|
|
248
|
+
]))
|
|
249
|
+
.min(1),
|
|
191
250
|
});
|
|
192
251
|
const OrFilterSchema = z.object({
|
|
193
|
-
or: z
|
|
252
|
+
or: z
|
|
253
|
+
.array(z.union([
|
|
194
254
|
BaseFilterConditionSchema,
|
|
195
255
|
z.object({
|
|
196
256
|
and: z.array(BaseFilterConditionSchema).min(1),
|
|
197
|
-
})
|
|
198
|
-
]))
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
AndFilterSchema,
|
|
203
|
-
OrFilterSchema,
|
|
204
|
-
]));
|
|
257
|
+
}),
|
|
258
|
+
]))
|
|
259
|
+
.min(1),
|
|
260
|
+
});
|
|
261
|
+
const SearchFilterSchema = z.array(z.union([BaseFilterConditionSchema, AndFilterSchema, OrFilterSchema]));
|
|
205
262
|
export default SearchFilterSchema;
|
|
206
263
|
//# sourceMappingURL=searchSchema.js.map
|
package/dist/searchSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchSchema.js","sourceRoot":"","sources":["../src/searchSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,kBAAkB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"searchSchema.js","sourceRoot":"","sources":["../src/searchSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,kBAAkB,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC1E,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACvF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACnF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACrF,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAC/E,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;CACxF,CAAC;KACD,MAAM,EAAE;KACR,MAAM,CACL,CAAC,IAAI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CAAC,CAAC;SAC/C,CAAC;KACH,CAAC,CACH;SACA,GAAG,CAAC,CAAC,CAAC;CACV,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAChC,CAAC,CAAC,KAAK,CAAC,CAAC,yBAAyB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CACtE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { CplaceApiClient } from '../api.js';
|
|
4
|
+
export declare function formatDocumentContentError(prefix: string, error: unknown): string;
|
|
4
5
|
export declare const DOCUMENT_TOOL_DEFINITIONS: {
|
|
5
6
|
readonly cplace_get_document: {
|
|
6
7
|
readonly 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.";
|
|
@@ -13,6 +14,28 @@ export declare const DOCUMENT_TOOL_DEFINITIONS: {
|
|
|
13
14
|
readonly title: "Get Document";
|
|
14
15
|
};
|
|
15
16
|
};
|
|
17
|
+
readonly cplace_download_document: {
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly inputSchema: {
|
|
20
|
+
readonly documentUID: z.ZodString;
|
|
21
|
+
readonly targetPath: z.ZodString;
|
|
22
|
+
};
|
|
23
|
+
readonly annotations: {
|
|
24
|
+
readonly title: "Download Document";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly cplace_upload_document: {
|
|
28
|
+
readonly description: string;
|
|
29
|
+
readonly inputSchema: {
|
|
30
|
+
readonly filePath: z.ZodString;
|
|
31
|
+
readonly pageUID: z.ZodOptional<z.ZodString>;
|
|
32
|
+
readonly documentUID: z.ZodOptional<z.ZodString>;
|
|
33
|
+
readonly fileName: z.ZodOptional<z.ZodString>;
|
|
34
|
+
};
|
|
35
|
+
readonly annotations: {
|
|
36
|
+
readonly title: "Upload Document";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
16
39
|
};
|
|
17
40
|
export declare function registerDocumentTools(server: McpServer, client: CplaceApiClient): void;
|
|
18
41
|
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -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;
|
|
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;AAqB5C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAMjF;AAGD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiF5B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QA+N/E"}
|
package/dist/tools/documents.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { debugLogWithTag } from '../logger.js';
|
|
3
3
|
import { checkResponseSize } from '../utils.js';
|
|
4
|
+
import { validateAbsolutePath, writeFileCreatingParents, validateUploadFile, readFileForUpload, defaultFileName, } from '../utils/fileIO.js';
|
|
4
5
|
const TOOL_GET_DOCUMENT = 'cplace_get_document';
|
|
6
|
+
const TOOL_DOWNLOAD_DOCUMENT = 'cplace_download_document';
|
|
7
|
+
const TOOL_UPLOAD_DOCUMENT = 'cplace_upload_document';
|
|
8
|
+
export function formatDocumentContentError(prefix, error) {
|
|
9
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
10
|
+
if (message.includes('(Status: 404)')) {
|
|
11
|
+
return `${prefix}: ${message}\nThis may mean the cplace instance does not yet support document download/upload endpoints. Check with cplace_check_version_compatibility.`;
|
|
12
|
+
}
|
|
13
|
+
return `${prefix}: ${message}`;
|
|
14
|
+
}
|
|
5
15
|
export const DOCUMENT_TOOL_DEFINITIONS = {
|
|
6
16
|
[TOOL_GET_DOCUMENT]: {
|
|
7
17
|
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.',
|
|
@@ -22,6 +32,46 @@ export const DOCUMENT_TOOL_DEFINITIONS = {
|
|
|
22
32
|
},
|
|
23
33
|
annotations: { title: 'Get Document' },
|
|
24
34
|
},
|
|
35
|
+
[TOOL_DOWNLOAD_DOCUMENT]: {
|
|
36
|
+
description: 'Download the binary file content of a document to a local file. Complements cplace_get_document, which returns extracted text only — use this tool to get the actual file (office documents, images, css/js assets, etc.). ' +
|
|
37
|
+
'Document UIDs are found in the documents array of page responses. ' +
|
|
38
|
+
'targetPath must be an absolute local path; missing parent directories are created and an existing file is overwritten silently.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
documentUID: z
|
|
41
|
+
.string()
|
|
42
|
+
.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`)"),
|
|
43
|
+
targetPath: z
|
|
44
|
+
.string()
|
|
45
|
+
.describe("Absolute local file path to write the downloaded file to (e.g., '/tmp/report.pptx'). Parent directories are created if missing; an existing file is overwritten silently. Relative paths are rejected."),
|
|
46
|
+
},
|
|
47
|
+
annotations: { title: 'Download Document' },
|
|
48
|
+
},
|
|
49
|
+
[TOOL_UPLOAD_DOCUMENT]: {
|
|
50
|
+
description: 'Upload a local file as a page attachment. Exactly one of pageUID (create mode) or documentUID (replace mode) must be provided. ' +
|
|
51
|
+
'Create mode attaches the file as a new document on the page; if the page already has a document with the same file name, a new version of that document is written instead of creating a duplicate (platform behavior). ' +
|
|
52
|
+
'Replace mode writes the file as a new version of an existing document — the document UID, name, and URL stay stable, so use this to update css/js assets referenced by widgets. ' +
|
|
53
|
+
'fileName applies to create mode only and defaults to the basename of filePath. ' +
|
|
54
|
+
'filePath must be an absolute local path. ' +
|
|
55
|
+
'Note: the fulltext of a freshly uploaded document becomes available asynchronously (~30s, Tika extraction).',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
filePath: z
|
|
58
|
+
.string()
|
|
59
|
+
.describe("Absolute local file path of the file to upload (e.g., '/tmp/report.pptx'). Relative paths are rejected."),
|
|
60
|
+
pageUID: z
|
|
61
|
+
.string()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("Create mode: UID of the page to attach the file to (e.g., 'page/abc123'). Exactly one of pageUID or documentUID must be provided. If the page already has a document with the same file name, a new version of that document is written instead of creating a duplicate."),
|
|
64
|
+
documentUID: z
|
|
65
|
+
.string()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe("Replace mode: UID of an existing document (e.g., 'document/abc123') whose content is replaced with a new version. The document UID, name, and URL stay stable — widgets referencing the document URL keep working."),
|
|
68
|
+
fileName: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('File name for the new document in create mode (defaults to the basename of filePath). Ignored in replace mode — the existing document keeps its name.'),
|
|
72
|
+
},
|
|
73
|
+
annotations: { title: 'Upload Document' },
|
|
74
|
+
},
|
|
25
75
|
};
|
|
26
76
|
export function registerDocumentTools(server, client) {
|
|
27
77
|
server.registerTool(TOOL_GET_DOCUMENT, DOCUMENT_TOOL_DEFINITIONS[TOOL_GET_DOCUMENT], async ({ documentUID, fulltextOffset, fulltextMaxLength }) => {
|
|
@@ -75,5 +125,117 @@ export function registerDocumentTools(server, client) {
|
|
|
75
125
|
};
|
|
76
126
|
}
|
|
77
127
|
});
|
|
128
|
+
server.registerTool(TOOL_DOWNLOAD_DOCUMENT, DOCUMENT_TOOL_DEFINITIONS[TOOL_DOWNLOAD_DOCUMENT], async ({ documentUID, targetPath }) => {
|
|
129
|
+
debugLogWithTag('DOCUMENTS', `Downloading document: ${documentUID} to ${targetPath}`);
|
|
130
|
+
const pathError = validateAbsolutePath(targetPath, 'targetPath');
|
|
131
|
+
if (pathError) {
|
|
132
|
+
return {
|
|
133
|
+
content: [{ type: 'text', text: pathError }],
|
|
134
|
+
isError: true,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const binary = await client.makeBinaryApiRequest('json/document/content', { documentUID });
|
|
139
|
+
await writeFileCreatingParents(targetPath, binary.data);
|
|
140
|
+
const result = {
|
|
141
|
+
documentUID,
|
|
142
|
+
fileName: binary.fileName,
|
|
143
|
+
mimeType: binary.contentType,
|
|
144
|
+
fileSize: binary.fileSize,
|
|
145
|
+
targetPath,
|
|
146
|
+
};
|
|
147
|
+
const sizeCheck = checkResponseSize(result);
|
|
148
|
+
if (sizeCheck.tooLarge) {
|
|
149
|
+
return {
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: `Response too large (${sizeCheck.actualSize} characters, max: 45000).`,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
isError: true,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
debugLogWithTag('DOCUMENTS', `Successfully downloaded document: ${documentUID} (${binary.fileSize} bytes)`);
|
|
160
|
+
return {
|
|
161
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
debugLogWithTag('DOCUMENTS', `Error downloading document: ${error instanceof Error ? error.message : String(error)}`);
|
|
166
|
+
return {
|
|
167
|
+
content: [
|
|
168
|
+
{ type: 'text', text: formatDocumentContentError('Error downloading document', error) },
|
|
169
|
+
],
|
|
170
|
+
isError: true,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
server.registerTool(TOOL_UPLOAD_DOCUMENT, DOCUMENT_TOOL_DEFINITIONS[TOOL_UPLOAD_DOCUMENT], async ({ filePath, pageUID, documentUID, fileName }) => {
|
|
175
|
+
debugLogWithTag('DOCUMENTS', `Uploading file: ${filePath} (pageUID: ${pageUID}, documentUID: ${documentUID})`);
|
|
176
|
+
if (!pageUID === !documentUID) {
|
|
177
|
+
return {
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: 'text',
|
|
181
|
+
text: 'Error: Exactly one of pageUID (create mode: attach as new document) or documentUID (replace mode: write a new version of an existing document) must be provided.',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
isError: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const pathError = validateAbsolutePath(filePath, 'filePath');
|
|
188
|
+
if (pathError) {
|
|
189
|
+
return {
|
|
190
|
+
content: [{ type: 'text', text: pathError }],
|
|
191
|
+
isError: true,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const fileCheck = await validateUploadFile(filePath);
|
|
195
|
+
if (!fileCheck.ok) {
|
|
196
|
+
return {
|
|
197
|
+
content: [{ type: 'text', text: fileCheck.error }],
|
|
198
|
+
isError: true,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const data = await readFileForUpload(filePath);
|
|
203
|
+
const effectiveFileName = fileName ?? defaultFileName(filePath);
|
|
204
|
+
const formData = new FormData();
|
|
205
|
+
formData.append('file', new Blob([data]), effectiveFileName);
|
|
206
|
+
if (pageUID) {
|
|
207
|
+
formData.append('pageUID', pageUID);
|
|
208
|
+
}
|
|
209
|
+
else if (documentUID) {
|
|
210
|
+
formData.append('documentUID', documentUID);
|
|
211
|
+
}
|
|
212
|
+
const result = await client.makeMultipartApiRequest('json/document/content', formData);
|
|
213
|
+
const sizeCheck = checkResponseSize(result);
|
|
214
|
+
if (sizeCheck.tooLarge) {
|
|
215
|
+
return {
|
|
216
|
+
content: [
|
|
217
|
+
{
|
|
218
|
+
type: 'text',
|
|
219
|
+
text: `Response too large (${sizeCheck.actualSize} characters, max: 45000).`,
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
isError: true,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
debugLogWithTag('DOCUMENTS', `Successfully uploaded file: ${filePath} (${fileCheck.size} bytes)`);
|
|
226
|
+
return {
|
|
227
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
debugLogWithTag('DOCUMENTS', `Error uploading document: ${error instanceof Error ? error.message : String(error)}`);
|
|
232
|
+
return {
|
|
233
|
+
content: [
|
|
234
|
+
{ type: 'text', text: formatDocumentContentError('Error uploading document', error) },
|
|
235
|
+
],
|
|
236
|
+
isError: true,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
78
240
|
}
|
|
79
241
|
//# sourceMappingURL=documents.js.map
|
|
@@ -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;
|
|
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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Aa,EAAE,WAAW,CAAC,CAAC;YAC9C,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;YAGvF,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,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,2BAA2B;yBAC7E;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YAED,eAAe,CACb,WAAW,EACX,+BAA+B,QAAQ,KAAK,SAAS,CAAC,IAAI,SAAS,CACpE,CAAC;YAEF,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,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACtF,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,CAAC,0BAA0B,EAAE,KAAK,CAAC,EAAE;iBACtF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { CplaceApiClient } from '../api.js';
|
|
4
|
+
export declare const ENUM_PROVIDER_SIMULATION_TOOL_DEFINITIONS: {
|
|
5
|
+
readonly cplace_simulate_enum_provider: {
|
|
6
|
+
readonly description: "Execute an enum provider script under the production enum-provider engine context — without persisting anything.\n\n**Two primary use cases:**\n1. **Pre-attach testing of a candidate script.** Attaching a provider via\ncplace_manage_enum_provider is destructive: its enumOptions() result REPLACES the\nattribute's stored enumeration options and the old static list cannot be recovered.\nSimulate the candidate first to see exactly what it would compute — zero changes\nto the attribute.\n2. **Per-page filterByValues verification.** filterByValues(ownerEntity) runs per\nentity at display time only; no write triggers it, so no other tool can verify it.\nPass ownerEntityUID to see the filtered subset a specific page would show.\n\n**Four modes** from the two optional parameters:\n- no `script`, no `ownerEntityUID`: re-runs the stored provider (cheap \"does the\n stored script still run\" check; executes the attached script even when the\n provider is disabled)\n- `script` only: candidate options preview\n- `script` + `ownerEntityUID`: candidate options + filtered subset for that page\n- `ownerEntityUID` only: stored provider options + filtered subset for that page\n\n**⚠️ Mode-dependent intersection semantics for filteredOptions:**\n- **Stored mode** (no `script`) mirrors what the page shows TODAY: the\n filterByValues result is intersected with the attribute's currently stored\n elements (production's display formula).\n- **Candidate mode** (`script` given) predicts the POST-ATTACH state: the\n filterByValues result is intersected with the candidate's own enumOptions()\n output instead.\nThe same script text can therefore yield different filteredOptions in the two\nmodes. The response names the base used in `intersectionBase`\n(\"storedElements\" | \"candidateOptions\").\n\n**Response**: `mode`, `options` (the enumOptions() output as\n{value, localizedName?, icon?}), `invalidOptionValues` (only when present:\noptions whose value is missing or type-mismatched for the attribute kind), and —\nonly when `ownerEntityUID` was given — `filterByValuesPresent`,\n`filteredOptions`, `intersectionBase`. When the script has no filterByValues,\n`filterByValuesPresent` is false and `filteredOptions` equals the full\nintersection base (production: no filtering). Script errors return\n{error: {message, line}}.\n\n**Injected bindings** (replicating the production engine row — see\n`script-context-cards/enum-provider.md`): `messages` (the type's message\nprovider), `enumValues` (the stored enumeration elements as primitives),\n`defaultValues` (the attribute's default values as primitives),\n`customAttribute` (the attribute's internal name).\n**Allowed type classes**: `Search`, `Filters`. **Mode**: read-only — the\nprovider script's execution path never writes. **Timeout**: 30 seconds.\n\n**Known deviations from production**: runs with the caller's read permissions\n(production suspends read checks); plugin-extension enumeration filters\n(FilterEnumerationValuesPluginExtension) are not applied.\n\n**Script contract**: the script must end with a top-level return of an object\nwith a mandatory enumOptions() function returning an array of options\n(plain value or {value, name, icon}), and an optional\nfilterByValues(ownerEntity) function. triggerEntities()/systemTriggers() may be\npresent but are not exercised by the simulation — nothing is persisted, so no\ntrigger registration happens. Only for low-code ENUM_PROVIDER scripts —\nnot the Java-class DynamicEnumerationProvider.";
|
|
7
|
+
readonly inputSchema: {
|
|
8
|
+
readonly workspaceId: z.ZodString;
|
|
9
|
+
readonly typeInternalName: z.ZodString;
|
|
10
|
+
readonly attributeName: z.ZodString;
|
|
11
|
+
readonly script: z.ZodOptional<z.ZodString>;
|
|
12
|
+
readonly ownerEntityUID: z.ZodOptional<z.ZodString>;
|
|
13
|
+
};
|
|
14
|
+
readonly annotations: {
|
|
15
|
+
readonly title: "Simulate Enum Provider Script";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function registerEnumProviderSimulationTools(server: McpServer, client: CplaceApiClient): void;
|
|
20
|
+
//# sourceMappingURL=enum-provider-simulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-provider-simulation.d.ts","sourceRoot":"","sources":["../../src/tools/enum-provider-simulation.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,yCAAyC;;;;;;;;;;;;;;CAwF5C,CAAC;AAEX,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAwE7F"}
|