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

> Integrate MCP server with Claude Code, Cursor, and VS Code using OfficeCLI. Easily configure JSON-RPC over STDIO with the officecli mcp command for seamless development.

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

---

**OfficeCLI provides a built-in MCP server that integrates with Claude Code, Cursor, and VS Code via JSON-RPC over STDIO, configured through the `officecli mcp` command that writes to client-specific JSON configuration files.**

The iOfficeAI/OfficeCLI repository ships with a native Model Context Protocol (MCP) server implementation that enables AI coding assistants to invoke OfficeCLI commands for editing Word, Excel, and PowerPoint files. This integration leverages JSON-RPC over standard input/output streams, allowing seamless registration with popular AI development tools through a unified command-line interface.

## Architecture Overview

The MCP integration consists of three core components defined in the OfficeCLI source:

- **[`McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpServer.cs)** – Implements the STDIO-based JSON-RPC server that listens on `stdin` and writes responses to `stdout`. Located at [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs).
- **[`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)** – Handles registration logic for Claude Code, Cursor, VS Code, and LM Studio. Located at [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs).
- **[`CommandBuilder.IntegrationStubs.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/CommandBuilder.IntegrationStubs.cs)** – Defines the `officecli mcp` subcommand interface and wires it to the installer logic.

The registration process targets specific configuration files for each AI client:

| AI Client | Configuration File Path | Registration Method |
|-----------|------------------------|---------------------|
| **Claude Code** | `~/.claude.json` | `InstallClaude()` with CLI fallback |
| **Cursor** | `~/.cursor/mcp.json` | `InstallJson()` |
| **VS Code** | `~/.vscode/mcp.json` | `InstallJson()` |

Each registration inserts a structured entry under the `mcpServers` key pointing to the stable OfficeCLI binary path.

## Registering OfficeCLI with Claude Code

To register OfficeCLI with Claude Code, execute:

```bash
officecli mcp claude

```

Under the hood, `McpInstaller.InstallClaude()` (lines 70–100 of [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)) first attempts to use the native `claude` CLI:

```bash
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()`, which directly writes to `~/.claude.json`:

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

```

## Registering OfficeCLI with Cursor

For Cursor IDE integration, run:

```bash
officecli mcp cursor

```

This invokes `InstallJson()` targeting `~/.cursor/mcp.json`. The entry follows the same JSON schema as Claude Code, specifying the OfficeCLI binary path and the `mcp` argument to start the server process.

## Registering OfficeCLI with VS Code

To enable OfficeCLI capabilities within VS Code's Copilot chat, execute:

```bash
officecli mcp vscode

```

The installer writes to `~/.vscode/mcp.json`, inserting the `officecli` entry under the `mcpServers` object. After registration, VS Code Copilot can spawn the OfficeCLI MCP server to process document manipulation requests.

## Managing MCP Registrations

### Listing Current Status

Check which AI clients have OfficeCLI registered:

```bash
officecli mcp list

```

The `ListStatus()` method (lines 403–420 in [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)) queries all known configuration files and outputs a status summary:

```

officecli MCP registration status:

  ✓ LM Studio       registered
  ✓ Claude Code     registered
  ✗ Cursor          not registered
  ✗ VS Code         not registered

```

### Uninstalling from a Target

To remove OfficeCLI integration from a specific client:

```bash
officecli mcp uninstall claude

```

This calls `McpInstaller.UninstallClaude()`, which either executes `claude mcp remove -s user officecli` or manually edits `~/.claude.json` to remove the `officecli` entry from the `mcpServers` object.

## How the Installer Locates and Registers the Binary

The `McpInstaller` class implements a robust resolution strategy to ensure registrations survive OfficeCLI upgrades:

1. **Binary Resolution** (lines 25–40) – The installer determines `OfficecliPath` by checking:
   - The self-installed path at `~/.local/bin/officecli` (preferred)
   - The first `officecli` binary found on `$PATH`
   - The current executing process path as fallback

2. **Target Routing** – A switch statement on the lower-cased target name (`claude`, `cursor`, `vscode`, `lms`) routes to the appropriate handler.

3. **Configuration Writing** – For Claude Code, the installer prefers native CLI commands but falls back to direct JSON manipulation. For Cursor and VS Code, it calls `InstallJson()` to write the standardized MCP server configuration.

The server entry always specifies the `mcp` subcommand as the argument array, which launches the JSON-RPC server implemented in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs).

## Summary

- **OfficeCLI** provides a built-in MCP server accessible via `officecli mcp` that communicates over STDIO using JSON-RPC.
- **Registration commands** (`officecli mcp claude`, `officecli mcp cursor`, `officecli mcp vscode`) write configuration to client-specific JSON files (`~/.claude.json`, `~/.cursor/mcp.json`, `~/.vscode/mcp.json`).
- **Claude Code** registration attempts CLI-based installation first, falling back to direct JSON editing if the `claude` binary is unavailable.
- **Source files** governing this behavior include [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs) for registration logic and [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs) for the protocol implementation.
- **Management commands** `officecli mcp list` and `officecli mcp uninstall <target>` provide visibility and cleanup capabilities.

## Frequently Asked Questions

### What is the Model Context Protocol (MCP) in OfficeCLI?

The MCP implementation in OfficeCLI is a STDIO-based JSON-RPC server defined in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs) that exposes OfficeCLI document manipulation capabilities to AI coding assistants. It follows the Model Context Protocol specification to allow Claude Code, Cursor, and VS Code Copilot to invoke OfficeCLI commands as tools.

### Where does OfficeCLI store MCP configuration for each AI client?

OfficeCLI stores configurations in client-specific locations: `~/.claude.json` for Claude Code, `~/.cursor/mcp.json` for Cursor, and `~/.vscode/mcp.json` for VS Code. Each file contains a top-level `mcpServers` object with an `officecli` entry specifying the binary path and startup arguments.

### Can I use OfficeCLI MCP with LM Studio?

Yes. OfficeCLI supports LM Studio through `officecli mcp lms`, which writes a plugin manifest to `~/.cache/lm-studio/extensions/plugins/mcp/officecli`. The `McpInstaller.InstallLmStudio()` method handles this specialized registration path differently from the JSON-based configurations used by Claude Code, Cursor, and VS Code.

### Why does Claude Code registration try the CLI first before editing JSON?

The `InstallClaude()` method prioritizes the `claude mcp add` CLI command (lines 70–84 in [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)) to ensure compatibility with Claude Code's native configuration management. If the `claude` binary is not in `$PATH`, it falls back to `InstallJson()` (lines 84–100) to directly manipulate `~/.claude.json`, providing robust registration regardless of CLI availability.