Automates the ctxslice pre-step so agents run it before every task without you doing anything manually.
Copy .cursorrules from the repo root into your project:
cp /path/to/ContextSlice/.cursorrules /path/to/your-project/.cursorrulesThat's it. Every Cursor Agent session now:
- Runs
ctxslice run "<your task>"automatically as its first action - Reads
.ctxslice.md - Works only within that context
- Never expands to the full codebase unless it hits a concrete blocker
You just type your task normally. The agent handles the rest.
The MCP server exposes three tools to Claude:
| Tool | When Claude calls it |
|---|---|
ctxslice_run |
Before every coding task — mandatory first step |
ctxslice_index |
When working in a new repo for the first time |
ctxslice_stats |
When asked about index health |
Step 1 — Find your Claude Desktop config file
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Step 2 — Add the MCP server
Open the config file and add the contextslice entry under mcpServers:
{
"mcpServers": {
"contextslice": {
"command": "python",
"args": ["/absolute/path/to/ContextSlice/mcp/server.py"],
"env": {}
}
}
}Replace /absolute/path/to/ContextSlice with your actual path. On macOS:
/Users/yourname/projects/ContextSlice/mcp/server.py
Step 3 — Restart Claude Desktop
Quit and reopen. The contextslice tools should appear in the tools list.
Step 4 — Use normally
Tell Claude any coding task:
Add server-side pagination to the users endpoint in src/api/UsersController.java
Claude will automatically call ctxslice_run first, read the context, then work within it. You never touch the terminal.
When Claude calls ctxslice_run:
- The server runs
ctxslice run "<task>" --repo <repo> --file <file>as a subprocess - Reads
.ctxslice.mdfrom the repo root - Returns the full content back to Claude as tool output
- Includes an instruction telling Claude to stay within the context
Claude receives the filtered codebase as tool output — same as if you had uploaded the file manually, but fully automatic.
ctxslice_run
task(required) — the task descriptionfile(optional) — active file relative to repo rootrepo(optional) — absolute path to repo root, defaults to cwdtokens(optional) — token budget, default 40000
ctxslice_index
repo(optional) — repo rootforce(optional) — full rebuild, default false
ctxslice_stats
repo(optional) — repo root
If Claude Desktop's working directory isn't your project, include the repo path in your task:
In /Users/me/projects/my-app, add pagination to UserList
Claude will pass it as the repo argument automatically.
Or set it once at the start of a conversation:
I'm working in /Users/me/projects/my-app. Always use that as the repo root.
There's no conflict. Use .cursorrules when working in Cursor Agent mode, and the MCP server when working in Claude Desktop. Same underlying pipeline, same output format, different integration surface.