How to Configure MCP Server Integration with Claude Code, Cursor, and VS Code Using OfficeCLI
Configure OfficeCLI's built-in MCP server for Claude Code, Cursor, or VS Code using the officecli mcp command, which auto-generates JSON-RPC configuration files in the appropriate client directories.
OfficeCLI provides native MCP (Model‑Context‑Protocol) integration, allowing AI assistants to invoke OfficeCLI commands directly. The officecli mcp command handles server registration, configuration file management, and status monitoring across multiple AI clients.
Understanding the MCP Server Architecture
OfficeCLI's MCP implementation consists of three core components defined in the source code:
| Component | Source File | Purpose |
|---|---|---|
| MCP Server | src/officecli/McpServer.cs |
STDIO-based JSON-RPC server that receives requests and forwards them to OfficeCLI commands |
| McpInstaller | src/officecli/McpInstaller.cs |
Registration helper that writes client-specific configuration files |
| CLI Frontend | src/officecli/CommandBuilder.IntegrationStubs.cs |
Parses officecli mcp subcommands and dispatches to McpInstaller |
The server operates as a long-running stdio process. When started with officecli mcp, it reads JSON‑RPC requests from stdin and writes responses to stdout. Client tools connect to this process to execute OfficeCLI operations like editing Word, Excel, or PowerPoint files.
How MCP Integration Works
Each AI client stores MCP server configuration in a target-specific location. The McpInstaller class (lines 25‑100 in McpInstaller.cs) handles four registration targets:
| Target | Configuration File | Registration Method |
|---|---|---|
| Claude Code | ~/.claude.json |
InstallClaude() — attempts claude mcp add CLI first, falls back to direct JSON edit |
| Cursor | ~/.cursor/mcp.json |
InstallJson() — direct JSON write |
| VS Code | ~/.vscode/mcp.json |
InstallJson() — direct JSON write |
| LM Studio | ~/.cache/lm-studio/extensions/plugins/mcp/officecli |
InstallLmStudio() — plugin manifest and bridge config |
All registrations use a stable binary path (OfficecliPath) that survives upgrades. The installer prefers ~/.local/bin/officecli, then $PATH, then the current process path (lines 25‑40).
The generated configuration follows this structure:
{
"mcpServers": {
"officecli": {
"command": "/home/user/.local/bin/officecli",
"args": ["mcp"]
}
}
}
Step-by-Step MCP Configuration
Register with Claude Code
officecli mcp claude
The McpInstaller.InstallClaude() method executes this sequence:
- Attempts
claude mcp remove -s user officeclito clean any existing entry - Runs
claude mcp add -s user officecli -- /home/user/.local/bin/officecli mcp - If the
claudeCLI is unavailable, falls back toInstallJson()writing directly to~/.claude.json(lines 84‑100)
Register with Cursor
officecli mcp cursor
This invokes InstallJson() with the Cursor target, creating or modifying ~/.cursor/mcp.json (line 62).
Register with VS Code (Copilot)
officecli mcp vscode
Writes the officecli entry to ~/.vscode/mcp.json using the same InstallJson() path.
Check Registration Status
officecli mcp list
The ListStatus() method (lines 403‑420) queries all target locations and outputs:
officecli MCP registration status:
✓ LM Studio registered
✓ Claude Code registered
✗ Cursor not registered
✗ VS Code not registered
Remove a Registration
officecli mcp uninstall claude
Calls McpInstaller.UninstallClaude(), which mirrors the install logic: prefers claude mcp remove CLI if available, otherwise edits ~/.claude.json directly.
Technical Implementation Details
The McpInstaller class provides these key methods for MCP server integration:
OfficecliPath(property, lines 25‑40): Resolves a stable, upgrade-resistant path to the OfficeCLI binaryInstallClaude()(lines 70‑100): Claude-specific registration with CLI fallbackInstallJson()(generic): Direct JSON file manipulation for Cursor and VS CodeInstallLmStudio(): Plugin manifest generation for LM StudioUninstallClaude(),UninstallJson(),UninstallLmStudio(): Symmetric removal operationsListStatus()(lines 403‑420): Cross-client status aggregation
The command entry point is defined in CommandBuilder.IntegrationStubs.cs, which maps:
officecli mcp <target>→McpInstaller.Install(target)officecli mcp list→McpInstaller.ListStatus()officecli mcp uninstall <target>→McpInstaller.Uninstall(target)
Summary
- OfficeCLI ships a native MCP server started with
officecli mcpand configured via themcpsubcommand - Registration is client-specific: Claude Code uses
~/.claude.json, Cursor uses~/.cursor/mcp.json, VS Code uses~/.vscode/mcp.json - The
McpInstallerclass (src/officecli/McpInstaller.cs) encapsulates all install/uninstall logic with automatic CLI detection for Claude Code - Always use
officecli mcp listto verify current registration state across all supported clients
Frequently Asked Questions
Does OfficeCLI require manual JSON editing for MCP setup?
No. The officecli mcp <target> command handles all configuration automatically. It locates the stable binary path, generates the correct JSON structure, and writes to the appropriate client-specific file. Manual editing is only necessary if the CLI tool is unavailable for Claude Code, where McpInstaller falls back to direct file modification.
What happens if I upgrade OfficeCLI after MCP registration?
The registration remains valid. The McpInstaller.OfficecliPath property (lines 25‑40) prefers ~/.local/bin/officecli, a stable location that survives upgrades. If you installed OfficeCLI elsewhere, re-run officecli mcp <target> to update the path in client configurations.
Can I use OfficeCLI's MCP server with clients not officially supported?
Yes, but manually. The MCP server itself (src/officecli/McpServer.cs) only requires a stdio-capable JSON-RPC client. Register any compatible tool using the configuration pattern: command path pointing to officecli with single argument mcp. The official installer only automates Claude Code, Cursor, VS Code, and LM Studio.
How do I troubleshoot MCP connection failures?
Run officecli mcp list to confirm registration status and binary path. Verify the configured path exists and is executable. Test the server directly with echo '{"jsonrpc":"2.0","id":1,"method":"initialize"}' | /path/to/officecli mcp — valid JSON responses indicate proper server operation.
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 →