local_dev_cleanup
Remove unused files and data from a local development environment to free up space and maintain organization. Supports cleaning by specifying an environment identifier.
Instructions
Clean up a local development environment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env_id | Yes | Environment identifier |
Input Schema (JSON Schema)
{
"properties": {
"env_id": {
"description": "Environment identifier",
"type": "string"
}
},
"required": [
"env_id"
],
"type": "object"
}
Implementation Reference
- src/mcp_local_dev/server.py:151-178 (handler)Dispatch handler for the local_dev_cleanup tool. Retrieves the environment by ID using get_environment, calls cleanup_environment(env) if exists, otherwise returns error response. Returns JSON-formatted success message.elif name == "local_dev_cleanup": 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']}", } ), ) ] cleanup_environment(env) return [ types.TextContent( type="text", text=json.dumps( { "success": True, "data": { "message": "Environment cleaned up successfully" }, } ), ) ]
- src/mcp_local_dev/server.py:57-67 (schema)Input schema definition for the local_dev_cleanup tool, requiring 'env_id' string.types.Tool( name="local_dev_cleanup", description="Clean up a local development environment", inputSchema={ "type": "object", "properties": { "env_id": {"type": "string", "description": "Environment identifier"} }, "required": ["env_id"], }, ),
- src/mcp_local_dev/server.py:76-79 (registration)Registration of tools list via MCP Server's list_tools handler, which returns the tools array including local_dev_cleanup.@server.list_tools() async def list_tools() -> List[types.Tool]: logger.debug("Tools requested") return tools
- Helper function implementing the core cleanup logic: removes environment from in-memory store and cleans up the sandbox.def cleanup_environment(env: Environment) -> None: """Clean up environment and its resources.""" if env.id in _ENVIRONMENTS: del _ENVIRONMENTS[env.id] cleanup_sandbox(env.sandbox)