Implementation:1mcp app Agent enableCommand
| Knowledge Sources | |
|---|---|
| Domains | CLI, MCP_Protocol |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete CLI commands for enabling or disabling an MCP server in the configuration, with runtime-backed mutation support via the admin API.
Description
The enableCommand and disableCommand functions toggle the disabled state of an MCP server in the configuration file. When a runtime is running, they route the mutation through the admin API with idempotency keys and optional admin session authentication. For local-only mutations (no runtime), they update the config file directly with a backup. They support dry-run preview and non-loopback confirmation for remote runtimes.
Usage
Import these functions when you need to:
- Enable a previously disabled server in the config
- Disable a server without removing it from the configuration
- Route enable/disable through a running runtime's admin API
- Preview the mutation with dry-run mode
Code Reference
Source Location
- Repository: 1MCP Agent
- File: src/commands/mcp/enable.ts (L154-178)
Signature
export interface EnableDisableCommandArgs extends GlobalOptions {
name: string;
context?: string;
url?: string;
json?: boolean;
idempotencyKey?: string;
waitMs?: number;
dryRun?: boolean;
confirmNonLoopback?: boolean;
yes?: boolean;
loginPrompt?: boolean;
}
export function buildEnableCommand(yargs: Argv): Argv;
export function buildDisableCommand(yargs: Argv): Argv;
export async function enableCommand(argv: EnableDisableCommandArgs, dependencies?: RuntimeBackedMcpDependencies): Promise<void>;
export async function disableCommand(argv: EnableDisableCommandArgs, dependencies?: RuntimeBackedMcpDependencies): Promise<void>;
Import
import { enableCommand, disableCommand, buildEnableCommand, buildDisableCommand } from '@src/commands/mcp/enable.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Server name to enable/disable |
| context | string | No | Runtime context URL |
| dryRun | boolean | No | Preview only |
| confirmNonLoopback | boolean | No | Confirm non-loopback mutation |
Outputs
| Name | Type | Description |
|---|---|---|
| config file | side effect | Server disabled flag updated |
| stdout | text | Mutation result |
Usage Examples
Enable and Disable
1mcp mcp enable my-server
1mcp mcp disable my-server
1mcp mcp enable my-server --dry-run