Skip to main content

CLI Module - MCP Tool Specification

This document defines the Model Context Protocol (MCP) tools for the cli module, which serves as the primary command-line interface entry point for the Codomyrmex platform.

General Considerations for CLI Tools​

  • Dependencies: Requires logging_monitoring module. Many handlers depend on their respective domain modules (e.g., handle_ai_generate requires agents module).
  • Initialization: No module-level initialization required. Individual handlers may initialize their dependencies lazily.
  • Error Handling: Errors are logged via logging_monitoring. Tools return {"success": false, "error": "description"} on failure.
  • Security: CLI tools execute with the permissions of the calling process. File path parameters are validated against the working directory.

Tool: cli_check_environment​

1. Tool Purpose and Description​

Verifies the Codomyrmex environment setup, checking for required dependencies, configuration files, and system prerequisites. Essential for diagnosing installation issues and ensuring the platform is ready for use.

2. Invocation Name​

cli_check_environment

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
verbosebooleanNoEnable verbose output with detailed dependency information. Default: falsetrue

Notes on Input Schema:

  • This tool has minimal parameters as it performs a standardized environment check.

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether all environment checks passedtrue
checksarray[object]List of individual check resultsSee below
checks[].namestringName of the check"python_version"
checks[].passedbooleanWhether the check passedtrue
checks[].messagestringDetailed status message"Python 3.11.4 detected"
missing_dependenciesarray[string]List of missing required dependencies["docker"]
warningsarray[string]Non-critical issues detected["Optional module 'spatial' not installed"]

5. Error Handling​

  • EnvironmentError: Raised when critical environment checks fail
  • PermissionError: Raised when unable to access required paths
  • Return Format: {"success": false, "error": "Environment check failed: <details>"}

6. Idempotency​

  • Idempotent: Yes
  • Explanation: This tool only performs read operations and checks. Repeated calls will return the same result given an unchanged environment.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_check_environment",
"arguments": {
"verbose": true
}
}

8. Security Considerations​

  • Input Validation: No user-supplied paths or code execution.
  • Permissions: Reads environment variables and checks file existence only.
  • Data Handling: No sensitive data processed.

Tool: cli_show_modules​

1. Tool Purpose and Description​

Lists all available Codomyrmex modules with their status, version, and health information. Useful for discovering platform capabilities and diagnosing module-specific issues.

2. Invocation Name​

cli_show_modules

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
filter_statusenum["available", "unavailable", "all"]NoFilter modules by availability status. Default: "all""available"
include_detailsbooleanNoInclude detailed module information (version, dependencies). Default: falsetrue

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
modulesarray[object]List of module informationSee below
modules[].namestringModule name"coding"
modules[].statusstringAvailability status"available"
modules[].versionstringModule version"0.1.0"
modules[].descriptionstringBrief module description"Code execution and review"
total_countintegerTotal number of modules55
available_countintegerNumber of available modules52

5. Error Handling​

  • ModuleNotFoundError: If module discovery fails
  • Return Format: {"success": false, "error": "Failed to enumerate modules: <details>"}

6. Idempotency​

  • Idempotent: Yes
  • Explanation: Read-only operation that queries module registry.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_show_modules",
"arguments": {
"filter_status": "available",
"include_details": true
}
}

8. Security Considerations​

  • Input Validation: Enum validation for filter_status.
  • Permissions: Read-only access to module metadata.
  • Data Handling: No sensitive data exposed.

Tool: cli_show_system_status​

1. Tool Purpose and Description​

Displays comprehensive system status including resource utilization, active workflows, running processes, and service health. Provides a dashboard view of the Codomyrmex platform state.

2. Invocation Name​

cli_show_system_status

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
include_resourcesbooleanNoInclude CPU/memory/disk usage. Default: truetrue
include_workflowsbooleanNoInclude active workflow status. Default: truetrue
formatenum["text", "json"]NoOutput format. Default: "json""json"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstringOverall system status"healthy"
resourcesobjectResource utilization (if requested)See below
resources.cpu_percentfloatCPU utilization percentage45.2
resources.memory_percentfloatMemory utilization percentage68.5
resources.disk_percentfloatDisk utilization percentage32.1
workflowsobjectWorkflow status (if requested)See below
workflows.activeintegerNumber of running workflows2
workflows.queuedintegerNumber of queued workflows5
servicesarray[object]Service health statusSee below
timestampstringISO timestamp of status check"2026-02-03T10:30:00Z"

5. Error Handling​

  • RuntimeError: If unable to collect system metrics
  • Return Format: {"success": false, "error": "Status collection failed: <details>"}

6. Idempotency​

  • Idempotent: Yes
  • Explanation: Read-only status query with no side effects.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_show_system_status",
"arguments": {
"include_resources": true,
"include_workflows": true,
"format": "json"
}
}

8. Security Considerations​

  • Input Validation: Enum validation for format parameter.
  • Permissions: Requires read access to system metrics.
  • Data Handling: May expose system resource information; appropriate for trusted environments.

Tool: cli_workflow_run​

1. Tool Purpose and Description​

Executes a defined workflow by name, optionally with custom parameters. Workflows orchestrate multi-step operations across Codomyrmex modules.

2. Invocation Name​

cli_workflow_run

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
workflow_namestringYesName of the workflow to execute"ai-analysis"
paramsobjectNoJSON parameters to pass to the workflow{"target_path": "./src"}
async_executionbooleanNoRun workflow asynchronously. Default: falsefalse
timeoutintegerNoExecution timeout in seconds. Default: 300600

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether workflow completed successfullytrue
workflow_idstringUnique identifier for this execution"wf-abc123"
statusstringExecution status"completed"
resultobjectWorkflow output data{"files_processed": 42}
duration_secondsfloatExecution duration23.5
steps_completedintegerNumber of workflow steps completed5

5. Error Handling​

  • WorkflowNotFoundError: Specified workflow does not exist
  • WorkflowTimeoutError: Execution exceeded timeout
  • WorkflowExecutionError: Step failure during execution
  • Return Format: {"success": false, "error": "Workflow failed: <details>", "failed_step": "<step_name>"}

6. Idempotency​

  • Idempotent: No
  • Explanation: Workflow execution may modify files, create resources, or have other side effects depending on workflow definition.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_workflow_run",
"arguments": {
"workflow_name": "code-review",
"params": {
"target_path": "./src/codomyrmex/coding",
"output_format": "json"
},
"timeout": 300
}
}

8. Security Considerations​

  • Input Validation: Workflow name validated against registered workflows. Parameters validated per workflow schema.
  • Permissions: Workflow execution inherits CLI process permissions.
  • Data Handling: Workflows may process source code; ensure appropriate access controls.
  • File Paths: All file paths in params are validated and sandboxed.

Tool: cli_ai_generate​

1. Tool Purpose and Description​

Generates code using AI assistance based on a natural language prompt. Leverages configured LLM providers to produce code in the specified programming language.

2. Invocation Name​

cli_ai_generate

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
promptstringYesNatural language description of code to generate"Create a function to validate email addresses"
languagestringNoTarget programming language. Default: "python""typescript"
providerstringNoLLM provider to use. Default: "openai""anthropic"
output_pathstringNoFile path to save generated code"./src/validators.py"
max_tokensintegerNoMaximum tokens in response. Default: 20484096

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether generation succeededtrue
codestringGenerated source code"def validate_email..."
languagestringLanguage of generated code"python"
providerstringLLM provider used"openai"
modelstringSpecific model used"gpt-4o"
tokens_usedintegerTotal tokens consumed856
output_pathstringPath where code was saved (if specified)"./src/validators.py"

5. Error Handling​

  • ProviderError: LLM provider unavailable or authentication failed
  • RateLimitError: Provider rate limit exceeded
  • GenerationError: AI failed to generate valid code
  • Return Format: {"success": false, "error": "Generation failed: <details>"}

6. Idempotency​

  • Idempotent: No
  • Explanation: Each call may produce different generated code. If output_path is specified, file will be overwritten.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_ai_generate",
"arguments": {
"prompt": "Create a TypeScript function that fetches data from a REST API with retry logic and exponential backoff",
"language": "typescript",
"provider": "anthropic",
"output_path": "./src/api/fetcher.ts"
}
}

8. Security Considerations​

  • Input Validation: Prompt sanitized for injection attacks. Language validated against supported list.
  • Permissions: Requires API keys for LLM providers (read from environment/config).
  • Data Handling: Prompts sent to external LLM providers; do not include sensitive data in prompts.
  • File Paths: Output paths validated and restricted to project directory.
  • Output Sanitization: Generated code is not automatically executed.

Tool: cli_analyze_code​

1. Tool Purpose and Description​

Performs static code analysis on a file or directory, checking for code quality issues, security vulnerabilities, and style violations. Integrates with multiple analysis tools.

2. Invocation Name​

cli_analyze_code

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to file or directory to analyze"./src/codomyrmex/"
outputstringNoDirectory for analysis reports"./reports/"
include_securitybooleanNoInclude security vulnerability scan. Default: truetrue
include_metricsbooleanNoInclude code metrics (complexity, etc). Default: truetrue
formatenum["text", "json", "html"]NoReport output format. Default: "json""json"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether analysis completedtrue
files_analyzedintegerNumber of files processed42
issuesarray[object]List of detected issuesSee below
issues[].severitystringIssue severity (error, warning, info)"warning"
issues[].filestringFile path containing issue"./src/module.py"
issues[].lineintegerLine number45
issues[].messagestringIssue description"Function too complex"
issues[].rulestringRule/check identifier"C901"
metricsobjectCode metrics summarySee below
security_findingsarray[object]Security issues foundSee below
output_pathstringPath to detailed report"./reports/analysis.json"

5. Error Handling​

  • FileNotFoundError: Specified path does not exist
  • AnalysisError: Analysis tool failed
  • Return Format: {"success": false, "error": "Analysis failed: <details>"}

6. Idempotency​

  • Idempotent: Yes
  • Explanation: Analysis is read-only. Repeated calls on unchanged code produce identical results.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_analyze_code",
"arguments": {
"path": "./src/codomyrmex/coding/",
"output": "./reports/",
"include_security": true,
"include_metrics": true,
"format": "json"
}
}

8. Security Considerations​

  • Input Validation: Path validated to exist within allowed directories.
  • Permissions: Read access to source files, write access to output directory.
  • Data Handling: Source code is analyzed but not transmitted externally.
  • File Paths: Strict path validation prevents traversal attacks.

Tool: cli_project_create​

1. Tool Purpose and Description​

Creates a new Codomyrmex project with specified template, setting up directory structure, configuration files, and initial dependencies.

2. Invocation Name​

cli_project_create

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
namestringYesProject name (alphanumeric, hyphens, underscores)"my-analysis-project"
templatestringNoProject template to use. Default: "ai_analysis""web_application"
descriptionstringNoProject description"Data analysis pipeline"
pathstringNoParent directory for project. Default: current directory"./projects/"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether project was createdtrue
project_pathstringFull path to created project"./projects/my-analysis-project"
template_usedstringTemplate applied"ai_analysis"
files_createdarray[string]List of created files["pyproject.toml", "README.md"]
next_stepsarray[string]Suggested next actions["cd my-project", "uv sync"]

5. Error Handling​

  • ProjectExistsError: Project directory already exists
  • TemplateNotFoundError: Specified template not available
  • PermissionError: Cannot create directory at specified path
  • Return Format: {"success": false, "error": "Project creation failed: <details>"}

6. Idempotency​

  • Idempotent: No
  • Explanation: Creates new files and directories. Re-running with same name will fail if project exists.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_project_create",
"arguments": {
"name": "code-review-system",
"template": "ai_analysis",
"description": "Automated code review with LLM integration",
"path": "./projects/"
}
}

8. Security Considerations​

  • Input Validation: Project name sanitized (alphanumeric, hyphens, underscores only). Path validated.
  • Permissions: Requires write access to parent directory.
  • Data Handling: No sensitive data processed.
  • File Paths: Path traversal prevented; projects created within allowed directories.

1. Tool Purpose and Description​

Searches available skills by keyword or category. Skills are reusable capability definitions that can be composed into workflows.

2. Invocation Name​

cli_skills_search

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
querystringYesSearch query for skills"code analysis"
categorystringNoFilter by skill category"Development"
limitintegerNoMaximum results to return. Default: 2010

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether search succeededtrue
resultsarray[object]Matching skillsSee below
results[].namestringSkill name"code_review"
results[].categorystringSkill category"Development"
results[].descriptionstringSkill description"Automated code review"
results[].match_scorefloatSearch relevance score0.95
total_resultsintegerTotal matching skills5

5. Error Handling​

  • SearchError: Search index unavailable
  • Return Format: {"success": false, "error": "Search failed: <details>"}

6. Idempotency​

  • Idempotent: Yes
  • Explanation: Read-only search operation.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_skills_search",
"arguments": {
"query": "security vulnerability scanning",
"category": "Security",
"limit": 10
}
}

8. Security Considerations​

  • Input Validation: Query sanitized, category validated against known categories.
  • Permissions: Read-only access to skills registry.
  • Data Handling: No sensitive data involved.

Tool: cli_run_quick​

1. Tool Purpose and Description​

Quick execution tool for running scripts, modules, or directories with minimal configuration. Supports parallel execution and glob patterns.

2. Invocation Name​

cli_run_quick

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
targetstringYesScript path, module name, directory, or glob pattern"./scripts/*.py"
argsarray[string]NoAdditional arguments to pass["--verbose", "--output", "results/"]
timeoutintegerNoTimeout per script in seconds. Default: 60120
parallelbooleanNoRun matching targets in parallel. Default: falsetrue

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
successbooleanWhether all executions succeededtrue
targets_runintegerNumber of targets executed5
resultsarray[object]Per-target resultsSee below
results[].targetstringTarget that was run"./scripts/analyze.py"
results[].exit_codeintegerProcess exit code0
results[].stdoutstringStandard output (truncated)"Analysis complete"
results[].duration_msfloatExecution duration2340.5
total_duration_msfloatTotal execution time5420.2

5. Error Handling​

  • TargetNotFoundError: No matching targets found
  • ExecutionError: Script execution failed
  • TimeoutError: Execution exceeded timeout
  • Return Format: {"success": false, "error": "Execution failed: <details>", "failed_targets": [...]}

6. Idempotency​

  • Idempotent: No
  • Explanation: Executes scripts which may have side effects.

7. Usage Examples (for MCP context)​

{
"tool_name": "cli_run_quick",
"arguments": {
"target": "./scripts/tests/*.py",
"args": ["--verbose"],
"timeout": 120,
"parallel": true
}
}

8. Security Considerations​

  • Input Validation: Target paths validated and sandboxed. Glob patterns restricted.
  • Permissions: Executes scripts with CLI process permissions.
  • Data Handling: Script output captured but may contain sensitive data.
  • File Paths: Strict validation prevents arbitrary code execution outside allowed directories.