dbecho 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install dependencies
24
+ run: pip install -e ".[dev]"
25
+
26
+ - name: Run tests
27
+ run: pytest -v
28
+
29
+ lint:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: "3.12"
37
+
38
+ - name: Install ruff
39
+ run: pip install ruff
40
+
41
+ - name: Check formatting
42
+ run: ruff format --check src/ tests/
43
+
44
+ - name: Lint
45
+ run: ruff check src/ tests/
@@ -0,0 +1,42 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - run: pip install -e ".[dev]"
22
+ - run: pytest -v
23
+
24
+ publish:
25
+ needs: test
26
+ runs-on: ubuntu-latest
27
+ environment: pypi
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: "3.12"
34
+
35
+ - name: Install build tools
36
+ run: pip install build
37
+
38
+ - name: Build package
39
+ run: python -m build
40
+
41
+ - name: Publish to PyPI
42
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,22 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.egg
8
+ .venv/
9
+ venv/
10
+ .env
11
+ dbecho.toml
12
+ *.db
13
+ *.sqlite
14
+ .mypy_cache/
15
+ .ruff_cache/
16
+ .pytest_cache/
17
+ .claude/
18
+ .mcp.json
19
+ CLAUDE.md
20
+ AGENTS.md
21
+ COPILOT.md
22
+ CURSOR.md
dbecho-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dbecho contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dbecho-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: dbecho
3
+ Version: 0.1.0
4
+ Summary: MCP server for multi-database PostgreSQL analytics. Ask your databases questions in natural language.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: mcp[cli]>=1.0.0
9
+ Requires-Dist: psycopg[binary]>=3.1.0
10
+ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=7.0; extra == 'dev'
13
+ Description-Content-Type: text/markdown
14
+
15
+ # dbecho
16
+
17
+ > Talk to your PostgreSQL databases through AI. No dashboards, no BI tools, just questions and answers.
18
+
19
+ **dbecho** is an [MCP server](https://modelcontextprotocol.io/) that gives AI agents (Claude Code, Cursor, Windsurf, or any MCP client) direct read-only access to your PostgreSQL databases. Point it at your databases, ask questions in plain language, get instant analytics.
20
+
21
+ ```
22
+ You: What are my most popular blog posts and why?
23
+ Claude: [runs schema → query → analyze → trend across 29 tables]
24
+ Here's what the data shows...
25
+ ```
26
+
27
+ ## What can it do?
28
+
29
+ **11 tools** that cover the full analytics workflow:
30
+
31
+ | Tool | Purpose |
32
+ |------|---------|
33
+ | `list_databases` | Show all connected databases |
34
+ | `health` | Check connectivity, PostgreSQL version, database size |
35
+ | `schema` | Full schema: tables, columns, types, PKs, row counts, sizes |
36
+ | `query` | Run read-only SQL (SELECT, WITH, EXPLAIN, SHOW) |
37
+ | `analyze` | Profile a table: nulls, cardinality, distributions, top values |
38
+ | `compare` | Same query across multiple databases, side by side |
39
+ | `summary` | Overview: table counts, total rows, largest tables |
40
+ | `trend` | Time-series: counts/averages grouped by day/week/month/year |
41
+ | `anomalies` | Data quality: high nulls, outliers, duplicates, future dates |
42
+ | `sample` | Preview rows from any table |
43
+ | `erd` | Entity-relationship diagram: PKs and foreign keys |
44
+
45
+ Plus **3 MCP Resources** (schema/summary per database) and **3 MCP Prompts** (guided exploration, cross-database comparison, data quality audit).
46
+
47
+ ## Why dbecho?
48
+
49
+ **The problem:** You have PostgreSQL databases across projects. Getting answers means context-switching to psql, pgAdmin, or a BI tool, writing SQL, formatting results, then bringing insights back to your conversation.
50
+
51
+ **The fix:** dbecho stays inside your AI agent's workflow. The agent explores schema, writes SQL, cross-references tables, and builds analysis without you leaving the conversation. One config file, zero context switches.
52
+
53
+ What makes it different from just giving an agent a connection string:
54
+ - **Multi-database.** Connect 1 or 20 databases. Compare across them with one tool call.
55
+ - **Safe by default.** Read-only connections, query timeouts, row limits, SQL injection prevention. You can't accidentally `DROP TABLE`.
56
+ - **Agent-optimized output.** Schema, stats, and query results are formatted so LLMs parse them efficiently, not as raw psql dumps.
57
+ - **Zero infrastructure.** No containers, no web UI, no background processes. A Python package that speaks MCP over stdio.
58
+
59
+ ## Real-world example
60
+
61
+ Connected to a blog database (29 tables, 34 MB), asked Claude to analyze post performance:
62
+
63
+ ```
64
+ You: Analyze my blog posts and tell me what topics I should write about.
65
+ ```
66
+
67
+ Claude autonomously ran 15+ queries across `post_posts`, `post_engagements`, `post_reactions`, `tags`, `topics`, `subscribers`, and `comment_comments`. Discovered:
68
+
69
+ - Posts with brand names in titles average 1800-3000 views (vs 400 without)
70
+ - 63% of readers leave in the first quarter of a post
71
+ - Investigation-style posts get 80-100% engagement rate
72
+ - 87% of 32,754 unique visitors never return (retention problem)
73
+ - Only 47 subscribers from all that traffic (0.07% conversion)
74
+ - Email bounce rate of 83% among confirmed subscribers
75
+
76
+ That's the kind of analysis that takes hours manually. dbecho made it a conversation.
77
+
78
+ ## Quick start
79
+
80
+ ### 1. Install
81
+
82
+ ```bash
83
+ pip install dbecho
84
+ ```
85
+
86
+ Or from source:
87
+
88
+ ```bash
89
+ git clone https://github.com/ginkida/dbecho.git
90
+ cd dbecho
91
+ pip install .
92
+ ```
93
+
94
+ Requires Python 3.10+.
95
+
96
+ ### 2. Configure
97
+
98
+ Create `dbecho.toml` in your project directory:
99
+
100
+ ```toml
101
+ [databases.myapp]
102
+ url = "postgres://user:pass@localhost:5432/myapp"
103
+ description = "Main application"
104
+
105
+ [databases.analytics]
106
+ url = "postgres://user:pass@localhost:5432/analytics"
107
+ description = "Analytics warehouse"
108
+
109
+ [settings]
110
+ row_limit = 500 # max rows returned per query (default: 500)
111
+ query_timeout = 30 # seconds before query is killed (default: 30)
112
+ ```
113
+
114
+ Environment variables work with `${VAR}` syntax:
115
+
116
+ ```toml
117
+ [databases.production]
118
+ url = "${DATABASE_URL}"
119
+ description = "Production (read replica)"
120
+ ```
121
+
122
+ ### 3. Connect to your MCP client
123
+
124
+ **Claude Code** (project-level, recommended):
125
+
126
+ Create `.mcp.json` in your project root:
127
+
128
+ ```json
129
+ {
130
+ "mcpServers": {
131
+ "dbecho": {
132
+ "command": "dbecho",
133
+ "args": ["--config", "/path/to/dbecho.toml"]
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ **Claude Code** (global):
140
+
141
+ Add to `~/.claude.json`:
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "dbecho": {
147
+ "command": "dbecho"
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ When no `--config` is passed, dbecho searches for config in:
154
+ 1. `./dbecho.toml` (current directory)
155
+ 2. `~/.config/dbecho/config.toml`
156
+ 3. `~/.dbecho.toml`
157
+
158
+ **Other MCP clients** (Cursor, Windsurf, etc.): use the same command/args in your client's MCP server configuration.
159
+
160
+ ### 4. Ask questions
161
+
162
+ ```
163
+ Show me a summary of all my databases
164
+ How many users signed up each month this year?
165
+ Compare order counts between staging and production
166
+ Find data quality issues in the events table
167
+ What's the relationship between users, orders, and products?
168
+ Which columns have the most nulls?
169
+ Show me the trend of daily revenue for the last 90 days
170
+ ```
171
+
172
+ The agent picks the right tools automatically. You don't need to know the tool names.
173
+
174
+ ## Safety
175
+
176
+ dbecho is designed to be safe to point at any database, including production:
177
+
178
+ - **Read-only connections.** Every connection sets `default_transaction_read_only=on` at the PostgreSQL level. Even if someone crafts malicious SQL, the database rejects writes.
179
+ - **Query whitelist.** Only `SELECT`, `WITH`, `EXPLAIN`, and `SHOW` statements are allowed. Checked before execution.
180
+ - **SQL injection prevention.** All table/column identifiers use `psycopg.sql.Identifier()` parameterization. User input is validated against `^[a-zA-Z_][a-zA-Z0-9_]*$`.
181
+ - **Query timeout.** Default 30 seconds. Prevents runaway queries from locking your database.
182
+ - **Row limit.** Default 500 rows per query. Prevents the agent from pulling entire tables into context.
183
+ - **Local only.** No network calls, no telemetry, no cloud. Data stays on your machine.
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ src/dbecho/
189
+ config.py TOML config loading, env var expansion, validation
190
+ db.py DatabaseManager: connections, schema cache, queries, stats, trends, anomalies
191
+ server.py FastMCP server: 11 tools, 3 resources, 3 prompts
192
+ ```
193
+
194
+ ~1000 lines of Python total. No framework beyond `mcp` and `psycopg`.
195
+
196
+ ## Development
197
+
198
+ ```bash
199
+ git clone https://github.com/ginkida/dbecho.git
200
+ cd dbecho
201
+ pip install -e ".[dev]"
202
+ pytest -v
203
+ ```
204
+
205
+ Tests are fully mocked, no PostgreSQL instance needed. CI runs on Python 3.10-3.13.
206
+
207
+ ## License
208
+
209
+ MIT
dbecho-0.1.0/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # dbecho
2
+
3
+ > Talk to your PostgreSQL databases through AI. No dashboards, no BI tools, just questions and answers.
4
+
5
+ **dbecho** is an [MCP server](https://modelcontextprotocol.io/) that gives AI agents (Claude Code, Cursor, Windsurf, or any MCP client) direct read-only access to your PostgreSQL databases. Point it at your databases, ask questions in plain language, get instant analytics.
6
+
7
+ ```
8
+ You: What are my most popular blog posts and why?
9
+ Claude: [runs schema → query → analyze → trend across 29 tables]
10
+ Here's what the data shows...
11
+ ```
12
+
13
+ ## What can it do?
14
+
15
+ **11 tools** that cover the full analytics workflow:
16
+
17
+ | Tool | Purpose |
18
+ |------|---------|
19
+ | `list_databases` | Show all connected databases |
20
+ | `health` | Check connectivity, PostgreSQL version, database size |
21
+ | `schema` | Full schema: tables, columns, types, PKs, row counts, sizes |
22
+ | `query` | Run read-only SQL (SELECT, WITH, EXPLAIN, SHOW) |
23
+ | `analyze` | Profile a table: nulls, cardinality, distributions, top values |
24
+ | `compare` | Same query across multiple databases, side by side |
25
+ | `summary` | Overview: table counts, total rows, largest tables |
26
+ | `trend` | Time-series: counts/averages grouped by day/week/month/year |
27
+ | `anomalies` | Data quality: high nulls, outliers, duplicates, future dates |
28
+ | `sample` | Preview rows from any table |
29
+ | `erd` | Entity-relationship diagram: PKs and foreign keys |
30
+
31
+ Plus **3 MCP Resources** (schema/summary per database) and **3 MCP Prompts** (guided exploration, cross-database comparison, data quality audit).
32
+
33
+ ## Why dbecho?
34
+
35
+ **The problem:** You have PostgreSQL databases across projects. Getting answers means context-switching to psql, pgAdmin, or a BI tool, writing SQL, formatting results, then bringing insights back to your conversation.
36
+
37
+ **The fix:** dbecho stays inside your AI agent's workflow. The agent explores schema, writes SQL, cross-references tables, and builds analysis without you leaving the conversation. One config file, zero context switches.
38
+
39
+ What makes it different from just giving an agent a connection string:
40
+ - **Multi-database.** Connect 1 or 20 databases. Compare across them with one tool call.
41
+ - **Safe by default.** Read-only connections, query timeouts, row limits, SQL injection prevention. You can't accidentally `DROP TABLE`.
42
+ - **Agent-optimized output.** Schema, stats, and query results are formatted so LLMs parse them efficiently, not as raw psql dumps.
43
+ - **Zero infrastructure.** No containers, no web UI, no background processes. A Python package that speaks MCP over stdio.
44
+
45
+ ## Real-world example
46
+
47
+ Connected to a blog database (29 tables, 34 MB), asked Claude to analyze post performance:
48
+
49
+ ```
50
+ You: Analyze my blog posts and tell me what topics I should write about.
51
+ ```
52
+
53
+ Claude autonomously ran 15+ queries across `post_posts`, `post_engagements`, `post_reactions`, `tags`, `topics`, `subscribers`, and `comment_comments`. Discovered:
54
+
55
+ - Posts with brand names in titles average 1800-3000 views (vs 400 without)
56
+ - 63% of readers leave in the first quarter of a post
57
+ - Investigation-style posts get 80-100% engagement rate
58
+ - 87% of 32,754 unique visitors never return (retention problem)
59
+ - Only 47 subscribers from all that traffic (0.07% conversion)
60
+ - Email bounce rate of 83% among confirmed subscribers
61
+
62
+ That's the kind of analysis that takes hours manually. dbecho made it a conversation.
63
+
64
+ ## Quick start
65
+
66
+ ### 1. Install
67
+
68
+ ```bash
69
+ pip install dbecho
70
+ ```
71
+
72
+ Or from source:
73
+
74
+ ```bash
75
+ git clone https://github.com/ginkida/dbecho.git
76
+ cd dbecho
77
+ pip install .
78
+ ```
79
+
80
+ Requires Python 3.10+.
81
+
82
+ ### 2. Configure
83
+
84
+ Create `dbecho.toml` in your project directory:
85
+
86
+ ```toml
87
+ [databases.myapp]
88
+ url = "postgres://user:pass@localhost:5432/myapp"
89
+ description = "Main application"
90
+
91
+ [databases.analytics]
92
+ url = "postgres://user:pass@localhost:5432/analytics"
93
+ description = "Analytics warehouse"
94
+
95
+ [settings]
96
+ row_limit = 500 # max rows returned per query (default: 500)
97
+ query_timeout = 30 # seconds before query is killed (default: 30)
98
+ ```
99
+
100
+ Environment variables work with `${VAR}` syntax:
101
+
102
+ ```toml
103
+ [databases.production]
104
+ url = "${DATABASE_URL}"
105
+ description = "Production (read replica)"
106
+ ```
107
+
108
+ ### 3. Connect to your MCP client
109
+
110
+ **Claude Code** (project-level, recommended):
111
+
112
+ Create `.mcp.json` in your project root:
113
+
114
+ ```json
115
+ {
116
+ "mcpServers": {
117
+ "dbecho": {
118
+ "command": "dbecho",
119
+ "args": ["--config", "/path/to/dbecho.toml"]
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ **Claude Code** (global):
126
+
127
+ Add to `~/.claude.json`:
128
+
129
+ ```json
130
+ {
131
+ "mcpServers": {
132
+ "dbecho": {
133
+ "command": "dbecho"
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ When no `--config` is passed, dbecho searches for config in:
140
+ 1. `./dbecho.toml` (current directory)
141
+ 2. `~/.config/dbecho/config.toml`
142
+ 3. `~/.dbecho.toml`
143
+
144
+ **Other MCP clients** (Cursor, Windsurf, etc.): use the same command/args in your client's MCP server configuration.
145
+
146
+ ### 4. Ask questions
147
+
148
+ ```
149
+ Show me a summary of all my databases
150
+ How many users signed up each month this year?
151
+ Compare order counts between staging and production
152
+ Find data quality issues in the events table
153
+ What's the relationship between users, orders, and products?
154
+ Which columns have the most nulls?
155
+ Show me the trend of daily revenue for the last 90 days
156
+ ```
157
+
158
+ The agent picks the right tools automatically. You don't need to know the tool names.
159
+
160
+ ## Safety
161
+
162
+ dbecho is designed to be safe to point at any database, including production:
163
+
164
+ - **Read-only connections.** Every connection sets `default_transaction_read_only=on` at the PostgreSQL level. Even if someone crafts malicious SQL, the database rejects writes.
165
+ - **Query whitelist.** Only `SELECT`, `WITH`, `EXPLAIN`, and `SHOW` statements are allowed. Checked before execution.
166
+ - **SQL injection prevention.** All table/column identifiers use `psycopg.sql.Identifier()` parameterization. User input is validated against `^[a-zA-Z_][a-zA-Z0-9_]*$`.
167
+ - **Query timeout.** Default 30 seconds. Prevents runaway queries from locking your database.
168
+ - **Row limit.** Default 500 rows per query. Prevents the agent from pulling entire tables into context.
169
+ - **Local only.** No network calls, no telemetry, no cloud. Data stays on your machine.
170
+
171
+ ## Architecture
172
+
173
+ ```
174
+ src/dbecho/
175
+ config.py TOML config loading, env var expansion, validation
176
+ db.py DatabaseManager: connections, schema cache, queries, stats, trends, anomalies
177
+ server.py FastMCP server: 11 tools, 3 resources, 3 prompts
178
+ ```
179
+
180
+ ~1000 lines of Python total. No framework beyond `mcp` and `psycopg`.
181
+
182
+ ## Development
183
+
184
+ ```bash
185
+ git clone https://github.com/ginkida/dbecho.git
186
+ cd dbecho
187
+ pip install -e ".[dev]"
188
+ pytest -v
189
+ ```
190
+
191
+ Tests are fully mocked, no PostgreSQL instance needed. CI runs on Python 3.10-3.13.
192
+
193
+ ## License
194
+
195
+ MIT
@@ -0,0 +1,12 @@
1
+ [databases.myapp]
2
+ url = "postgres://localhost:5432/myapp"
3
+ description = "Main application"
4
+
5
+ # Environment variables are supported with ${VAR} syntax:
6
+ # [databases.production]
7
+ # url = "${DATABASE_URL}"
8
+ # description = "Production database"
9
+
10
+ [settings]
11
+ row_limit = 500
12
+ query_timeout = 30
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "dbecho"
3
+ version = "0.1.0"
4
+ description = "MCP server for multi-database PostgreSQL analytics. Ask your databases questions in natural language."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.10"
8
+ dependencies = [
9
+ "mcp[cli]>=1.0.0",
10
+ "psycopg[binary]>=3.1.0",
11
+ "tomli>=2.0.0;python_version<'3.11'",
12
+ ]
13
+
14
+ [project.scripts]
15
+ dbecho = "dbecho:main"
16
+
17
+ [build-system]
18
+ requires = ["hatchling"]
19
+ build-backend = "hatchling.build"
20
+
21
+ [project.optional-dependencies]
22
+ dev = ["pytest>=7.0"]
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/dbecho"]
26
+
27
+ [tool.pytest.ini_options]
28
+ testpaths = ["tests"]
@@ -0,0 +1,3 @@
1
+ from dbecho.server import main
2
+
3
+ __all__ = ["main"]
@@ -0,0 +1,3 @@
1
+ from dbecho.server import main
2
+
3
+ main()