Integrates with GitHub Copilot in VSCode, enabling AI-powered Markdown document editing with comprehensive section management and file operations through the Copilot interface.
Provides powerful Markdown document editing capabilities with thread-safe operations, atomic transactions, section management, and validation for Markdown files.
SafeMarkdownEditor MCP Server
A Model Context Protocol (MCP) server that provides powerful Markdown document editing capabilities with thread-safe operations, atomic transactions, and comprehensive validation.
📦 Available on PyPI: quantalogic-markdown-mcp
🚀 Quick Start: Install with uv add quantalogic-markdown-mcp
or pip install quantalogic-markdown-mcp
Current version: 0.1.2
Features
✨ Comprehensive Markdown Editing
- Insert, update, delete, and move sections
- Thread-safe operations with atomic transactions
- Immutable section references that remain stable across edits
- Comprehensive validation with configurable strictness levels
🔧 MCP Tools Available
File Operations:
load_document
- Load a Markdown document from a file path (supports absolute, relative, and ~ expansion)save_document
- Save the current document to a file pathget_file_info
- Get information about the currently loaded filetest_path_resolution
- Test and verify path resolution for different path formats
Document Editing:
insert_section
- Insert new sections at specified positionsdelete_section
- Remove sections by ID or headingupdate_section
- Modify section content while preserving structuremove_section
- Reorder sections within the documentget_section
- Retrieve individual section content and metadatalist_sections
- Get an overview of all document sectionsget_document
- Export the complete Markdown documentundo
- Rollback the last operation
📊 MCP Resources
document://current
- Real-time access to the current documentdocument://history
- Transaction history for undo/redo operationsdocument://metadata
- Document metadata (title, author, timestamps)
🎯 MCP Prompts
summarize_section
- Generate section summariesrewrite_section
- Improve section clarity and concisenessgenerate_outline
- Create document outlines
Installation
Prerequisites
- Python 3.11 or higher
- uv (recommended) or pip
Quick Install from PyPI (Recommended)
The package is available on PyPI! Install the latest version (0.1.2
) directly:
Run Directly with uvx (No Installation Required)
You can run the MCP server directly without installing it locally:
Development Installation
For development or to contribute to the project:
Quick Start
Running the Server
Method 1: Direct Execution (PyPI Installation)
If you installed from PyPI:
Method 2: Development Installation
If you cloned the repository:
Method 3: Using the Development Script
For development from source:
Connecting to Claude Desktop
To use this MCP server with Claude Desktop, add the following configuration to your claude_desktop_config.json
:
Option 1: Using PyPI Installation (Recommended)
macOS/Linux:
Windows:
Option 2: Using uvx (No Installation Required)
macOS/Linux:
Windows:
Option 3: Development Installation
For development from source:
macOS/Linux:
Windows:
Configuration file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
After adding the configuration, restart Claude Desktop.
Connecting to VSCode
To use this MCP server with VSCode and GitHub Copilot, you have several configuration options depending on your needs.
Prerequisites:
- VSCode 1.102 or later
- GitHub Copilot extension installed and configured
- MCP support enabled in your organization (if applicable)
Workspace Configuration (Recommended for Projects)
Create a .vscode/mcp.json
file in your workspace root to share the configuration with your team:
Option 1: Development Installation (Recommended)
For this project, use the development setup since you're working with the source code:
Option 2: Alternative Development Approach
Using environment variables for Python path:
Option 3: Using PyPI Installation (If Installed Globally)
Only use this if you have installed the package globally:
For Windows (adjust command names):
User Configuration (Global Settings)
For system-wide access across all workspaces:
- Open Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Run
MCP: Open User Configuration
- Add the server configuration:
Option 1: Using PyPI Installation
Option 2: Using uvx
Option 3: Development Installation
Development Container Support
For containerized development environments, add to your devcontainer.json
:
Alternative Installation Methods
Command Line Installation:
URL Installation: You can create installation links using the VSCode URL handler format:
Using the MCP Server in VSCode
Once configured:
- Open the Chat view (
Ctrl+Cmd+I
/Ctrl+Alt+I
) - Select Agent mode from the dropdown
- Click the Tools button to see available MCP tools
- Enable the markdown-editor tools you want to use
- Start chatting with commands like:
- "Load the README.md file and show me all sections"
- "Create a new section called 'Installation' with setup instructions"
- "Move the 'Features' section to be the first section"
Managing MCP Servers:
- View installed servers:
MCP: List Servers
- Manage servers: Go to Extensions view (
Ctrl+Shift+X
) → MCP SERVERS section - View server logs: Right-click server → Show Output
- Start/Stop servers: Right-click server → Start/Stop/Restart
Development and Debugging:
For development, you can enable watch mode and debugging in your .vscode/mcp.json
:
Working with Files
The MCP server supports loading and saving Markdown documents from various file path formats:
Supported Path Formats
- Absolute paths:
/Users/username/documents/file.md
- Relative paths:
./documents/file.md
ordocuments/file.md
- Home directory expansion:
~/Documents/file.md
- Environment variables:
$HOME/documents/file.md
File Operations Examples
Usage Examples
Basic Document Operations
Once connected to Claude Desktop (or another MCP client), you can use natural language commands:
Working with Different Path Types
Programmatic Usage
You can also use the server programmatically with FastMCP clients:
Tool Reference
File Operation Tools
load_document(file_path: str, validation_level: str = "NORMAL")
Load a Markdown document from a file path with support for various path formats.
Parameters:
file_path
: Path to the Markdown file (supports absolute, relative, ~, and $ENV expansion)validation_level
: Validation strictness - "STRICT", "NORMAL", or "PERMISSIVE"
Returns: Success status with file information and document statistics
Examples:
load_document("/Users/me/notes.md")
load_document("./docs/README.md")
load_document("~/Documents/project.md")
save_document(file_path?: str, backup: bool = True)
Save the current document to a file path.
Parameters:
file_path
: Target path to save to (optional, uses current file if not provided)backup
: Whether to create a .bak backup of existing files
Returns: Success status with save location information
get_file_info()
Get detailed information about the currently loaded file.
Returns: File metadata including path, size, permissions, and timestamps
test_path_resolution(path: str)
Test and validate path resolution for different path formats.
Parameters:
path
: The path to test and resolve
Returns: Detailed path resolution information including expansion details
Document Editing Tools
insert_section(heading: str, content: str, position: int)
Insert a new section at the specified position.
Parameters:
heading
: The section heading textcontent
: The section content (can include Markdown)position
: Where to insert (0 = beginning, or after existing section)
Returns: Success/failure status with section ID if successful
delete_section(section_id?: str, heading?: str)
Delete a section by ID or heading.
Parameters:
section_id
: Unique section identifier (optional)heading
: Section heading text (optional)
Note: Either section_id
or heading
must be provided.
update_section(section_id: str, content: str)
Update the content of an existing section.
Parameters:
section_id
: Unique section identifiercontent
: New content for the section
move_section(section_id: str, new_position: int)
Move a section to a new position in the document.
Parameters:
section_id
: Unique section identifiernew_position
: Target position (0-based)
get_section(section_id: str)
Retrieve detailed information about a specific section.
Returns: Section heading, content, position, level, and ID
list_sections()
Get metadata for all sections in the document.
Returns: Array of section metadata (ID, heading, position, level, path)
get_document()
Export the complete Markdown document.
Returns: Full document as Markdown text
undo()
Undo the last operation performed on the document.
Returns: Success/failure status
Configuration Options
The server supports several configuration options through environment variables:
Development
Running Tests
Code Quality
Development Server
For development, you can run the server with additional debugging:
Troubleshooting
Common Issues
Server not appearing in Claude Desktop:
- Check that the path in
claude_desktop_config.json
is absolute - Verify that
uv
is in your PATH (which uv
on macOS/Linux,where uv
on Windows) - Restart Claude Desktop after configuration changes
- Check Claude Desktop logs for error messages
Server not appearing in VSCode:
- Ensure VSCode 1.102 or later is installed
- Verify GitHub Copilot extension is installed and active
- Check that MCP support is enabled in your organization settings
- Confirm
.vscode/mcp.json
file exists in workspace root (for workspace config) - Use
MCP: List Servers
command to see if server is registered - Check Extensions view → MCP SERVERS section for server status
- Verify
uv
is in your PATH and accessible from VSCode's integrated terminal
VSCode MCP server not starting:
- Check the MCP server output: Right-click server → Show Output
- For development setup: Ensure you're using the correct configuration:
- Verify the command path and arguments in your configuration
- Test the command manually in a terminal from the correct working directory:
- Ensure all required dependencies are installed:
uv sync
- Check file permissions on the server executable
- For dev containers, verify the container has access to required tools
VSCode agent mode not showing MCP tools:
- Confirm you're in Agent mode (not Ask mode) in the Chat view
- Click the Tools button to enable/disable specific MCP tools
- Check if you have more than 128 tools enabled (VSCode limit)
- Verify the MCP server is running (green indicator in Extensions view)
- Try restarting the MCP server: Right-click → Restart
Tool execution errors:
- Ensure the document is initialized (the server auto-initializes if needed)
- Check section IDs are valid using
list_sections
first - Verify that section references haven't changed after edits
Performance issues:
- Large documents may take time to process
- Consider using section-level operations instead of full document operations
- Monitor transaction history size
Debug Mode
Enable debug logging by setting:
Logging
The server uses Python's logging module and writes to stderr to avoid interfering with MCP's stdio transport. To see debug logs:
Architecture
The server is built on several key components:
- SafeMarkdownEditor: Core thread-safe editing engine with atomic operations
- MarkdownMCPServer: MCP server wrapper that exposes editing capabilities
- FastMCP: Modern MCP framework for Python with automatic schema generation
- Transaction System: Atomic operations with rollback support
- Validation Engine: Configurable document structure validation
Contributing
Contributions are welcome! Please read our contributing guidelines:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure all tests pass and code is formatted
- Submit a pull request
Development Setup
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Projects
- Model Context Protocol - The protocol specification
- FastMCP - Python framework for building MCP servers
- Claude Desktop - AI assistant with MCP support
Need help? Open an issue on GitHub or check the documentation.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
Provides powerful Markdown document editing capabilities with thread-safe operations, atomic transactions, and comprehensive validation.
- Features
- Installation
- Quick Start
- Working with Files
- Usage Examples
- Tool Reference
- File Operation Tools
- load_document(file_path: str, validation_level: str = "NORMAL")
- save_document(file_path?: str, backup: bool = True)
- get_file_info()
- test_path_resolution(path: str)
- Document Editing Tools
- insert_section(heading: str, content: str, position: int)
- delete_section(section_id?: str, heading?: str)
- update_section(section_id: str, content: str)
- move_section(section_id: str, new_position: int)
- get_section(section_id: str)
- list_sections()
- get_document()
- undo()
- Configuration Options
- Development
- Troubleshooting
- Architecture
- Contributing
- License
- Related Projects
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityConverts various file types and web content to Markdown format. It provides a set of tools to transform PDFs, images, audio files, web pages, and more into easily readable and shareable Markdown text.Last updated -10111,966TypeScriptMIT License
- AsecurityAlicenseAqualityConverts various file formats to Markdown using the MarkItDown utility and can be integrated with MCP clients for seamless document processing and conversion.Last updated -49PythonMIT License
- AsecurityAlicenseAqualityProvides comprehensive document processing, including reading, converting, and manipulating various document formats with advanced text and HTML processing capabilities.Last updated -168911TypeScriptMIT License
- AsecurityAlicenseAqualityA document conversion server that transforms various file formats (PDFs, documents, images, audio, web content) to Markdown with improved multilingual and UTF-8 support.Last updated -1029TypeScriptMIT License