Skip to main content

A MCP server for managing structured Markdown documents

Project description

Document MCP Server

PyPI version Python 3.8+

A Model Context Protocol (MCP) server for managing structured Markdown documents. This server provides tools to create, read, update, and analyze documents composed of multiple chapters.

Installation

pip install document-mcp

Quick Start

# Start the MCP server
python -m document_mcp.doc_tool_server sse --host localhost --port 3001

Overview

This MCP server treats "documents" as directories containing multiple "chapter" files (Markdown .md files). Chapters are ordered alphanumerically by their filenames (e.g., 01-introduction.md, 02-main_content.md).

Document Structure

documents_storage/           # Root directory for all documents
├── my_book/                     # A document (directory)
│   ├── 01-introduction.md       # Chapter 1 (alphanumeric ordering)
│   ├── 02-main_content.md       # Chapter 2
│   ├── 03-conclusion.md         # Chapter 3
│   └── _manifest.json           # Optional: For future explicit chapter ordering
└── research_paper/              # Another document
    ├── 00-abstract.md
    ├── 01-methodology.md
    └── 02-results.md

Configuration

The server uses the following environment variables:

  • DOCUMENT_ROOT_DIR: Root directory for storing documents (default: documents_storage/)

Running the Server

The server supports both HTTP SSE and stdio transports. HTTP SSE is the default and recommended transport.

HTTP SSE Transport (Recommended)

# Run with HTTP SSE transport (default)
python -m document_mcp.doc_tool_server sse --host localhost --port 3001

# Or specify arguments explicitly
python -m document_mcp.doc_tool_server sse --host 0.0.0.0 --port 8000

Stdio Transport

# Run with stdio transport
python -m document_mcp.doc_tool_server stdio

MCP Tools Reference

The server exposes the following tools via the Model Context Protocol:

Document Management

Tool Parameters Description
list_documents - Lists all available documents with metadata
create_document document_name: str Creates a new document directory
delete_document document_name: str Deletes a document and all its chapters

Chapter Management

Tool Parameters Description
list_chapters document_name: str Lists all chapters in a document, ordered by filename
create_chapter document_name: str, chapter_name: str, initial_content: str = "" Creates a new chapter file
delete_chapter document_name: str, chapter_name: str Deletes a chapter from a document

Content Operations

Tool Parameters Description
read_chapter_content document_name: str, chapter_name: str Reads the content and metadata of a specific chapter
read_paragraph_content document_name: str, chapter_name: str, paragraph_index_in_chapter: int Reads a specific paragraph from a chapter
read_full_document document_name: str Reads the entire document, concatenating all chapters
write_chapter_content document_name: str, chapter_name: str, new_content: str Overwrites the entire content of a chapter
modify_paragraph_content document_name: str, chapter_name: str, paragraph_index: int, new_paragraph_content: str, mode: str Modifies a paragraph (replace, insert_before, insert_after, delete)
append_paragraph_to_chapter document_name: str, chapter_name: str, paragraph_content: str Appends a new paragraph to the end of a chapter

Text Operations

Tool Parameters Description
replace_text_in_chapter document_name: str, chapter_name: str, text_to_find: str, replacement_text: str Replaces all occurrences of text in a specific chapter
replace_text_in_document document_name: str, text_to_find: str, replacement_text: str Replaces all occurrences of text throughout all chapters

Analysis Tools

Tool Parameters Description
get_chapter_statistics document_name: str, chapter_name: str Retrieves statistics (word count, paragraph count) for a chapter
get_document_statistics document_name: str Retrieves aggregated statistics for an entire document

Search Tools

Tool Parameters Description
find_text_in_chapter document_name: str, chapter_name: str, query: str, case_sensitive: bool = False Finds paragraphs containing the query string in a specific chapter
find_text_in_document document_name: str, query: str, case_sensitive: bool = False Finds paragraphs containing the query string across all chapters

Data Models

The server uses Pydantic models for structured data exchange:

  • DocumentInfo: Metadata for a document
  • ChapterMetadata: Metadata for a chapter
  • ChapterContent: Full content and metadata of a chapter
  • ParagraphDetail: Information about a specific paragraph
  • FullDocumentContent: Complete content of a document
  • StatisticsReport: Word and paragraph count statistics
  • OperationStatus: Success/failure status for operations

Requirements

  • Python 3.8+
  • fastapi
  • uvicorn[standard]
  • pydantic-ai
  • mcp[cli]
  • python-dotenv
  • google-generativeai

Examples and Documentation

For comprehensive examples, tutorials, and usage guides, visit the GitHub repository.

License

MIT License

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

document_mcp-0.0.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

document_mcp-0.0.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file document_mcp-0.0.1.tar.gz.

File metadata

  • Download URL: document_mcp-0.0.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for document_mcp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 95f07267bd335668c760e22c8b7835d655691939d186021320347c378d1856e5
MD5 8e4cab846bffc0d279994b0d5f7f67ed
BLAKE2b-256 e872da4c2c203207b637c7a13e0af44f17a02879a72ebe2be4b8e97cd6cb469c

See more details on using hashes here.

File details

Details for the file document_mcp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: document_mcp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for document_mcp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7655d36ea4b99c9cc16b30efaa107c2fb5f48da90ffa3adc0d8c4d8d2aaa243
MD5 24f8aa4e649068b89e13f9b781c35ff4
BLAKE2b-256 740fc8a01140ca87b7abc6aea5fe00c3e2f3f1be87241de68b885ed04ccb5c66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page