Android Source Explorer MCP Server
Provides tools for exploring Android source code (AOSP and AndroidX), including searching classes, extracting method bodies, listing class members, getting class hierarchy, and searching in source. It syncs Android framework sources and AndroidX libraries locally for offline access.
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 Servercan you show me the source for Activity.onSaveInstanceState?"
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
This server cannot be deployed
Maintenance
Related MCP Connectors
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Search indexed code, trace dependencies, assess change impact, and recall repository memory.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Ask who calls a route, what a change breaks or who reads a field, across a system's repos.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables searching and browsing Android source code across projects like Android, AndroidX, and Android Studio via cs.android.com. It provides tools for regex-based code searches, full file content retrieval, and symbol autocomplete suggestions.414 npm29MIT
- AlicenseBqualityDmaintenanceProvides on-demand access to AOSP and Jetpack source code to help AI understand Android framework internals. It features a hybrid architecture using Tree-sitter and LSP for precise code extraction, cross-file navigation, and local source indexing.11101Apache 2.0
- FlicenseNot gradedqualityAmaintenanceEnables AI tools to access and navigate AOSP and AndroidX source code on demand, with class and method lookups, hierarchy inspection, cross-file references, and type information.-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to query real AOSP and AndroidX source code on demand, offering class and method lookup, class member and hierarchy inspection, source-wide text/regex search, and optional LSP-powered cross-file definition, reference, and type resolution from a local offline cache.-