# How to Configure MCP Server Integration with Claude Code, Cursor, and VS Code Using OfficeCLI

> Easily configure MCP server integration for Claude Code, Cursor, or VS Code. OfficeCLI's mcp command auto-generates JSON-RPC files for seamless setup.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-08-03

---

**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`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs) | STDIO-based JSON-RPC server that receives requests and forwards them to OfficeCLI commands |
| **McpInstaller** | [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs) | Registration helper that writes client-specific configuration files |
| **CLI Frontend** | [`src/officecli/CommandBuilder.IntegrationStubs.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/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`](https://github.com/iOfficeAI/OfficeCLI/blob/main/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:

```json
{
  "mcpServers": {
    "officecli": {
      "command": "/home/user/.local/bin/officecli",
      "args": ["mcp"]
    }
  }
}

```

## Step-by-Step MCP Configuration

### Register with Claude Code

```bash
officecli mcp claude

```

The `McpInstaller.InstallClaude()` method executes this sequence:

1. Attempts `claude mcp remove -s user officecli` to clean any existing entry
2. Runs `claude mcp add -s user officecli -- /home/user/.local/bin/officecli mcp`
3. If the `claude` CLI is unavailable, falls back to `InstallJson()` writing directly to `~/.claude.json` (lines 84‑100)

### Register with Cursor

```bash
officecli mcp cursor

```

This invokes `InstallJson()` with the Cursor target, creating or modifying `~/.cursor/mcp.json` (line 62).

### Register with VS Code (Copilot)

```bash
officecli mcp vscode

```

Writes the `officecli` entry to `~/.vscode/mcp.json` using the same `InstallJson()` path.

### Check Registration Status

```bash
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

```bash
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 binary
- **`InstallClaude()`** (lines 70‑100): Claude-specific registration with CLI fallback
- **`InstallJson()`** (generic): Direct JSON file manipulation for Cursor and VS Code
- **`InstallLmStudio()`**: Plugin manifest generation for LM Studio
- **`UninstallClaude()`**, **`UninstallJson()`**, **`UninstallLmStudio()`**: Symmetric removal operations
- **`ListStatus()`** (lines 403‑420): Cross-client status aggregation

The command entry point is defined in [`CommandBuilder.IntegrationStubs.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/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 mcp` and configured via the `mcp` subcommand
- **Registration is client-specific**: Claude Code uses `~/.claude.json`, Cursor uses `~/.cursor/mcp.json`, VS Code uses `~/.vscode/mcp.json`
- **The `McpInstaller` class** ([`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs)) encapsulates all install/uninstall logic with automatic CLI detection for Claude Code
- **Always use `officecli mcp list`** to 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`](https://github.com/iOfficeAI/OfficeCLI/blob/main/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.