sublime_mcp_server

sublime_mcp_server

An MCP server that exposes Sublime Text's unsaved buffers as tools via local HTTP, enabling AI clients to read, list, and close buffers without saving to disk.

Category
访问服务器

README

MCPServer

MCPServer is a Sublime Text package that exposes MCP tools over local HTTP from inside Sublime's Python runtime.

Today it ships with MCP tools for unsaved buffers:

  • list_open_buffers
  • read_buffer
  • close_buffer

Use Cases

  • Read temporary scratch notes or prompts directly from open unsaved tabs.
  • Summarize or refine a draft in an AI client, then send the result to another MCP such as Notion.
  • Clean up working tabs by closing consumed scratch buffers via close_buffer.
  • Build lightweight editor automations without saving throwaway notes to disk.

The architecture is fully in-process. By default it starts:

  • Sublime bridge on 127.0.0.1:6123
  • MCP endpoint on 127.0.0.1:6124/mcp

No separate Node or TypeScript MCP server is required.

Requirements

  • Sublime Text 4 build 4171 or newer
  • Python 3.8 compatibility for the plugin package
  • Python 3.11+ if you want to run the repo tests locally
  • A local MCP client that can talk to a streamable HTTP MCP endpoint

Project Layout

  • sublime_mcp_server/: bridge logic and in-process MCP HTTP server
  • sublime_mcp_server_plugin.py: Sublime Text plugin entrypoint
  • messages.json and messages/*.txt: Package Control install and upgrade messages
  • python_tests/: pytest coverage for bridge and MCP behavior

Install The Sublime Plugin

For normal usage, install the packaged artifact into Sublime's Installed Packages folder.

On macOS:

mkdir -p "$HOME/Library/Application Support/Sublime Text/Installed Packages"
cp dist/MCPServer.sublime-package \
  "$HOME/Library/Application Support/Sublime Text/Installed Packages/MCPServer.sublime-package"

If you previously installed an unpacked development copy, remove it first so Sublime does not load the package twice:

rm -rf "$HOME/Library/Application Support/Sublime Text/Packages/MCPServer"

Restart Sublime Text after copying the files.

The packaged release includes the repository's tracked .python-version file at the package root so Sublime can select the correct Python runtime when loading the archive.

For local development, you can still use an unpacked checkout under Packages/MCPServer, but that is now a development-only workflow instead of the recommended installation method.

Port Configuration

The package reads its host and port configuration from MCPServer.sublime-settings.

Default values:

{
  "bridge_host": "127.0.0.1",
  "bridge_port": 6123,
  "mcp_host": "127.0.0.1",
  "mcp_port": 6124
}

To override them in Sublime Text:

  1. Open the command palette.
  2. Run Preferences: MCPServer Settings.
  3. Put your overrides in the right-hand user settings pane.
  4. Restart Sublime Text.

Example:

{
  "bridge_port": 7001,
  "mcp_port": 7002
}

The bridge and MCP ports must be different when using the same host.

Package And Release

There are two common release paths for Sublime Text packages:

  • Package Control default channel: publish this repo on GitHub, create a semantic version tag such as 0.2.5, and submit the repository to Package Control once. After approval, future semver tags are how users receive updates.
  • Custom distribution: build a .sublime-package archive and host your own packages.json channel if you do not want to use Package Control's default channel.

This repo now includes release-facing metadata:

Suggested release checklist:

  1. Update the version in pyproject.toml and sublime_mcp_server/init.py.
  2. Add a matching upgrade note under messages/.
  3. Build a .sublime-package artifact from the repo root:
python3 scripts/build_release.py
  1. Run pytest and python3 -m py_compile sublime_mcp_server_plugin.py sublime_mcp_server/*.py.
  2. Commit the release changes.
  3. Create and push a semver tag such as 0.2.5.
  4. If this is the first public release, submit the GitHub repository URL to Package Control.

For manual installs, use the generated dist/MCPServer.sublime-package file. The stable filename keeps the package name clean in Sublime, and the builder injects package-metadata.json so the description and version are visible in package UIs.

Verify The Plugin Is Running

Once Sublime restarts, the plugin should start two localhost services:

  • GET http://127.0.0.1:6123/buffers
  • POST http://127.0.0.1:6124/mcp

Check the bridge:

curl -sf http://127.0.0.1:6123/buffers | python3 -m json.tool

Check the MCP endpoint:

curl -sf \
  -X POST http://127.0.0.1:6124/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}' \
  | python3 -m json.tool

You should see serverInfo.name set to sublime_mcp_server.

If you changed the ports in settings, use those values instead of 6123 and 6124.

MCP Client Setup

This project serves MCP over HTTP from inside Sublime, so your MCP client only needs to connect to the plugin's endpoint.

Recommended MCP client configuration:

{
  "mcpServers": {
    "sublime_mcp_server": {
      "type": "http",
      "url": "http://127.0.0.1:6124/mcp"
    }
  }
}

Available Tools

list_open_buffers

Lists unsaved open Sublime buffers. Each buffer descriptor includes:

  • buffer_id
  • title
  • window_id
  • is_dirty
  • syntax
  • preview

read_buffer

Reads the current live text and metadata for one unsaved Sublime buffer.

Input:

{
  "buffer_id": "38"
}

close_buffer

Force-closes an unsaved Sublime buffer and discards its current contents.

Input:

{
  "buffer_id": "38"
}

Manual End-To-End Check

  1. Open Sublime Text.
  2. Create one or more new unsaved tabs.
  3. Add some test text.
  4. Verify the buffer list:
curl -sf http://127.0.0.1:6123/buffers | python3 -m json.tool
  1. Use an MCP client or direct JSON-RPC request to list tools and read a buffer.

Direct JSON-RPC example:

curl -sf \
  -X POST http://127.0.0.1:6124/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
  | python3 -m json.tool
curl -sf \
  -X POST http://127.0.0.1:6124/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"read_buffer","arguments":{"buffer_id":"38"}}}' \
  | python3 -m json.tool
curl -sf \
  -X POST http://127.0.0.1:6124/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"close_buffer","arguments":{"buffer_id":"38"}}}' \
  | python3 -m json.tool

Development

Run tests:

pytest

Check syntax:

python3 -m py_compile sublime_mcp_server_plugin.py sublime_mcp_server/*.py

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选