# Connect your agent

> Let Claude Code, Claude.ai, Cursor, Codex or any MCP client read your architecture and write your databases through Architure's MCP server, with an API key or OAuth.

Source: https://docs.architure.dev/docs/connect-your-agent

Architure serves your organization's architecture to agents through an MCP server (Streamable HTTP): the tech stack, the repositories and their packages, the team's skills, the environment variable names (never the values) and the databases, which agents also write. Its address:


```text
https://app.architure.dev/api/mcp
```



In the app, **Agents** in the organization's sidebar and **Connect an agent** in the canvas's top bar show the same address. The Agents page also holds the organization's API keys, each repository's [install link](/docs/skills#install-link) status and the list of the MCP tools.

Connecting an agent takes two things: **access** to the MCP server (an API key or OAuth) and, recommended, the **[skill](/docs/skill)**, which teaches the agent how to work with Architure: find the package it works in, read the tech stack before choosing a library, follow the team's skills, use the organization's variable names, read the database before writing, check it after writing.

## API key or OAuth

| | API key | OAuth |
| --- | --- | --- |
| Who it acts as | The organization; changes are signed with the key's name | You, with your role in the organization |
| What it may do | Chosen when the key is created: **Read** (every read tool), or **Read and write** (also the database writes) | Read and write, limited by your role: an owner, admin or member writes; a viewer's agent only reads |
| Who sets it up | An owner or admin creates the key on the organization's **Agents** page | You, by signing in from the agent |
| Best for | CI, scripts, shared or headless machines | Your own Claude Code, Claude.ai, Cursor or Codex |
| How to stop it | Revoke the key on **Agents** | Remove the connection in the agent; leaving the organization stops it too |

Both reach one organization only: a key or a token never sees another organization's work. Neither ever returns an environment variable's value, and agents never change the tech stack, skills or variables: they write databases only.

### Create an API key

1. In the app, open **Agents** in your organization's sidebar. Only owners and admins create and revoke keys; other members connect through OAuth.
2. Give the key a **Name** that says where it runs (for example `Claude Code on my laptop` or `ci`), choose its **Permission**, **Read** or **Read and write**, and choose **Create key**.
3. Copy the key, which starts with `architure_`. It is shown once: if you lose it, revoke it and create another.

Keep the key in an environment variable, never in a file you commit. The examples below read it from `ARCHITURE_API_KEY`:

```bash
export ARCHITURE_API_KEY="architure_..."
```

A key allows 600 requests per minute. Create one key per machine or pipeline, so its changes are signed with its own name and you can revoke it alone. The Agents page lists each key with its permission and when it was last used.

### Sign in with OAuth

When an agent connects without a key, it opens your browser on **Connect *agent* to Architure**: sign in to Architure (or create an account), read what the agent asks for, choose the **Organization** it works on (it works on that organization only), check the return address the page shows, and choose **Allow**; **Deny** tells the agent no. The agent receives a token for that organization with the scopes `schema:read` and `schema:write`. Your membership and your role are checked again on every call: leave the organization, or become a viewer, and the agent loses what it had.

If you belong to no organization yet, the page says so: choose **Deny**, then **Create an organization**, and start the connection again from the agent. The page expires after ten minutes; start again from the agent if it says the request has expired.

Agents find the sign-in on their own: the server answers a request without a credential with `401` and the address of its OAuth metadata (`/.well-known/oauth-protected-resource`). Architure accepts sign-ins that return to:

- Claude.ai, Claude Desktop and Claude's mobile apps (Claude's hosted callback);
- Cursor on the web and Cursor's cloud agents (Cursor's hosted callback);
- an agent on your own machine, such as Claude Code, Cursor's desktop app or Codex, which listens on a `localhost` or `127.0.0.1` address.

Any other hosted service cannot sign in: give it an API key.

## Claude Code

### With the plugin and OAuth (recommended)

The `architure` plugin installs the skill and the MCP server together.

**1. Install the plugin.** Add the marketplace and install the plugin from your shell:

```bash
claude plugin marketplace add architure/skills
claude plugin install architure@architure
```

**2. Sign in.** Start Claude Code (`claude`), run `/mcp`, select `architure` and choose **Authenticate**. Your browser opens: sign in, choose the organization, and allow access. If the browser does not open, copy the address Claude Code prints.

**3. Check.** Ask Claude "List my Architure databases". It calls `list_databases` and lists them.

### With an API key

**1. Create a key.** [Create a key](#create-an-api-key) and export `ARCHITURE_API_KEY`.

**2. Add the MCP server** for every repository on this machine (`--scope user`):


```bash
claude mcp add --transport http --scope user architure https://app.architure.dev/api/mcp \
  --header "Authorization: Bearer $ARCHITURE_API_KEY"
```



To share the server with your team through the repository instead, commit a `.mcp.json` at its root that reads the key from each person's environment:


```json
{
  "mcpServers": {
    "architure": {
      "type": "http",
      "url": "https://app.architure.dev/api/mcp",
      "headers": {
        "Authorization": "Bearer ${ARCHITURE_API_KEY}"
      }
    }
  }
}
```



**3. Install the skill** on its own, since the plugin would add a second, OAuth connection:

```bash
npx skills add architure/skills
```

**4. Check.** Run `claude mcp list` (or `/mcp` in Claude Code) to see `architure` connected, then ask "List my Architure databases".

## Claude.ai

Custom connectors are available on every Claude plan (one custom connector on the Free plan).

1. Open **Customize**, then **Connectors**. Choose **+ Add**, then **Add custom connector**.
2. Name it `Architure` and enter the server address shown below, then choose **Continue**.
3. Review the detected settings and choose **Continue** again.
4. Under **Authentication**, choose **Sign in when needed** (or **Sign in now**). Under **OAuth client**, keep **Use Claude's published identity (Recommended)**.
5. Choose **Add**. When you sign in, choose the organization and allow access.


```text
https://app.architure.dev/api/mcp
```



To use an API key instead, choose **No sign in** at step 4 and add a request header `Authorization` with the value `Bearer architure_...`. Everyone who uses this connector then shares the key; prefer OAuth for a team.

On Team and Enterprise plans, an owner adds the connector once in **Organization settings**, **Connectors**, **Add**, **Custom**, **Web**, with the same steps; each member then finds it in **Customize**, **Connectors** and chooses **Connect**.

To add the skill, upload it in **Customize**, **Skills** as a ZIP file whose root is the `architure` folder of the `architure/skills` repository (skills need code execution to be turned on). See [Skill](/docs/skill).

## Cursor

**1. Create a key.** [Create a key](#create-an-api-key) and set `ARCHITURE_API_KEY` in the environment Cursor starts from (your shell profile).

**2. Add the server** to `~/.cursor/mcp.json` for every repository, or to `.cursor/mcp.json` in one repository:


```json
{
  "mcpServers": {
    "architure": {
      "url": "https://app.architure.dev/api/mcp",
      "headers": {
        "Authorization": "Bearer ${env:ARCHITURE_API_KEY}"
      }
    }
  }
}
```



**3. Turn it on.** Open **Customize**, find `architure` and turn it on. The **Output** panel's **MCP Logs** show the connection and any error.

**4. Install the skill:**

```bash
npx skills add architure/skills
```

To use OAuth in Cursor's desktop app, leave out `headers`: Cursor opens your browser to sign in.

## Codex

**1. Create a key.** [Create a key](#create-an-api-key) and export `ARCHITURE_API_KEY` in the shell that runs Codex.

**2. Add the server** to `~/.codex/config.toml`:


```toml
[mcp_servers.architure]
url = "https://app.architure.dev/api/mcp"
bearer_token_env_var = "ARCHITURE_API_KEY"
```



Recent versions of the Codex CLI write the same entry with `codex mcp add architure --url <address> --bearer-token-env-var ARCHITURE_API_KEY`.

**3. Install the skill:**

```bash
npx skills add architure/skills
```

**4. Check.** Run `codex mcp list` to see `architure` enabled.

To use OAuth instead, add the server without a bearer token, then sign in:


```bash
codex mcp add architure --url https://app.architure.dev/api/mcp
codex mcp login architure
```



## Any other MCP client

Any client that speaks MCP over Streamable HTTP connects the same way: point it at the server address above.

- **With OAuth**, the client needs nothing more: the server answers its first request with `401` and the address of its OAuth metadata, and the client opens the sign-in. Architure accepts only the return addresses listed in [Sign in with OAuth](#sign-in-with-oauth): a client on your own machine listening on `localhost` or `127.0.0.1` works; a hosted service that is not listed there needs an API key.
- **With an API key**, send it on every request as the header `Authorization: Bearer architure_...`.

Then install the skill, if the client reads skills, with `npx skills add architure/skills`, or give the client the content of its `SKILL.md`.

## Tell your agent where it works

Architure answers for a package: a folder of an imported [repository](/docs/repositories) that runs with its own environment, such as `apps/web`. With the repository (`owner/name`) and the folder it works in, `list_skills`, `list_environment_variables` and `list_databases` return what that package uses; without them, they return the whole organization's.

With the skill installed, the agent finds both itself: it reads `git remote get-url origin` and the folder it works in. Without the skill, or when the repository's remote is not the GitHub repository you imported, say it in your prompt:

```text
I work in the repository acme/shop, in the folder apps/web.
```

Ask "Which Architure repositories and packages do we have?" to see what the agent can name: it calls `list_repositories`.

## First prompts

Once connected, try these in a repository you imported (each names the tools the agent calls):

- "Which libraries should I use for this package? Check the Architure tech stack." (`list_tech_stack`)
- "Which skills does our team want you to follow here? Read them." (`list_skills`, `get_skill`)
- "Which environment variables does this package read? Add them to the config module." (`list_environment_variables`; names only)
- "Show me the schema of the database this package uses." (`list_databases`, `get_database`)
- "Add a `reviews` table linked to `books`, with information types and descriptions, then check the database." (`create_table`, `check_database`)

The open canvas shows the agent's database changes within seconds.

## The tools

The server has 15 tools: `list_repositories`, `list_tech_stack`, `list_skills`, `get_skill` and `list_environment_variables` read the workspace; `list_databases`, `get_database`, `get_table`, `search_columns`, `list_column_definitions` and `check_database` read databases; `create_table`, `update_column`, `set_description` and `apply_operations` write them. A read key or `schema:read` calls the first eleven; the four writes need a write key, or `schema:write` for an owner, admin or member. Every tool, with its inputs and answers, is on [MCP tools](/docs/mcp-tools).

Agents address objects as `schema.table.column` (for example `public.books.isbn`), or `table.column` when the table's name is unique across schemas; ids are accepted too. Write tools take the revision the agent read (`baseRevision`; `apply_operations` requires it). When someone changed the database in between, the write fails with a conflict that carries the missing changes: the agent reads the database again, then writes again.

## Troubleshooting

- **401 Unauthorized**: the key is missing, mistyped, revoked, or sent without `Bearer `. With OAuth, sign in again (`/mcp` in Claude Code, `codex mcp login architure` in Codex).
- **`Forbidden` on a write tool**: the key is a **Read** key, or your role is viewer. An OAuth token without `schema:write` gets a `403` that asks the agent to sign in again with that scope.
- **429 Too Many Requests**: the key passed 600 requests in a minute. Wait a minute, or give each machine its own key.
- **The sign-in page refuses the agent's redirect**: the agent is a hosted service Architure does not list above. Use an API key.
- **`NotFound` from `list_skills`, `list_environment_variables` or `list_databases`**: the `repository` the agent sent is not imported in this organization, or no package holds its `path`. Import the repository in [Repositories](/docs/repositories), check its packages with `list_repositories`, or ask the agent to leave `repository` out.
- **This connection request has expired**: the sign-in page is valid for ten minutes. Start the connection again from the agent.
- **`PlanRequired`**: the organization has no active trial or subscription. Reading still works; writes come back once an owner or admin subscribes. See [Billing and trial](/docs/billing).
- **`Conflict`**: the database changed since the agent read it, and the answer lists the changes. The skill tells the agent to call `get_database` again, redo its change on the current schema and retry with the new revision.
