Skip to main content
Glama

n8n_save_data

Save structured information to n8n via webhooks for storage, indexing, and retrieval. Submit project name, title, and text content for organized data management.

Instructions

Guardar información en n8n a través de webhook para indexación y almacenamiento

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNameYesNombre del proyecto
titleYesTítulo del contenido
textYesTexto completo del contenido a guardar

Implementation Reference

  • index.ts:21-50 (registration)
    Registers the MCP tool 'n8n_save_data' with Zod input schema, description, and inline handler function that delegates to webhookTools.saveDataToWebhook and formats the markdown response.
    server.tool( "n8n_save_data", "Guardar información en n8n a través de webhook para indexación y almacenamiento", { projectName: z.string().describe("Nombre del proyecto"), title: z.string().describe("Título del contenido"), text: z.string().describe("Texto completo del contenido a guardar") }, async (args) => { console.error(`📤 Guardando datos en n8n: ${args.title}`); const result = await webhookTools.saveDataToWebhook({ projectName: args.projectName, title: args.title, text: args.text }); const statusIcon = result.success ? '✅' : '❌'; const content = result.success ? `${statusIcon} **Datos guardados exitosamente**\n\n**Proyecto:** ${args.projectName}\n**Título:** ${args.title}\n**ID:** ${result.id}\n**Timestamp:** ${result.timestamp}\n\n${result.message}` : `${statusIcon} **Error al guardar datos**\n\n**Error:** ${result.message}\n**Timestamp:** ${result.timestamp}`; return { content: [{ type: "text", text: content }], }; } );
  • Core handler function that constructs the webhook payload, sends POST request to n8n webhook URL using fetch, handles HTTP responses, errors, and returns success/failure status with details.
    export async function saveDataToWebhook(args: SaveDataArgs): Promise<WebhookResponse> { try { console.error(`📤 Enviando datos al webhook n8n...`); console.error(`URL: ${WEBHOOK_URL}/${WEBHOOK_ID}`); const payload = buildWebhookPayload(args); console.error(`📋 Payload generado:`, JSON.stringify(payload, null, 2)); const response = await fetch(`${WEBHOOK_URL}/${WEBHOOK_ID}`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization-n8n-api-key': API_KEY, 'User-Agent': 'MCP-N8N-Webhook/1.0' }, body: JSON.stringify(payload) }); console.error(`📡 Respuesta HTTP: ${response.status} ${response.statusText}`); if (!response.ok) { const errorText = await response.text(); console.error(`❌ Error en respuesta:`, errorText); return { success: false, message: `Error HTTP ${response.status}: ${response.statusText}. ${errorText}`, timestamp: generateTimestamp() }; } let responseData: any; try { responseData = await response.json(); } catch (parseError) { // Si no es JSON válido, usar el texto de respuesta const textResponse = await response.text(); responseData = { message: textResponse }; } console.error(`✅ Datos enviados exitosamente:`, responseData); return { success: true, message: 'Datos guardados exitosamente en n8n', id: responseData.id || payload.project.id, timestamp: generateTimestamp() }; } catch (error) { console.error(`❌ Error enviando datos al webhook:`, error); return { success: false, message: `Error de conexión: ${(error as Error).message}`, timestamp: generateTimestamp() }; }
  • Zod schema defining input parameters for the 'n8n_save_data' tool: projectName, title, text.
    { projectName: z.string().describe("Nombre del proyecto"), title: z.string().describe("Título del contenido"), text: z.string().describe("Texto completo del contenido a guardar") },
  • TypeScript interface defining the input arguments for saveDataToWebhook, matching the tool schema.
    export interface SaveDataArgs { projectName: string; title: string; text: string; }
  • Helper function to build the complete WebhookPayload object from input args, including metadata, project ID generation, and content.
    function buildWebhookPayload(args: SaveDataArgs): WebhookPayload { const timestamp = generateTimestamp(); return { metadata: { timestamp, source: 'mcp_assistant', version: '1.0' }, project: { id: generateProjectId(args.projectName), name: args.projectName }, content: { title: args.title, text: args.text } }; }

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gcorroto/mcp-n8n-webhook'

If you have feedback or need assistance with the MCP directory API, please join our Discord server