Skip to main content

datahub-ai-service

DataHub's AI service. It serves DataHub's MCP tools (from datahub-core-mcp-tools) over streamable HTTP at /mcp, and an unauthenticated /health probe.

Authentication follows GMS. When GMS auth is on (METADATA_SERVICE_AUTH_ENABLED=true), every MCP request carries its caller's DataHub personal access token as Authorization: Bearer <token>; the service checks it with GMS and calls DataHub as that caller. When GMS auth is off, no token is needed and requests run as DataHub's system user, as direct calls to GMS do. The service never holds a shared or system credential. While GMS can't be reached, or its auth mode can't be told, /mcp answers 503.

While GMS auth is off, anyone who reaches /mcp acts as the system user, so /mcp answers only requests addressed to an allowed host (DATAHUB_AI_ALLOWED_HOSTS) and, when they carry an Origin, from an allowed origin (DATAHUB_AI_ALLOWED_ORIGINS). This stops a web page from reaching /mcp through DNS rebinding; it is not authentication. Behind the DataHub frontend, set DATAHUB_AI_TRUSTED_PROXIES to the frontend so its X-Forwarded-Host is believed.

/health reports the auth mode it last saw, for status pages and debugging.

Run​

export DATAHUB_GMS_URL=http://localhost:8080
datahub-ai-service serve

Then point an MCP client at http://localhost:9005/mcp, for example:

claude mcp add --transport http datahub http://localhost:9005/mcp \
--header "Authorization: Bearer <personal access token>"

Or run the image (docker/datahub-ai-service/Dockerfile, built with ./gradlew :packages:datahub-ai-service:docker):

docker run -p 9005:9005 -e DATAHUB_GMS_URL=http://host.docker.internal:8080 acryldata/datahub-ai-service:head

The image runs as a non-root user and reports health from /health. Its third-party dependencies are locked in docker/datahub-ai-service/requirements.lock; regenerate it with ./gradlew :packages:datahub-ai-service:lockfileUpdate.

Configuration​

VariableDefaultMeaning
DATAHUB_GMS_URLrequiredGMS base URL; may include a path prefix
DATAHUB_AI_HOST0.0.0.0Interface to listen on
DATAHUB_AI_PORT9005Port to listen on
DATAHUB_AI_MCP_ENABLEDtrueServe MCP at /mcp
DATAHUB_AI_MCP_RESPONSE_MODEssesse streams responses; json returns one body
DATAHUB_AI_AUTH_MODEautoauto follows GMS; required serves /mcp only while GMS auth is on
DATAHUB_AI_ALLOWED_HOSTSlocalhost,127.0.0.1,[::1]Hosts /mcp answers while GMS auth is off (host or host:port)
DATAHUB_AI_ALLOWED_ORIGINShttp(s):// those hostsOrigins /mcp accepts while GMS auth is off (scheme://host[:port])
DATAHUB_AI_TRUSTED_PROXIESnoneIPs, networks or hostnames whose X-Forwarded-Host is believed
DATAHUB_MCP_TOKEN_CACHE_TTL_SECONDS300How long a verified token is trusted before checking again
DATAHUB_AI_GMS_TIMEOUT_SECONDS30Connect and read timeout for each GMS request
DATAHUB_AI_TOOL_TIME_LIMIT_SECONDS300How long one tool call may keep sending requests to GMS

DATAHUB_GMS_TOKEN is refused: each caller sends their own token.

Requests to GMS are retried only when GMS never ran them (a refused connection or a 429), so a write is never applied twice.

Use json only behind proxies that can't stream responses, and give them idle timeouts longer than the slowest tool call.

Development​

../../gradlew :packages:datahub-ai-service:lintFix
../../gradlew :packages:datahub-ai-service:lint
../../gradlew :packages:datahub-ai-service:testQuick