# Set up your agent

> Exact setup for Claude Code, Codex, other MCP clients and scripts, and the instructions to give your agent.

Use this page for host-by-host MCP configuration snippets, bearer token protection, CLI linking, and reusable agent instructions; for the 5-minute overview, see [Connect an agent](/docs/connect/).

Turn on **MCP connection** in Studio under **Settings** › **Connect** first. The server listens only on your Mac at:

```text title="MCP endpoint"
http://127.0.0.1:48271/mcp
```

## Connect an MCP client

#### Claude Code

Run the command from **Copy** under **Claude Code setup**. Without protection, it is:

```sh title="Terminal"
claude mcp add --transport http --scope user pixling http://127.0.0.1:48271/mcp
```

#### Codex

Add this block to your Codex `config.toml` (shared by Codex CLI, desktop, and IDE), or paste what **Copy** under **Codex setup** gives you:

```toml title="config.toml"
[mcp_servers.pixling]
url = "http://127.0.0.1:48271/mcp"
```

#### Other MCP clients

Point any Streamable HTTP client at `http://127.0.0.1:48271/mcp`. There is no stdio server and no SSE stream.

Pixling supports protocol versions `2025-06-18`, `2025-11-25`, and `2026-07-28`; see [MCP server](/docs/reference/mcp/).

## With protection on

Turn on **Protect MCP connection** to require a bearer token. **Copy** then includes the `Authorization` header:

#### Claude Code

```sh title="Terminal"
claude mcp add --transport http --scope user pixling http://127.0.0.1:48271/mcp --header 'Authorization: Bearer <TOKEN>'
```

#### Codex

```toml title="config.toml"
[mcp_servers.pixling]
url = "http://127.0.0.1:48271/mcp"
http_headers = { Authorization = "Bearer <TOKEN>" }
```

> [!CAUTION]
> **Toggling rotates the token**
> Turning off **Protect MCP connection** or **MCP connection** deletes the stored token. Turning it back on generates a new one, so paste the updated setup again.

## Scripts and hooks: the CLI

Turn on **CLI connection**, then link the bundled binary onto your `PATH`. **Copy** gives the exact command for your install; for an app in `/Applications`, run:

```sh title="Terminal"
mkdir -p ~/.local/bin && ln -sf '/Applications/Pixling.app/Contents/Helpers/PixlingCLI.app/Contents/MacOS/pixling' ~/.local/bin/pixling
```

For scripts and programs, use `pixling call <operation> [json | @file | -]` for one-shot JSON calls, `pixling rpc` for a persistent NDJSON worker over one connection, and `pixling schema [operation]` to inspect input schemas offline — all three always output JSON. Human-oriented subcommands accept `--json` (or `PIXLING_FORMAT=json`) to print one JSON document on stdout for both success and failure. See [CLI](/docs/reference/cli/) for details and exit codes.

## Verify the connection

```sh title="Terminal"
pixling doctor
```

`doctor` checks the CLI, the socket, the app, and the MCP endpoint in one run, then prints the next step for any check that fails.

- **App Store build**: The sandboxed CLI cannot access the network, so it skips the MCP check.
- **Protected MCP**: Pass the bearer token through `PIXLING_MCP_TOKEN`; never pass it as a CLI argument.

## Instructions to give your agent

Your agent reads the basics from the server's instructions when it connects. Add this snippet to the instructions file your host loads so it applies to every session, such as `~/.claude/CLAUDE.md` for Claude Code:

```md title="~/.claude/CLAUDE.md"
## Pixling

- Own one Pixling resident per conversation. Call `pixling_resident_ensure`
  with namespace `<your agent's name>` and a key you record for this
  conversation; the first call also needs an `assetID` from `pixling_zukan_list`.
- Write only to `client:<namespace>/<key>`. Speak with `pixling_message_send`,
  ask with `pixling_question_ask`.
- Nothing is pushed to you. Read what the user wrote with
  `pixling_inbox_watch`, then `pixling_inbox_read`.
- Unless the user says otherwise, make saved changes only when asked.
```

Replace `<your agent's name>` with a stable name such as `claude-code`. Add your own rules for when to speak: a word when starting, a question when blocked, or a short summary when done.

If you also use a [plugin](/docs/plugins/), use the namespace and key it provides at session start instead of picking your own; a different key binds a second resident.

## Next steps

- [Give your agent a resident](/docs/connect/own-a-resident/): Bind a resident, address it safely, and read messages from the inbox.
- [MCP server reference](/docs/reference/mcp/): Endpoint details, supported protocol versions, and authentication.
