sublime-text-mcp
sublime-text-mcp
Control Sublime Text 4 from AI assistants via the Model Context Protocol
Overview
Sublime Text is fast, scriptable, and loved by developers, but it does not include a built-in HTTP API. Its Python API only exists inside the editor process, which means an external AI assistant cannot directly inspect the active file, read selections, move the cursor, or trigger editor commands.
sublime-text-mcp solves that with a two-part bridge architecture. A Sublime Text 4 plugin runs inside the editor and exposes a local HTTP JSON-RPC endpoint. A Dockerized MCP server talks to Claude Desktop, Claude Code, Cursor, or any compatible MCP client over stdio, then relays tool calls to the bridge.
The result is direct, practical editor control from your assistant. Claude and Cursor can read files, navigate code, search, refactor selected text, manage settings, open and save files, run builds, and work with the same editor state you are looking at in Sublime Text.
Architecture Diagram
Claude Desktop / Claude Code / Cursor
|
| MCP (stdio)
v
sublime-mcp-server ---- Docker container ---- Python 3.11
|
| HTTP JSON-RPC -> localhost:6124
v
SublimeMCPBridge plugin ---- runs inside Sublime Text 4
|
| Sublime Python API
v
Sublime Text 4
Features
| Tool | Description |
|---|---|
| check_connection | Verify the bridge plugin is running and reachable |
| get_sublime_info | Get Sublime Text version, platform, and architecture |
| get_active_file_content | Read the full text of the currently active file |
| get_active_file_info | Get file name, syntax, encoding, line count, and dirty state |
| get_selection | Get the currently selected text (supports multiple selections) |
| get_cursor_position | Get the current cursor row and column |
| list_open_files | List all open files in the current window |
| get_unsaved_buffers | List new unsaved scratch buffers |
| replace_selection | Replace selected text with new content |
| insert_at_cursor | Insert text at the current cursor position |
| replace_file_content | Replace the entire content of the active file |
| find_in_file | Search with regex or literal pattern, returns all matches with line numbers |
| get_line_content | Read a specific line by 1-indexed line number |
| get_line_range | Read a range of lines (start-end, inclusive) |
| goto_line | Move the cursor to a specific line |
| open_file | Open a file by absolute path |
| save_active_file | Save the current file to disk |
| get_syntax | Get the current language/syntax |
| set_syntax | Change the file syntax/language |
| get_project_folders | List all folders in the current project |
| run_build | Trigger the Sublime Text build system |
| get_settings | Read Sublime Text preferences (single key or common set) |
| set_setting | Write a Sublime Text preference value |
Prerequisites
- Sublime Text 4 (build 4000+)
- Docker Desktop
- One of: Claude Desktop, Claude Code CLI, or Cursor
Installation
Step 1 — Install The Sublime Text Bridge Plugin
Copy the SublimeMCPBridge/ folder to your Sublime Text Packages directory:
macOS: ~/Library/Application Support/Sublime Text/Packages/
Windows: %APPDATA%\Sublime Text\Packages\
Linux: ~/.config/sublime-text/Packages/
The folder must keep the name SublimeMCPBridge and contain both files:
sublime_mcp_bridge.py.python-version
Restart Sublime Text and verify the bridge:
curl -s -X POST http://127.0.0.1:6124/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"sublime/ping","params":{}}'
# Expected output:
# {"jsonrpc": "2.0", "id": 1, "result": {"status": "ok", "version": "1.0.0"}}
Step 2 — Build The Docker Image
git clone https://github.com/OmkarGowda990/sublime-text-mcp.git
cd sublime-text-mcp/sublime-mcp-server
docker build -t sublime-mcp-server .
Client Configuration
Claude Desktop
Find Your 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
Config To Add
{
"mcpServers": {
"sublime-text": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "SUBLIME_BRIDGE_URL=http://host.docker.internal:6124",
"sublime-mcp-server:latest"
]
}
}
}
Linux Variant
{
"mcpServers": {
"sublime-text": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--add-host=host.docker.internal:host-gateway",
"-e", "SUBLIME_BRIDGE_URL=http://host.docker.internal:6124",
"sublime-mcp-server:latest"
]
}
}
}
Verification
Restart Claude Desktop, look for the hammer icon, then try: "What file is open in Sublime Text?"
Example Prompts
- "What file is currently open in Sublime Text?"
- "Read the active file and summarize what it does"
- "Find all TODO comments in the current file"
- "Refactor the selected function to use a list comprehension"
- "Go to line 87 in Sublime Text"
- "What syntax/language is the active file?"
- "Set word wrap to true"
- "Save the current file"
Claude Code
Option A — CLI (Recommended)
# Add for current project only (local scope)
claude mcp add sublime-text -- docker run -i --rm \
-e SUBLIME_BRIDGE_URL=http://host.docker.internal:6124 \
sublime-mcp-server:latest
# Add globally (all projects)
claude mcp add --scope user sublime-text -- docker run -i --rm \
-e SUBLIME_BRIDGE_URL=http://host.docker.internal:6124 \
sublime-mcp-server:latest
# Linux variant
claude mcp add --scope user sublime-text -- docker run -i --rm \
--add-host=host.docker.internal:host-gateway \
-e SUBLIME_BRIDGE_URL=http://host.docker.internal:6124 \
sublime-mcp-server:latest
Option B — Edit ~/.claude.json Directly
{
"mcpServers": {
"sublime-text": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "SUBLIME_BRIDGE_URL=http://host.docker.internal:6124",
"sublime-mcp-server:latest"
]
}
}
}
Project-Shared Config
Commit .mcp.json to the repo root with the same JSON.
Verification
/mcp
# Should show: sublime-text: connected (23 tools)
Scope Explanation
| Scope | Config file | Who sees it |
|---|---|---|
| local (default) | .claude/ in project | Only you, this project |
| user | ~/.claude.json | You, all projects |
| project | .mcp.json in project root | Everyone on the team |
Cursor
Global Config
~/.cursor/mcp.json is available in all projects:
{
"mcpServers": {
"sublime-text": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "SUBLIME_BRIDGE_URL=http://host.docker.internal:6124",
"sublime-mcp-server:latest"
]
}
}
}
Project Config
Use .cursor/mcp.json in the project root for one-project scope, with the same JSON.
Linux Variant
Add the same --add-host=host.docker.internal:host-gateway flag used in the Claude examples.
Verification
Settings → Tools & MCP → look for sublime-text with a green dot.
Note On Tool Limits
Cursor degrades past ~40 active tools across all servers. If you have many MCP servers, toggle off tools you don't use from the Tools & MCP panel.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| ❌ Cannot reach Sublime Text bridge | Plugin not installed or ST not running | Check Packages folder, restart ST, run curl ping |
| Tools don't appear in client | Config file wrong path or invalid JSON | Validate JSON, check config path for your OS |
| Connection refused on Linux | host.docker.internal not resolving | Add --add-host=host.docker.internal:host-gateway to docker args |
| Plugin loads but commands fail | Write op on wrong thread | Ensure you are on ST 4, not ST 3 |
| docker: command not found | Docker not in PATH | Ensure Docker Desktop is running |
Development / Contributing
Contributions are welcome. See CONTRIBUTING.md for local setup, tool development rules, and the PR checklist.
License
MIT — see LICENSE.