How to Set Up MCP Server Integration with Claude Code, Cursor, and VS Code Using OfficeCLI
OfficeCLI provides a built-in MCP server that you can register with Claude Code, Cursor, VS Code, and LM Studio using simple officecli mcp commands that write JSON configuration files to each tool's settings directory.
OfficeCLI's Model Context Protocol (MCP) integration enables AI coding assistants to invoke OfficeCLI commands directly for editing Word, Excel, and PowerPoint files. This guide covers the complete setup process based on the iOfficeAI/OfficeCLI source code, including the McpInstaller registration system and McpServer JSON-RPC implementation.
What Is the OfficeCLI MCP Server?
The MCP server in OfficeCLI is a long-running stdio process that communicates via JSON-RPC. Located in src/officecli/McpServer.cs, it reads requests from stdin and writes responses to stdout, translating MCP calls into OfficeCLI CLI operations.
The companion McpInstaller (src/officecli/McpInstaller.cs) handles the registration plumbing—locating a stable binary path and writing configuration files for each supported AI client.
Supported AI Clients and Configuration Locations
OfficeCLI supports four targets with distinct configuration paths:
| Target | Configuration File | Registration Method |
|---|---|---|
| Claude Code | ~/.claude.json |
CLI-first (claude mcp add), with JSON fallback |
| Cursor | ~/.cursor/mcp.json |
Direct JSON write |
| VS Code (Copilot) | ~/.vscode/mcp.json |
Direct JSON write |
| LM Studio | ~/.cache/lm-studio/extensions/plugins/mcp/officecli |
Plugin manifest + bridge config |
Each registration creates an mcpServers.officecli entry with the command path and ["mcp"] arguments.
Registering OfficeCLI with Claude Code
Claude Code receives preferred treatment in the installer. The McpInstaller.InstallClaude() method (lines 70-100 of McpInstaller.cs) first attempts to use the native claude CLI:
officecli mcp claude
Under the hood, this executes:
claude mcp remove -s user officecli
claude mcp add -s user officecli -- /home/user/.local/bin/officecli mcp
If the claude binary is unavailable, the installer falls back to InstallJson(), writing directly to ~/.claude.json:
{
"mcpServers": {
"officecli": {
"command": "/home/user/.local/bin/officecli",
"args": ["mcp"]
}
}
}
Registering OfficeCLI with Cursor
Cursor uses the generic JSON installer path. Run:
officecli mcp cursor
The McpInstaller.InstallJson() method (called from line 62) writes to ~/.cursor/mcp.json with identical structure to the Claude Code example above.
Registering OfficeCLI with VS Code
VS Code Copilot integration follows the same pattern:
officecli mcp vscode
This updates ~/.vscode/mcp.json via InstallJson().
Verifying and Managing Registrations
List Current Status
Check which clients have OfficeCLI registered:
officecli mcp list
Output format (from ListStatus(), lines 403-420):
officecli MCP registration status:
✓ LM Studio registered
✓ Claude Code registered
✗ Cursor not registered
✗ VS Code not registered
Unregister from a Target
Remove OfficeCLI from any client:
officecli mcp uninstall claude
officecli mcp uninstall cursor
officecli mcp uninstall vscode
Each invokes the corresponding UninstallClaude(), UninstallJson(), or UninstallLmStudio() method to clean up configuration files.
How McpInstaller Locates Your Binary
The registration process requires a stable binary path that survives OfficeCLI upgrades. The OfficecliPath property (lines 25-40 of McpInstaller.cs) resolves in priority order:
~/.local/bin/officecli— self-installed path- Binary found on
$PATH - Current process path (fallback)
This ensures configuration files reference a durable location rather than temporary or version-specific paths.
Complete Command Reference
| Command | Purpose | Source Method |
|---|---|---|
officecli mcp claude |
Register with Claude Code | InstallClaude() |
officecli mcp cursor |
Register with Cursor | InstallJson() |
officecli mcp vscode |
Register with VS Code | InstallJson() |
officecli mcp lms |
Register with LM Studio | InstallLmStudio() |
officecli mcp list |
Show registration status | ListStatus() |
officecli mcp uninstall <target> |
Remove registration | Uninstall*() methods |
Summary
- Start the server:
officecli mcplaunches the JSON-RPC stdio server (McpServer.cs) - Register clients:
officecli mcp <target>handles Claude Code, Cursor, VS Code, and LM Studio - Claude Code gets CLI integration: Uses
claude mcp addwhen available, JSON fallback when not - Stable paths matter: Installer prefers
~/.local/bin/officeclifor durable registrations - Manage easily:
listanduninstallsubcommands provide full lifecycle control
Frequently Asked Questions
Does OfficeCLI support other MCP clients beyond Claude Code, Cursor, and VS Code?
Yes. The McpInstaller also supports LM Studio via officecli mcp lms, which writes a plugin manifest to ~/.cache/lm-studio/extensions/plugins/mcp/officecli rather than a JSON config file. The underlying MCP server protocol is standard, so manual registration with other JSON-RPC-over-stdio clients is possible by replicating the command/args structure.
Why does Claude Code registration try the CLI first while other clients use direct JSON?
The InstallClaude() method specifically checks for the claude binary to leverage native MCP management commands, which handle schema validation and potential future format changes. Other clients lack exposed CLI tooling for MCP management, so InstallJson() writes configuration directly to their expected paths. This hybrid approach appears in lines 70-100 of McpInstaller.cs.
What happens if I move or upgrade the OfficeCLI binary after registration?
Registrations may break if the binary path changes. Re-run officecli mcp <target> after any installation that modifies the binary location. The McpInstaller recalculates OfficecliPath on each run and updates configuration files with the current stable path.
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 →