MCP Server Configuration Options in OfficeCLI: Environment Variables, JSON Flags, and Command Setup
The MCP server in OfficeCLI supports configuration through environment variables (OFFICECLI_NO_AUTO_RESIDENT, OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT), a persistent JSON flag (mcp-server), and CLI commands (officecli mcp) to register with AI agents.
OfficeCLI provides a Model Context Protocol (MCP) server that integrates with AI coding assistants like Claude Code, Cursor, and VS Code. Understanding the available MCP server configuration options allows you to control resident process behavior, suppress stream warnings, and manage seamless agent registration.
Environment Variables for MCP Server Behavior
The McpServer.cs file defines two environment variables that fine-tune server operation without modifying persistent configuration files.
Disable Automatic Resident Spawning
Set OFFICECLI_NO_AUTO_RESIDENT to "1" to prevent the MCP process from auto-spawning a resident server. This ensures that no persistent background process remains after a lone MCP session completes, while still permitting an existing resident to handle requests if one is already running.
As implemented in src/officecli/McpServer.cs (lines 41-43):
export OFFICECLI_NO_AUTO_RESIDENT=1
officecli mcp # starts MCP server without auto-resident
Suppress Stdin Redirect Warnings
Set OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT to "1" to suppress the "stdin is also redirected; stdin will be ignored" warning emitted during batch operations under MCP transport. Since this warning is harmless for MCP transport, the variable defaults to allowing this condition when set.
According to src/officecli/McpServer.cs (lines 50-52):
export OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT=1
officecli mcp # suppresses stdin redirect warnings
Persistent Configuration via JSON
For settings that persist across sessions, OfficeCLI reads a global configuration file at ~/.officecli/config.json.
Enable the MCP Server Flag
Set the mcp-server boolean flag to true in your global configuration to activate the MCP server automatically on CLI startup. This persistent setting applies to agents that read the OfficeCLI configuration file.
Add to ~/.officecli/config.json:
{
"mcp-server": true
}
This option is documented in the repository's README.md and activates the server without requiring additional command-line arguments.
Agent Registration Commands
The officecli mcp sub-command registers the current OfficeCLI binary as an MCP server within various AI client configurations, handled by McpInstaller.cs and routed through Program.cs.
Registering with AI Clients
Run the registration command with a specific target to write the appropriate MCP server configuration to the client's settings:
officecli mcp claude
# writes entry to ~/.claude.json or equivalent
Supported Targets
The officecli mcp [target] command supports the following agents as implemented in src/officecli/Program.cs (lines 87-108):
claude– Claude Codelms– LM Studiocursor– Cursor IDEvscode– VS Code / Copilot
To unregister OfficeCLI from a specific client:
officecli mcp uninstall vscode
Implementation Details
These MCP server configuration options are implemented across three core files in the iOfficeAI/OfficeCLI repository:
src/officecli/McpServer.cs– Implements the MCP stdio server and defines environment variable defaults for resident mode and stdin handlingsrc/officecli/McpInstaller.cs– Handles registration and unregistration with external AI client configurationssrc/officecli/Program.cs– Parses theofficecli mcpcommand line and routes execution to the installer or server
Summary
- Use
OFFICECLI_NO_AUTO_RESIDENT=1to prevent persistent resident processes after isolated MCP sessions - Set
OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT=1to silence harmless stdin redirect warnings during batch operations - Configure
"mcp-server": truein~/.officecli/config.jsonfor persistent MCP activation - Run
officecli mcp [target]to register the binary with Claude Code, Cursor, LM Studio, or VS Code
Frequently Asked Questions
How do I prevent OfficeCLI from leaving a resident process running after an MCP session?
Set the environment variable OFFICECLI_NO_AUTO_RESIDENT to "1" before starting the MCP server. As defined in McpServer.cs, this prevents the auto-spawning of a resident server while still allowing existing residents to handle requests.
What does the OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT environment variable control?
This variable suppresses the warning message about stdin being redirected during batch MCP calls. Since MCP transport over stdio makes this warning irrelevant, setting this variable to "1" allows the process to continue silently without emitting warnings to stderr.
Where does OfficeCLI store persistent MCP configuration?
The persistent configuration resides in ~/.officecli/config.json as a JSON file containing the mcp-server boolean flag. When set to true, OfficeCLI activates the MCP server automatically on startup for agents that read this global configuration.
Which AI clients support direct MCP registration via OfficeCLI?
OfficeCLI supports registration with Claude Code (claude), LM Studio (lms), Cursor (cursor), and VS Code/Copilot (vscode). The registration logic in Program.cs routes these targets to McpInstaller.cs, which writes the appropriate configuration entries to each client's settings file.
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 →