@netpad/mcp-server 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22172,16 +22172,142 @@ async function main() {
22172
22172
  filename: `${slug}.ts`,
22173
22173
  envVars: STANDARD_ENV_VARS
22174
22174
  });
22175
+ const importConfig = {
22176
+ name: schema.name,
22177
+ description: schema.description,
22178
+ fieldConfigs: schema.fieldConfigs,
22179
+ multiPage: schema.multiPage,
22180
+ theme: schema.theme
22181
+ };
22182
+ const base64Config = Buffer.from(JSON.stringify(importConfig)).toString("base64");
22183
+ const baseUrl = process.env.NETPAD_URL || "https://netpad.io";
22184
+ const importUrl = `${baseUrl}/api/forms/import?config=${base64Config}&source=claude-mcp`;
22185
+ const outputWithImport = formatToolOutput(output) + `
22186
+
22187
+ ---
22188
+
22189
+ ## Quick Import (No Code Required!)
22190
+
22191
+ Click this link to import the form directly into NetPad:
22192
+ **[Import to NetPad](${importUrl})**
22193
+
22194
+ Or use the create_import_link tool for a shorter, more reliable link (recommended for complex forms).
22195
+ `;
22175
22196
  return {
22176
22197
  content: [
22177
22198
  {
22178
22199
  type: "text",
22179
- text: formatToolOutput(output)
22200
+ text: outputWithImport
22180
22201
  }
22181
22202
  ]
22182
22203
  };
22183
22204
  }
22184
22205
  );
22206
+ server.tool(
22207
+ "create_import_link",
22208
+ "Create a shareable import link for a NetPad form configuration. Use this to generate a short, reliable import URL that users can click to import the form directly into their NetPad account. Recommended for complex forms or when the base64 URL would be too long.",
22209
+ {
22210
+ config: external_exports.object({
22211
+ name: external_exports.string().describe("Form name"),
22212
+ description: external_exports.string().optional().describe("Form description"),
22213
+ fieldConfigs: external_exports.array(external_exports.object({
22214
+ path: external_exports.string(),
22215
+ label: external_exports.string(),
22216
+ type: external_exports.string(),
22217
+ included: external_exports.boolean(),
22218
+ required: external_exports.boolean().optional(),
22219
+ placeholder: external_exports.string().optional(),
22220
+ options: external_exports.array(external_exports.any()).optional(),
22221
+ validation: external_exports.any().optional(),
22222
+ conditionalLogic: external_exports.any().optional()
22223
+ })).describe("Array of field configurations"),
22224
+ multiPage: external_exports.any().optional().describe("Multi-page configuration"),
22225
+ theme: external_exports.any().optional().describe("Theme configuration")
22226
+ }).describe("Form configuration object"),
22227
+ projectId: external_exports.string().optional().describe("Target project ID (user will pick if not specified)"),
22228
+ expiresIn: external_exports.number().optional().describe("Expiry time in seconds (default: 24 hours, max: 7 days)")
22229
+ },
22230
+ async ({ config: config2, projectId, expiresIn }) => {
22231
+ const baseUrl = process.env.NETPAD_URL || "https://netpad.io";
22232
+ try {
22233
+ const response = await fetch(`${baseUrl}/api/forms/import`, {
22234
+ method: "POST",
22235
+ headers: {
22236
+ "Content-Type": "application/json"
22237
+ },
22238
+ body: JSON.stringify({
22239
+ config: config2,
22240
+ projectId,
22241
+ source: "claude-mcp",
22242
+ expiresIn: expiresIn || 86400,
22243
+ // Default 24 hours
22244
+ mcpVersion: "2.3.0"
22245
+ })
22246
+ });
22247
+ if (!response.ok) {
22248
+ const error48 = await response.json().catch(() => ({}));
22249
+ return {
22250
+ content: [
22251
+ {
22252
+ type: "text",
22253
+ text: `\u274C Failed to create import link: ${error48.error || response.statusText}
22254
+
22255
+ Fallback: Use the generate_form tool with outputFormat: "json" and manually import the config.`
22256
+ }
22257
+ ]
22258
+ };
22259
+ }
22260
+ const result = await response.json();
22261
+ return {
22262
+ content: [
22263
+ {
22264
+ type: "text",
22265
+ text: `\u2705 **Import Link Created!**
22266
+
22267
+ **Form:** ${config2.name}
22268
+ **Fields:** ${config2.fieldConfigs.length}
22269
+ **Expires:** ${new Date(result.expiresAt).toLocaleString()}
22270
+
22271
+ ---
22272
+
22273
+ ## Click to Import
22274
+
22275
+ [**\u2192 Import "${config2.name}" to NetPad**](${result.importUrl})
22276
+
22277
+ ---
22278
+
22279
+ **Import ID:** \`${result.importId}\`
22280
+ **Direct URL:** ${result.importUrl}
22281
+
22282
+ The user will be prompted to log in (if needed) and select a project before importing.`
22283
+ }
22284
+ ]
22285
+ };
22286
+ } catch (error48) {
22287
+ const base64Config = Buffer.from(JSON.stringify(config2)).toString("base64");
22288
+ const fallbackUrl = `${baseUrl}/api/forms/import?config=${base64Config}&source=claude-mcp`;
22289
+ return {
22290
+ content: [
22291
+ {
22292
+ type: "text",
22293
+ text: `\u26A0\uFE0F Could not create short import link (API unavailable). Using fallback URL.
22294
+
22295
+ **Form:** ${config2.name}
22296
+ **Fields:** ${config2.fieldConfigs.length}
22297
+
22298
+ ---
22299
+
22300
+ ## Fallback Import Link
22301
+
22302
+ [**\u2192 Import "${config2.name}" to NetPad**](${fallbackUrl})
22303
+
22304
+ Note: This URL may be long. If it doesn't work, ask the user to use the NetPad form builder directly.`
22305
+ }
22306
+ ]
22307
+ };
22308
+ }
22309
+ }
22310
+ );
22185
22311
  server.tool(
22186
22312
  "generate_field",
22187
22313
  "Generate a single field configuration for a NetPad form. Use this when you need to add a specific field to an existing form.",