dbhawk

v0.4.2
com.datasparc/dbhawk Checked 15 hours ago Published 1 month ago

Secure access to DBHawk datasources: browse schemas, run governed queries, DBHawk AI text-to-SQL.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_permissions Get MCP permissions

What the current user may do over MCP: their MCP tier(s), the allowed operations (with the SQL keywords that classify a statement as each operation), the row cap, and which operations need the user's confirmation. Call this before writing SQL that changes data or schema.

list_datasources List datasources

List the datasources assigned to the current user. Returns name, dbType, readOnly, requiresDbLogin, aiEnabled.

get_datasource Get datasource

Get capabilities of one datasource (dbType, readOnly, whether it needs a DB login, whether DBHawk AI is enabled).

ParameterTypeDescription
datasource *stringDatasource name, e.g. 'Oracle-OVH'

list_catalogs List catalogs

List the catalogs (databases) of a datasource, for DB types that have a catalog level above the schema (MSSQL, Snowflake). Returns an empty list for databases with no catalog concept (Oracle, MySQL, MongoDB) - for those, skip the catalog argument on list_schemas/list_objects/list_columns.

ParameterTypeDescription
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

list_schemas List schemas

List the schemas of a datasource.

ParameterTypeDescription
catalogstringCatalog / database name, if the DB uses one
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

list_objects List objects

List database objects (tables/views/etc) in a schema. Access control of the calling user applies.

ParameterTypeDescription
schema *stringSchema name
catalogstringCatalog / database name, if the DB uses one
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE
querystringCase-insensitive name filter
typestringJDBC object types, comma separated (e.g. 'TABLE,VIEW'). Defaults to TABLE.

list_columns List columns

List the columns of a table/view: name, type, nullable.

ParameterTypeDescription
object *stringTable or view name
schema *stringSchema name
catalogstringCatalog / database name, if the DB uses one
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

run_query Run read-only query

Run a READ-ONLY SQL statement (SELECT, WITH, SHOW ...) against a datasource. For execution plans use explain_plan instead. Anything that changes data or schema is refused here - use execute_statement for that. Rows are capped (default 200, the MCP tier may lower the max of 5000); the result reports { rows, rowCount, truncated }. Access control and column masking of the user apply.

ParameterTypeDescription
query *stringA single read-only SQL statement
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE
maxRowsintegerRow cap for this call (<= 5000)

explain_plan Explain plan

Show the execution plan of ONE SQL statement. DBHawk builds and reads the plan in a single call on one database connection (Oracle EXPLAIN PLAN + DBMS_XPLAN, SQL Server SHOWPLAN, EXPLAIN on PostgreSQL, MySQL, Snowflake, Redshift ...), and never executes the statement. Send the plain statement, without EXPLAIN. Use this tool for plans: do NOT run EXPLAIN PLAN FOR and DBMS_XPLAN.DISPLAY through run_query - every call uses its own connection, so the plan is lost between the two calls. Returns planText (single-column plans) and the plan rows. Needs the explain_plan operation in the user's MCP tier…

ParameterTypeDescription
query *stringThe single SQL statement to explain, e.g. SELECT * FROM orders WHERE id = 1
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

execute_statement Execute data / schema change

Execute ONE SQL statement that changes data or schema (INSERT, UPDATE, DELETE, MERGE, CREATE, ALTER, DROP...). Only works when the user's MCP tier allows that operation - see get_permissions. Workflow: 1) show the exact statement to the user; 2) call this tool without confirm - if the tier requires confirmation, DBHawk returns { confirmationRequired: true, executed: false } and runs nothing; 3) only after the user explicitly approves THIS statement, call again with the same statement and confirm=true. Never set confirm=true on your own initiative. Returns the affected row count.

ParameterTypeDescription
statement *stringA single SQL statement that changes data or schema
confirmbooleantrue only after the user explicitly approved this exact statement
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

list_sessions List database sessions

List the active sessions of the datasource's database: sessionId, user, status, program, machine, logonTime, secondsInCall and the current SQL (first 200 characters; omitted when DBHawk does not share data with AI models). The same sessions DBHawk's Session Manager shows. Works for Oracle, SQL Server, PostgreSQL, Redshift and MySQL / MariaDB. Needs the active_sessions operation in the user's MCP tier - see get_permissions.

ParameterTypeDescription
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

kill_session End a database session

End ONE database session, by a sessionId returned by list_sessions (Oracle: 'sid,serial#', e.g. '123,4567'; other databases: a number). Its open transaction is rolled back. DBHawk builds the command itself - do not send KILL / ALTER SYSTEM statements through execute_statement for this. Workflow: 1) show the session (user, program, SQL) to the user; 2) call without confirm - if the tier requires confirmation DBHawk returns { confirmationRequired: true, executed: false, session } and ends nothing; 3) only after the user explicitly approves ending THIS session, call again with confirm=true. Never…

ParameterTypeDescription
sessionId *stringSession id from list_sessions, e.g. '123,4567' (Oracle) or '55'
confirmbooleantrue only after the user explicitly approved ending this session
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE

text_to_sql Text to SQL

DBHawk AI text-to-SQL: turn a natural-language question into a SQL statement for the datasource. Only works when the datasource has aiEnabled=true. It only generates statement types the user's MCP tier allows. It does not execute anything: run the result with run_query, or execute_statement for a change.

ParameterTypeDescription
prompt *stringThe natural-language question
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE
sessionIdstringOptional conversation id to keep context across calls

optimize_sql Optimize SQL

DBHawk AI SQL optimization suggestions for a given statement. Does not execute anything.

ParameterTypeDescription
sql *stringThe SQL statement to optimize
datasourcestringDatasource name; defaults to DBHAWK_DEFAULT_DATASOURCE
schemastringSchema context, if relevant

format_sql Format SQL

Pretty-print / format a SQL statement.

ParameterTypeDescription
query *stringThe SQL statement to format
dbDialectstringOptional dialect hint (e.g. ORACLE, MYSQL, POSTGRESQL)