What is MCP?
MCP (Model Context Protocol) is a standard protocol for connecting AI assistants to external tools and data sources. The m87 MCP server allows AI agents to programmatically interact with your devices, deployments, and infrastructure.Quick Start
Start the MCP server:Configuration
Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
m87 is not in your PATH, use an absolute path:
Claude Code
Add to your MCP settings:Other MCP Clients
Any MCP-compatible client can connect to the m87 server using the stdio transport:Server Information
m87-mcpMatches m87 CLI version
- Tools: Yes
- Prompts: No
- Resources: No
Available Tools
The MCP server exposes the following categories of tools:Device Management
devices_list- List all accessible devicesdevices_approve- Approve pending device registrationsdevices_reject- Reject pending device registrationsdevice_status- Get device health and status (supports batch)device_audit_logs- Get device audit logs (supports batch)
Device Access Control
device_access_list- List users with device accessdevice_access_add- Grant device accessdevice_access_remove- Revoke device access
File Operations
device_ls- List files on devicedevice_cp- Copy files between local and remotedevice_sync- Sync files (rsync-style)
Remote Execution
device_exec- Execute commands on devices (supports batch)docker_exec- Run Docker commands on devices
Port Forwarding
forward_start- Start persistent port forwarding sessionforward_stop- Stop forwarding sessionforward_list- List active forwarding sessions
Deployments
device_deploy- Deploy specs to devicesdevice_undeploy- Remove deployment specsdevice_deployment_list- List deployments (supports batch)device_deployment_new- Create new deploymentdevice_deployment_show- Show deployment detailsdevice_deployment_status- Get deployment status (supports batch)device_deployment_active- Get active deployment IDdevice_deployment_activate- Set active deploymentdevice_deployment_rm- Remove deploymentdevice_deployment_clone- Clone deployment
Organization Management
org_list- List organizationsorg_create- Create organizationorg_delete- Delete organizationorg_update- Update organizationorg_members_list- List organization membersorg_members_add- Add organization memberorg_members_remove- Remove organization memberorg_devices_list- List organization devicesorg_devices_add- Add device to organizationorg_devices_remove- Remove device from organization
Batch Operations
Many tools support batch operations for efficiency. Instead of passing a singledevice parameter, you can pass a devices array:
device_statusdevice_audit_logsdevice_execdevice_deployment_listdevice_deployment_status
Authentication
The MCP server uses your existing m87 CLI credentials. Ensure you’re logged in before starting the server:Error Handling
The MCP server returns errors in two ways:- MCP-level errors: Invalid requests, missing parameters, etc.
- Operation errors: Returned as data in the response (e.g., command failures)
Example: Command with Non-Zero Exit
Output Formatting
All tool responses:- Return JSON-formatted data
- Strip ANSI color codes (not useful for AI agents)
- Include relevant context (device names, IDs, etc.)
Session Management
The MCP server supports long-running operations:Port Forwarding Sessions
Forwarding runs in the background and persists across multiple tool calls:Docker Containers
For long-running containers, use the-d (detached) flag:
Best Practices
The server automatically handles device name resolution, authentication, and connection management.