<!-- generated by build_articles.py — edit content/answers/local-search-mcp-for-codex-and-cursor.md instead -->
---
title: "A local search tool for Codex and Cursor"
canonical: "https://xerj.org/answers/local-search-mcp-for-codex-and-cursor"
updated: "2026-10-20"
source: "content/answers/local-search-mcp-for-codex-and-cursor.md"
---

# Search tool for a Codex agent, on the files you have

**Short answer** (updated 2026-10-20): A search tool for a Codex agent starts with `xerj init`. The command writes the MCP entry for Claude Code, and it writes Cursor and Codex only when those folders already exist. Codex reads the entry in trusted projects only. On 2026-10-20 `xerj mcp` returned 17 tools from a running node.

**Key number:** xerj mcp tools/list returned 17 tools from the running node. (as of 2026-10-20; source: [benchmarks/agent-queries-2026-10-20/05-tool-names.txt](https://github.com/xerj-org/xerj/blob/main/benchmarks/agent-queries-2026-10-20/05-tool-names.txt))

**TL;DR** — A search tool for a Codex agent starts with `xerj init`. The command writes the MCP entry for Claude Code, and it writes Cursor and Codex only when those folders already exist. Codex reads the entry in trusted projects only. On 2026-10-20 `xerj mcp` returned 17 tools from a running node.

## Agent prompt

```text
Read https://xerj.org/llms.txt. Start one local node. In a project that already has .codex and .cursor, run xerj init with the node URL. Restart the agent. Call xerj_search only after tools/list shows it. xerj mcp does not start a node.
```

## Commands

### Command 1

Note: Start the node first. xerj mcp does not start one.

```sh
xerj --insecure --data-dir /tmp/xerj-aq-2026-10-20/node --bind 127.0.0.1 --port 9217
```

### Command 2

Note: Run inside a project that already has .codex and .cursor. The capture wrote both configs.

```sh
xerj init --url http://127.0.0.1:9217 --disable-feedback
```

### Command 3

Note: stdio MCP. tools/list on this binary returned 17 tools.

```sh
xerj mcp --url http://127.0.0.1:9217 --disable-feedback
```

XERJ is a new way for AI to search for data.

## Run init where the folders already are

The capture made an empty project with `.codex/` and `.cursor/`, put `model = "gpt-5"` in `.codex/config.toml`, and ran init against `http://127.0.0.1:9217`.

```text
wrote    .mcp.json
wrote    .cursor/mcp.json
wrote    .cursor/rules/xerj.mdc
wrote    .cursor/rules/xerj-hub.mdc
appended .codex/config.toml
wrote    AGENTS.md
```

`.mcp.json` and `.cursor/mcp.json` both got `mcpServers.xerj` with `command`, `args` `["mcp"]`, and `XERJ_URL`. Codex got `[mcp_servers.xerj]` appended under the model line. Init did not create `.codex/`. On a project without that directory, the Codex file is not written.

The printed lines for Windsurf, Claude Desktop and Cline say to copy the entry. They are instructions, not files written.

This binary also printed a hub line and wrote `xerj-hub.mdc`. A build without a hub signing key does not. Read what your binary printed.

## Start the node, then the MCP server

```sh
xerj --insecure --data-dir /tmp/xerj-node --bind 127.0.0.1 --port 9217
xerj mcp --url http://127.0.0.1:9217 --disable-feedback
```

`xerj mcp` talks to the node. It does not start one. Agents that read `https://xerj.org/llms.txt` before the first call get the field names and the caveats in that file.

The capture sent MCP `initialize` and `tools/list` to `xerj mcp`. The server named itself `xerj-mcp` version `1.0.0-rc.97` and returned 17 tools. The first is `xerj_search`. Codex itself was not installed on the capture machine, so this is the tool list Codex would be handed, not a Codex session.

## Measured on 2026-10-20

| Check | Result |
|---|---|
| `xerj init` with `.cursor/` and `.codex/` | Wrote both MCP configs and appended Codex |
| Windsurf, Claude Desktop, Cline | Printed only. No config file written |
| `tools/list` | 17 tools, version 1.0.0-rc.97 |
| Codex process | Not run. No Codex install on the machine |

## When not to use XERJ

If the agent only needs one file it already has open, a search server is extra machinery. Init is for the agent that will call a tool instead of reading the tree.

## FAQ

### Search tool for a Codex agent?

Run `xerj init` in a project that already has `.codex/`. It appends `[mcp_servers.xerj]`. Codex reads that file in trusted projects only.

### Plug search into Cursor?

If `.cursor/` exists, init writes `.cursor/mcp.json` with the same `mcpServers.xerj` entry. Restart Cursor.

### Does init configure Windsurf and Cline?

It prints the entry and tells you to copy it. It does not write their config files.

### How many tools does xerj mcp serve?

17 on this binary, from a live `tools/list`. The count includes the hub tools. Do not copy an old list of 13.

### Does xerj mcp start the node?

No. Start the node, then run `xerj mcp`. The handshake can succeed and every tool call can still fail if nothing is listening.

## Evidence

- xerj init wrote .mcp.json and .cursor/mcp.json and appended .codex/config.toml. — `benchmarks/agent-queries-2026-10-20/05-init-stdout.txt`
- tools/list returned 17 tools from xerj mcp v1.0.0-rc.97. — `benchmarks/agent-queries-2026-10-20/05-tool-names.txt`
- Codex config is read for trusted projects only. — `engine/crates/xerj-autoindex/src/init.rs:221`

## Related

- [Can ChatGPT search a folder on my laptop, or do I need something else?](/answers/give-chatgpt-claude-local-file-access)
- [I need my agent to find a passage and cite the file, not dump the whole tree. How?](/answers/code-search-mcp-for-claude-code)
- [Should an agent use API search or vector search?](/answers/mcp-api-search-or-vector-search)
