tinystruct-smart-dba
An AI database agent for the terminal, built on the tinystruct Java framework. You ask questions in plain English, such as "show me the ten newest orders" or "how many users signed up this week?". The agent works out the SQL, runs it against your database, and shows the results.
Install / Use
claude mcp add tinystruct -- npx -y github:tinystruct/tinystruct-smart-dbaIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of tinystruct-smart-dba
tinystruct-smart-dba scores 81/100 on our quality scale, 726th of 945 AI & Machine Learning skills we index.
Its MCP Server is 10.0 KB long, well organised into 24 sections with 12 code examples: a thorough specification that gives an agent plenty to work with.
It has 3 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated 6 days ago, so tinystruct-smart-dba is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 92/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-11-01. Automated pattern scan on 2026-11-01. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
tinystruct-smart-dba compared with similar skills
All 4 of these similar skills score higher than tinystruct-smart-dba; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| tinystruct-smart-dba (this skill)by tinystruct | 81 | 3 | 6d ago | MCP Server |
| claude-memby thedotmack | 100 | 108.0k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 107.3k | 7d ago | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 89.4k | 6d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 78.5k | 1d ago | CLAUDE.md |
Frequently asked questions
- How do I install tinystruct-smart-dba?
- Run
claude mcp add tinystruct -- npx -y github:tinystruct/tinystruct-smart-dba. The install tabs above show the steps for each supported agent. - Which AI agents does tinystruct-smart-dba work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is tinystruct-smart-dba safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is Apache-2.0-licensed and scores 92/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is tinystruct-smart-dba still maintained?
- The repository was last updated 6 days ago, so tinystruct-smart-dba is actively maintained.
Skill content
View source on GitHubSmartDBA - AI Database Agent
SmartDBA is an AI database agent built on the tinystruct framework (1.7.36). Ask questions in plain English ("show me the ten newest orders"); the agent works out the SQL, runs it through a set of MCP database tools, and shows the results as formatted tables in your terminal.
Features
- Interactive CLI: Streams the model's reply live and renders Markdown (headings, lists, code blocks, tables) with ANSI colors.
- Database tools over MCP: List tables, describe schemas, query, insert, update, delete, and run raw SQL (JOINs, subqueries, CTEs).
- Any JDBC database: MySQL/MariaDB, PostgreSQL, SQLite, H2, SQL Server and other JDBC drivers. Schema discovery uses JDBC metadata, and identifier quoting adapts to the dialect.
- Gemini or OpenAI-compatible LLMs: Defaults to Gemini (
gemini-3.5-flash-lite). - HTTP + SSE: The same
chataction is available over HTTP, with token-by-token updates pushed over Server-Sent Events. - Conversation memory: History is kept between turns in
.agent_history.json; an optional skill file adds extra guidance for the model.
Safety model
The model's output is treated as untrusted input.
- Writes need approval.
db/insert,db/updateanddb/delete(thetypesafe.routing.confirm-actionslist), file writes and shell commands all ask[y/N]in the terminal. - Raw SQL is classified first.
db/executeruns without a prompt only when the statement is provably read-only (no stacked statements, comments, or write keywords, soWITH ... DELETEis caught). Anything else needs approval. If a TypeSafe key is configured, the JEV model gives an extra opinion on read-only SQL. - No approver, no write. Outside the interactive terminal (for example the HTTP
chataction) there is nobody to approve, so writes, shell commands and modifying tool calls are refused. - Confined file access. The agent's
readandwriteactions only touch files inside the workspace (agent.workspace, default: the working directory).application.propertiesand.agent_history.jsonare blocked, as are paths that escape via..or symlinks. - Validated WHERE clauses.
db/updateanddb/deleterequire a WHERE clause, which must be a plain predicate: no subqueries,UNION, DML/DDL, comments, stacked statements or always-true conditions. The clause is still spliced into the SQL text, so treat approval as the real safeguard.
Use a database account with only the privileges you are comfortable giving the agent.
Prerequisites
- Java 17 or higher
- Maven 3.6+ (or use the bundled
mvnw) - A JDBC database and its driver on the classpath
- A Google Gemini or OpenAI-compatible API key
Quick start
An embedded H2 database is configured by default, so you only need an API key.
git clone https://github.com/tinystruct/tinystruct-smart-dba.git
cd tinystruct-smart-dba
./mvnw package -DskipTests # builds and copies dependencies into lib/
Set your Gemini key (the sample config reads it from the GEMINI_API_KEY environment variable, so nothing needs editing):
export GEMINI_API_KEY=your-key # Linux / macOS
$env:GEMINI_API_KEY = "your-key" # Windows PowerShell
Run it from the project root:
bin/dispatcher chat # Linux / macOS
bin\dispatcher.cmd chat # Windows
Then try: create a table of books with title and author, add three rows, and show them. Writes will ask for your approval.
Chinese and other non-ASCII text work out of the box: the launch scripts switch the console and the JVM to UTF-8 (chcp 65001 on Windows, -Dfile.encoding=UTF-8). If you start the app another way, for example from an IDE, add -Dfile.encoding=UTF-8 to the JVM options. For a legible console font on Windows, use Windows Terminal.
Configuration
Everything lives in src/main/resources/application.properties. A value written as $_NAME is read from the environment variable NAME.
# LLM
agent.api_key=$_GEMINI_API_KEY # or paste the key directly
agent.model=gemini-3.5-flash-lite
# agent.api_url=... # OpenAI-compatible endpoint; defaults to Gemini
# agent.workspace=. # root for the agent's file access
# agent.skill_file=path/to/SKILL.md # extra guidance for the model (empty by default)
# Database (sample default: embedded H2 in your home directory)
driver=org.h2.Driver
database.url=jdbc:h2:~/test
database.user=
database.password=
# Internal MCP server. Change the token from the sample value.
mcp.server.url=http://localhost:8080/
mcp.auth.token=123456
Using your own database: put its JDBC driver in pom.xml (H2 and PostgreSQL are already there; sqlite-jdbc, MySQL and others work the same way), run ./mvnw package -DskipTests again, and update driver, database.url, database.user and database.password. For example, MySQL:
driver=com.mysql.cj.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/your_db
database.user=root
database.password=secret
PostgreSQL (the driver is bundled, so no pom.xml change is needed):
driver=org.postgresql.Driver
database.url=jdbc:postgresql://localhost:5432/your_db
database.user=postgres
database.password=secret
SmartDBA works in the connection's current schema (public by default; add ?currentSchema=myschema to the URL to change it). Table names are matched case-insensitively, and the agent is told PostgreSQL's rules for lower-case folding, reserved words and SERIAL keys.
To use an OpenAI-compatible API, set agent.api_url (for example https://api.openai.com/v1/chat/completions), agent.model and agent.api_key.
Approval rules (TypeSafe settings)
typesafe.routing.confirm-actions=db/insert,db/update,db/delete
typesafe.api-key=$_TYPESAFE_API_KEY
typesafe.routing.confirm-actionsis the list of tools that always ask for approval. Adddb/executeor any other tool to be stricter; removing entries is not recommended.typesafe.api-key(environment variableTYPESAFE_API_KEY) is optional. With it, a TypeSafe JEV model also reviews read-onlydb/executeSQL as a second opinion. Without it, SmartDBA relies on its built-in read-only check, so everything works either way.- The other
typesafe.*keys in the sample file (endpoint, model, confidence thresholds, cache, workflow) belong to the TypeSafe integration and can be left at their defaults.
Logging
logging.enabled=FALSE is the default, which hides framework warnings and errors. Set it to TRUE when something misbehaves and the terminal shows nothing useful.
Ports
The embedded HTTP/MCP server starts on tinystruct's default port, 8080, and mcp.server.url must point at it. The agent starts it itself, so you do not run a separate server.
Usage
Interactive session
bin/dispatcher chat
Type a request such as "Show me the top 5 users created this month". Other commands: clear resets the history, exit or quit leaves.
Single message
bin/dispatcher chat --message "List all tables"
Prints the answer and exits. Single messages cannot ask for approval, so they are limited to read-only actions. Use the interactive session for anything that modifies data.
HTTP
With the app running, the same chat action is reachable through tinystruct's HTTP server on port 8080, and streamed tokens are pushed over SSE. HTTP requests are read-only for the same reason.
Troubleshooting
| Symptom | Fix |
|---|---|
| API key not configured | Set GEMINI_API_KEY (or agent.api_key) in the same shell you run the dispatcher from. |
| API returned status 400 ... API key not valid | The key is wrong or for a different API; check agent.model and agent.api_url too. |
| ClassNotFoundException: org.tinystruct.system.Dispatcher | Run ./mvnw package -DskipTests first so lib/ is populated, and run the dispatcher from the project root. On Windows use bin\dispatcher.cmd, not the bash script. |
| Driver or database.url errors | Make sure the JDBC driver is in pom.xml and lib/. |
| Port 8080 already in use | Set server.port in application.properties and update mcp.server.url to match. |
Tools exposed over MCP
| Tool | Purpose |
|---|---|
| db/list-tables | List tables and views |
| db/describe | Columns, types, keys of a table |
| db/query | Select rows with optional WHERE and LIMIT (max 1000) |
| db/insert | Insert a row (parameterized) |
| db/update | Update rows (WHERE required) |
| db/delete | Delete rows (WHERE required) |
| db/execute | Raw SQL for JOINs, CTEs, DDL |
Project layout
SmartDBA.java: chat loop, LLM streaming, Markdown renderer, approval logic.SmartDBAServer.java: MCP server that registers the database tools.tools/DatabaseTool.java: the MCP database tools, SQL classifier and WHERE validation.
Testing
./mvnw test
License
Apache License 2.0. See LICENSE.
Related Skills
claude-mem
108.0kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
107.3kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Understand-Anything
89.4kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
78.5kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
