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

# Connect Your Agent to the CLI

> Serve a local CoreStory index to Claude Code, GitHub Copilot, Cursor, or Codex over MCP.

## How the connection works

Your agent talks to CoreStory by starting `corestory mcp`, a local MCP server that communicates over standard input and output (stdio). There is no URL, sign-in, or token. The server runs on your machine for as long as the agent session lasts.

**The server serves the repository it starts in.** It finds the corpus by looking for `.corestory/` in the folder it was started from. Every configuration below makes sure the server starts in your repository folder. If an agent starts it somewhere else, the server reports that the repository is not initialized.

Before you connect, finish [Install and Set Up](https://docs.corestory.ai/cli/install-and-setup.md): run `corestory setup`, then `corestory init` and `corestory ingest` in the repository. The agent can also run `init` and `ingest` through MCP tools, but it cannot run `setup` for you.

***

## Configure your agent

> [tab] Claude Code
>
> **Option 1: Install the plugin (recommended).** It configures the MCP server and installs CoreStory's [Agent Skills](https://docs.corestory.ai/skills/index.md), which teach Claude workflows that use it.
>
> ```bash theme={null}
> claude plugin marketplace add corestoryai/agent-skills
> claude plugin install corestory-local@corestory
> ```
>
> Install `corestory-local`, not `corestory`. The `corestory` plugin connects to the CoreStory web app through its sign-in MCP server instead.
>
> Start Claude Code from the repository folder. Run `/mcp` to confirm the `corestory-local` server is connected.
>
> **Option 2: Configure MCP only.** Create `.mcp.json` at the repository root:
>
> ```json .mcp.json theme={null}
> {
>   "mcpServers": {
>     "corestory": {
>       "type": "stdio",
>       "command": "corestory",
>       "args": ["mcp"]
>     }
>   }
> }
> ```
>
> Start Claude Code from the repository folder. Run `/mcp` to confirm `corestory` is connected.

> [tab] GitHub Copilot
>
> Create `.mcp.json` at the repository root. This works for both Copilot in VS Code and the Copilot CLI:
>
> ```json .mcp.json theme={null}
> {
>   "mcpServers": {
>     "corestory": {
>       "type": "stdio",
>       "command": "corestory",
>       "args": ["mcp"]
>     }
>   }
> }
> ```
>
> Open the repository folder in VS Code, or start the Copilot CLI from the repository folder.

> [tab] Cursor
>
> Cursor does not always start MCP servers in the workspace folder, so this configuration changes into the folder first. Create `.cursor/mcp.json` in the repository:
>
> ```json .cursor/mcp.json theme={null}
> {
>   "mcpServers": {
>     "corestory": {
>       "type": "stdio",
>       "command": "sh",
>       "args": ["-c", "cd \"$0\" && exec corestory mcp", "${workspaceFolder}"]
>     }
>   }
> }
> ```
>
> Check **Cursor Settings → MCP** to confirm the server is running.

> [tab] Codex
>
> Codex reads MCP servers from your user config, so set the working folder explicitly. Add this to `~/.codex/config.toml`:
>
> ```toml ~/.codex/config.toml theme={null}
> [mcp_servers.corestory]
> command = "corestory"
> args = ["mcp"]
> cwd = "/absolute/path/to/your-repo"
> ```
>
> Because `cwd` points to one repository, add a separate entry with a different name for each repository you want to serve.
>
> To install CoreStory's Agent Skills for Codex:
>
> ```bash theme={null}
> gh skill install corestoryai/agent-skills --all --agent codex --scope user
> ```

> [tab] Other agents
>
> Any agent that can start a stdio MCP server can use CoreStory. Configure it to:
>
> * run the command `corestory` with the argument `mcp`
> * start it with the repository root as the working directory
>
> If the agent cannot set a working directory, wrap the command in a shell that changes into the folder first, as in the Cursor example.

> [!TIP]
>
> **Installing with an agent.** You can ask your coding agent: *"Install CoreStory from get.corestory.ai and set it up for this repository."* The agent follows the instructions at [get.corestory.ai/llms.txt](https://get.corestory.ai/llms.txt). It will stop and ask you to run `corestory setup` yourself.

***

## What your agent can do

The server provides these tools.

| Tool | What it does |
| - | - |
| `status` | Reports whether the repository is initialized, which corpus and snapshot are selected, and the latest ingest. Agents call this first. |
| `init` | Creates the corpus for this repository, like `corestory init`. Makes no model calls. |
| `ingest` | Ingests the current files, like `corestory ingest`. Makes model calls on your key. |
| `corpus_info` | Describes the corpus and the selected snapshot. |
| `search` | Finds code and rules related to a question, ranked by meaning. |
| `list_files` | Lists the files captured in the snapshot. |
| `read_file` | Reads a file as it was captured in the snapshot, along with the rules that cite the lines returned. |
| `rules_for` | Lists the rules with evidence in a given file or line range. |
| `entity` | Shows one rule or code chunk in detail, including its summary and evidence. |
| `connections` | Follows the links from one entity to related rules, evidence, and code. |

`init` and `ingest` write local state and can cost money, so a well-behaved agent asks before calling them. The other tools only read.

### Guidance the server gives the agent

When an agent connects, the server sends instructions on how to use these tools well. In short, it tells the agent to:

* call `status` first, and ask you before anything that changes local state or makes model calls
* use `rules_for` before editing a file, and `search` for open-ended questions
* check rules against the cited source before relying on them, because they are leads, not proof
* follow pagination, since a first page of results is not a complete list
* remember that results describe the ingested snapshot, which may be older than the working tree

If you write your own workflow instructions and want to leave these out, start the server with `corestory mcp --no-instructions`.

***

## Keeping the index current

The agent sees the snapshot from your last ingest, not your latest edits. After significant changes, run `corestory ingest` again, or ask the agent to call its `ingest` tool. The new snapshot becomes the selected one.

***

## Troubleshooting

> [accordion] The agent says the repository is not initialized
>
> If you already ran `corestory init` and `corestory ingest`, the server probably started outside your repository. Check the agent's MCP configuration and make sure it starts `corestory mcp` in the folder that contains `.corestory/`. For Codex, check `cwd`. For Cursor, use the `sh -c` wrapper shown above.
>
> Don't let the agent call `init` to fix this. That creates a new, empty corpus in whatever folder the server started in.

> [accordion] The agent says setup is not complete
>
> Run `corestory setup` in your own terminal and finish all of its steps. Agents cannot accept the terms for you.

> [accordion] The agent cannot find corestory
>
> The agent's environment may not include the folder where `corestory` is installed. Run `which corestory` (or `where corestory` on Windows) and either add that folder to the `PATH` the agent uses or put the full path to the binary in the `command` field.

> [accordion] Answers do not match the current code
>
> The snapshot is older than your edits. Run `corestory ingest`. If the agent still sees the old snapshot, start a new agent session.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.