Skip to content

MCP use JWT token authen failed g.user not found #41610

Closed

Description

@cw1427

Bug description

I have successfuly start mcp and setup the mcp client via cline. which could fetcht eh mcp tools info as below successfully with the user's access_token. But when ask to execute the SQL have error response the g.user not found.

`Error: Error calling tool 'execute_sql': No authenticated user found. Tried:

  • g.user was not set by JWT middleware (MCP_AUTH_ENABLED=True, JWT keys configured=True)
  • MCP_DEV_USERNAME is not configured

Either pass a valid JWT bearer token or configure MCP_DEV_USERNAME for development.
2026-07-01 06:13:55,068:ERROR:superset.mcp_service.auth:MCP user resolution failed, denying request: No authenticated user found. Tried:

  • g.user was not set by JWT middleware (MCP_AUTH_ENABLED=True, JWT keys configured=True)
  • MCP_DEV_USERNAME is not configured

Either pass a valid JWT bearer token or configure MCP_DEV_USERNAME for development.
[07/01/26 06:13:55] Error calling tool 'execute_sql'
╭─────────── Traceback (most recent call last) ────────────╮
│ /usr/local/lib/python3.10/site-packages/fastmcp/server/s │
│ erver.py:1282 in call_tool │
│ │
│ /usr/local/lib/python3.10/site-packages/fastmcp/tools/ba │
│ se.py:392 in _run │
│ │
│ ... 2 frames hidden ... │
│ │
│ /usr/local/lib/python3.10/site-packages/superset/mcp_ser │
│ vice/auth.py:309 in _setup_user_context │
│ │
│ 306 │ │
│ 307 │ for attempt in range(2): │
│ 308 │ │ try: │
│ ❱ 309 │ │ │ user = get_user_from_request() │
│ 310 │ │ │ │
│ 311 │ │ │ # Validate user has necessary relation │
│ 312 │ │ │ # Force access to ensure they're loade │
│ │
│ /usr/local/lib/python3.10/site-packages/superset/mcp_ser │
│ vice/auth.py:213 in get_user_from_request │
│ │
│ 210 │ │ │ f"JWT keys configured={jwt_configured} │
│ 211 │ │ ) │
│ 212 │ │ details.append("MCP_DEV_USERNAME is not co │
│ ❱ 213 │ │ raise ValueError( │ │ 214 │ │ │ "No authenticated user found. Tried:\n │ │ 215 │ │ │ + "\n".join(f" - {d}" for d in detail │ │ 216 │ │ │ + "\n\nEither pass a valid JWT bearer │ ╰──────────────────────────────────────────────────────────╯ ValueError: No authenticated user found. Tried: - g.user was not set by JWT middleware (MCP_AUTH_ENABLED=True, JWT keys configured=True) - MCP_DEV_USERNAME is not configured Either pass a valid JWT bearer token or configure MCP_DEV_USERNAME for development. 2026-07-01 06:13:55,130:ERROR:superset.mcp_service.middleware:MCP tool error: tool=execute_sql, user_id=None, duration_ms=62, error_type=ToolError, error=Error calling tool 'execute_sql': No authenticated user found. Tried: - g.user was not set by JWT middleware (MCP_AUTH_ENABLED=True, JWT keys configured=True) - MCP_DEV_USERNAME is not configured Either pass a valid JWT bearer Token: [REDACTED] configure MCP_DEV_USERNAME for development. 2026-07-01 06:13:55,131:WARNING:superset.mcp_service.middleware:Failed to log error event: DBEventLogger.log() missing 3 required positional arguments: 'dashboard_id', 'slice_id', and 'referrer'
`

Mcp server was successfully started:

docker: entrypoint.sh script to start the mcp and superset
if [ "$SUPERSET_ENV" = "prod" ]; then
# Start superset worker for SQL Lab
celery --app=superset.tasks.celery_app:app worker -f /home/superset/log/celery_worker1.log -Ofair -nworker1 -c 4 -Q celery,thumbnails,reports &
celery --app=superset.tasks.celery_app:app worker -f /home/superset/log/celery_worker2.log -Ofair -nworker2 -c 4 -Q celery,thumbnails,reports &
celery --app=superset.tasks.celery_app:app beat -f /home/superset/log/celery_beat.log -s /home/superset/log/celerybeat-schedule &
celery --app=superset.tasks.celery_app:app flower --basic-auth=fadm:${FLOWER_PWD} &
superset mcp run --host 0.0.0.0 --port 5008 > /home/superset/log/mcp_server.log 2>&1 &
echo Started Celery workers[worker1, worker2] mcp server and Flower UI.

# Start the prod web server
gunicorn -w 10 -k gevent --timeout 600 -b  0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 "superset.app:create_app()"

026-07-01 06:11:34,339:INFO:httpx:HTTP Request: GET https://pypi.org/pypi/fastmcp/json "HTTP/1.1 200 OK"

╭──────────────────────────────────────────────────────────────────────────────╮
│ │
│ │
│ ▄▀▀ ▄▀█ █▀▀ ▀█▀ █▀▄▀█ █▀▀ █▀█ │
│ █▀ █▀█ ▄▄█ █ █ ▀ █ █▄▄ █▀▀ │
│ │
│ │
│ │
│ FastMCP 3.4.2 │
│ https://gofastmcp.com │
│ │
│ 🖥 Server: Mozart MCP Server, 3.4.2 │
│ 🚀 Deploy free: https://horizon.prefect.io │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯

[07/01/26 06:11:34] INFO Starting MCP server 'Mozart MCP transport.py:304
Server' with transport
'streamable-http' (stateless) on
http://0.0.0.0:5008/mcp
INFO: Started server process [90]
INFO: Waiting for application startup.
2026-07-01 06:11:34,368:INFO:mcp.server.streamable_http_manager:StreamableHTTP session manager started
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:5008 (Press CTRL+C to quit)
"mcp_server.log" 477L, 44759C

Screenshots/recordings

Image

mcp client connected successfully, but ask execute sql got g.user not found error

Superset version

6.1.0

Python version

3.10

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • 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.

Activity

  1. added
    sqllabNamespace | Anything related to the SQL Lab
    on Jul 1, 2026
  2. rusackas commented on Jul 1, 2026

    @rusackas
    Member

    @aminghadersohi might be able to help here, but I'm wondering if this is actually a Superset bug (requiring a fix PR) or if this is a config issue and should be moved to a GitHub Discussion.

  3. linchangyang-sg commented on Jul 6, 2026

    @linchangyang-sg

    the problem is even the user got authenticated, the fast_mcp is still using MCP_DEV_USERNAME as g.user. If you didn't set MCP_DEV_USERNAME, it's null.
    otherwise you need to extract the g.user from the request of fast_mcp to superset. With the help of Claude, we patched it with ContextVar.

  4. lp-jump commented on Jul 25, 2026

    @lp-jump

    mcp_service/mcp_config.py:default_user_resolver is defined but never called, and
    MCP_USER_RESOLVER is referenced nowhere. mcp_service/auth.py:get_user_from_request()
    reads a pre-set g.user — populated only by Preset's hosted WorkspaceContextMiddleware, which OSS
    does not ship — and otherwise falls back to MCP_DEV_USERNAME. Unset that and every tool call
    fails with No authenticated user found.

  5. rusackas commented on Jul 29, 2026

    @rusackas
    Member

    The user-resolution path here has had a substantial rework since this was filed, after @lp-jump's most recent comment.

    _resolve_user_from_jwt_context resolves via FastMCP's per-request JWT context now instead of g.user, and MCP_USER_RESOLVER/default_user_resolver are wired up and in active use on master, not dead code.

    Closing this out, but if you're still hitting the original error on a current master build, let us know and we'll reopen this, no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationRelated to authenticationsqllabNamespace | Anything related to the SQL Labvalidation:requiredA committer should validate the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions