m365-api
v0.1.6
Published
Local API adapter for Microsoft 365 Copilot Code models and reasoning effort
Readme
m365-api
Connect Microsoft 365 Copilot Code to Claude CLI, Claude Desktop, and OpenAI-compatible clients.
Quick start (Windows PowerShell)
Install Node.js 24+, Edge, and your preferred Claude client. Your work account must have access to the Microsoft 365 Copilot Code page.
npm install -g m365-api --allow-scripts=m365-apiGlobal installation automatically runs setup: choose a port, initially 8787; a saved port is reused without asking. It configures the discovered Claude clients, enables Windows sign-in startup, starts the gateway, and prints the absolute configuration paths. To rerun setup or change the port:
m365-api setup --port 8787If your network cannot reach npmjs, install the same package with its bundled dependencies from the distribution site:
npm install -g https://m365api.claxlink.top/releases/latest.tgz --allow-scripts=https://m365api.claxlink.top/releases/latest.tgz --no-audit --no-fund --foreground-scriptsThe first startup attempts silent Microsoft sign-in. If interaction or MFA is required:
m365-api login --headed
m365-api startInstallation behavior
Global Windows npm installation deploys the runtime and command, then automatically runs setup. Runtime deployment does not scan or change old source PATH registrations, discover or back up legacy startup targets, or automatically migrate old deployments. Existing managed data is retained. Setup writes the current VBS startup entry directly.
If client configuration or first-use sign-in needs attention, the command stays installed and the console explains how to finish with m365-api setup. npm installs using --ignore-scripts require m365-api setup afterwards. Portable mode (M365_API_PORTABLE=1), local dependency installs, and non-Windows installs skip automatic host setup. Explicit source migration is available separately with m365-api migrate --legacy-root <path>; it is never run automatically.
Usage
claude --model opus --effort max
claude --model sonnet --effort maxIn Claude Desktop, restart and use the selected m365-api profile, displayed as M365APP. Open Code and select a local project.
| Interface | Default address | |---|---| | Web interface / Claude base URL | http://127.0.0.1:8787 | | OpenAI base URL | http://127.0.0.1:8787/v1 |
Use the address shown by setup or status if you selected another port. Upload files through the web interface or compatible Claude / Anthropic file APIs; see reference.
Common commands
| Action | Command |
|---|---|
| Configure clients and start | m365-api setup |
| Start / stop / restart | m365-api start / m365-api stop / m365-api restart |
| Show status and configuration paths | m365-api status |
| Check for an update | m365-api update --check-only |
| Download, verify and apply an update | m365-api update |
| Run in the foreground | m365-api start --foreground |
| Preview client configuration | m365-api setup --check-only |
| Enable / disable startup | m365-api startup / m365-api startup:remove |
| Sign in interactively | m365-api login --headed |
Stopping interrupts active requests and does not disable startup. Setup enables Windows sign-in startup automatically; use m365-api startup:remove to disable it. Development-only command registration and test commands are available from Git checkouts.
With startup enabled, npm installations check the saved distribution address at each Windows sign-in, apply a verified update if available, then start the gateway. If the check or update fails, the preserved runtime still starts. Results are saved in .local/startup-update.log. Upgrading an older package also upgrades its existing startup launcher at the next start.
Updates and data
npm installations keep data under %LOCALAPPDATA%\m365-api on Windows. The saved settings are in .env; credentials, conversations and attachments are under .local. M365_API_HOME selects another data directory. Setup and status show the actual absolute configuration path.
m365-api update downloads a complete runtime from m365api.claxlink.top, verifies its SHA-512 digest, stages it alongside the current version and performs a self-check before switching. It requires no Git or npm-registry access. A running gateway is restarted and health-checked; failure attempts to restore the previous version and service. User data is shared across runtime versions. Interactive updates ask for y/n confirmation before interrupting connected clients. Unattended login updates preserve the running gateway when clients are connected. Preview does not change files or stop the gateway.
To use another distribution source, run m365-api update --source <HTTPS URL>. Package installation inherits your npm registry settings; the runtime distribution address is configured separately. Node.js and Edge remain system prerequisites.
For source development, configuration, file APIs and limitations, see the reference and contribution guide.
