Skip to main content
Glama
android-sqlite-mcp

android-sqlite-mcp

by Feliicks

Android SQLite MCP Server

A Model Context Protocol (MCP) server to connect AI agents directly to the embedded SQLite/Room databases of your Android applications.

What problem does this solve?

Accessing embedded databases (SQLite, Room, SQLDelight) on Android devices during development has historically been a cumbersome process. It requires running adb shell run-as commands, manually copying files, dealing with .db-wal (Write-Ahead Logging) files to prevent data loss, and then using external SQL clients to read the information.

This MCP server automates the entire process. It allows any AI agent (like Claude, Cursor, or Antigravity) to inspect tables, read schemas, and execute live SQL queries (SELECT, INSERT, UPDATE, DELETE) on your application's database, right from the chat window.

Related MCP server: android-sqlite-inspector

Features

  • 📥 Secure Extraction: Uses adb exec-out run-as to safely extract data without corruption and without requiring root access.

  • 🗄️ Smart Caching: Stores local copies organized in ~/.android-sqlite-mcp/cache/.

  • 🔍 Search and Inspection: Tools to search installed packages, list databases, view tables, and retrieve full DDL schemas.

  • ⚡ Queries (CRUD): Executes raw SQL queries locally and returns the results in JSON format to the AI.

Technical Prerequisites

  1. Node.js: Version 18 or higher.

  2. Android Debug Bridge (ADB): Must be installed and configured in your system's PATH (verify with adb version).

  3. Device/Emulator: A device or emulator must be connected (adb devices).

  4. Debuggable App: The Android app must be compiled in debug mode (android:debuggable="true").

Getting Started (Standard Configuration)

There is no need to manually download or build this repository. You can run the server on the fly using npx.

The standard format to register an MCP server in any client is the following:

{
  "mcpServers": {
    "android-sqlite": {
      "command": "npx",
      "args": ["-y", "android-sqlite-mcp"]
    }
  }
}

AI Client Installation Guides

{
  "mcpServers": {
    "android-sqlite": {
      "command": "npx",
      "args": ["-y", "android-sqlite-mcp"]
    }
  }
}

Local development and stability

package.json is the source of truth for the server version. To bump the patch version and synchronize package-lock.json, run:

npm version patch --no-git-tag-version

Use minor or major instead of patch when appropriate. The MCP server reads the version directly from its installed package.json; no source edit is needed.

Requires Node.js 22.15 or newer. Run npm test to compile and run regression tests. To test this checkout (instead of the published npm package), build with npm run build and configure the MCP entry with an absolute path:

{
  "command": "node",
  "args": ["D:\\android-mcp\\build\\index.js"]
}

Tool arguments use appId and dbName. Legacy package_name is accepted as an alias for appId; conflicting values are rejected. Queries operate on the local cache only and never push writes back to Android. Results are capped at 1000 rows and 1 MiB; truncated indicates omitted rows. SQLite operations run in a separate process with a 15 second timeout and request cancellation. A timed-out write may already have committed; inspect the cache before retrying writes.

ADB commands have a 15 second timeout. Set ANDROID_SERIAL when multiple devices are connected. Use separate ANDROID_MCP_CACHE_DIR values for different devices; new extractions record the device and reject replacing a cache from another device. Older caches have no device identity until their first successful new extraction. ANDROID_MCP_LOG_DIR optionally overrides the file log directory.

Extraction compares two consecutive copies of the DB and WAL and rejects detected changes, then recovers/checks the snapshot in a temporary directory before publishing. Stop app writes for a reliable snapshot: comparison cannot guarantee a transactionally consistent snapshot of an actively changing Android database. Existing local SQLite sidecars cause CacheConflict rather than being mixed with a new copy; close other readers and use a fresh cache directory. Concurrent cache operations fail with DatabaseBusy. If a server is forcibly killed, a .mcp-lock file may remain; remove it only after verifying no process still uses that cached database.

claude mcp add android-sqlite npx -y android-sqlite-mcp
  1. Go to Cursor Settings > Features > MCP.

  2. Click on "+ Add New MCP Server".

  3. Fill in the details:

    • Type: command

    • Name: android-sqlite

    • Command: npx -y android-sqlite-mcp

  4. Save and verify that the indicator changes to "Connected" (green).

Available Tools

7 tools
execute_queryB

Executes a raw SQL query on a cached database. Can be used for SELECT or write operations (INSERT/UPDATE/DELETE).

Inputs: appId (required), query (required), dbName (required), params.

get_cache_statusA

Returns information about the currently cached Android SQLite databases ready to be queried.

Inputs: no named parameters.

get_schemaA

Returns the DDL schema (CREATE TABLE) for a specific table in a cached database.

Inputs: appId (required), dbName (required), tableName (required).

list_databasesA

Lists all SQLite database files available in the internal storage of a specific Android app on the connected device.

Inputs: appId (required).

list_packagesA

Lists installed Android application packages on the device, optionally filtered by a query.

Inputs: query.

list_tablesA

Lists all tables and views in a cached database along with their approximate row counts.

Inputs: appId (required), dbName (required).

pull_databaseA

Extracts an SQLite database and its WAL files from an Android device into the local cache using adb run-as.

Inputs: appId (required), dbName (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct stage in the workflow: discovering packages, listing databases, pulling a database, checking cache status, listing tables, getting schema, and executing queries. There is no overlap between tools, even between list_databases and get_cache_status which clearly distinguish remote vs. cached databases.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case (e.g., list_packages, pull_database, get_schema, execute_query). The naming style is uniform and predictable, with no mixed conventions or vague verbs.

    Tool Count5/5

    The server has 7 tools, well within the ideal range of 3-15. Each tool serves a distinct and necessary step in the pipeline from device discovery to SQL querying, with no redundancy or bloat.

    Completeness5/5

    The toolset covers the entire lifecycle of working with Android SQLite databases: discovery (list_packages, list_databases), extraction (pull_database), cache management (get_cache_status), introspection (list_tables, get_schema), and querying (execute_query). There are no obvious gaps for the stated purpose.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers