pub async fn run(
from_config: Option<String>,
server: Option<String>,
args: Vec<String>,
env: Vec<String>,
cwd: Option<String>,
http: Option<String>,
sse: Option<String>,
headers: Vec<String>,
name: Option<String>,
output_dir: Option<PathBuf>,
dry_run: bool,
connect_timeout_secs: Option<u64>,
discover_timeout_secs: Option<u64>,
output_format: OutputFormat,
) -> Result<ExitCode>Expand description
Runs the generate command.
Generates progressive loading TypeScript files from an MCP server.
This command performs the following steps:
- Builds
ServerConfigfrom CLI arguments or loads from ~/.claude/mcp.json - Introspects the MCP server to discover tools
- Generates TypeScript files (one per tool) using progressive loading pattern
- Exports VFS to
~/.claude/servers/{server-id}/directory
§Arguments
from_config- Load server config from ~/.claude/mcp.json by nameserver- Server command (binary name or path), None for HTTP/SSEargs- Arguments to pass to the server commandenv- Environment variables in KEY=VALUE formatcwd- Working directory for the server processhttp- HTTP transport URLsse- SSE transport URLheaders- HTTP headers in KEY=VALUE formatname- Custom server name for directory (default:server_id)output_dir- Custom output directory (default: ~/.claude/servers/)dry_run- When true, preview files without writing to diskconnect_timeout_secs- Connection (handshake) timeout override, in seconds. Ignored whenfrom_configis set (themcp.jsonentry’sconnectTimeoutSecsapplies instead). Same bounds asmcp.json: must be greater than zero and at most 600 seconds.discover_timeout_secs- Tool discovery timeout override, in seconds. Same rules asconnect_timeout_secs.output_format- Output format (json, text, pretty)
§Errors
Returns an error if:
- Server configuration is invalid
- Server not found in mcp.json (when using –from-config)
- Server connection fails
- Tool introspection fails
- Code generation fails
- File export fails (skipped in dry-run mode)