local_dev_run_tests
Auto-detect and execute tests in sandboxed local development environments, supporting Python, Node, Bun, and multiple test runners for efficient debugging and validation.
Instructions
Auto-detect and run tests in a local development environment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env_id | Yes | Environment identifier |
Implementation Reference
- src/mcp_local_dev/server.py:122-149 (handler)Handler for the local_dev_run_tests tool: retrieves environment by ID, runs tests using run_environment_tests, formats response with success status, test summary, and coverage metrics if available.elif name == "local_dev_run_tests": env = get_environment(arguments["env_id"]) if not env: return [ types.TextContent( type="text", text=json.dumps( { "success": False, "error": f"Unknown environment: {arguments['env_id']}", } ), ) ] result = await run_environment_tests(env) response = { "success": result["success"], "summary": result["summary"], } if result.get("coverage"): response["coverage"] = { "lines": result["coverage"].lines, "statements": result["coverage"].statements, "branches": result["coverage"].branches, "functions": result["coverage"].functions, "files": result["coverage"].files } return [types.TextContent(type="text", text=json.dumps(response))]
- src/mcp_local_dev/server.py:46-56 (schema)Tool schema definition including name, description, and input schema requiring 'env_id'.types.Tool( name="local_dev_run_tests", description="Auto-detect and run tests in a local development environment", inputSchema={ "type": "object", "properties": { "env_id": {"type": "string", "description": "Environment identifier"} }, "required": ["env_id"], }, ),
- Helper function that invokes detect_and_run_tests on the environment and catches exceptions.async def run_environment_tests(env: Environment) -> Dict[str, Any]: """Run tests in environment.""" try: return await detect_and_run_tests(env) except Exception as e: return {"success": False, "error": str(e)}
- Core helper that detects available test runners, selects the first one, and executes tests via execute_runner.async def detect_and_run_tests(env: Environment) -> Dict[str, Any]: """Auto-detect and run tests in environment.""" runners = await detect_runners(env) if not runners: return {"success": False, "error": "No test runners detected"} config = RunConfig(runner=runners[0], env=env, test_dirs=[env.sandbox.work_dir]) result = await execute_runner(config) return result