> ## Documentation Index
> Fetch the complete documentation index at: https://developers.clay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP server

> Understand how the Clay plugin exposes Clay to agents over the Model Context Protocol.

The Clay plugin has two halves: the Clay CLI for scripting and ephemeral operations, and a local MCP server that exposes Clay's tools to an MCP host such as Claude Code, Cursor, or Claude Desktop. Installing the plugin wires up both.

## How it works

An MCP host spawns [`clay mcp`](/cli/reference/mcp), which runs as a long-running server over stdio and forwards the host's tool calls to Clay. It authenticates with the same credentials as the rest of the CLI — the session from [`clay login`](/cli/reference/login), or the `CLAY_API_KEY` environment variable. You do not put an API key into the host config.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "mcpServers": {
    "clay": { "command": "clay", "args": ["mcp"] }
  }
}
```

## Workspace pinning

An MCP connection is pinned to whichever workspace the stored credential was scoped to when the server started. Re-running `clay login` only updates the credential on disk — the running MCP server keeps using the workspace it loaded at startup. To switch workspaces, sign in to the new workspace and then have the host restart the server so it picks up the new credential.

## CLI or MCP

Use the MCP server when an agent host should call Clay's tools as part of its normal tool-use loop. Reach for the [CLI](/cli/quickstart) for one-off runs, scripting, and inspecting data from a shell, and the [Public API](/public-api/quickstart) when you are building a service or app that calls Clay programmatically.
