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

> Effortlessly set up the MCP server for Claude Code, Cursor, and VS Code integration with OfficeCLI. Configure your tools for seamless AI coding assistance using a single command.

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

---

**OfficeCLI provides a native Model Context Protocol (MCP) server that integrates with Claude Code, Cursor, and VS Code via stdio-based JSON-RPC, configured through a single `officecli mcp <target>` command.**

The iOfficeAI/OfficeCLI repository ships a minimalist MCP server implementation that enables AI-enabled editors to invoke OfficeCLI commands directly. Setting up this integration requires registering the server with each client's specific configuration file and launching the long-lived stdio process. This guide walks through the complete setup process using the built-in `McpInstaller` class and command-line interface.

## What Is the OfficeCLI MCP Server?

The MCP server is a stdio-based JSON-RPC 2.0 service embedded within the `officecli` binary. When you run `officecli mcp`, the application enters server mode defined in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs), reading requests from stdin and dispatching OfficeCLI tools back to the AI client. This architecture allows Claude Code, Cursor, and VS Code Copilot to discover and execute OfficeCLI capabilities without external network dependencies.

## Prerequisites

Before configuring the integration, ensure you have:

- The `officecli` binary installed and available in your system PATH
- Write access to your home directory for creating configuration files
- One or more target AI clients installed (Claude Code, Cursor, or VS Code)

## Step-by-Step MCP Server Setup

The `McpInstaller` class in [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs) handles all registration logic through the `officecli mcp <target>` command interface.

### Install the OfficeCLI Binary

First, ensure OfficeCLI is fully installed with all skill files and MCP support:

```bash
officecli install all

```

This command installs the binary and prepares the MCP server components for all detected agents on your system.

### Register with Claude Code

To set up the MCP server for Claude Code integration, run:

```bash
officecli mcp claude

```

According to the source code in [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs) (lines 78-100), the installer first attempts to use the native `claude mcp add` CLI command. If the Claude CLI is unavailable, it falls back to directly writing an entry to `~/.claude.json` under the `mcpServers` key. The configuration points to the stable `officecli` binary path with `args` set to `["mcp"]`.

### Register with Cursor

For Cursor integration, execute:

```bash
officecli mcp cursor

```

The `McpInstaller` uses its generic JSON installer method (`InstallJson`) to write to `~/.cursor/mcp.json` (lines 62-66 in [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs)). This creates or merges an `mcpServers` object containing an `"officecli"` entry with the command path and MCP arguments.

### Register with VS Code

To configure VS Code (Copilot) integration:

```bash
officecli mcp vscode

```

As implemented in lines 68-74 of [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs), this writes the server configuration to `~/.vscode/mcp.json` using the same generic installer pattern. The JSON structure matches the `mcpServers` schema expected by VS Code's MCP client.

## How the Registration Works

The registration process relies on the `InstallJson` method (lines 78-108 in [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs)), which performs the following operations:

1. **Locates the target configuration file** based on the `target` parameter ("claude", "cursor", or "vscode")
2. **Reads existing JSON** or initializes a new configuration object
3. **Creates or updates the `mcpServers` object** with an entry named `"officecli"`
4. **Sets the `command` property** to the absolute path of the current `officecli` binary
5. **Specifies the arguments** as `["mcp"]` to launch the server mode

This approach ensures that each AI client discovers the OfficeCLI capabilities through their standard MCP discovery mechanisms.

## Starting the MCP Server

Once registered, start the long-lived MCP server process:

```bash
officecli mcp

```

This command launches the stdio-based server implemented in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs) (lines 14-21). The server reads JSON-RPC requests from stdin, dispatches the appropriate OfficeCLI commands, and periodically checks for updates while maintaining a clean stdio stream for continuous communication with the AI client.

## Uninstalling the MCP Integration

To remove the OfficeCLI MCP server from any client, use the uninstall subcommand:

```bash
officecli mcp uninstall claude   # Removes entry from ~/.claude.json

officecli mcp uninstall cursor   # Removes entry from ~/.cursor/mcp.json

officecli mcp uninstall vscode   # Removes entry from ~/.vscode/mcp.json

```

## Summary

- **OfficeCLI embeds a native MCP server** that communicates via JSON-RPC 2.0 over stdio, implemented in [`src/officecli/McpServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpServer.cs).
- **Registration is client-specific**: use `officecli mcp claude`, `officecli mcp cursor`, or `officecli mcp vscode` to write configurations to `~/.claude.json`, `~/.cursor/mcp.json`, or `~/.vscode/mcp.json` respectively.
- **The `McpInstaller` class** handles all setup logic, including fallback mechanisms for Claude Code when its CLI is unavailable.
- **Launch the server** with `officecli mcp` to enable real-time command execution from AI clients.
- **Remove integrations** using `officecli mcp uninstall <target>` to clean up configuration files.

## Frequently Asked Questions

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

The Model Context Protocol is an open standard that enables AI systems to discover and invoke external tools through a standardized JSON-RPC interface. OfficeCLI implements MCP over stdio, allowing AI editors like Claude Code and Cursor to execute OfficeCLI commands as native functions without requiring custom plugins or API integrations.

### Where does OfficeCLI store the MCP configuration?

OfficeCLI stores configurations in client-specific JSON files in your home directory: `~/.claude.json` for Claude Code, `~/.cursor/mcp.json` for Cursor, and `~/.vscode/mcp.json` for VS Code. Each file contains a `mcpServers` object with an `"officecli"` entry pointing to the binary path and MCP arguments, as managed by the `InstallJson` method in [`src/officecli/McpInstaller.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/McpInstaller.cs).

### Can I run the MCP server manually without registration?

Yes, you can launch the MCP server directly by running `officecli mcp` without arguments. However, AI clients will not discover the server unless you manually add the configuration entry to the appropriate JSON file, or use the `officecli mcp <target>` command to register it automatically.

### How do I troubleshoot MCP connection issues?

Verify that the `officecli` binary path in your client's MCP configuration file matches your current installation location. Check that `officecli mcp` runs without errors in your terminal, and ensure the target JSON files (`~/.claude.json`, `~/.cursor/mcp.json`, or `~/.vscode/mcp.json`) contain valid JSON under the `mcpServers.officecli` key with the correct command and args structure.