feat(mcp): add database connection listing and info tools#39111
feat(mcp): add database connection listing and info tools#39111aminghadersohi merged 7 commits intomasterfrom
Conversation
Add MCP tools for listing and getting database connection details, filling a gap where databases were the only core Superset resource without MCP tool coverage. New tools: - list_databases: List database connections with filtering/pagination - get_database_info: Get detailed database connection metadata by ID Also registers "database" as a model type in get_schema for column/filter discovery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #39111 +/- ##
==========================================
+ Coverage 64.52% 64.53% +0.01%
==========================================
Files 2536 2540 +4
Lines 131208 131413 +205
Branches 30457 30467 +10
==========================================
+ Hits 84661 84811 +150
- Misses 45084 45139 +55
Partials 1463 1463
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Move the repeated Literal["chart", "dataset", "dashboard", "database"] type alias to a shared ModelType in constants.py, replacing 4 inline occurrences across schema_discovery.py, mcp_core.py, and get_schema.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove `backend` from DatabaseFilter (it's a @Property, not a SQL column, so DAO filtering would fail at query time) - Add UUID support to GetDatabaseInfoRequest (identifier: int | str) and expose uuid field on DatabaseInfo — Database inherits UUIDMixin via ImportExportMixin - Exclude sensitive columns (sqlalchemy_uri, password, encrypted_extra, server_cert) from schema discovery via new exclude_columns parameter on get_columns_from_model() - Update get_database_info docstring with UUID examples Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review Agent Run #ef0696
Actionable Suggestions - 2
-
superset/mcp_service/database/schemas.py - 2
- datetime.now() called without timezone · Line 256-258
- datetime.now() called without timezone · Line 288-288
Additional Suggestions - 2
-
tests/unit_tests/mcp_service/database/tool/test_database_tools.py - 1
-
Missing Type Hints · Line 34-34Add explicit type hints to parameters and return type for create_mock_database to comply with type safety requirements for new Python code.
Code suggestion
@@ -34,11 +34,11 @@ -def create_mock_database( - database_id=1, - database_name="examples", - backend="postgresql", - expose_in_sqllab=True, - allow_ctas=False, - allow_cvas=False, - allow_dml=False, - allow_file_upload=False, - allow_run_async=False, -): +def create_mock_database( + database_id: int = 1, + database_name: str = "examples", + backend: str = "postgresql", + expose_in_sqllab: bool = True, + allow_ctas: bool = False, + allow_cvas: bool = False, + allow_dml: bool = False, + allow_file_upload: bool = False, + allow_run_async: bool = False, +) -> MagicMock:
-
-
superset/mcp_service/mcp_core.py - 1
-
Update model_type docstring · Line 525-525The type annotation for model_type has been changed from Literal["chart", "dataset", "dashboard"] to ModelType, which includes "database" as well. The docstring at line 540 should be updated accordingly to maintain consistency.
-
Review Details
-
Files reviewed - 13 · Commit Range:
bbc6abf..81c4b12- superset/mcp_service/app.py
- superset/mcp_service/common/schema_discovery.py
- superset/mcp_service/constants.py
- superset/mcp_service/database/__init__.py
- superset/mcp_service/database/schemas.py
- superset/mcp_service/database/tool/__init__.py
- superset/mcp_service/database/tool/get_database_info.py
- superset/mcp_service/database/tool/list_databases.py
- superset/mcp_service/mcp_core.py
- superset/mcp_service/system/tool/get_schema.py
- tests/unit_tests/mcp_service/database/__init__.py
- tests/unit_tests/mcp_service/database/tool/__init__.py
- tests/unit_tests/mcp_service/database/tool/test_database_tools.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
… defaults for database tools - Add created_by_fk and changed_by_fk to DatabaseFilter columns so users can filter databases by creator (matching chart/dashboard patterns) - Add field_validator for filters and select_columns to handle JSON string parsing from MCP clients (double-serialization bug workaround) - Remove duplicate DEFAULT_DATABASE_COLUMNS from list_databases.py, import from schema_discovery.py instead - Update app.py instructions to document database created_by_fk workflow
- Fix datetime.now() without timezone in DatabaseError.create() and _humanize_timestamp() — use timezone-aware datetimes consistently - Add type hints to create_mock_database() test helper - Update mcp_core.py ModelGetSchemaCore docstring to include "database" in the model_type description
- Fix misleading "permissions" in app.py and get_database_info docstring — replaced with "capabilities" to match actual response fields - Add changed_on to DATABASE_DEFAULT_COLUMNS so humanized timestamps can be computed reliably (matching chart/dataset pattern) - Fix not-found test to use result.data["error_type"] instead of result.content (matching existing dataset/dashboard test patterns)
Code Review Agent Run #301849Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…ve filter columns - Add _get_backend() helper that safely handles backend @Property access on row proxies from DAO list queries (property requires URI decryption which fails on column-only query results) - Add exclude_filter_columns parameter to ModelGetSchemaCore to strip sensitive columns (sqlalchemy_uri, password, encrypted_extra, server_cert) from filter discovery responses - Wire DATABASE_EXCLUDE_COLUMNS into database schema discovery
Code Review Agent Run #94a163Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Amin Ghadersohi <amin.ghadersohi@gmail.com> (cherry picked from commit a62be68)
SUMMARY
Add MCP tools for listing and getting database connection details, filling a gap where databases were the only core Superset resource without MCP tool coverage.
New tools:
list_databases— List database connections with filtering, search, and pagination (tag:core)get_database_info— Get detailed database connection metadata by ID (tag:discovery)Schema discovery integration:
"database"as a model type inget_schema, so LLM clients can discover available columns, filters, and sort optionsFollows existing patterns exactly — modeled after the dataset tool domain (
ModelListCore,ModelGetInfoCore, Pydantic schemas,MetadataCacheControl, event logging).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only MCP tool additions, no UI changes.
TESTING INSTRUCTIONS
list_databases— should return paginated database connectionsget_database_infowith a known database ID — should return full connection metadataget_schema(model_type="database")— should return column/filter/sort metadatapytest tests/unit_tests/mcp_service/database/ADDITIONAL INFORMATION