Skip to main content
Glama

local_dev_run_tests

Run automated tests in a local development sandbox to validate code functionality and detect issues during development.

Instructions

Auto-detect and run tests in a local development environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
env_idYesEnvironment identifier

Implementation Reference

  • Tool handler logic: retrieves environment by ID, calls run_environment_tests, formats response with success, summary, and coverage.
    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))]
  • Tool schema definition including 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 the test detection and running logic, with error handling.
    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 (pytest, jest, etc.), selects first, and executes tests.
    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
  • Registration of tools list via MCP server decorator, which includes the local_dev_run_tests tool.
    @server.list_tools()
    async def list_tools() -> List[types.Tool]:
        logger.debug("Tools requested")
        return tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/txbm/mcp-local-dev'

If you have feedback or need assistance with the MCP directory API, please join our Discord server