@igloo302/mcp
v0.1.0-dev
Published
MD SafeEdit Model Context Protocol (MCP) Server.
Downloads
62
Readme
@igloo302/mcp
MD SafeEdit Model Context Protocol (MCP) Server.
This package exposes MD SafeEdit as an MCP server, allowing AI coding assistants (like Cursor, Claude Desktop, Windsurf, etc.) to safely read and edit Markdown files using the signature-guarded CAS (Compare-and-Swap) patch protocol.
Features
Exposes the 4 core MD SafeEdit services as MCP tools:
inspect: Inspects a Markdown file's outline, line endings, size, and current revision.search: Searches for text patterns within structural nodes or section paths.read: Reads target node contents and acquires signed, opaqueanchor_tokens.patch: Safely performs edits (replace, delete, insert) using issued anchor tokens with relocation and concurrency protection.
Installation
Local Setup
Ensure you have built the monorepo packages first:
npm run buildThe executable script will be located at:
[workspace-root]/packages/mcp/dist/index.js
Configuration
You can configure the MCP server in your favorite editor/client.
1. Claude Desktop
Add the following to your Claude Desktop configuration file (typically located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"md-safeedit": {
"command": "node",
"args": [
"/Users/jyshen/Projects/md-safeedit/packages/mcp/dist/index.js"
],
"env": {
"MDSE_ALLOWED_ROOTS": "/Users/jyshen/Projects/md-safeedit"
}
}
}
}[!IMPORTANT]
- Replace
/Users/jyshen/Projects/md-safeeditwith your actual workspace path.MDSE_ALLOWED_ROOTSis required to restrict the files the server is authorized to read or write, preventing directory traversal.
2. Cursor
To configure the server in Cursor:
- Open Cursor Settings -> Features -> MCP.
- Click + Add New MCP Server.
- Fill in the form:
- Name:
md-safeedit - Type:
stdio - Command:
node /Users/jyshen/Projects/md-safeedit/packages/mcp/dist/index.js
- Name:
- Set the environment variable
MDSE_ALLOWED_ROOTSif needed, or it will default to the current working directory of the process.
Security
- Path Restriction: The server resolves all paths to their canonical form (resolving symlinks) and rejects any path outside the
MDSE_ALLOWED_ROOTSenvironment variable (defaults to the current working directory). - Token Integrity: Anchor tokens are HMAC-signed using a random machine-local key (stored securely in
~/.md-safeedit-secret.key). If an LLM or process attempts to bypass authorization or manually forge/edit the token, signature checks fail immediately. - Untrusted Input: Markdown and replacement content are treated strictly as raw text data. No code block execution or markdown rendering occurs.
