Skip to main content
Glama
gcorroto

MCP N8N Webhook Server

by gcorroto

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
        }
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the mechanism ('a través de webhook' - via webhook) which is useful context, but fails to disclose critical behavioral traits: whether this is a read or write operation (though 'Guardar' implies write), what permissions are needed, whether data is persisted permanently, what happens on failure, or any rate limits. For a data storage tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Spanish that communicates the core functionality. It's appropriately sized for a tool with 3 parameters and no complex behavior described. While concise, it could be more front-loaded with critical information about the tool's nature (write operation, webhook-based).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a data storage tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after data is saved (success/failure responses, return values), doesn't mention authentication requirements, and provides no information about data persistence or retrieval. For a tool that presumably writes data to n8n, this leaves too many unanswered questions about how to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all parameters are documented in the schema itself. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions. It doesn't explain relationships between parameters, provide examples, or add context about how parameters are used together. This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Guardar información' - Save information) and target ('en n8n a través de webhook' - in n8n via webhook), providing a specific verb+resource combination. It also mentions the purpose ('para indexación y almacenamiento' - for indexing and storage), which gives additional context about why this tool exists. However, it doesn't explicitly differentiate from its sibling tool (n8n_health_check), which is why it doesn't reach a score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or when not to use it. While it mentions the purpose ('para indexación y almacenamiento'), it doesn't specify use cases, prerequisites, or limitations. There's no comparison with the sibling tool (n8n_health_check), leaving the agent to guess when each is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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