> For the complete documentation index, see [llms.txt](https://docs.metamynd.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metamynd.ai/get-started/connect-an-agent-to-an-ai-app.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# Connect an Agent to an AI App

Give an AI app you already use (Claude Desktop, Claude Code, Cursor or VS Code) tools that run as one of your agents, under that agent's mandate. No code: everything is set up from the agent's page in the dashboard. Every tool call is then checked by MetaMynd first: allowed calls run, the rest are refused or wait for your approval, and each one appears in the agent's activity.

{% embed url="<https://youtu.be/1eYscx7NKok>" %}

Under the hood this is the [MetaMynd MCP gateway](https://docs.metamynd.ai/sdks/mcp-gateway). Why put MetaMynd in front of tools that already have permissions? See [Beyond a Service's Own Permissions](https://docs.metamynd.ai/core-concepts/beyond-a-services-own-permissions).

#### Before you start <a href="#user-content-before-you-start" id="user-content-before-you-start"></a>

* An agent with a mandate. If it has none, use **Set mandate** on its page first.
* The agent's key: the one you saved when you created the agent. Lost it? Use **Rotate key** under Network identities, which issues a new one.
* An account with the service you want to connect (for example Notion), where you can create an integration or token.

#### 1. Choose the app and the tools <a href="#user-content-1-choose-the-app-and-the-tools" id="user-content-1-choose-the-app-and-the-tools"></a>

On the agent's page, click **Connect to an AI app**.

1. **Pick the app:** Claude Desktop, Claude Code, Cursor or VS Code.
2. **Tick the tools** the agent may use. Each is described in plain language, with what it does: *reads*, *changes*, *deletes or archives* or *moves money*. Pick only what the agent needs.

#### 2. Grant what the tools need <a href="#user-content-2-grant-what-the-tools-need" id="user-content-2-grant-what-the-tools-need"></a>

Every tool runs under **its own action**: Notion's reading tools under `notion-read`, its editing tools under `notion-write`, and so on. If the agent's mandate doesn't grant an action yet, the dialog lists it under **Grant these actions first**, with what it covers.

Click **Grant `<action>`**. The grant is for that one action only: no other permission comes with it, and for an action that moves money you set its limits. A grant for something else (say, `flight-purchase`) never covers a tool, so the agent's mandates always say exactly what it may do, and its evidence always records what it actually did.

Build stays disabled until nothing you picked would be refused.

#### 3. Create the service's credential with only what the tools need <a href="#user-content-3-create-the-services-credential-with-only-what-the-tools-need" id="user-content-3-create-the-services-credential-with-only-what-the-tools-need"></a>

The setup steps list the service's own permissions the picked tools need, for example in Notion:

* read-only tools: *Read content*, *Read comments* and *Read user information without email addresses*;
* add editing tools: also *Insert content*, *Update content* and *Insert comments*.

Turn on only those, and share only the pages or records the agent needs. This is the outer fence: if anything else failed, the credential still couldn't do more.

#### 4. Install it <a href="#user-content-4-install-it" id="user-content-4-install-it"></a>

**Claude Desktop**

1. Click **Build extension**, then download the `.mcpb` file.
2. Open it. Claude Desktop shows the extension and asks to install it.
3. It asks for the **agent key** and each tool's credential (for example the *Notion integration token*). Claude Desktop stores them securely; MetaMynd never sees them.
4. Turn the extension on.

**Claude Code, Cursor, VS Code**

1. Click **Download the setup folder** and unzip it into a folder you'll keep. It holds the gateway's settings and the agent's identity, and no key or password.
2. Store the agent key and each credential in your computer's keychain. The dialog shows one command for each (`npx -y @metamynd/mcp-gateway@<version> secret set <name>`); run each in a terminal. It asks for the value without showing it.
3. Enter the folder's location. The dialog shows the snippet for your app and where it goes: .cursor/mcp.json for Cursor, .vscode/mcp.json for VS Code (under `servers`), or a `claude mcp add` command for Claude Code.
4. Restart the app.

#### 5. Remove any direct connection to the same service <a href="#user-content-5-remove-any-direct-connection-to-the-same-service" id="user-content-5-remove-any-direct-connection-to-the-same-service"></a>

If the app can also reach the service directly (its own MCP entry, an extension or a connector for the same tool), remove it. While it's there, the AI can use that service without MetaMynd.

#### Using it <a href="#user-content-using-it" id="user-content-using-it"></a>

Ask the app to do something that needs the tools. What you'll see:

| What happens                                 | What it means                                                                                                                                                      |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| The tool runs                                | MetaMynd allowed it. It's in the agent's governance activity.                                                                                                      |
| "MetaMynd refused this call (`REASON`)"      | Not allowed by the mandate or a rule. Look up the reason in the [Reason Code Registry](https://docs.metamynd.ai/agent-protocol/reason-code-registry). Nothing ran. |
| "MetaMynd is holding this call for approval" | A rule needs a person. Approve it in the dashboard, then ask again with the same request: it runs once.                                                            |
| "Not sent: argument(s) not allowed"          | The AI tried to send something the tool's review doesn't allow. Nothing was sent.                                                                                  |

#### Troubleshooting <a href="#user-content-troubleshooting" id="user-content-troubleshooting"></a>

* **The tools don't appear.** Restart the app after installing. In Claude Desktop, check the extension is turned on. For the folder-based apps, check the snippet's path points at `mcp-gateway.json` in the unzipped folder.
* **"cannot resolve credential reference" when the app starts the gateway.** A keychain item is missing: run the `secret set` commands again with the names the dialog shows.
* **Everything is refused with `NO_MANDATE` or `MANDATE_REVOKED`.** The agent's mandate doesn't grant (or no longer grants) that tool's action. Grant it from **Connect to an AI app** or the agent's page.
* **Everything is refused with `GATE_UNREACHABLE`.** The computer can't reach MetaMynd. Nothing runs until it can.
* **To stop the agent at once,** contain it on its page: every tool refuses it from the next call, in every app.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.metamynd.ai/get-started/connect-an-agent-to-an-ai-app.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
