Terminal-based database client for Oracle and PostgreSQL with SSH jump server support.
- Multi-Database Support - Connect to Oracle (service name/SID) or PostgreSQL
- SSH Jump Server - Tunnel connections through SSH jump servers with key-based or password authentication
- Interactive SQL Prompt - Full-featured terminal prompt with history and auto-completion
- Table Formatting - Results displayed as formatted tables in the terminal
- Saved Connections - SQLite database to save and load connection profiles
- Meta Commands -
.tables,.describe,.connect,.save,.load, etc. - MCP Server - Expose database tools to LLMs via Model Context Protocol (
tdb-mcp) - MCP Query Control - Configure which tools and query modes the LLM can use via
~/.terminal_db/mcp.toml
- Python 3.10+
- Oracle Instant Client (for
oracledbthick mode, optional)
cd terminal-db-client
pip install -e .tdb| Command | Description |
|---|---|
.connect |
Connect to a database (interactive prompt) |
.connect <name> |
Connect using a saved connection |
.disconnect |
Disconnect from database |
.tables |
List all tables in current schema |
.describe <table> |
Show table structure |
.save <name> |
Save current connection |
.load <name> |
Load a saved connection |
.list |
List all saved connections |
.delete <name> |
Delete a saved connection |
.clear |
Clear screen |
.exit / .quit |
Exit the application |
.help |
Show help |
Just type any SQL query and press Enter:
SELECT * FROM user_tables;| Shortcut | Action |
|---|---|
Ctrl+R |
Search command history |
Tab |
Auto-completion |
Ctrl+C |
Cancel current input |
Ctrl+D |
Exit |
Connections are saved in ~/.terminal_db/connections.db (SQLite).
Query history is saved in ~/.terminal_db/query_history.txt.
| Field | Description | Example |
|---|---|---|
| Database Type | oracle or postgres |
oracle |
| Host | Database server hostname | db.example.com |
| Port | Database port | 1521 (Oracle) / 5432 (PostgreSQL) |
| Service Name | Oracle service name or PostgreSQL database name | ORCLPDB1 / mydb |
| SID | Oracle SID (alternative to service name) | ORCL |
| Username | Database username | system |
| Password | Database password | •••••• |
| Field | Description | Example |
|---|---|---|
| SSH Host | Jump server hostname | jump.example.com |
| SSH Port | SSH port (default: 22) | 22 |
| SSH Username | SSH username | admin |
| SSH Key Path | Path to SSH private key | ~/.ssh/id_rsa |
| SSH Password | SSH password (if no key) | •••••• |
src/terminal_db/
├── main.py # CLI entry point
├── config.py # Pydantic models for connection config
├── db_connection.py # Base ABC + OracleConnection + factory
├── db_connection_postgres.py # PostgreSQL connection
├── ssh_tunnel.py # SSH tunnel manager with paramiko
├── query_executor.py # SQL query executor (Oracle & PostgreSQL)
├── connection_store.py # SQLite connection storage
└── mcp/ # MCP server for LLM integration
├── server.py # tools: connect, list_tables, describe_table, execute_query
└── mcp_config.py # config loader (mcp.toml + CLI flags)
DataPad provides an MCP server so LLMs (Claude, Copilot, etc.) can query your databases directly.
tdb-mcpConfigure in your MCP client (e.g., Claude Desktop):
{
"mcpServers": {
"datapad": {
"command": "tdb-mcp"
}
}
}Available tools:
list_connections— List saved connectionsconnect(connection_name)— Connect using a saved profilelist_tables— List tables in current schemadescribe_table(table_name)— Show column structureexecute_query(query)— Run SQL queries (subject to query mode)
Save a connection first via tdb, then the MCP server uses the same ~/.terminal_db/connections.db.
Control what the LLM can do by editing ~/.terminal_db/mcp.toml:
[tools]
allowed = ["list_tables", "describe_table", "execute_query", "connect", "list_connections"]
[query]
mode = "read-only" # "read-only" | "write"
max_rows = 200| Mode | Allowed |
|---|---|
read-only |
SELECT only |
write |
Any query (INSERT, UPDATE, DELETE, DDL) |
tdb-mcp --allow-write # enable write mode for this session
tdb-mcp --max-rows 500 # override max rows
tdb-mcp --tools list_tables,describe_table # restrict available toolsMIT
