8
n8n 中文网amn8n.com

Context7 Smithery AI Agent MCP 服务器

高级

这是一个Engineering, AI领域的自动化工作流,包含 18 个节点。主要使用 McpClientTool, Agent, McpTrigger, ToolWorkflow, ExecuteWorkflowTrigger 等节点,结合人工智能技术实现智能自动化。 使用 Context7 和 Gemini 的文档查找 AI 代理

前置要求
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "vqujIu65SFbZUz0n",
  "meta": {
    "instanceId": "3612a0c89f35a354ddd1216385240db51b4635fde7cae2a0d5004be915b832f3",
    "templateCredsSetupCompleted": true
  },
  "name": "Context7 Smithery AI Agent MCP 服务器",
  "tags": [],
  "nodes": [
    {
      "id": "a42ae423-a348-460e-888c-f3df2b82021d",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        440,
        380
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "c8jj7D6oz6RJ81qp",
          "name": "Google Gemini Context7"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "22f3e783-4310-4d15-a875-cbb400a82c1b",
      "name": "context7-解析库ID",
      "type": "n8n-nodes-mcp.mcpClientTool",
      "position": [
        1280,
        480
      ],
      "parameters": {
        "toolName": "resolve-library-id",
        "operation": "executeTool",
        "connectionType": "http",
        "toolParameters": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tool_Parameters', `Generate a JSON object with the parameters for this tool.\nThe tool expects a JSON object with one **required** key:\n- \"libraryName\": (string) The common name of the software library or framework.\nExample: {\"libraryName\": \"react\"}`, 'json') }}",
        "descriptionType": "manual",
        "toolDescription": "Resolves a general library name (e.g., 'nextjs', 'mongodb') into a unique Context7-compatible library ID (e.g., '/vercel/next.js', '/mongodb/docs'). Use this tool first to get the correct ID before attempting to fetch its documentation."
      },
      "credentials": {
        "mcpClientHttpApi": {
          "id": "CL3sgNzCgbtRRxtL",
          "name": "smithery_context7"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "526eab1c-7a08-45eb-8169-7e8d4578c117",
      "name": "context7-获取库文档",
      "type": "n8n-nodes-mcp.mcpClientTool",
      "position": [
        1840,
        480
      ],
      "parameters": {
        "toolName": "get-library-docs",
        "operation": "executeTool",
        "connectionType": "http",
        "toolParameters": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tool_Parameters', `Generate a JSON object with the parameters for this tool.\nThe tool expects a JSON object with the following keys:\n- \"context7CompatibleLibraryID\": (string, **required**) The exact Context7-compatible library ID (e.g., \"/vercel/next.js\").\n- \"topic\": (string, optional) A specific topic to focus the documentation on (e.g., \"routing\").\n- \"tokens\": (number, optional, default: 10000) Maximum number of tokens for the documentation. Minimum effective value is 10000.\nExample for required only: {\"context7CompatibleLibraryID\": \"/mongodb/docs\"}\nExample with optional: {\"context7CompatibleLibraryID\": \"/vercel/next.js\", \"topic\": \"authentication\", \"tokens\": 15000}`, 'json') }}",
        "descriptionType": "manual",
        "toolDescription": "Fetches documentation for a specified library using its Context7-compatible library ID. You can optionally focus on a specific topic within the documentation and set a maximum token limit for the returned content."
      },
      "credentials": {
        "mcpClientHttpApi": {
          "id": "CL3sgNzCgbtRRxtL",
          "name": "smithery_context7"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5cafb0d4-19ac-4589-88d8-34b88404e0f1",
      "name": "Context7 MCP 服务器触发器",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        120,
        -860
      ],
      "webhookId": "c597b9e9-33bf-41d9-8602-e63d2bee174b",
      "parameters": {
        "path": "dafdfsdfsdf6e8-ea19-43b7-b337-a5iuodsf98vjfewf"
      },
      "typeVersion": 1
    },
    {
      "id": "945d8818-c346-44ba-b4c1-56d166a4f381",
      "name": "Context7 AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        880,
        -20
      ],
      "parameters": {
        "text": "={{ $('Context7 Workflow Start').item.json.query }}",
        "options": {
          "systemMessage": "You are an AI assistant with access to Context7 tools to help users find software library documentation.\nYour primary functions are to:\n1.  **Resolve Library IDs:** When a user asks for documentation for a library like 'Next.js' or 'MongoDB', first use the `resolve-library-id` tool to find its specific Context7-compatible ID (e.g., '/vercel/next.js'). The input for this tool is the `libraryName`.\n2.  **Get Library Documentation:** Once you have the `context7CompatibleLibraryID` from the previous step, use the `get-library-docs` tool to fetch the documentation.\n    *   The required parameter is `context7CompatibleLibraryID`.\n    *   If the user specifies a particular `topic` (e.g., \"routing in Next.js\"), include this in the `topic` parameter.\n    *   You can also adjust the `tokens` parameter if a different length of documentation is implicitly or explicitly requested, keeping in mind the default and minimum is 10000.\n\nAlways use `resolve-library-id` before `get-library-docs` if you don't already have the exact Context7-compatible library ID. Be precise with the IDs."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "1b0cd3cc-8566-4cb5-932c-005149a2467b",
      "name": "Context7 工作流开始",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        100,
        -20
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "query"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e955aa60-2b80-45d5-885b-24b7fe56a426",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        700,
        520
      ],
      "parameters": {
        "sessionKey": "={{ $execution.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4927c593-5762-4a26-87eb-8a7e0a4b3d32",
      "name": "call_context7_ai_agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        280,
        -460
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "vqujIu65SFbZUz0n",
          "cachedResultName": "Context7 Smithery AI Agent MCP Server"
        },
        "description": "=处理自然语言查询,使用 Context7 查找并检索软件库文档。它智能地使用子工具首先将库名称解析为 Context7 ID,然后获取相关文档。",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', `The user's natural language question or request for software library documentation. For example: 'How do I implement authentication in Next.js?' or 'Get docs for MongoDB aggregation framework'.`, 'string') }}"
          },
          "schema": [
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d72a2661-5622-4bfa-9d42-8c96b5fef877",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1700,
        -40
      ],
      "parameters": {
        "width": 680,
        "height": 320,
        "content": "## 用于 Roo Code 等的 MCP JSON"
      },
      "typeVersion": 1
    },
    {
      "id": "c0dc815b-3d0f-49e2-8da0-08d2f45d0991",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -1140
      ],
      "parameters": {
        "color": 4,
        "width": 580,
        "height": 420,
        "content": "此节点是 Context7 AI Agent 服务的公共入口点。"
      },
      "typeVersion": 1
    },
    {
      "id": "adc54a99-b04d-40be-a9a4-25f837453c14",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -680
      ],
      "parameters": {
        "color": 4,
        "width": 580,
        "height": 340,
        "content": "此节点代表外部客户端通过 MCP Server Trigger 调用的工具。"
      },
      "typeVersion": 1
    },
    {
      "id": "5cc037d1-4155-49dc-86f5-7af9976149bf",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1700,
        -660
      ],
      "parameters": {
        "color": 2,
        "width": 680,
        "height": 600,
        "content": "## 主 MCP 服务器工作流概述"
      },
      "typeVersion": 1
    },
    {
      "id": "79bf63c1-b325-4a3c-950e-30df5aef15e4",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 200,
        "content": "这是 AI Agent 子工作流的入口点。"
      },
      "typeVersion": 1
    },
    {
      "id": "2486cacc-b06a-4e30-b363-456930cf0ea5",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -280
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 440,
        "content": "核心 AI 逻辑单元。"
      },
      "typeVersion": 1
    },
    {
      "id": "f5f12aa6-d90a-419c-9baa-2c7c451a71d1",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        640
      ],
      "parameters": {
        "color": 6,
        "width": 360,
        "height": 200,
        "content": "为 AI Agent 提供对话记忆。"
      },
      "typeVersion": 1
    },
    {
      "id": "d2598e8e-3931-436f-a480-b4bef659bccb",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        640
      ],
      "parameters": {
        "color": 6,
        "width": 480,
        "height": 500,
        "content": "此节点允许 AI Agent 使用外部的 'resolve-library-id' Context7 MCP 工具。"
      },
      "typeVersion": 1
    },
    {
      "id": "7bebd852-75e5-427e-a3ee-781cd85f20e6",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1620,
        640
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 500,
        "content": "此节点允许 AI Agent 使用外部的 'get-library-docs' Context7 MCP 工具。"
      },
      "typeVersion": 1
    },
    {
      "id": "f4749f9a-6f9e-45c5-b6a9-a89d4dc77dec",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -1380
      ],
      "parameters": {
        "color": 7,
        "width": 1140,
        "height": 1040,
        "content": "## n8n AI Agent 作为 MCP 服务(Context7 文档示例)"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "785e4ebf-bb80-48e3-872c-40d1b9a8d14b",
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Context7 AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "call_context7_ai_agent": {
      "ai_tool": [
        [
          {
            "node": "Context7 MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Context7 Workflow Start": {
      "main": [
        [
          {
            "node": "Context7 AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Context7 AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "context7-get-library-docs": {
      "ai_tool": [
        [
          {
            "node": "Context7 AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "context7-resolve-library-id": {
      "ai_tool": [
        [
          {
            "node": "Context7 AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 工程, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量18
分类2
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Jez

Jez

@jez

I'm passionate about combining traditional web development with AI and automation to create impactful online solutions. As Founder & CEO of Jezweb, an award-winning Newcastle, Australia agency, I lead a 30+ person team delivering high-quality web design, development, and hosting services to over 3000 clients.

外部链接
在 n8n.io 查看

分享此工作流