Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1mcp app Agent runCommand

From Leeroopedia
Knowledge Sources
Domains CLI, MCP_Protocol
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete CLI command for directly invoking an MCP tool on a connected server with JSON arguments, timeout control, and formatted output.

Description

The runCommand function invokes a specific MCP tool on a connected server via the running 1MCP runtime. It takes a `server/tool` target reference, JSON arguments, and optional timeout. It connects to the runtime via the HTTP API or MCP client surface, sends the `tools/call` request, and prints the formatted CallToolResult. The exit code reflects success or failure of the tool call.

Usage

Import this function when you need to:

  • Invoke a specific MCP tool from the command line
  • Test tool behavior with specific arguments before agent integration
  • Run tools with a custom timeout
  • Get formatted output for tool results

Code Reference

Source Location

  • Repository: 1MCP Agent
  • File: src/commands/run/run.ts (L141)

Signature

export interface RunCommandOptions extends GlobalOptions, ProjectSelectionOptions {
  target: string;
  args?: string;
  url?: string;
  context?: string;
  format?: RunOutputFormat;
  timeout?: number;
}

export async function runCommand(options: RunCommandOptions): Promise<void>;

Import

import { runCommand } from '@src/commands/run/run.js';

I/O Contract

Inputs

Name Type Required Description
target string Yes server/tool reference
args string No JSON arguments
url string No Runtime URL
timeout number No Tool call timeout in ms
format RunOutputFormat No Output format

Outputs

Name Type Description
stdout formatted text MCP CallToolResult
exit code number 0 on success, non-zero on failure

Usage Examples

Invoke a Tool

1mcp run my-server/my-tool --args '{"path": "/tmp/file.txt"}'
1mcp run my-server/my-tool --args '{"query": "hello"}' --timeout 30000

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment