> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/connect/readme.md).

# Connect

Connect to n8n from code, scripts, and AI tools.

Use this documentation when you want to work with n8n outside the editor. You can call the public API, script against it with the CLI, or connect MCP-compatible clients.

This section includes the n8n API guides and reference material, the n8n CLI reference, and the docs for the built-in n8n MCP server. It also covers authentication, connection setup, and client-specific instructions for connecting tools and agents to n8n.

{% hint style="info" %}
Choose the interface that matches your workflow. Each option uses a different access model and fits a different job.
{% endhint %}

{% tabs %}
{% tab title="n8n API" %}
Manage n8n programmatically over HTTP.

Best for:

* Building platforms and tooling on top of n8n
* Triggering and monitoring executions from external systems
* Automating workflow and credential management

Start with [n8n API](/connect/n8n-api.md).
{% endtab %}

{% tab title="n8n CLI" %}
Control n8n directly from your terminal.

Best for:

* Importing and exporting workflows
* Running executions in scripts and CI pipelines
* Local development and debugging

Start with [n8n CLI](/connect/n8n-cli.md).
{% endtab %}

{% tab title="MCP server" %}
Connect AI agents and MCP clients directly to your n8n instance.

Best for:

* Claude Code, Claude Desktop, Lovable, and similar tools
* Discovering and executing workflows from an AI agent
* Managing workflows through an MCP client

Start with [Connect to n8n MCP server](/connect/connect-to-n8n-mcp-server.md).
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.n8n.io/connect/readme.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
