> For the complete documentation index, see [llms.txt](https://chain-love.gitbook.io/mcp-module/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chain-love.gitbook.io/mcp-module/getting-started/connect-ai-agent.md).

# Connect an AI agent

Chain.Love MCP Gateway exposes a hosted MCP endpoint that an AI agent can use as a Web3 gateway:

```
https://app.chain.love/mcp
```

{% hint style="info" %}
The hosted Chain.Love gateway currently does not require authorization. For most setups, you only need the endpoint URL below.
{% endhint %}

## Basic connection flow

Use this quick setup flow first, then copy the config example that matches your case.

{% stepper %}
{% step %}

#### Add the public endpoint

Add `https://app.chain.love/mcp` to your MCP-compatible AI agent. This is enough for public gateway access.
{% endstep %}

{% step %}

#### Add optional token or downstream credentials

If you want to use a Chain.Love token, add `Authorization: Bearer <CHAINLOVE_MCP_TOKEN>`. If a private MCP needs its own credentials, pass them as `x-chainlove-cred-*` headers in the same MCP config.
{% endstep %}

{% step %}

#### Restart or reload your agent

Most AI clients load MCP configuration on startup. Restart the client or reload its MCP servers after changing the config.
{% endstep %}

{% step %}

#### Test discovery

Ask the agent to call `discover_networks`. If the configuration is correct, it should return the list of supported chain keys.
{% endstep %}
{% endstepper %}

***

## Minimal `mcp_config.json` example

```json
{
  "mcpServers": {
    "chainlove-gateway": {
      "url": "https://app.chain.love/mcp"
    }
  }
}
```

## Optional Chain.Love token

If you want to create a Chain.Love token, open the Chain.Love UI:

<https://app.chain.love/user>

Use it as an HTTP bearer token in your MCP client:

```json
{
  "mcpServers": {
    "chainlove-gateway": {
      "url": "https://app.chain.love/mcp",
      "headers": {
        "Authorization": "Bearer <CHAINLOVE_MCP_TOKEN>"
      }
    }
  }
}
```

Token hygiene:

* Store the token in local config or a secret manager.
* Never commit real tokens into Git, screenshots, examples, or public issues.
* Rotate the token if it was exposed.

## Downstream credentials for private MCP servers

Use the hosted gateway URL in your MCP client and add downstream credentials only when a private MCP requires them, using `x-chainlove-cred-<credentialKey>` headers.

To understand which header name you need, open the open-source registry file at [mcpservers.csv](https://github.com/Chain-Love/chain-love/blob/main/references/offers/mcpservers.csv) or browse the UI at <https://app.chain.love/toolbox/mcpservers>, choose the MCP server you want, and check its `credentialKey` value.

## Generic private MCP credential pattern

```json
{
  "mcpServers": {
    "chainlove-gateway": {
      "url": "https://app.chain.love/mcp",
      "headers": {
        "x-chainlove-cred-<credentialKey>": "<credentialValue>"
      }
    }
  }
}
```

## Example: GitHub MCP

```json
{
  "mcpServers": {
    "chainlove-gateway": {
      "url": "https://app.chain.love/mcp",
      "headers": {
        "x-chainlove-cred-github": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

For GitHub MCP, the `credentialKey` is `github`, so the header becomes `x-chainlove-cred-github`.

***

## Self-hosted MCP servers

Self-hosted MCP servers cannot be proxied through the public hosted endpoint. They need to be deployed and run locally in the user's environment. Chain.Love can help the agent understand how that MCP should be set up in the local workspace so the agent can connect to it directly.

***

## First test prompt

After restarting your agent, ask:

```
Use Chain.Love MCP and call discover_networks. Which networks are supported?
```

Then try a registry search:

```
Use Chain.Love MCP to search for GitHub MCP in the mcpservers category.
```

{% hint style="info" %}
For a visual overview and more examples, see the MCP Gateway landing page: <https://chain.love/mcp-gateway>
{% endhint %}


---

# 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://chain-love.gitbook.io/mcp-module/getting-started/connect-ai-agent.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.
