feat(ai): follow GMS's auth mode on /mcp
Closed
NW
4d ago+2738+2738+0123456789012345678901234567890123456789-124-124-012345678901234567890123456789
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--gms-config-auth-enabled (the previous PR in the stack); review only its own commit. This PR changes GMS, the frontend, Docker or CI, not only the new Python packages. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).
Stack so far:
- #21332
- #21333
- #21334
- #21335
- #21336
- #21337
- #21338
- #21339
- #21340
- #21341
- #21342
- #21343
- #21344
- #21345
- #21346 ā this PR
- #21347
- #21348
- #21349
- #21350
- #21351
- #21352
- #21353
- #21435
- #21436
- #21437
- #21438
- #21439
- #21440
- #21441
- #21442
- #21443
- #21444
- #21445
- #21447
- #21501
- #21502
- #21503
- #21504
- #21505
- #21506
- #21507
- #21508
- #21509
- #21510
- #21511
- #21512
What this does
datahub-ai-service now reads whether GMS requires authentication instead of always
demanding a token, so quickstart clients (GMS auth off) connect with the
URL alone.
- The mode comes from /config's authentication.enabled, refreshed every
60 s. A GMS without the field is probed once a minute with an
unauthenticated GraphQLme: 401/403 means on, a well-formed answer
naming a user means off, anything else (errors, odd bodies, no answer)
is unknown and asked again. - Auth on: a PAT is required and checked as before (401 when missing or
rejected). Auth off: no token is needed; any header is passed to GMS as
is and requests run as the system user. Unknown: 503. - DATAHUB_AI_AUTH_MODE=required serves /mcp only while GMS auth is on;
with auth off it answers 503 with how to fix it, since GMS then can't
check a token. - Cached token verdicts are dropped when the mode changes, and a token's
verdict is dropped when GMS answers 401/403 to one of its calls. - /health reports the last mode seen and whether /mcp is available, for
the settings page; get_me says when auth is off instead of warning about
a nonexistent user. GmsServerInfo gains auth_enabled.
Testing
Live: probe path with auth on; flip to off picked up without restart; Claude Code with no token.
Checklist
- The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
- Tests for the changes have been added/updated (if applicable)
- Docs related to the changes have been added/updated (if applicable). The MCP docs come later in the stack.
- For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. The release notes come later in the stack.
š¤ Generated with Claude Code