How to Configure the OfficeCLI MCP Server for Integration with Claude Code, Cursor, or VS Code
OfficeCLI provides a built-in MCP server that communicates via JSON-RPC over STDIO and can be registered with Claude Code, Cursor, VS Code, and LM Studio using the officecli mcp command.
The OfficeCLI repository includes a native implementation of the Model Context Protocol (MCP), enabling AI assistants to invoke OfficeCLI commands for editing Word, Excel, and PowerPoint files. This guide explains how to configure the MCP server for integration with Claude Code, Cursor, or VS Code using the registration utilities provided in the source code.
Architecture Overview
The MCP implementation in OfficeCLI consists of three primary components that handle server execution, client registration, and CLI integration.
The MCP Server Component
The actual server implementation resides in src/officecli/McpServer.cs. This file implements a long-running stdio process that reads JSON-RPC requests from stdin and writes responses to stdout. When started with the officecli mcp command, the server listens for incoming tool invocations and forwards them to the OfficeCLI CLI implementation.
The Registration Logic
McpInstaller (src/officecli/McpInstaller.cs) contains the core logic for registering and unregistering the server with various AI clients. This static class handles:
- Binary path resolution (lines 25-40): Determines a stable path to the
officecliexecutable that survives upgrades, preferring~/.local/bin/officecli, then$PATH, then the current process path. - Target-specific configuration: Writes JSON configuration files to client-specific locations.
- Claude CLI integration: Attempts to use the
claudeCLI tool when available, falling back to direct JSON file manipulation.
CLI Integration
The mcp sub-command is defined in src/officecli/CommandBuilder.IntegrationStubs.cs and exposed through the help system in CommandBuilder.Help.cs. This front-end parses commands like officecli mcp claude or officecli mcp list and delegates to the appropriate McpInstaller methods.
Configure the MCP Server for Claude Code
Claude Code supports MCP servers through a configuration file at ~/.claude.json or via the claude CLI tool.
To register OfficeCLI with Claude Code, run:
officecli mcp claude
Under the hood, McpInstaller.InstallClaude() (lines 70-100) executes the following logic:
- Attempts to run
claude mcp remove -s user officeclito clear any existing entry. - Attempts to run
claude mcp add -s user officecli -- /home/user/.local/bin/officecli mcp. - If the
claudebinary is not available, falls back toInstallJson()which writes directly to~/.claude.json.
The resulting configuration in ~/.claude.json appears as:
{
"mcpServers": {
"officecli": {
"command": "/home/user/.local/bin/officecli",
"args": ["mcp"]
}
}
}
Configure the MCP Server for Cursor
Cursor stores MCP server configurations in ~/.cursor/mcp.json under the mcpServers key.
To register OfficeCLI with Cursor:
officecli mcp cursor
This invokes McpInstaller.InstallJson() (line 62), which writes the server entry directly to ~/.cursor/mcp.json. The JSON structure mirrors the Claude Code format, specifying the command path and ["mcp"] arguments array.
Configure the MCP Server for VS Code
VS Code (including GitHub Copilot chat integration) uses ~/.vscode/mcp.json for MCP server registration.
To configure the integration:
officecli mcp vscode
The McpInstaller class handles this target through the same InstallJson() method used for Cursor, inserting the officecli entry into the mcpServers object within the VS Code configuration file.
Verify and Manage Registrations
After configuring one or more targets, verify the registration status:
officecli mcp list
This executes McpInstaller.ListStatus() (lines 403-420) and displays output similar to:
officecli MCP registration status:
✓ LM Studio registered
✓ Claude Code registered
✗ Cursor not registered
✗ VS Code not registered
Unregistering the MCP Server
To remove the OfficeCLI MCP server from a specific client:
officecli mcp uninstall claude
officecli mcp uninstall cursor
officecli mcp uninstall vscode
Each command invokes the corresponding UninstallClaude(), UninstallJson(), or target-specific removal method to delete the entry from the respective configuration file.
Summary
- MCP Server Location: The STDIO-based JSON-RPC server is implemented in
src/officecli/McpServer.csand started viaofficecli mcp. - Registration Logic:
src/officecli/McpInstaller.cshandles binary path resolution and client-specific configuration. - Claude Code: Uses
~/.claude.json; prefers theclaudeCLI tool when available, otherwise writes JSON directly. - Cursor: Uses
~/.cursor/mcp.jsonvia direct JSON manipulation. - VS Code: Uses
~/.vscode/mcp.jsonvia direct JSON manipulation. - Management: Use
officecli mcp listto check status andofficecli mcp uninstall <target>to remove configurations.
Frequently Asked Questions
Where does OfficeCLI store the MCP configuration for Claude Code?
Claude Code configuration is stored in ~/.claude.json under the mcpServers key. The McpInstaller class attempts to use the claude CLI tool first (lines 70-100), but if unavailable, it falls back to writing this JSON file directly.
Can I use the OfficeCLI MCP server with LM Studio?
Yes. Run officecli mcp lms to register with LM Studio. According to McpInstaller.cs, this creates a plugin manifest in ~/.cache/lm-studio/extensions/plugins/mcp/officecli using the InstallLmStudio() method, enabling the server to communicate with LM Studio's plugin system.
What happens if the officecli binary is moved or upgraded?
The McpInstaller determines a stable binary path during registration (lines 25-40). It prefers ~/.local/bin/officecli over temporary paths, ensuring that the configuration remains valid after upgrades. If you move the binary manually, re-run the registration command to update the paths in the client configuration files.
How do I troubleshoot MCP connection issues?
First, verify the registration using officecli mcp list to confirm the target shows as "registered". Check that the binary path in the respective JSON file (e.g., ~/.claude.json) points to a valid executable. The server communicates over STDIO, so ensure no other process is interfering with the stdin/stdout streams when the AI client launches the officecli mcp command.
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 →