@formio/uag 1.8.0 → 1.9.0-rc.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.
|
@@ -16,6 +16,14 @@ export declare class UAGProjectInterface extends ProjectInterface {
|
|
|
16
16
|
addForm(form: Form, key: string): UAGFormInterface | undefined;
|
|
17
17
|
router(): Promise<any>;
|
|
18
18
|
authorizeRequest(req: SubmissionRequest, res: Response, next: NextFunction): Promise<Response<any, Record<string, any>> | undefined>;
|
|
19
|
+
mcpJSONResponse(data?: object, isError?: boolean): {
|
|
20
|
+
isError?: boolean | undefined;
|
|
21
|
+
content: {
|
|
22
|
+
type: "text";
|
|
23
|
+
text: string;
|
|
24
|
+
}[];
|
|
25
|
+
structuredContent: object;
|
|
26
|
+
};
|
|
19
27
|
mcpResponse(templateName: ResponseTemplate, data?: object, isError?: boolean): {
|
|
20
28
|
isError?: boolean | undefined;
|
|
21
29
|
content: {
|
|
@@ -81,6 +81,18 @@ class UAGProjectInterface extends appserver_1.ProjectInterface {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
mcpJSONResponse(data = {}, isError = false) {
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'text',
|
|
89
|
+
text: JSON.stringify(data),
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
structuredContent: data,
|
|
93
|
+
...(isError && { isError: true }),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
84
96
|
mcpResponse(templateName, data = {}, isError = false) {
|
|
85
97
|
return {
|
|
86
98
|
content: [
|
|
@@ -76,6 +76,10 @@ class SchemaBuilder {
|
|
|
76
76
|
this.schema.criteria = zod_1.default.enum(['all', 'required', 'optional']).default('required').describe('Returns only the fields of the specified criteria. "all" returns all fields, "required" returns only the required fields, and "optional" returns only optional fields. To start a new form collection flow, you typically want to get only the "required" fields first.');
|
|
77
77
|
return this;
|
|
78
78
|
}
|
|
79
|
+
as_json() {
|
|
80
|
+
this.schema.as_json = zod_1.default.boolean().optional().default(false).describe('If true, the submission data will be returned as a JSON object result instead of formatted text. Any errors will also be returned as a structured JSON array. Set this property to `true` ONLY if the prompt indicates that JSON output of the submission data is required.');
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
79
83
|
/**
|
|
80
84
|
* An array of search criteria to find matching submissions.
|
|
81
85
|
* All criteria must match (AND logic).
|
package/lib/tools/collectData.js
CHANGED
|
@@ -13,8 +13,9 @@ const collectData = async (project) => {
|
|
|
13
13
|
.form_name()
|
|
14
14
|
.form_data()
|
|
15
15
|
.parent_path()
|
|
16
|
+
.as_json()
|
|
16
17
|
.updates().schema,
|
|
17
|
-
execute: async ({ form_name, form_data, parent_path, updates }, extra) => {
|
|
18
|
+
execute: async ({ form_name, form_data, parent_path, as_json, updates }, extra) => {
|
|
18
19
|
const form = await project.getForm(form_name);
|
|
19
20
|
if (!form) {
|
|
20
21
|
return project.mcpResponse(template_1.ResponseTemplate.formNotFound, { formName: form_name }, true);
|
|
@@ -30,8 +31,15 @@ const collectData = async (project) => {
|
|
|
30
31
|
// Find next required field that hasn't been filled
|
|
31
32
|
const fields = await form.getFields(submission, extra.authInfo, parent?.data_path);
|
|
32
33
|
if (fields.errors.length > 0) {
|
|
34
|
+
if (as_json) {
|
|
35
|
+
return project.mcpJSONResponse(fields.errors);
|
|
36
|
+
}
|
|
33
37
|
return project.mcpResponse(template_1.ResponseTemplate.fieldValidationErrors, { invalidFields: fields.errors });
|
|
34
38
|
}
|
|
39
|
+
// If JSON output is requested, return the raw submission data.
|
|
40
|
+
if (as_json) {
|
|
41
|
+
return project.mcpJSONResponse(submission);
|
|
42
|
+
}
|
|
35
43
|
// If no required fields remain, then we can move onto a new tool.
|
|
36
44
|
if (!fields.required.components.length) {
|
|
37
45
|
return project.mcpResponse(template_1.ResponseTemplate.allFieldsCollected, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/uag",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0-rc.1",
|
|
4
4
|
"description": "The Form.io Universal Agent Gateway (UAG).",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@formio/appserver": "^2.
|
|
26
|
+
"@formio/appserver": "^2.9.0",
|
|
27
27
|
"@formio/core": "2.5.1-dev.291.6557e4e",
|
|
28
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"debug": "^4.4.1",
|
|
31
31
|
"dotenv": "^17.2.1",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"jsonwebtoken": "^9.0.2",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"node-cache": "^5.1.2",
|
|
36
|
-
"zod": "^4.
|
|
36
|
+
"zod": "^4.3.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/chai": "^5.2.3",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@types/jsonwebtoken": "^9.0.10",
|
|
45
45
|
"@types/lodash": "^4.17.21",
|
|
46
46
|
"@types/mocha": "^10.0.10",
|
|
47
|
-
"@types/node": "^
|
|
47
|
+
"@types/node": "^25.0.3",
|
|
48
48
|
"@types/supertest": "^6.0.3",
|
|
49
|
-
"chai": "^6.2.
|
|
49
|
+
"chai": "^6.2.2",
|
|
50
50
|
"mocha": "^11.7.5",
|
|
51
|
-
"supertest": "^7.
|
|
51
|
+
"supertest": "^7.2.2",
|
|
52
52
|
"terser": "^5.44.1",
|
|
53
53
|
"ts-node": "^10.9.2",
|
|
54
54
|
"tsx": "^4.21.0",
|