The MCP server with the most ironic name in the registry — persistent semantic memory for your SQL databases
Project description
amnesic — the MCP server with the most ironic name in the registry
Persistent semantic memory for your SQL databases. The name is ironic — it remembers everything.
"The MCP server with the most ironic name in the registry. It's anything but amnesic — it remembers your database so your AI doesn't have to."
The problem
Every session with an AI starts cold. You spend the first few minutes re-explaining what tables exist, what a status column value of 3 means, which FK connects orders to users. Then the session ends, and you do it all over again tomorrow.
amnesic fixes this. It gives your AI a persistent SQLite knowledge store — one per database — that survives across sessions. Annotate a status enum once; every future session sees those labels automatically. Discover FK relationships once; every future JOIN query uses that graph.
Install
# Core only (SQLite works out of the box)
pip install amnesic
# With driver extras
pip install "amnesic[postgres]"
pip install "amnesic[mssql]"
pip install "amnesic[mysql]"
pip install "amnesic[all]"
# Or run directly with uvx (no install needed)
uvx amnesic
Setup
1. Create config
amnesic init
This creates ~/.config/amnesic/connections.toml with a commented template.
2. Edit the config
# ~/.config/amnesic/connections.toml
# Nested style: [connections.product.env]
[connections.orders.prod]
driver = "mssql"
server = "localhost"
port = 11433
database = "OrdersDB"
user = "${ORDERS_PROD_USER}"
password = "${ORDERS_PROD_PASSWORD}"
tunnel_script = "~/.scripts/mssql-tunnel.sh" # optional SSH tunnel
[connections.orders.staging]
driver = "mssql"
server = "localhost"
port = 11434
database = "OrdersDB_Staging"
user = "${ORDERS_STAGING_USER}"
password = "${ORDERS_STAGING_PASSWORD}"
# Flat style: [connections.name]
[connections.analytics]
driver = "postgres"
server = "analytics.company.com"
port = 5432
database = "warehouse"
user = "${ANALYTICS_DB_USER}"
password = "${ANALYTICS_DB_PASSWORD}"
# SQLite — no credentials needed
[connections.local]
driver = "sqlite"
database = "/Users/me/data/local.db"
Use ${ENV_VAR} for credentials — never hardcode passwords.
Canonical connection names use dot notation: orders.prod, orders.staging, analytics, local.
3. Test connectivity
amnesic test # tests all connections
amnesic test orders.prod # tests one connection
Add to your AI client
Claude Code
Add to ~/.claude/mcp.json:
{
"mcpServers": {
"amnesic": {
"command": "uvx",
"args": ["amnesic"]
}
}
}
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"amnesic": {
"command": "uvx",
"args": ["amnesic"]
}
}
}
Cursor
Add to .cursor/mcp.json in your project (or ~/.cursor/mcp.json globally):
{
"mcpServers": {
"amnesic": {
"command": "uvx",
"args": ["amnesic"]
}
}
}
VS Code (with MCP extension)
Add to .vscode/mcp.json:
{
"servers": {
"amnesic": {
"type": "stdio",
"command": "uvx",
"args": ["amnesic"]
}
}
}
Tools
| Tool | Description |
|---|---|
db_list_connections() |
List all configured connections (no secrets exposed) |
db_list_tables(connection) |
All known tables with descriptions and column counts |
db_get_schema(table, connection) |
Column schema merged with saved annotations |
db_query(sql, connection) |
Execute a read-only SELECT query |
db_annotate(table, connection, ...) |
Persist semantic annotations for tables/columns |
db_sync_knowledge(from, to) |
Copy annotations between connections (e.g. staging → prod) |
db_discover_relationships(connection) |
Discover all FK relationships from the live DB |
db_get_relationships(table, connection) |
Navigate the FK graph for JOIN planning |
The knowledge layer
The core differentiator. Every annotation survives restarts, model updates, and new sessions.
Session 1 — you discover something
You: What does status=3 mean in the orders table?
AI: Let me check. [runs db_query: SELECT DISTINCT status FROM dbo.orders]
I see values 1, 2, 3, 4. Let me look at some examples...
Based on the data, 3 appears to be "cancelled".
You: Save that. And status=1 is "pending", 2 is "confirmed", 4 is "delivered".
AI: [calls db_annotate]
db_annotate(
table="dbo.orders",
column="status",
column_description="Order lifecycle status",
enum_values={"1": "pending", "2": "confirmed", "3": "cancelled", "4": "delivered"}
)
Saved. Future sessions will see these labels automatically.
Session 2 — the knowledge is already there
You: How many cancelled orders are there this month?
AI: [calls db_get_schema("dbo.orders")]
Schema response includes:
column: "status"
description: "Order lifecycle status"
enum_values: {"1": "pending", "2": "confirmed", "3": "cancelled", "4": "delivered"}
[writes correct SQL immediately]
SELECT COUNT(*) FROM dbo.orders WHERE status = 3 AND ...
No re-discovery. No wasted turns. The annotation persisted.
Relationship graph
Understand your schema's JOIN structure once, reuse it forever.
AI: [db_discover_relationships(connection="orders.prod")]
Discovered 47 foreign key relationships.
AI: [db_get_relationships(table="orders", depth=2)]
neighbors:
orders → users (via user_id → id)
orders → order_items (via id ← order_id)
paths:
orders -> users
orders -> order_items
order_items -> products
Now the AI knows exactly how to JOIN across your schema without guessing.
Sync between environments
Build up annotations in staging, then promote to prod:
db_sync_knowledge(from_connection="orders.staging", to_connection="orders.prod")
Returns {synced: [...], skipped: [{table, reason}], warnings: [{table, column, reason}]}.
Tables missing from the target schema cache are skipped with a clear reason. Columns missing from target schema are warned but don't block the rest of the sync.
Supported databases
| Database | Driver | Extra |
|---|---|---|
| PostgreSQL | psycopg2 | pip install "amnesic[postgres]" |
| MySQL / MariaDB | pymysql | pip install "amnesic[mysql]" |
| Microsoft SQL Server | pymssql | pip install "amnesic[mssql]" |
| SQLite | built-in | no extra needed |
Security
- Read-only enforcement: two layers — static SQL analysis rejects any write/DDL statement before a connection opens, plus every query runs inside an immediately-rolled-back transaction.
- No credentials in responses:
db_list_connectionsstrips passwords and usernames from output. - Credentials via env vars:
${ENV_VAR}expansion at load time — secrets never touch the config file on disk. - Identifier validation: table names, schema names, and database names are validated against
[A-Za-z0-9_]before any interpolation into SQL.
Roadmap
What's coming: knowledge lifecycle management (v0.2 — db_deprecate, drift detection, export/import for team handoff), query intelligence (v0.3 — db_explain, query history), team sharing (v0.4), and more. See ROADMAP.md for the full picture.
Have an idea? Open an issue.
Track usage
pypistats.org/packages/amnesic
License
MIT — see LICENSE.
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 amnesic-0.1.0.tar.gz.
File metadata
- Download URL: amnesic-0.1.0.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9811e98898597595754d990f88173b7ac3d4fdc362fde9c0fc7c8404d9afe0
|
|
| MD5 |
4bc2f39f544dfcec40acf040eff47012
|
|
| BLAKE2b-256 |
18bdeaaf58c53f613c8748fffa71bde5f709a2584cd51f416f6ef7c758bcbe95
|
Provenance
The following attestation bundles were made for amnesic-0.1.0.tar.gz:
Publisher:
publish.yml on SurajKGoyal/amnesic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amnesic-0.1.0.tar.gz -
Subject digest:
6d9811e98898597595754d990f88173b7ac3d4fdc362fde9c0fc7c8404d9afe0 - Sigstore transparency entry: 1632209773
- Sigstore integration time:
-
Permalink:
SurajKGoyal/amnesic@8ac8c0a127bd585ea620a72759e1b519a186f90b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/SurajKGoyal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ac8c0a127bd585ea620a72759e1b519a186f90b -
Trigger Event:
push
-
Statement type:
File details
Details for the file amnesic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: amnesic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5f32c094b4fbff72aaf24b395fa138fbbf0012bb42536b428bf2da5bba0cb3a
|
|
| MD5 |
57d6504dfc5938f8f373a9708eb10c4a
|
|
| BLAKE2b-256 |
ad336576b5645db67b3d3ed9d70419dc9e181df752312d1ca55720fe9e9de366
|
Provenance
The following attestation bundles were made for amnesic-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on SurajKGoyal/amnesic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amnesic-0.1.0-py3-none-any.whl -
Subject digest:
e5f32c094b4fbff72aaf24b395fa138fbbf0012bb42536b428bf2da5bba0cb3a - Sigstore transparency entry: 1632209788
- Sigstore integration time:
-
Permalink:
SurajKGoyal/amnesic@8ac8c0a127bd585ea620a72759e1b519a186f90b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/SurajKGoyal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ac8c0a127bd585ea620a72759e1b519a186f90b -
Trigger Event:
push
-
Statement type: