@restforgejs/mcp-server 1.2.0 → 1.2.2
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 +51 -8
- package/dist/server.js +71 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/codegen/dbschema-apply.d.ts +2 -0
- package/dist/tools/codegen/dbschema-apply.js +324 -0
- package/dist/tools/codegen/dbschema-apply.js.map +1 -0
- package/dist/tools/codegen/dbschema-diff.d.ts +2 -0
- package/dist/tools/codegen/dbschema-diff.js +352 -0
- package/dist/tools/codegen/dbschema-diff.js.map +1 -0
- package/dist/tools/codegen/dbschema-generate-ddl.js +6 -3
- package/dist/tools/codegen/dbschema-generate-ddl.js.map +1 -1
- package/dist/tools/codegen/dbschema-init.js +9 -2
- package/dist/tools/codegen/dbschema-init.js.map +1 -1
- package/dist/tools/codegen/dbschema-introspect.js +25 -19
- package/dist/tools/codegen/dbschema-introspect.js.map +1 -1
- package/dist/tools/codegen/dbschema-migrate.js +55 -26
- package/dist/tools/codegen/dbschema-migrate.js.map +1 -1
- package/dist/tools/codegen/dbschema-models.js +11 -12
- package/dist/tools/codegen/dbschema-models.js.map +1 -1
- package/dist/tools/codegen/dbschema-template.d.ts +2 -0
- package/dist/tools/codegen/dbschema-template.js +384 -0
- package/dist/tools/codegen/dbschema-template.js.map +1 -0
- package/dist/tools/codegen/dbschema-validate.js +13 -13
- package/dist/tools/codegen/dbschema-validate.js.map +1 -1
- package/dist/tools/codegen/generate-payload.js +1 -1
- package/dist/tools/codegen/get-dbschema-catalog.js +4 -2
- package/dist/tools/codegen/get-dbschema-catalog.js.map +1 -1
- package/dist/tools/codegen/index.js +6 -0
- package/dist/tools/codegen/index.js.map +1 -1
- package/dist/tools/codegen/list-tables.js +4 -1
- package/dist/tools/codegen/list-tables.js.map +1 -1
- package/dist/tools/designer/generate.d.ts +2 -0
- package/dist/tools/designer/generate.js +212 -0
- package/dist/tools/designer/generate.js.map +1 -0
- package/dist/tools/designer/index.d.ts +2 -0
- package/dist/tools/designer/index.js +17 -0
- package/dist/tools/designer/index.js.map +1 -0
- package/dist/tools/designer/init-project.d.ts +2 -0
- package/dist/tools/designer/init-project.js +235 -0
- package/dist/tools/designer/init-project.js.map +1 -0
- package/dist/tools/designer/inspect-plugin.d.ts +2 -0
- package/dist/tools/designer/inspect-plugin.js +148 -0
- package/dist/tools/designer/inspect-plugin.js.map +1 -0
- package/dist/tools/designer/list-plugins.d.ts +2 -0
- package/dist/tools/designer/list-plugins.js +141 -0
- package/dist/tools/designer/list-plugins.js.map +1 -0
- package/dist/tools/designer/preview-files.d.ts +2 -0
- package/dist/tools/designer/preview-files.js +150 -0
- package/dist/tools/designer/preview-files.js.map +1 -0
- package/dist/tools/designer/scaffold-plugin.d.ts +2 -0
- package/dist/tools/designer/scaffold-plugin.js +162 -0
- package/dist/tools/designer/scaffold-plugin.js.map +1 -0
- package/dist/tools/designer/validate-payload.d.ts +2 -0
- package/dist/tools/designer/validate-payload.js +158 -0
- package/dist/tools/designer/validate-payload.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { execProcess } from '../../lib/exec.js';
|
|
4
|
+
export function registerDesignerValidatePayload(server) {
|
|
5
|
+
server.registerTool('designer_validate_payload', {
|
|
6
|
+
title: 'Validate Designer Payload',
|
|
7
|
+
description: `Validate a frontend UI Definition File (UDF) payload against the schema of the RESTForge Designer plugin it targets, by running restforge-designer validate.
|
|
8
|
+
|
|
9
|
+
USE WHEN:
|
|
10
|
+
- The user asks to validate, check, or verify a frontend designer payload / UI definition (UDF) file
|
|
11
|
+
- The user asks things like "validasi UDF", "cek payload frontend", "is this UI definition valid", "validate designer payload", "apakah payload UDF benar", "check the frontend payload against the plugin schema"
|
|
12
|
+
- Before previewing or generating frontend code from a UDF, to confirm the payload is structurally valid against the plugin schema
|
|
13
|
+
- The user mentions a designer/frontend payload JSON and wants to know whether it conforms to the plugin it targets
|
|
14
|
+
- Routine pre-generation sanity check on a UDF file
|
|
15
|
+
|
|
16
|
+
DO NOT USE FOR:
|
|
17
|
+
- Validating a backend RDF payload against the database schema -> use 'codegen_validate_payload'
|
|
18
|
+
- Validating an SDF (database schema definition) -> use 'codegen_dbschema_validate'
|
|
19
|
+
- Validating raw SQL -> use 'codegen_validate_sql'
|
|
20
|
+
- Generating the frontend code itself (this only validates, it does not write files)
|
|
21
|
+
|
|
22
|
+
This tool wraps the RESTForge Designer CLI command: restforge-designer validate --payload=<payload> [--plugins-dir=<pluginsDir>], run in the given cwd.
|
|
23
|
+
The CLI reads the UDF payload JSON, resolves the target plugin (auto-detected or from --plugins-dir), and reports whether
|
|
24
|
+
the payload is valid against that plugin's schema, listing structural errors when it is not. It does not modify any file and
|
|
25
|
+
does not require a license.
|
|
26
|
+
|
|
27
|
+
Preconditions:
|
|
28
|
+
- The 'restforge-designer' binary must be installed and reachable on PATH. This tool pre-checks that by running
|
|
29
|
+
'restforge-designer --version'; if the binary is missing, the response will surface that as a non-error precondition.
|
|
30
|
+
|
|
31
|
+
PRESENTATION GUIDANCE:
|
|
32
|
+
- Match the user's language. If the user writes in Indonesian, respond in Indonesian.
|
|
33
|
+
- Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "validate the UI definition", "preview the generated files", "generate the frontend code").
|
|
34
|
+
- Speak in plain language. Summarise the result; do not paste raw CLI output unless the user explicitly asks.
|
|
35
|
+
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
36
|
+
inputSchema: {
|
|
37
|
+
cwd: z
|
|
38
|
+
.string()
|
|
39
|
+
.min(1)
|
|
40
|
+
.describe('Absolute path of the working directory where the binary is run'),
|
|
41
|
+
payload: z
|
|
42
|
+
.string()
|
|
43
|
+
.min(1)
|
|
44
|
+
.describe('Path to the UDF payload JSON file (relative to cwd or absolute)'),
|
|
45
|
+
pluginsDir: z
|
|
46
|
+
.string()
|
|
47
|
+
.min(1)
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('Override path to the plugins folder. When omitted, the binary auto-detects the plugins directory.'),
|
|
50
|
+
},
|
|
51
|
+
annotations: {
|
|
52
|
+
title: 'Validate Designer Payload',
|
|
53
|
+
readOnlyHint: true,
|
|
54
|
+
idempotentHint: true,
|
|
55
|
+
},
|
|
56
|
+
}, async ({ cwd, payload, pluginsDir }) => {
|
|
57
|
+
const projectCwd = resolve(cwd);
|
|
58
|
+
// Precondition check: the restforge-designer binary must be reachable on PATH.
|
|
59
|
+
// Treated as a non-error precondition per the authoring guide §3.4. The probe
|
|
60
|
+
// distinguishes "binary missing" (precondition) from "binary ran and reported
|
|
61
|
+
// something" (which falls through to the real execution below).
|
|
62
|
+
const probe = await execProcess('restforge-designer', ['--version'], {
|
|
63
|
+
cwd: projectCwd,
|
|
64
|
+
timeout: 10_000,
|
|
65
|
+
});
|
|
66
|
+
if (!probe.success) {
|
|
67
|
+
return {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: 'text',
|
|
71
|
+
text: `Precondition not met: the RESTForge Designer command-line tool is not installed or not on PATH.
|
|
72
|
+
|
|
73
|
+
Working directory: ${projectCwd}
|
|
74
|
+
Payload: ${payload}
|
|
75
|
+
Plugins dir: ${pluginsDir ?? 'auto-detect'}
|
|
76
|
+
Probe command: ${probe.command}
|
|
77
|
+
Exit code: ${probe.exitCode}
|
|
78
|
+
|
|
79
|
+
For the assistant:
|
|
80
|
+
- The user needs to install RESTForge Designer (and ensure it is on the system PATH) before a frontend payload can be validated.
|
|
81
|
+
- When explaining to the user, say something like "the RESTForge Designer tool isn't installed or isn't on your PATH yet — please install it and try again". Do not mention internal tool names.
|
|
82
|
+
- Once it is installed, retry validating the payload.`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
isError: false, // per §3.4
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Forward only the arguments the user supplied. The plugins directory is
|
|
89
|
+
// auto-detected by the binary when --plugins-dir is omitted. per §3.5
|
|
90
|
+
const args = ['validate', `--payload=${payload}`];
|
|
91
|
+
if (pluginsDir)
|
|
92
|
+
args.push(`--plugins-dir=${pluginsDir}`);
|
|
93
|
+
const result = await execProcess('restforge-designer', args, {
|
|
94
|
+
cwd: projectCwd,
|
|
95
|
+
timeout: 30_000,
|
|
96
|
+
});
|
|
97
|
+
// D7: this is a read-only tool. The pre-flight already confirmed the binary
|
|
98
|
+
// spawns, so an unexpected crash/timeout (no real exit code -> -1) is the only
|
|
99
|
+
// real error here -> isError: true. Any genuine exit code is a verdict to relay.
|
|
100
|
+
if (result.exitCode === -1) {
|
|
101
|
+
return {
|
|
102
|
+
content: [
|
|
103
|
+
{
|
|
104
|
+
type: 'text',
|
|
105
|
+
text: `Designer payload validation did not complete — the command crashed or timed out.
|
|
106
|
+
|
|
107
|
+
Working directory: ${projectCwd}
|
|
108
|
+
Payload: ${payload}
|
|
109
|
+
Plugins dir: ${pluginsDir ?? 'auto-detect'}
|
|
110
|
+
Command: ${result.command}
|
|
111
|
+
|
|
112
|
+
--- stderr ---
|
|
113
|
+
${result.stderr}
|
|
114
|
+
--- end stderr ---
|
|
115
|
+
|
|
116
|
+
For the assistant:
|
|
117
|
+
- The Designer CLI did not finish (likely a crash or timeout), so there is no validation verdict to report.
|
|
118
|
+
- Tell the user the check could not be completed and offer to retry. Do not mention internal tool names.`,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
isError: true, // per §3.4 — unexpected crash/timeout
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// D7: single response for ANY real exit code (success branch no longer split on
|
|
125
|
+
// result.success). A non-zero exit means the CLI reported an actionable negative
|
|
126
|
+
// verdict (invalid payload, plugin/file not found), which is a legitimate result
|
|
127
|
+
// to relay — NOT a tool failure. The model classifies from the fenced output.
|
|
128
|
+
const stderrBlock = result.stderr
|
|
129
|
+
? `\n--- stderr ---\n${result.stderr}\n--- end stderr ---\n`
|
|
130
|
+
: '';
|
|
131
|
+
return {
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'text',
|
|
135
|
+
text: `Designer payload validation ran.
|
|
136
|
+
|
|
137
|
+
Working directory: ${projectCwd}
|
|
138
|
+
Payload: ${payload}
|
|
139
|
+
Plugins dir: ${pluginsDir ?? 'auto-detect'}
|
|
140
|
+
Command: ${result.command}
|
|
141
|
+
Exit code: ${result.exitCode}
|
|
142
|
+
|
|
143
|
+
--- stdout ---
|
|
144
|
+
${result.stdout}
|
|
145
|
+
--- end stdout ---
|
|
146
|
+
${stderrBlock}
|
|
147
|
+
For the assistant:
|
|
148
|
+
- The Designer CLI ran to completion. Read the CLI output above and classify the result:
|
|
149
|
+
(a) Positive result — the payload is VALID against the target plugin schema. Confirm this in plain language and suggest the next step: preview the files that would be generated from this payload, or generate the frontend code. Describe steps by what they do.
|
|
150
|
+
(b) Actionable negative verdict — the payload is INVALID (the output lists structural errors), or the payload file was not found, or the target plugin / plugins directory could not be resolved. These are legitimate results to RELAY to the user, not tool malfunctions. Summarise the concrete problems (which fields, components, or paths are wrong) and offer to re-check after the user fixes them.
|
|
151
|
+
- A non-zero exit code here means the CLI reported a negative verdict (case b), NOT that the tool failed. Never tell the user "the tool failed" for case (b).
|
|
152
|
+
- Do not paste the raw CLI output unless the user explicitly asks. Do not mention internal tool names. Match the user's language.`,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=validate-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-payload.js","sourceRoot":"","sources":["../../../src/tools/designer/validate-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM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
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restforgejs/mcp-server",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "MCP server
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "RESTForge MCP Server — Model Context Protocol server that exposes RESTForge Platform commands to AI agents (Claude Desktop, Cursor, Claude CLI, and other MCP clients). Orchestrates project setup, code generation, and runtime launch via natural language. A thin orchestrator for the RESTForge Platform CLI, not a generic MCP framework or API testing tool.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"restforge-mcp": "./dist/index.js"
|