MCP Document Converter

MCP Document Converter

Converts DOCX files to Markdown with formatting preservation and image extraction, and provides image analysis tools for document processing workflows.

Category
访问服务器

README

MCP Document Converter

A lightweight Model Context Protocol (MCP) server that provides DOCX to Markdown conversion and image analysis tools for VS Code Copilot. Focused on document processing without heavy browser automation dependencies.

Installation

npm install -g mcp-document-converter

Features

Document Conversion Tools

  • convert_docx_to_markdown - Convert DOCX files to Markdown with formatting preservation
  • Extract and save embedded images from documents
  • Preserve formatting (bold, italic, headers, lists, etc.)
  • Generate clean Markdown output with metadata

Core Capabilities

  • Complete formatting preservation (headers, tables, lists, colors)
  • Image extraction with proper file naming
  • HTML entity escaping for proper markdown display
  • JSON-RPC over stdio (standard MCP protocol)
  • Compatible with VS Code Copilot and other MCP clients
  • Lightweight with minimal dependencies

Image Analysis Tools

  • read_image_info - Read image metadata and dimensions
  • analyze_images_directory - Analyze all images in a folder
  • create_image_viewer - Generate HTML viewer for images

Requirements

  • Node.js 14+
  • Dependencies: mammoth, turndown, turndown-plugin-gfm

Usage

As a Global Command

After installing globally:

mcp-document-converter

Programmatically

node src/server.js

With npx

npx mcp-browser-opener

The server will listen for JSON-RPC messages on stdin and respond on stdout.

MCP Protocol

The server implements the standard MCP protocol using JSON-RPC over stdio:

Initialize

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": { "name": "test", "version": "1.0.0" }
  }
}

List Tools

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list"
}

Call Tool

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "open_browser",
    "arguments": {
      "query": "How to use VS Code Copilot"
    }
  }
}

Call browser_input_text Tool

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "browser_input_text",
    "arguments": {
      "url": "https://www.google.com",
      "selector": "textarea[name=\"q\"]",
      "text": "automated search query",
      "submit": true,
      "headless": false,
      "screenshot": true
    }
  }
}

Tool: open_browser

Opens a Chrome browser window with optional URL or search query.

Parameters:

  • url (optional): Specific URL to open
  • query (optional): Search query for Google search

Example:

{
  "name": "open_browser",
  "arguments": {
    "query": "JavaScript tutorial"
  }
}

Tool: browser_input_text

Controls a headless browser to input text into web forms and elements using Puppeteer.

Parameters:

  • url (required): URL to navigate to
  • selector (required): CSS selector for the input element (e.g., 'input[name="search"]', '#searchbox')
  • text (required): Text to input into the element
  • submit (optional): Whether to submit the form after inputting text (default: false)
  • headless (optional): Whether to run browser in headless mode (default: true)
  • screenshot (optional): Whether to take a screenshot after the action (default: false)

Example:

{
  "name": "browser_input_text",
  "arguments": {
    "url": "https://example.com/form",
    "selector": "#email",
    "text": "test@example.com",
    "submit": false,
    "headless": true,
    "screenshot": true
  }
}

Tool: convert_docx_to_markdown

Converts DOCX documents to Markdown format while preserving formatting and extracting embedded images.

Parameters:

  • inputFile (required): Path to the input DOCX file
  • outputFile (optional): Path for the output Markdown file (returns content if not specified)
  • extractImages (optional): Whether to extract and save images (default: true)
  • imageDir (optional): Directory name for extracted images (default: 'images')
  • preserveFormatting (optional): Whether to preserve formatting (default: true)

Example:

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "convert_docx_to_markdown",
    "arguments": {
      "inputFile": "document.docx",
      "outputFile": "document.md", 
      "extractImages": true,
      "imageDir": "images",
      "preserveFormatting": true
    }
  }
}

Features:

  • Preserves text formatting (bold, italic, strikethrough)
  • Converts headers, lists, and blockquotes
  • Extracts embedded images to separate files
  • Generates relative image links in Markdown
  • Adds conversion metadata header
  • Handles complex document structures

Integration with VS Code Copilot

This server can be configured as an MCP server in VS Code to provide browser automation and document conversion capabilities. Add it to your MCP configuration:

{
  "mcpServers": {
    "browser-opener": {
      "command": "mcp-browser-opener"
    }
  }
}

Development

  1. Clone the repository
  2. Install dependencies: npm install
  3. Run the server: npm start or node src/server.js

Project Structure

  • src/ - Source code and toolset modules
  • test/ - All test files, sample data, and generated outputs
  • test/docx_convertion/ - Sample DOCX files for testing document conversion

Testing

Basic Tests

Run all basic tool tests:

npm test

DOCX Conversion Tests

Test document conversion functionality:

npm run test:docx

Manual Testing

Test the server by sending JSON-RPC messages:

echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | mcp-browser-opener

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选