MCP tool error: DetachedInstanceError on PermissionView in list_dashboards (user_id=None)
- Dominant language
- Python
- Stars
- 74.8k
- Forks
- 18.3k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 685
Description
### Bug description
Error:
DetachedInstanceError: Parent instance
is not bound to a Session; lazy load of 'permission' cannot proceed
Also: DBEventLogger.log() missing 3 required positional arguments
Context:
- tool=list_dashboards
- user_id=None (possible auth/session issue)
- mcp_service/middleware logs the error but secondary logger also fails
### Screenshots/recordings
```
❯ export SUPERSET_MCP_TOKEN='xxxx'
❯ SESSION_ID=$(
curl -sS -D - \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-H "Authorization: Bearer $SUPERSET_MCP_TOKEN" \
-X POST 'https://xxxx/mcp' \
--data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"clientInfo":{"name":"curl","version":"1.0.0"}}}' \
| awk '/^Mcp-Session-Id:/ {print $2}' | tr -d '\r'
)
❯ curl -sS \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-H "Authorization: Bearer $SUPERSET_MCP_TOKEN" \
-H "Mcp-Session-Id: $SESSION_ID" \
-X POST 'https://xxxx/mcp' \
--data '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_dashboards","arguments":{"request":{"page":1}}}}'
event: message
data: {"method":"notifications/message","params":{"level":"info","data":{"msg":"Listing dashboards: page=1, page_size=10, search=None","extra":null}},"jsonrpc":"2.0"}
event: message
data: {"method":"notifications/message","params":{"level":"debug","data":{"msg":"Dashboard listing filters: filters=0, order_column=None, order_direction=asc","extra":null}},"jsonrpc":"2.0"}
event: message
data: {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"Error: Internal error in list_dashboards: An unexpected error occurred. Error ID: err_1779738544. Please contact support if this persists."}],"isError":false}}
```
### Superset version
6.1.0
### Python version
3.9
### Node version
Not applicable
### Browser
Not applicable
### Additional context
Docker image:
```
FROM apache/superset:6.1.0
USER root
RUN apt update && apt install -y gcc libpq-dev python3-dev pkg-config default-libmysqlclient-dev && apt clean && rm -rf /var/lib/apt/lists/*
RUN uv pip install psycopg2-binary mysqlclient clickhouse-connect fastmcp
```
mcp_config:
```
import os
MCP_SERVICE_HOST = "0.0.0.0"
MCP_SERVICE_PORT = 5008
MCP_SERVICE_URL = "https://xxxxx"
MCP_AUTH_ENABLED = True
MCP_JWT_ALGORITHM = "HS256"
MCP_JWT_SECRET = os.environ.get("MCP_JWT_SECRET")
MCP_JWT_ISSUER = "xxx"
MCP_JWT_AUDIENCE = "superset-mcp"
MCP_DEV_USERNAME = os.environ.get("MCP_DEV_USERNAME")
MCP_STORE_CONFIG = {
"enabled": True,
"CACHE_REDIS_URL": "redis://superset-redis-headless:6379/1",
"event_store_max_events": 100,
"event_store_ttl": 3600,
}
```
Logs:
```
[superset-mcp-7d5d9894c4-dlljf] 2026-05-25T19:32:10.650358183Z 2026-05-25 19:32:10,650:ERROR:superset.mcp_service.middleware:Unexpected error [err_1779737530] in list_dashboards: Parent instance is not bound to a Session; lazy load operation of attribute 'permission' cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3)
[superset-mcp-7d5d9894c4-dlljf] 2026-05-25T19:32:10.665464304Z 2026-05-25 19:32:10,665:INFO:superset.mcp_service.middleware:MCP tool call: tool=list_dashboards, agent_id=None, user_id=None, method=tools/call, dashboard_id=None, slice_id=None, dataset_id=None, duration_ms=70, success=False
```
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Contributor guide
Assessment
This issue has not been assessed yet.