Android Source Explorer MCP Server
The Android Source Explorer MCP Server provides on-demand access to AOSP and AndroidX source code, giving AI tools precise access to real Android framework internals for advanced code exploration.
Search for classes by glob pattern or substring (e.g.,
*ViewModel*orActivity) across the synced source treeRetrieve full class source code for any Android Framework or AndroidX class
Look up a specific method's source code within a class, including its Javadoc and annotations
List all method and field signatures (members) of a given class
Get the inheritance hierarchy (superclass and implemented interfaces) for any class
Search for text or regex patterns within a specific class or across all synced source files
List available versions of an AndroidX artifact (e.g.,
androidx.compose.runtime:runtime)Check the integrity of the local source cache and index
Go to definition of a symbol at a specific line/character position (requires LSP)
Find all references to a symbol across the entire source tree (requires LSP)
Get type information and documentation (hover data) for a symbol (requires LSP)
The server uses a hybrid architecture combining Tree-sitter for fast single-file parsing with optional LSP engines for cross-file intelligence, and operates offline via a local cache of synced sources.
Enables on-demand, precise exploration of the Android Open Source Project (AOSP) and Jetpack (AndroidX) libraries, allowing for class searches, method body extraction, and analysis of framework internals like lifecycle management and Compose.
Syncs source code and library artifacts directly from Google-hosted infrastructure, including the Android Open Source Project (AOSP) repositories and the Google Maven repository.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Android Source Explorer MCP Server show me the implementation of the onCreate method in Activity.java"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Android Source Explorer MCP Server
MCP server for exploring AOSP internals and Jetpack libraries.
Purpose
When building Android applications, AI tools often rely on outdated training data or incomplete summaries of the Android Framework. This MCP server provides on-demand, precise access to the actual source code (AOSP and AndroidX), enabling the AI to understand complex framework internals like the Activity lifecycle, ViewModel restoration, or Compose internals directly from the truth.
Related MCP server: Android Source Explorer MCP Server
Installation & Setup
Prerequisites
uv (Recommended) or Python 3.11+
Git
Recommended Installation (via uv)
The easiest way to install and keep android-source-explorer up to date is using uv. It handles dependencies (including native ones like Tree-sitter and Cryptography) reliably across platforms.
uv tool install git+https://github.com/mrmike/android-source-explorer-mcpThis will make the android-source-explorer command available globally in your PATH.
Initial Sync
After installation, you need to perform an initial sync to fetch the Android source code:
# Sync API 36 (Android 16) and common AndroidX packages
android-source-explorer sync --api-level 36 --androidx "compose,lifecycle,activity"
# (Optional) Download LSP servers for cross-file features
android-source-explorer sync --lspCheck sync status:
android-source-explorer statusKeeping Sources Up-to-Date
To check for and download the latest available Android Framework revisions (AOSP tags) and newer stable versions of your synced AndroidX packages, run:
# Update all synced framework APIs and AndroidX packages, then rebuild the index
android-source-explorer update
# (Optional) Clean up older versions of updated AndroidX packages
android-source-explorer update --clean
# Update only a specific API level or AndroidX package
android-source-explorer update --api-level 36
android-source-explorer update --androidx activity-composeConfiguration
Add the MCP server to your configuration file (e.g., Claude Desktop, Cursor, Gemini CLI).
Global Usage (Recommended)
If installed via uv tool install, the tool is available globally.
Basic Setup:
{
"mcpServers": {
"android-sources": {
"command": "android-source-explorer",
"args": ["serve"]
}
}
}With LSP Features Enabled:
{
"mcpServers": {
"android-sources": {
"command": "android-source-explorer",
"args": ["serve"],
"env": {
"ANDROID_SOURCE_LSP": "true"
}
}
}
}Development Usage
If you cloned the repository and want to run it from the source:
{
"mcpServers": {
"android-sources": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/android-source-explorer", "android-source-explorer", "serve"]
}
}
}How It Works
1. Hybrid Architecture (Tree-sitter + LSP)
The server uses a dual-engine approach to balance speed and intelligence:
Tree-sitter (Surgical Engine): Provides near-instant (sub-10ms) AST parsing of single files. It precisely extracts method bodies (including Javadoc and annotations), class members, and inheritance hierarchies without the overhead of a full compiler.
LSP (Global Engine): Optionally leverages the Eclipse JDT LS (Java) and Kotlin Language Server for cross-file navigation. This enables finding references across millions of lines of code and resolving types that span multiple libraries.
2. Local Sync Strategy
To ensure all lookups are instant and offline-ready, the server uses a sync or update command to manage sources in a local cache (~/.android-sources/):
AOSP: Fetches framework sources directly from
android.googlesource.comusing git sparse-checkouts.AndroidX: Downloads
-sources.jarfiles from the Google Maven repository (dl.google.com/dl/android/maven2/).Hybrid Indexing: Prioritizes your local
$ANDROID_HOMEsources if available, supplemented by the downloaded cache.Automatic Updates: The
updatecommand queries remote endpoints (AOSP Git tags & Google Maven indexes) for updates, downloads newer revisions/versions, and rebuilds the class index.
Available Tools
Tool | Engine | Description |
| Index | Search for classes by glob pattern or substring. |
| FS | Retrieve the full source code for a specific class. |
| Tree-sitter | Extract a precise method body + its Javadoc/annotations. |
| Tree-sitter | List all method and field signatures in a class. |
| Tree-sitter | Get the inheritance chain (superclass + interfaces). |
| FS/Regex | Search for text/regex across the entire source tree. |
| LSP | Resolve the cross-file definition of a symbol. |
| LSP | Find all usages of a class/method across the whole tree. |
| LSP | Get documentation and type info via hover data. |
*Requires ANDROID_SOURCE_LSP=true
License
Apache License 2.0
Available Tools
11 toolscheck_integrityB
Check the integrity of the local source cache and index.
Inputs: no named parameters. Returns: result
find_referencesC
Find all references to a symbol at a specific position (Requires LSP).
Inputs: class_name (required), line (required), character (required). Returns: result
get_class_hierarchyB
Get the inheritance hierarchy (superclass and interfaces) for a class.
Inputs: class_name (required). Returns: result
get_type_infoC
Get type information and documentation (hover) for a symbol (Requires LSP).
Inputs: class_name (required), line (required), character (required). Returns: result
goto_definitionB
Resolve the definition of a symbol at a specific position (Requires LSP).
Inputs: class_name (required), line (required), character (required). Returns: result
list_available_versionsC
List available versions for an AndroidX artifact (e.g. 'androidx.compose.runtime:runtime').
Inputs: artifact. Returns: result
list_class_membersB
List all method and field signatures for a given class.
Inputs: class_name (required). Returns: result
lookup_classB
Retrieve the full source code for a given Android Framework or AndroidX class.
Inputs: class_name (required), max_lines. Returns: result
lookup_methodB
Look up a specific method's source code within a class.
Inputs: class_name (required), method_name (required). Returns: result
search_classesB
Search for classes by glob pattern or substring (e.g. 'ViewModel' or 'Activity').
Inputs: pattern (required), limit. Returns: result
search_in_sourceB
Search for a text/regex pattern within a specific class or across all synced files (if class_name is omitted).
Inputs: pattern (required), class_name, limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have distinct purposes, but there is some overlap between 'lookup_class' and 'lookup_method' as both retrieve source code, which could cause mild confusion. The LSP-based tools ('find_references', 'get_type_info', 'goto_definition') are clearly differentiated, and other tools like 'search_classes' and 'search_in_source' serve unique functions.
All tool names follow a consistent snake_case pattern with clear verb_noun structures (e.g., 'list_available_versions', 'get_class_hierarchy', 'search_classes'). There are no deviations in naming conventions, making the set predictable and easy to understand.
With 11 tools, the count is well-scoped for exploring Android source code, covering tasks from integrity checks to LSP operations and searches. Each tool appears to serve a specific, necessary function without bloat or redundancy, fitting the server's purpose effectively.
The toolset provides comprehensive coverage for source exploration, including search, lookup, LSP features, and version management. A minor gap exists in update or modification tools (e.g., no 'edit_source' or 'apply_patch'), but this is reasonable for a read-only explorer, and agents can work around it.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Codebase intelligence for agents: 152 structured artifacts across 21 programs, one call.
Search indexed code, trace dependencies, assess change impact, and recall repository memory.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables AI tools to perform precise, on-demand lookups of AOSP and AndroidX source code, including class and method extraction, inheritance hierarchies, full-text search, and optional cross-file navigation via LSP. It maintains a local synced cache of framework and Jetpack sources so framework internals can be explored offline.-
- FlicenseNot gradedqualityAmaintenanceEnables AI tools to perform on-demand, precise lookups of AOSP and AndroidX source code, including class and method extraction, inheritance hierarchy, cross-file references, and type information. Supports local syncing and updating of framework and Jetpack sources for offline, instant exploration.-
- FlicenseNot gradedqualityAmaintenanceEnables AI tools to retrieve and search actual AOSP and AndroidX source code on demand, including class lookup, method extraction, class members, hierarchy, source search, and optional cross-file navigation via LSP. It provides precise, offline-ready access to framework internals such as Activity lifecycle, ViewModel restoration, and Compose internals.-
- FlicenseNot gradedqualityAmaintenanceProvides AI tools with on-demand, precise access to AOSP and AndroidX source code for methods, classes, members, inheritance, definitions, references, and type information. It supports local source syncing/updating and optional LSP-powered cross-file navigation.-