Cursor
Install context-mode on Cursor with native JSON hooks in .cursor/hooks.json. Local-folder plugin today, one-click Marketplace plugin once published.
Cursor is a first-class context-mode host. It uses native lower-camel hook names
and flat hook entries in .cursor/hooks.json (not Claude Code's settings.json
format), so context-mode routes data-heavy tool output into the sandbox and keeps
the bulk of raw payload bytes out of your context window. Cursor wires three hooks
— preToolUse, postToolUse, and stop — and relies on a routing rules file
(.cursor/rules/context-mode.mdc) for session-start awareness, because Cursor's
sessionStart hook is currently rejected by its validator.
The Cursor Marketplace listing is still awaiting Cursor team review
(#485 /
#489). Until it is listed,
install via the local-folder or manual path below. Once the Marketplace plugin
ships, a one-click install will register the MCP server, hooks (preToolUse,
postToolUse, sessionStart, stop, afterAgentResponse), rules, and skills
with no manual config.
Install
Choose the local-folder plugin path or the manual config path. Both deliver the same routing; pick whichever fits your workflow.
The local-folder install symlinks (or copies) the plugin checkout into Cursor's
local plugins directory. The plugin's hook commands run npx -y context-mode hook cursor <event>, so no global install is required.
Clone the repository
Clone context-mode somewhere on your machine.
git clone https://github.com/mksglu/context-mode.gitLink the plugin into Cursor
On macOS and Linux, symlink the checkout into Cursor's local plugins directory.
ln -s "$PWD/context-mode" ~/.cursor/plugins/local/context-modeOn Windows, Cursor does not follow symlinks or junctions, so copy the folder
with robocopy instead.
robocopy . "$env:USERPROFILE\.cursor\plugins\local\context-mode" /MIRRestart Cursor
Restart so the MCP server, hooks, and rules register. The plugin appears in Settings → Plugins as "Context Mode (Local)".
The manual path installs context-mode globally and registers the MCP server, hooks, and routing rules by hand.
Install the package
npm install -g context-modeRegister the MCP server
Create .cursor/mcp.json in your project root (or ~/.cursor/mcp.json for a
global install).
{
"mcpServers": {
"context-mode": {
"command": "context-mode"
}
}
}Register the hooks
Create .cursor/hooks.json (or ~/.cursor/hooks.json for global). Each command
is context-mode hook cursor <event> with a lowercase event name.
{
"version": 1,
"hooks": {
"preToolUse": [
{ "command": "context-mode hook cursor pretooluse" }
],
"postToolUse": [
{ "command": "context-mode hook cursor posttooluse" }
],
"stop": [
{ "command": "context-mode hook cursor stop" }
]
}
}Copy the routing rules file
Cursor has no working sessionStart hook, so the model reads routing awareness
from an .mdc rules file.
mkdir -p .cursor/rules
cp node_modules/context-mode/configs/cursor/context-mode.mdc .cursor/rules/context-mode.mdcRestart Cursor
Restart Cursor or open a new agent session so the server, hooks, and rules load.
Do not run both the local plugin and a .cursor/hooks.json install at once.
Each event would fire twice. context-mode doctor warns when both register
context-mode hooks — remove one configuration to keep events single-fire.
Hooks
| Hook | What it does |
|---|---|
preToolUse | Inspects and reroutes data-heavy tool calls into the sandbox before they run, and can block with { "permission": "deny", "user_message": "..." }. |
postToolUse | Captures tool events into the session knowledge base. |
stop | Marks turn end and can return followup_message to continue the loop. |
Cursor accepts additional_context in postToolUse and sessionStart hook
responses but does not surface it to the model (a Cursor upstream bug). Routing
enforcement relies on the .mdc rules file and MCP tool descriptions instead of
hook context injection.
Configure
Configuration is optional. context-mode reads its session ID from the
conversation_id field on Cursor's hook payloads, falling back to
CURSOR_TRACE_ID and then the parent process ID.
See /docs/configuration for storage relocation with
CONTEXT_MODE_DIR and the full list of environment variables.
Verify
Confirm the install with the doctor. It checks language runtimes, the FTS5 knowledge base, and hook registration, then reports anything that needs attention.
context-mode doctorA clean run means context-mode is ready to route your next data-heavy command.
Cursor does not register Claude-style slash commands. Run the doctor and the
other status commands from the terminal with context-mode <command>, or ask
the agent in chat to run them.