A pure Python SDK providing a stateless, Model Context Protocol (MCP) compliant interface for AI Agents to interact with the Android Build System and the CLI tools (Soong, Ninja, aconfig, etc.).
envsetup.sh and lunch results. No manual environment sourcing required.OUT_DIR redirection to avoid workspace pollution.android_build/ ├── api/ # Layer 1: Core Build System APIs │ ├── build.py # Build execution, progress parsing, and structured log analysis │ ├── config.py # Build variables and aconfig queries │ ├── env.py # Environment snapshotting and BuildContext │ ├── module.py # module-info.json parsing and cache management │ └── ninja.py # Ninja graph queries, dependency analysis, and command retrieval ├── interface/ # Layer 2: MCP/CLI Interface │ ├── cli.py # Unified entry point and server daemon │ ├── server.py # JSON-RPC 2.0 Server with Batch/Progress support │ ├── registry.py # Tool registration and discovery logic │ └── schema.py # Auto-generation of JSON schemas from dataclasses ├── tests/ # Isolated Unit Tests ├── settings.json # Portable MCP configuration template └── run_tests.sh # Test execution script
This SDK is integrated into the standard Googlers' developer workflow. When launching the shared MCP server, the SDK is automatically available as the MCP tools.
If you need to register the server manually (e.g., for an external MCP client or troubleshooting), use the built-in helper:
Generate the registration command:
python3 interface/cli.py --print-registration-cmd
Execute the output command: The output will follow the correct positional syntax:
gemini mcp add android_build python3 '/path/to/cli.py' -e PYTHONPATH='/path/to/sdk' --trust
You can interact with the server manually via stdin/stdout:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | python3 interface/cli.py
To run the full suite of isolated unit tests:
source build/envsetup.sh && lunch <lunch product> && atest -c build_sdk_lib_test