Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Build Custom MCP Server with n8n

说明与用途

在45–60分钟内使用n8n构建MCP服务器:Webhook、验证、路由、响应格式化和头部身份验证,适用于任何LLM。

问题

LLMs need a standardized way to call external tools without hard‑coding provider payloads.

结果

Within 45–60 minutes, a fully functional MCP server is deployed in n8n, providing authenticated, validated, and error‑handled tool calls for any LLM.

工作流

  • Create n8n webhook with POST /mcp and Respond with JSON
  • Add Function node to validate MCP payload using Ajv schema
  • Add Switch node to route based on $json["method"] to tool cases
  • For each tool case, add appropriate action nodes (e.g., HTTP Request for Google Search)
  • Add Function node to format MCP response {result, error}
  • Connect final Function node to webhook response output
  • Enable Header Auth on webhook and set secret token in n8n environment
  • Test endpoint with curl using Authorization header
  • Register tool with LLM (e.g., OpenAI Assistant) using function schema

证据

You can spin up a bespoke Model Context Protocol (MCP) server in under an hour using n8n's visual workflow engine

来源

The webhook is the public entry point the LLM will hit. Using the "Respond with JSON" mode ensures the response complies with MCP's expected shape.

来源

Header authentication is simple, works with any LLM client, and avoids exposing a public API key.

来源

  • 记录日期: 2026-09-15T05:01:22.718Z