MO

mhackermsft/officemcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 5 forks 质量 53 趋势 14

MCP server to create and read Office documents

概览

A Model Context Protocol (MCP) server that enables AI assistants to create, read, write, and manipulate Microsoft Office documents (Word, Excel, PowerPoint) and PDFs directly from natural language instructions. - — unified office_* API works across all supported formats - — granular word_*, excel_*, and pptx_* tools for advanced operations - — write Word/PDF content using plain Markdown - — perform multiple document operations in a single tool call - — create, read, watermark, and extract pages from PDFs - — detection and support for protected Office files - — tiered tool exposure keeps context lean - — embed images in Word, PowerPoint, and Excel documents - — extract all embedded images from Word, PowerPoint, and PDF files as base64 data with MIME type for direct AI vision analysis (OCR, captioning) - — office_read on .docx returns an ordered content list of headings, paragraphs, tables, and inline images in document sequence, preserving section context around every image - .

README

以下为原文 README 节选,完整内容请查看原文。

OfficeMCP

A Model Context Protocol (MCP) server that enables AI assistants to create, read, write, and manipulate Microsoft Office documents (Word, Excel, PowerPoint) and PDFs directly from natural language instructions.

Features

  • Format-agnostic tools — unified office_* API works across all supported formats
  • Format-specific tools — granular word_*, excel_*, and pptx_* tools for advanced operations
  • Markdown support — write Word/PDF content using plain Markdown
  • Batch operations — perform multiple document operations in a single tool call
  • PDF support — create, read, watermark, and extract pages from PDFs
  • Encrypted document handling — detection and support for protected Office files
  • Progressive tool disclosure — tiered tool exposure keeps context lean
  • Image creation — embed images in Word, PowerPoint, and Excel documents
  • Image extraction — extract all embedded images from Word, PowerPoint, and PDF files as base64 data with MIME type for direct AI vision analysis (OCR, captioning)
  • Rich document reading — office_read on .docx returns an ordered content list of headings, paragraphs, tables, and inline images in document sequence, preserving section context around every image

Supported Formats

Format Extension Read Write Create Convert
Word .docx ✅ ✅ ✅ ✅
Excel .xlsx ✅ ✅ ✅ —
PowerPoint .pptx ✅ ✅ ✅ —
PDF .pdf ✅ ✅ ✅ ✅
Markdown .md — — — ✅

Prerequisites

  • .NET 10 SDK
  • An MCP-compatible client (e.g., Claude Desktop, VS Code with Copilot)

Building

git clone https://github.com/your-org/OfficeMCP.git
cd OfficeMCP
dotnet build

Running

dotnet run --project OfficeMCP/OfficeMCP.csproj

The server communicates over stdio using the MCP protocol.

MCP Client Configuration

Claude Desktop

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "OfficeMCP": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "C:/path/to/OfficeMCP/OfficeMCP/OfficeMCP.csproj"
      ]
    }
  }
}

Or point to the compiled binary directly for faster startup:

{
  "mcpServers": {
    "OfficeMCP": {
      "command": "C:/path/to/OfficeMCP/OfficeMCP/bin/Release/net10.0/OfficeMCP.exe"
    }
  }
}

Available Tools

Consolidated Office Tools (format-agnostic)

These tools work across all supported formats and are organized into three tiers.

Tier 1 — Core (always exposed)

Tool Description
office_create Create a new document in any supported format
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "OfficeMCP": { "command": "dotnet", "args": [ "run", "--project", "C:/path/to/OfficeMCP/OfficeMCP/OfficeMCP.csproj" ] } } }