codemap_script_run

Manually execute a script. Primarily for utility scripts, but can run any category with custom context.

scriptexecuterun

Parameters

NameTypeRequiredDescription
categorystringaudit | build | orient | close | utility✅ RequiredScript category
namestring✅ RequiredScript name (filename without .js extension)
contextobject❌ OptionalOptional context overrides to pass to script (merged with base context)

Usage Examples

MCP Usage (for AI Agents like Claude)

json
{
  "name": "codemap_script_run",
  "arguments": {
    "category": "utility",
    "name": "generate-report"
  }
}

Example Output

JSON Response

json
{
  "success": true,
  "script": {
    "category": "utility",
    "name": "generate-report"
  },
  "result": {
    "data": "Report generated successfully",
    "files": 245,
    "timestamp": "2026-04-08T12:34:56Z"
  },
  "message": "Script executed: utility/generate-report.js"
}
ℹ️When to Use This Tool
  • Execute utility scripts manually
  • Test audit scripts before integration
  • Run ad-hoc analysis scripts
  • Validate script logic
  • Debug script issues
💡Common Patterns
Run and Check Result
const result = await codemap.scripts.run('audit', 'validate');
if (!result.passed) {
console.error('Validation failed:', result.message);
process.exit(1);
}


Run Multiple Scripts
const scripts = ['check-imports', 'validate-structure'];
for (const name of scripts) {
await codemap.scripts.run('audit', name);
}


Pass Custom Context
await codemap.scripts.run('utility', 'report', {
context: { format: 'json', verbose: true }
});
💡Pro Tips
Utility scripts are best - Use utility category for manual execution. Audit/build/orient/close run automatically.
Check result format - Audit scripts return {passed, message}. Other scripts vary.
Pass context for flexibility - Use context parameter to customize script behavior.
Best Practices
Verify script exists - Use script_list before running
Handle errors - Wrap in try-catch for graceful failure
Check result structure - Different script categories return different formats
⚠️Common Mistakes
Mistake: Running non-existent script
await codemap.scripts.run('utility', 'nonexistent');

Instead: Check first
const scripts = await codemap.scripts.list('utility');
if (scripts.some(s => s.name === 'report')) {
await codemap.scripts.run('utility', 'report');
}


---

Mistake: Not handling script errors
const result = await codemap.scripts.run('audit', 'validate');
// Assumes success

Instead: Check result
const result = await codemap.scripts.run('audit', 'validate');
if (!result.passed) {
console.error('Failed:', result.message);
process.exit(1);
}