Skip to main content

Documentation Lookup AI Agent using Context7 and Gemini

Workflow preview

Workflow preview
100%
Documentation Lookup AI Agent using Context7 and Gemini preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n workflow template uses community nodes and is only compatible with the self hosted version of n8n. This workflow demonstrates how to build and expose a sophisticated n8n AI Agent as a sing...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-mcp.mcpclienttool, @n8n/n8n-nodes-langchain.mcptrigger, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.executeworkflowtrigger, @n8n/n8n-nodes-langchain.memorybufferwindow, @n8n/n8n-nodes-langchain.toolworkflow, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Jez.

Original n8n.io source

1.1 Workflow description

Title
Documentation Lookup AI Agent using Context7 and Gemini
Workflow name
Documentation Lookup AI Agent using Context7 and Gemini

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

This workflow demonstrates how to build and expose a sophisticated n8n AI Agent as a single, callable tool using the Multi-Agent Collaboration Protocol (MCP). It allows external clients or other AI systems to easily query software library documentation via Context7, without needing to manage the underlying tool orchestration or complex conversational logic.

Core Idea: Instead of building complex agentic loops on the client-side (e.g., in Python, a VS Code extension, or another AI development environment), this workflow offloads the entire agent's reasoning and tool-use process to n8n. The client simply sends a natural language query (like "How do I use Flexbox in Tailwind CSS?") to an SSE endpoint, and the n8n agent handles the rest.

Key Features & How It Works:

  1. Public MCP Endpoint:
    • The main workflow uses the Context7 MCP Server Trigger node to create an SSE endpoint. This makes the agent accessible to any MCP-compatible client.
    • The path for the endpoint is kept long and random for basic 'security by obscurity'.
  2. Tool Workflow as an Interface:
    • A Tool Workflow node (named call_context7_ai_agent in this example) is connected to the MCP Server Trigger. This node defines the single "tool" that external clients will see and call.
  3. Dedicated AI Agent Sub-Workflow:
    • The call_context7_ai_agent tool invokes a separate sub-workflow which contains the actual AI logic.
    • This sub-workflow starts with a Context7 Workflow Start node to receive the user's query.
    • A Context7 AI Agent node (using Google Gemini in this example) is the brain, equipped with:
      • A system prompt to guide its behavior.
      • Simple Memory to retain context for each execution (using {{ $execution.id }} as the session key).
      • Two specialized Context7 MCP client tools:
        • context7-resolve-library-id: To convert library names (e.g., 'Next.js') into Context7-specific IDs.
        • context7-get-library-docs: To fetch documentation using the resolved ID, with options for specific topics and token limits.
  4. Seamless Tool Use: The AI Agent autonomously decides when and how to use the resolve-library-id and get-library-docs tools based on the user's query, handling the multi-step process internally.

Benefits of This Approach:

  • Simplified Client Integration: Clients interact with a single, powerful tool, sending a simple query.
  • Reduced Client-Side Token Consumption: The detailed prompts, tool descriptions, and conversational turns are managed server-side by n8n, saving tokens on the client (especially useful if the client is another LLM).
  • Centralized Agent Management: Update your agent's capabilities, tools, or LLM model within n8n without any changes needed on the client side.
  • Modularity for Agentic Systems: Perfect for building complex, multi-agent systems where this n8n workflow can act as a specialized "expert" agent callable by others (e.g., from environments like Smithery).
  • Cost-Effective: By using a potentially less expensive model (like Gemini Flash) for the agent's orchestration and leveraging the free tier or efficient pricing of services like Context7, you can build powerful solutions economically.

Use Cases:

  • Providing an intelligent documentation lookup service for coding assistants or IDE extensions.
  • Creating specialized AI "micro-agents" that can be consumed by larger AI applications.
  • Building internal knowledge base query systems accessible via a simple API-like interface.

Setup:

  • Ensure you have the necessary n8n credentials for Google Gemini (or your chosen LLM) and the Context7 MCP client tools.
  • The Path in the Context7 MCP Server Trigger node should be unique and secure.
  • Clients connect to the "Production URL" (SSE endpoint) provided by the trigger node.

This workflow is a great example of how n8n can serve as a powerful backend for building and deploying modular AI agents.

I've made a video to try and explain this a bit too https://www.youtube.com/watch?v=dudvmyp7Pyg

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 2 - context7-resolve-library-id

Type / Role
n8n-nodes-mcp.mcpClientTool - mcpClientTool
Config choices
Version 1

Block 3 - context7-get-library-docs

Type / Role
n8n-nodes-mcp.mcpClientTool - mcpClientTool
Config choices
Version 1

Block 4 - Context7 MCP Server Trigger

Type / Role
@n8n/n8n-nodes-langchain.mcpTrigger - mcpTrigger
Config choices
Version 1

Block 5 - Context7 AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 6 - Context7 Workflow Start

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 7 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 8 - call_context7_ai_agent

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 2.2

Block 9 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Documentation Lookup AI Agent using Context7 and Gemini
Complexity advanced
Nodes 18
Categories Internal Wiki, AI RAG
Author Jez
Published 01 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4547/4547.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Documentation Lookup AI Agent using Context7 and Gemini do?

This n8n workflow template uses community nodes and is only compatible with the self hosted version of n8n. This workflow demonstrates how to build and expose a sophisticated n8n AI Agent as a sing...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.