How to Set Up the OfficeCLI MCP Server for Claude Code, Cursor, and VS Code
OfficeCLI includes a built-in MCP server that exposes JSON-RPC over STDIO; register it with any supported AI client using the officecli mcp <target> command.
The iOfficeAI/OfficeCLI repository provides a native Model Context Protocol (MCP) server that allows AI assistants to invoke OfficeCLI commands for document manipulation. This guide covers the exact steps to configure MCP integrations with Claude Code, Cursor, and VS Code, referencing the specific source files and registration logic used under the hood.
Architecture Overview
OfficeCLI’s MCP implementation consists of two core components defined in the source:
McpServer.cs– A long-running stdio process (src/officecli/McpServer.cs) that reads JSON-RPC requests fromstdinand writes responses tostdout.McpInstaller.cs– A static helper class (src/officecli/McpInstaller.cs) that registers or unregisters the server with AI clients by writing configuration entries to the appropriate JSON files.
The server is started via the officecli mcp command, which is wired in CommandBuilder.IntegrationStubs.cs.
Supported Clients and Configuration Locations
Each target client stores its MCP server definitions in a specific location:
- Claude Code –
~/.claude.jsonunder the top-levelmcpServerskey - Cursor –
~/.cursor/mcp.jsonundermcpServers - VS Code (Copilot) –
~/.vscode/mcp.jsonundermcpServers - LM Studio –
~/.cache/lm-studio/extensions/plugins/mcp/officecli/
Registering the MCP Server
Claude Code
Run the install command:
officecli mcp claude
Under the hood, McpInstaller.InstallClaude() first attempts to use the claude CLI directly by executing claude mcp remove -s user officecli followed by claude mcp add -s user officecli -- /path/to/officecli mcp. If the CLI is unavailable, the installer falls back to InstallJson(), which writes directly to ~/.claude.json (see lines 70–100 of McpInstaller.cs).
The resulting entry appears as:
{
"mcpServers": {
"officecli": {
"command": "/home/user/.local/bin/officecli",
"args": ["mcp"]
}
}
}
Cursor
Execute:
officecli mcp cursor
This invokes InstallJson() to write the server configuration to ~/.cursor/mcp.json. Cursor will detect the new entry on restart.
VS Code
Execute:
officecli mcp vscode
The McpInstaller writes the same JSON structure to ~/.vscode/mcp.json, enabling Copilot and other VS Code AI extensions to invoke OfficeCLI tools.
LM Studio
Execute:
officecli mcp lms
McpInstaller.InstallLmStudio() creates a plugin manifest and bridge configuration in the LM Studio cache directory.
Managing Registrations
Check Current Status
List which clients are registered:
officecli mcp list
The ListStatus() method (lines 403–420 in McpInstaller.cs) checks each configuration file and outputs a concise status table:
officecli MCP registration status:
✓ LM Studio registered
✓ Claude Code registered
✗ Cursor not registered
✗ VS Code not registered
Uninstall a Target
Remove the registration from a specific client:
officecli mcp uninstall claude
This calls McpInstaller.UninstallClaude(), which either runs claude mcp remove or edits ~/.claude.json directly to delete the officecli entry.
How the Installer Locates the Binary
To ensure registrations survive upgrades, McpInstaller determines a stable binary path (lines 25–40) using the following priority:
- The self-installed path at
~/.local/bin/officecli - The first
officeclifound on$PATH - The current process executable path
This path is stored in the command field of every MCP configuration file.
Summary
- OfficeCLI provides a built-in MCP server implemented in
McpServer.csthat communicates via JSON-RPC over stdio. - Registration is handled by
McpInstaller.cs, which supports Claude Code, Cursor, VS Code, and LM Studio. - Commands follow the pattern
officecli mcp <target>, writing entries to client-specific JSON files such as~/.claude.json. - Claude Code registration prefers the
claudeCLI when available, falling back to direct JSON manipulation. - Status and removal are managed via
officecli mcp listandofficecli mcp uninstall <target>.
Frequently Asked Questions
What is the MCP server in OfficeCLI?
The MCP server is a stdio-based JSON-RPC service implemented in src/officecli/McpServer.cs. It exposes OfficeCLI’s document editing capabilities to AI clients that support the Model Context Protocol, allowing assistants to read and modify Word, Excel, and PowerPoint files programmatically.
Where does OfficeCLI store MCP configuration for Claude Code?
OfficeCLI writes Claude Code configuration to ~/.claude.json under the mcpServers key. If the claude CLI is installed, the installer (McpInstaller.InstallClaude()) uses it to manage the entry; otherwise, it edits the JSON file directly.
Can I use the MCP server without installing the Claude CLI?
Yes. The McpInstaller detects missing CLI tools and automatically falls back to InstallJson(), which writes the configuration directly to the client’s JSON file. For Claude Code, this means editing ~/.claude.json manually if the claude command is unavailable.
Why does the installer use a stable binary path instead of the current process path?
The installer (lines 25–40 of McpInstaller.cs) prioritizes ~/.local/bin/officecli to ensure that MCP registrations remain valid after upgrading OfficeCLI. Using a fixed installation path prevents broken references when the binary location changes during updates.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →