aminghadersohi opened a new pull request, #40356:
URL: https://github.com/apache/superset/pull/40356

   ### SUMMARY
   
   Adds a new `create_rls_filter` MCP mutation tool that allows AI assistants 
to create row-level security (RLS) filter rules in Apache Superset.
   
   RLS filters restrict which rows users can see based on their role 
membership. This tool enables programmatic creation of these access-control 
policies via the MCP service.
   
   **Key design decisions:**
   - Uses `CreateRLSRuleCommand` from `superset.commands.security.create` — 
same command used by the REST API `POST /api/v1/rowlevelsecurity/`
   - Admin-only: requires `Row Level Security` write permission 
(`class_permission_name="Row Level Security"`, `method_permission_name="write"`)
   - Tagged `mutate` with `readOnlyHint=False` following the mutation tool 
pattern
   - Located in `superset/mcp_service/rls/` following the existing module 
structure
   - Returns structured error response (not exception) for validation failures 
(role/table not found)
   
   **Supported filter types:**
   - `Regular`: Hides rows from specified roles unless the SQL clause matches
   - `Base`: Shows only rows where the SQL clause matches to specified roles
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — backend-only MCP tool.
   
   ### TESTING INSTRUCTIONS
   
   1. Start the Superset MCP server
   2. Connect an MCP client (e.g., Claude Desktop) with admin credentials
   3. Call `create_rls_filter` with:
      ```json
      {
        "name": "EMEA filter",
        "filter_type": "Regular",
        "tables": [<valid_table_id>],
        "roles": [<valid_role_id>],
        "clause": "region = 'EMEA'"
      }
      ```
   4. Verify the filter appears in Superset under Security → Row Level Security
   
   **Error cases to test:**
   - Invalid table ID → returns error field with 
`DatasourceNotFoundValidationError` message
   - Invalid role ID → returns error field with `RolesNotFoundValidationError` 
message
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to