Principle:1mcp app Agent CLI Agent Integration
| Knowledge Sources | |
|---|---|
| Domains | CLI, MCP_Protocol |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Pattern that connects an AI agent client to a 1MCP runtime through CLI setup, instruction fetching, tool inspection, and direct tool invocation commands.
Description
CLI Agent Integration provides the bridge between an AI agent (Claude Desktop, Codex) and the 1MCP aggregated runtime. The workflow starts with installing the 1MCP CLI, adding upstream MCP servers, starting the runtime, and then using `cli-setup` to write agent configuration files (e.g., `.mcp.json`). Once connected, the agent can fetch runtime instructions for context, inspect available servers and tool schemas, and directly invoke tools via the `run` command. This decouples the agent's tool discovery from the runtime's server management.
Usage
Use this principle when:
- An AI agent needs to discover and use MCP tools through a CLI rather than a programmatic SDK
- Agent configuration files must be generated for Claude Desktop or Codex targets
- Runtime instructions (aggregated from all connected servers) need to be fetched as text
- Tool schemas must be inspected before invocation to understand parameter requirements
- Tools must be invoked directly from the command line with JSON arguments
Theoretical Basis
The integration follows a connect → discover → invoke sequence:
install → add servers → serve → cli-setup → instructions → inspect → run
Each step is a CLI command that interacts with the runtime via HTTP:
// Abstract flow (NOT real implementation)
await serve(); // Start runtime
await cliSetup({ claude: true }); // Write .mcp.json
const instructions = await instructionsCommand(); // Fetch aggregated instructions
const tools = await inspectCommand({ target }); // Discover tool schemas
const result = await runCommand({ target, args }); // Invoke a tool
Practical Guide
- Install the CLI globally via npm to get the `1mcp` binary on PATH
- Use `cli-setup` with `--claude` or `--codex` to generate agent-specific config files
- Fetch instructions from the running runtime to provide the agent with tool context
- Use `inspect` with a `server/tool` target to get JSON schemas before invocation
- Use `run` with JSON arguments and a timeout to invoke tools and get formatted results
Related Pages
Implemented By
- Implementation:1mcp_app_Agent_serveCommand
- Implementation:1mcp_app_Agent_cliSetupCommand
- Implementation:1mcp_app_Agent_instructionsCommand
- Implementation:1mcp_app_Agent_inspectCommand
- Implementation:1mcp_app_Agent_runCommand
- Implementation:1mcp_app_Agent_addCommand
- Implementation:1mcp_app_Agent_installCommand