Phil's ST MCP
This server (MCP Commander) exposes Sublime Text 4 to AI assistants via the Model Context Protocol, providing 63+ tools across these capabilities:
Read & Introspect: Get active file content, selections, cursor context, open files, project folders, symbols, output panel content, phantoms, build variables, command palette entries, commands, menu items, syntaxes, scope/word at cursor, bookmarks, line count, encoding, settings, and window layout.
Navigate: Open files (with line/column jump), move cursor to a specific line, show output panels, and focus pane groups.
Edit: Perform string replacements, replace selections/lines, insert snippets, duplicate lines, toggle comments, sort lines, select/fold lines, undo/redo, and run arbitrary ST commands.
Search: Find patterns in the active file or across project folders, with regex and case-sensitivity options.
File & Project Management: Save, close, or revert files; save all open files; add/remove project folders.
Syntax & Encoding: Set the syntax and character encoding of the active file.
Settings & Window: Set ST settings, toggle the sidebar, set window pane layout, and write to the status bar.
Build: Trigger the current build system or run custom build commands.
Terminus Integration: Send text to any open tab, simulating keyboard input for Terminus terminal tabs.
Scripting: Execute arbitrary Python code in ST's main thread or the system interpreter, and retrieve console logs.
Controls a running Sublime Text 4 instance, providing tools for reading and editing files, navigating, searching, building, managing settings and layout, and executing Python scripts through a local HTTP bridge.
MCP Commander
Exposes Sublime Text to AI assistants (Claude Code, Cursor, etc.) via the Model Context Protocol. The MCP server is built directly into the ST plugin — no separate process or external dependency required.
63 tools covering reading, navigation, editing, searching, build, Terminus integration, settings, layout, menus, console log, and live Python scripting.
Architecture
The plugin runs two local servers on startup:
Server | Default port | Purpose |
MCP SSE | 9502 (Win) / 9503 (Mac/Linux) | MCP 2024-11-05 SSE transport — connect your agent here |
HTTP bridge | 9500 (Win) / 9501 (Mac/Linux) | Internal REST API used by the SSE dispatcher |
Claude Code (MCP client)
│ MCP SSE (port 9502)
▼
sublime_mcp.py ← ST plugin — MCP server + HTTP bridge, all in one file
│ sublime API
▼
Sublime Text 4Related MCP server: Unity AI Bridge
Installation
1. Install via Package Control
Open the Command Palette (
Ctrl+Shift+P)Run Package Control: Install Package
Search for MCP Commander and install
The plugin loads automatically. Check View › Show Console for:
sublime-mcp: MCP SSE on 127.0.0.1:9502, HTTP bridge on 127.0.0.1:9500Manual install: copy
sublime_mcp.py(and optionallysublime_mcp_browse.py) into yourPackages/User/folder.
2. Register with Claude Code
Add to ~/.claude/settings.json under "mcpServers":
Windows:
"sublime-mcp": { "type": "sse", "url": "http://127.0.0.1:9502/sse" }Mac / Linux:
"sublime-mcp": { "type": "sse", "url": "http://127.0.0.1:9503/sse" }Restart Claude Code. Tools appear with the mcp__sublime-mcp__ prefix.
Server management
The MCP server starts automatically when ST loads the plugin. To stop or restart it, open the Command Palette and run:
MCP Commander: Server Status
The panel shows whether the server is running and on which port, and lets you start or stop it with a single keypress.
Tab and Sheet Indexing
IMPORTANT: Users refer to tabs by 1-based numbering (tab 1, tab 2, etc.), but
get_sheets() returns 0-based indexes. Always convert user tab references before using:
User tab 1 = index 0
User tab 2 = index 1
When targeting a specific tab, call get_sheets() first to verify the index.
Tools
Read / Introspect
Tool | Description |
| Path, full content, cursor line/col, dirty flag, and syntax name |
| Current selection(s): text and begin/end line+col for each |
|
|
| All files open in the current window (path, name, is_dirty) |
| All sheets (tabs) in the window by index — includes images and untitled buffers |
| Content of any tab by sheet index (from |
| Project root folder paths |
| Full content of any already-open file by path |
| Full content of any open tab by name (partial match, case-insensitive) |
| Total character count of any open tab |
| Text at character offsets begin..end (0-based, end exclusive) |
| Phantom HTML and extracted plain text from a named view |
| Text content of a named output panel ( |
| Active panel id and, if it is an output panel, its content |
| All symbols (functions, classes, etc.) in the active file with line numbers |
| Find where a symbol is defined across all open files |
| Raw |
| ST build variables: |
| Command Palette entries from installed |
| Runnable command ids from loaded command classes |
| Menu items from |
| All syntax definitions available in ST (name + path) |
| Full syntax scope string at the cursor position |
| Word under the cursor and its line/col |
| All bookmarked positions in the active file |
| Total number of lines in the active file |
| Character encoding of the active file |
| A ST setting by key. |
| Current window layout (groups, cells) and which files are in each group |
Navigate
Tool | Description |
| Open a file, optionally jumping to a specific line and column |
| Move cursor to line (and optional column) in the active file |
| Bring an output panel to the front. Default |
| Move focus to a pane group by 0-based index |
Edit
Tool | Description |
| ST-native editor: |
| Replace the current selection(s) with text |
| Replace lines begin..end (inclusive, 1-based) in the active file |
| Insert at the cursor using ST snippet syntax |
| Duplicate the current line(s) |
| Toggle line comment, or block comment if |
| Sort selected lines, or all lines if nothing is selected |
| Select lines begin..end (1-based, inclusive) |
| Fold (collapse) lines begin..end in the active file |
| Undo the last edit |
| Redo the last undone edit |
| Run any ST command with optional args |
Search
Tool | Description |
| Find all occurrences of a pattern in the active file |
| Search across project folders. Skips |
File / Project
Tool | Description |
| Save the active file (or a specific file by path) |
| Save all open files |
| Close a file by path, or the active file if path is omitted |
| Revert the active file to its last saved state |
| Add a folder to the current project |
| Remove a folder from the current project by path |
Syntax / Encoding
Tool | Description |
| Set the syntax of the active file by name (case-insensitive partial match) |
| Set the character encoding of the active file |
Settings / Window
Tool | Description |
| Set a ST setting by key |
| Show or hide the sidebar |
| Set the window pane layout |
| Write a message to ST's status bar |
Build
Tool | Description |
| Trigger the current build system, or pass |
Terminus Integration
Terminus is a popular ST terminal package.
send_to_view is Terminus-aware: when targeting a Terminus tab it uses
terminus_send_string to type text into the terminal session.
Tool | Description |
| Send text to any open tab. For Terminus tabs, types as if the user typed it. Include |
Scripting
Tool | Description |
| Execute arbitrary Python in ST's main thread. Returns captured stdout in |
| Execute Python in the system interpreter outside ST's sandbox |
| Recent ST console output. |
| Entire captured ST console buffer since startup |
Configuration
Ports
Server | Windows | Mac/Linux | Env var override |
MCP SSE | 9502 | 9503 |
|
HTTP bridge | 9500 | 9501 |
|
Telling Claude how to use the tools
Add a section like this to your project's CLAUDE.md (or ~/.claude/CLAUDE.md):
## Sublime Text MCP tools
MCP Commander is connected. Prefer it over standard file tools when working in ST:
- Read files with `get_active_file` or `get_file_content` rather than the Read tool
- Edit with `str_replace_based_edit_tool` — edits appear live with gutter diff and undo
- Use `find_in_files` for project-wide search
- Use `send_to_view` to run commands in a Terminus terminal tab
- Use `eval_python` for one-off ST scripting (no plugin file needed)
- Check `get_console_log` when a plugin isn't behaving as expected
Tab indexing: `get_sheets()` returns 0-based indexes; users refer to tabs
1-based. Always call `get_sheets()` first when targeting a specific tab.Security note
Both servers bind to 127.0.0.1 only and accept any request without
authentication. Do not expose these ports to a network interface.
Requirements
Sublime Text 4
Terminus package (optional — only required for
send_to_viewon terminal tabs)
Known limitations
No multi-window support — tools target the most recently focused ST window
No image editing —
get_sheet_contentreturns the path for image tabs, not pixel dataNo ST3 support — the plugin uses ST4 APIs throughout
Testing
The test suite requires Sublime Text to be running with sublime_mcp.py loaded.
cd /path/to/sublime-mcp
pip install httpx pytest
pytest tests/ -vContributing
Adding a tool:
Add a handler function in
sublime_mcp.py(run via_on_mainfor ST API calls)Add an entry to
_MCP_TOOLSand the_GET/_POSTrouting dictsAdd a row to the Tools table in
README.md
Good first issues:
Multi-window support (
sublime.windows()instead ofsublime.active_window())get_diagnostics— expose LSP error/warning annotationsset_bookmark/clear_bookmarks— write counterparts toget_bookmarks
Open an issue or PR on GitHub.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dpc00/sublime-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server