aminghadersohi opened a new pull request, #37966:
URL: https://github.com/apache/superset/pull/37966
### SUMMARY
The AI chatbot didn't know who the current user was. When asked "what's the
chart I created most recently?", it queried all charts and assumed the user was
whoever created the top result (e.g., assumed Sophie was Antonio Rivero).
This PR adds:
1. **`current_user` field to `get_instance_info` response** - exposes
`g.user` identity (id, username, first_name, last_name, email) so the LLM knows
who it's talking to
2. **`created_by_fk` filter column** on `list_charts` and `list_dashboards`
- lets the LLM filter assets by creator
3. **Updated LLM instructions** - tells the chatbot to greet the user by
name and documents the workflow for finding own assets
4. **Fixed `parse_request` decorator bug** - was checking
`MCP_PARSE_REQUEST_ENABLED` at decoration time instead of call time, causing
string/dict parsing to silently fail
The LLM workflow becomes:
```
get_instance_info -> current_user.id -> list_charts(filters=[{col:
"created_by_fk", opr: "eq", value: <user_id>}])
```
No `list_users` tool needed (privacy). RBAC already limits results to
accessible assets.
[sc-98639]
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - backend/API only change
### TESTING INSTRUCTIONS
**QA Steps:**
1. **Verify current_user in get_instance_info:**
- Call `get_instance_info` via MCP client
- Confirm the response includes a `current_user` object with `id`,
`username`, `first_name`, `last_name`, `email`
- Verify the user info matches the authenticated user
2. **Verify created_by_fk filter on charts:**
- Call `list_charts` with filter `[{"col": "created_by_fk", "opr": "eq",
"value": <user_id>}]`
- Confirm only charts created by that user are returned
- Try with a different user ID and confirm different results
3. **Verify created_by_fk filter on dashboards:**
- Call `list_dashboards` with filter `[{"col": "created_by_fk", "opr":
"eq", "value": <user_id>}]`
- Confirm only dashboards created by that user are returned
4. **Verify LLM chatbot behavior:**
- Ask the chatbot "What's the most recent chart I created?"
- Confirm it calls `get_instance_info` first, identifies you correctly,
then filters charts by your user ID
- Confirm it does NOT assume you are a different user
5. **Verify invalid filter column is rejected:**
- Try `list_charts` with `col: "nonexistent_column"` and confirm it
returns a validation error
### ADDITIONAL INFORMATION
- [x] Has associated issue:
[sc-98639](https://app.shortcut.com/preset/story/98639)
- [ ] 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]