Android Source Explorer MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/mrmike/android-source-explorer-mcp
cd android-source-explorer-mcp

Then follow the repository README for any remaining dependency or build steps before continuing.

2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add android-source-explorer -- node "<FULL_PATH_TO_ANDROID_SOURCE_EXPLORER_MCP>/dist/index.js"

Replace <FULL_PATH_TO_ANDROID_SOURCE_EXPLORER_MCP>/dist/index.js with the actual folder you prepared in step 1.

README.md

MCP server for exploring AOSP internals and Jetpack libraries.

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.


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-mcp

This 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 --lsp

Check sync status:

android-source-explorer status

Configuration

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 command to pre-fetch sources into a local cache (~/.android-sources/):

  • AOSP: Fetches framework sources directly from android.googlesource.com using git sparse-checkouts.
  • AndroidX: Downloads -sources.jar files from the Google Maven repository (dl.google.com/dl/android/maven2/).
  • Hybrid Indexing: Prioritizes your local $ANDROID_HOME sources if available, supplemented by the downloaded cache.

Available Tools

Tool Engine Description
search_classes Index Search for classes by glob pattern or substring.
lookup_class FS Retrieve the full source code for a specific class.
lookup_method Tree-sitter Extract a precise method body + its Javadoc/annotations.
list_class_members Tree-sitter List all method and field signatures in a class.
get_class_hierarchy Tree-sitter Get the inheritance chain (superclass + interfaces).
search_in_source FS/Regex Search for text/regex across the entire source tree.
goto_definition* LSP Resolve the cross-file definition of a symbol.
find_references* LSP Find all usages of a class/method across the whole tree.
get_type_info* LSP Get documentation and type info via hover data.

*Requires ANDROID_SOURCE_LSP=true


License

Apache License 2.0

Tools (9)

search_classesSearch for classes by glob pattern or substring.
lookup_classRetrieve the full source code for a specific class.
lookup_methodExtract a precise method body plus its Javadoc and annotations.
list_class_membersList all method and field signatures in a class.
get_class_hierarchyGet the inheritance chain including superclass and interfaces.
search_in_sourceSearch for text or regex across the entire source tree.
goto_definitionResolve the cross-file definition of a symbol.
find_referencesFind all usages of a class or method across the whole tree.
get_type_infoGet documentation and type info via hover data.

Environment Variables

ANDROID_SOURCE_LSPEnables LSP features like cross-file navigation and reference finding.

Configuration

claude_desktop_config.json
{"mcpServers": {"android-sources": {"command": "android-source-explorer", "args": ["serve"], "env": {"ANDROID_SOURCE_LSP": "true"}}}}

Try it

Search for the Activity class in the Android framework and list its members.
Show me the source code for the ViewModel class.
Find all references to the onCreate method within the current Android source tree.
What is the class hierarchy for the Compose UI component?
Search for regex patterns related to lifecycle restoration in the AndroidX source code.

Frequently Asked Questions

What are the key features of Android Source Explorer?

On-demand access to AOSP and AndroidX source code. Hybrid architecture using Tree-sitter for fast AST parsing. Optional LSP integration for cross-file navigation and type resolution. Local source indexing for offline-ready lookups. Precise extraction of method bodies, Javadoc, and class hierarchies.

What can I use Android Source Explorer for?

Debugging Android framework internals during app development. Understanding complex Jetpack library implementations like Compose or Lifecycle. Providing AI assistants with accurate, up-to-date context on Android APIs. Navigating large Android codebases to find symbol definitions and references.

How do I install Android Source Explorer?

Install Android Source Explorer by running: uv tool install git+https://github.com/mrmike/android-source-explorer-mcp

What MCP clients work with Android Source Explorer?

Android Source Explorer works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Android Source Explorer docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare