# How to Set Up the OfficeCLI MCP Server for Claude Code, Cursor, and VS Code

> Easily set up the OfficeCLI MCP server for integration with Claude Code, Cursor, and VS Code. Use the officecli mcp command to connect AI clients to your development environment.

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

---

**OfficeCLI includes a built-in MCP server that exposes JSON-RPC over STDIO; register it with any supported AI client using the `officecli mcp <target>` command.**

The **iOfficeAI/OfficeCLI** repository provides a native **Model Context Protocol (MCP)** server that allows AI assistants to invoke OfficeCLI commands for document manipulation. This guide covers the exact steps to configure MCP integrations with Claude Code, Cursor, and VS Code, referencing the specific source files and registration logic used under the hood.

## Architecture Overview

OfficeCLI’s MCP implementation consists of two core components defined in the source:

- **[`McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpServer.cs)** – A long-running stdio process ([`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs)) that reads JSON-RPC requests from `stdin` and writes responses to `stdout`.
- **[`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)** – A static helper class ([`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs)) that registers or unregisters the server with AI clients by writing configuration entries to the appropriate JSON files.

The server is started via the `officecli mcp` command, which is wired in [`CommandBuilder.IntegrationStubs.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/CommandBuilder.IntegrationStubs.cs).

## Supported Clients and Configuration Locations

Each target client stores its MCP server definitions in a specific location:

- **Claude Code** – `~/.claude.json` under the top-level `mcpServers` key
- **Cursor** – `~/.cursor/mcp.json` under `mcpServers`
- **VS Code (Copilot)** – `~/.vscode/mcp.json` under `mcpServers`
- **LM Studio** – `~/.cache/lm-studio/extensions/plugins/mcp/officecli/`

## Registering the MCP Server

### Claude Code

Run the install command:

```bash
officecli mcp claude

```

Under the hood, `McpInstaller.InstallClaude()` first attempts to use the `claude` CLI directly by executing `claude mcp remove -s user officecli` followed by `claude mcp add -s user officecli -- /path/to/officecli mcp`. If the CLI is unavailable, the installer falls back to `InstallJson()`, which writes directly to `~/.claude.json` (see lines 70–100 of [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)).

The resulting entry appears as:

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

```

### Cursor

Execute:

```bash
officecli mcp cursor

```

This invokes `InstallJson()` to write the server configuration to `~/.cursor/mcp.json`. Cursor will detect the new entry on restart.

### VS Code

Execute:

```bash
officecli mcp vscode

```

The `McpInstaller` writes the same JSON structure to `~/.vscode/mcp.json`, enabling Copilot and other VS Code AI extensions to invoke OfficeCLI tools.

### LM Studio

Execute:

```bash
officecli mcp lms

```

`McpInstaller.InstallLmStudio()` creates a plugin manifest and bridge configuration in the LM Studio cache directory.

## Managing Registrations

### Check Current Status

List which clients are registered:

```bash
officecli mcp list

```

The `ListStatus()` method (lines 403–420 in [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)) checks each configuration file and outputs a concise status table:

```

officecli MCP registration status:

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

```

### Uninstall a Target

Remove the registration from a specific client:

```bash
officecli mcp uninstall claude

```

This calls `McpInstaller.UninstallClaude()`, which either runs `claude mcp remove` or edits `~/.claude.json` directly to delete the `officecli` entry.

## How the Installer Locates the Binary

To ensure registrations survive upgrades, `McpInstaller` determines a **stable binary path** (lines 25–40) using the following priority:

1. The self-installed path at `~/.local/bin/officecli`
2. The first `officecli` found on `$PATH`
3. The current process executable path

This path is stored in the `command` field of every MCP configuration file.

## Summary

- **OfficeCLI** provides a built-in MCP server implemented in [`McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpServer.cs) that communicates via JSON-RPC over stdio.
- **Registration** is handled by [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs), which supports Claude Code, Cursor, VS Code, and LM Studio.
- **Commands** follow the pattern `officecli mcp <target>`, writing entries to client-specific JSON files such as `~/.claude.json`.
- **Claude Code** registration prefers the `claude` CLI when available, falling back to direct JSON manipulation.
- **Status and removal** are managed via `officecli mcp list` and `officecli mcp uninstall <target>`.

## Frequently Asked Questions

### What is the MCP server in OfficeCLI?

The **MCP server** is a stdio-based JSON-RPC service implemented in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs). It exposes OfficeCLI’s document editing capabilities to AI clients that support the Model Context Protocol, allowing assistants to read and modify Word, Excel, and PowerPoint files programmatically.

### Where does OfficeCLI store MCP configuration for Claude Code?

OfficeCLI writes Claude Code configuration to **`~/.claude.json`** under the `mcpServers` key. If the `claude` CLI is installed, the installer (`McpInstaller.InstallClaude()`) uses it to manage the entry; otherwise, it edits the JSON file directly.

### Can I use the MCP server without installing the Claude CLI?

Yes. The `McpInstaller` detects missing CLI tools and automatically falls back to `InstallJson()`, which writes the configuration directly to the client’s JSON file. For Claude Code, this means editing `~/.claude.json` manually if the `claude` command is unavailable.

### Why does the installer use a stable binary path instead of the current process path?

The installer (lines 25–40 of [`McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/McpInstaller.cs)) prioritizes `~/.local/bin/officecli` to ensure that MCP registrations remain valid after upgrading OfficeCLI. Using a fixed installation path prevents broken references when the binary location changes during updates.