Embeddable database exploration toolkit — connect, explore, and query any SQL database in Python.
Project description
Pocket Analyst
Connect any database. Ask questions in plain English. Get answers backed by real SQL.
Pocket Analyst is an AI-powered database analyst you run on your own infrastructure. Your data never leaves your environment — it stays in your container, on your machine or server, and only a plain-text question travels to the LLM API.
See It In Action
Connect a database → ask "which products had the highest revenue last quarter?" → get a plain-English answer with the SQL shown
The web UI is the fastest way to see what Pocket Analyst does. Run the full package (3 commands below) and open your browser.
Get Started — Choose Your Setup
Full Package — open browser, connect a database, done
No coding required. Everything included.
git clone https://github.com/MattMcnally118/pocket-analyst-containerized.git
cd pocket-analyst-containerized
cp .env.example .env # add your ANTHROPIC_API_KEY
docker compose up --build
MCP Add-on — use Pocket Analyst inside Claude Desktop
Already using Claude Desktop? Add Pocket Analyst as a tool. The backend runs in Docker, the connector is a 2-minute setup.
Step 1 — start the backend:
docker compose -f docker-compose.core.yml up --build
Step 2 — install the MCP connector:
pip install -r requirements-mcp.txt
Step 3 — add to Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"pocket-analyst": {
"command": "/path/to/your/python3",
"args": ["/path/to/pocket-analyst-containerized/mcp_server.py"]
}
}
}
Restart Claude Desktop. Pocket Analyst tools will appear automatically.
Core API — build your own interface on top
REST API access to all database tools. No UI, no assumptions about how you'll use it. Connect from R Shiny, Python, curl, or any HTTP client.
docker compose -f docker-compose.core.yml up --build
Key endpoints at http://localhost:8080:
| Method | Endpoint | What it does |
|---|---|---|
POST |
/api/v1/connect |
Connect to a database |
GET |
/api/v1/schema |
Full schema introspection |
GET |
/api/v1/tables |
List all tables |
GET |
/api/v1/tables/{name} |
Describe a table |
POST |
/api/v1/query |
Run a SELECT query |
POST |
/api/v1/disconnect |
End session |
Full API docs at http://localhost:8080/docs when running.
Supported Databases
| Database | Connection string format |
|---|---|
| DuckDB | duckdb:////data/mydb.duckdb |
| SQLite | sqlite:///mydb.sqlite |
| PostgreSQL | postgresql://user:pass@host/dbname |
| MySQL | mysql+pymysql://user:pass@host/dbname |
Drop .duckdb or .sqlite files into datasets_safe/ and they'll be available inside the container at /data/.
Data Privacy
Pocket Analyst runs entirely on your infrastructure. Your database connection, queries, and results stay inside your container. The only data that leaves is the plain-text question and schema summary sent to the LLM API (Anthropic, AWS Bedrock, or GCP Vertex AI — your choice).
LLM Providers
Set LLM_PROVIDER in your .env:
Anthropic (default)
LLM_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_MODEL_ID=claude-sonnet-4-6
AWS Bedrock
LLM_PROVIDER=bedrock
BEDROCK_REGION=us-east-1
BEDROCK_MODEL_ID=anthropic.claude-sonnet-4-6-v1:0
GCP Vertex AI
LLM_PROVIDER=vertex
VERTEX_PROJECT_ID=my-gcp-project
VERTEX_LOCATION=us-central1
VERTEX_MODEL_ID=claude-sonnet-4-6@20251001
Configuration
| Variable | Description | Default |
|---|---|---|
LLM_PROVIDER |
anthropic, bedrock, or vertex |
anthropic |
ANTHROPIC_API_KEY |
Anthropic API key | — |
ANTHROPIC_MODEL_ID |
Model to use | claude-sonnet-4-6 |
MAX_AGENT_TURNS |
Max tool-calling rounds per message | 10 |
MAX_RESPONSE_TOKENS |
Max tokens per response | 4096 |
LOG_LEVEL |
DEBUG, INFO, WARNING |
INFO |
PORT |
Port to serve on | 8080 |
Deployment
AWS ECS (Fargate)
See cloudformation/ for ready-to-use CloudFormation templates.
GCP Cloud Run
See scripts/cloud-run-service.yaml and scripts/setup-gcp-iam.sh.
Project Structure
├── app/
│ ├── agent/loop.py # Agentic tool-calling loop (LLM decides what to query)
│ ├── llm/ # LLM clients (Anthropic, Bedrock, Vertex)
│ ├── routers/ # FastAPI routes (chat, REST API, health)
│ ├── tools/ # Tool registry and executor
│ ├── config.py # Settings
│ ├── session.py # Per-session state (connection, history)
│ └── main.py # App entry point
├── db/
│ ├── connection.py # SQLAlchemy engine factory
│ └── schema.py # Schema introspection (all 4 dialects)
├── tools_impl/
│ ├── connect.py # connect / disconnect / set_context
│ ├── explore.py # explore_schema / describe_table
│ └── query.py # run_query / list_tables
├── static/index.html # Web UI
├── datasets_safe/ # Drop database files here (gitignored)
├── mcp_server.py # Claude Desktop MCP connector
├── docker-compose.yml # Full package (same as docker-compose.full.yml)
├── docker-compose.full.yml # Tier 3: full package
├── docker-compose.core.yml # Tier 1: core API only
└── ARCHITECTURE.md # Layer diagrams and design decisions
Architecture
See ARCHITECTURE.md for the full layer diagram, 3-tier distribution model, and explanation of how the agent, REST API, and MCP server relate to each other.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pocket_analyst-0.1.0.tar.gz.
File metadata
- Download URL: pocket_analyst-0.1.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94387c26a66c9408b890488ddc35ddc5ee806ddbaa35d5e9547b06f58be31641
|
|
| MD5 |
1ae9e404f799187bc2ea6a68a12be988
|
|
| BLAKE2b-256 |
0274d6509f33b33c221bccf99d1c846cffca2761a8092b65a61f00578cfad24e
|
File details
Details for the file pocket_analyst-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pocket_analyst-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e63c20f8314fcedada5d6d473095e66a52d0e0b9d744efeb619ce917f59d7070
|
|
| MD5 |
182419836fda4e21dc4355895dfb534d
|
|
| BLAKE2b-256 |
b07747ffe655af92f327d477aa9ac612d75469413f87ed019688c08508e77f99
|