feat(agent-superset): extend SupersetClient with agent-critical methods + DDL/DML guard + tests (126 passed)
Ported from mcp-superset research module, integrated into existing async SupersetClient: New mixins (4 files): - safety.py: DDL/DML guard (13 keywords), comment/string stripping, viz_type validation - _sql_lab.py: execute_sql, format_sql, results, estimate, CSV export, query history - _saved_queries.py: saved queries CRUD (5 methods) - _audit.py: permissions audit matrix (user × dashboard × dataset × RLS) Extended mixins (4 files): - _dashboards_write.py: +create, +update (general), +copy, +publish, +unpublish - _dashboards_crud.py: +standalone get_dashboard_charts/datasets, +get_dashboard - _datasets.py: +create, +delete, +duplicate, +refresh_schema, +get_or_create, +export/import - _databases.py: +update, +test_connection, +schemas/tables/catalogs, +validate_sql, +select_star, +table_metadata FastAPI proxy (2 files): - agent_superset.py (284L): SQL Lab + Dashboards/Datasets write endpoints - agent_superset_explore.py (240L): DB explore + Audit + Saved Queries endpoints Agent tools (2 files): - tools.py: +7 LangChain @tools (24 total), intent-routing keywords - _tool_resolver.py: updated SAFE/GUARDED/FAST_CONFIRM classification sets Tests (3 files, 126 tests): - test_superset_safety.py (51): DDL/DML bypass/legitimate/safe scenarios - test_superset_extended.py (42): all mixin methods with mock AsyncAPIClient - test_superset_tools.py (33): agent tool registration, intent matching, @tool .ainvoke()
This commit is contained in:
@@ -23,6 +23,11 @@ _SAFE_AGENT_TOOLS = {
|
||||
"list_llm_providers",
|
||||
"get_llm_status",
|
||||
"list_maintenance_events",
|
||||
# NEW: read-only Superset tools
|
||||
"superset_execute_sql",
|
||||
"superset_explore_database",
|
||||
"superset_audit_permissions",
|
||||
"superset_format_sql",
|
||||
}
|
||||
_GUARDED_AGENT_TOOLS = {
|
||||
"create_branch",
|
||||
@@ -33,6 +38,10 @@ _GUARDED_AGENT_TOOLS = {
|
||||
"run_llm_documentation",
|
||||
"start_maintenance",
|
||||
"end_maintenance",
|
||||
# NEW: guarded Superset write operations
|
||||
"superset_create_dashboard",
|
||||
"superset_copy_dashboard",
|
||||
"superset_create_dataset",
|
||||
}
|
||||
_DANGEROUS_AGENT_TOOLS = {
|
||||
"deploy_dashboard",
|
||||
@@ -44,6 +53,9 @@ _FAST_CONFIRM_TOOLS = {
|
||||
"list_llm_providers",
|
||||
"get_llm_status",
|
||||
"list_maintenance_events",
|
||||
"superset_explore_database",
|
||||
"superset_audit_permissions",
|
||||
"superset_format_sql",
|
||||
}
|
||||
# #endregion AgentChat.ToolResolver.Sets
|
||||
|
||||
|
||||
Reference in New Issue
Block a user