feat(mcp): shared limits, truncation, list coercion and ToolError mapping
Merged
NW
4d ago+3852+3852+0123456789012345678901234567890123456789-153-153-012345678901234567890123456789
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-execution-helpers (the previous PR in the stack); review only its own commit. It changes only the shared datahub-core-mcp-tools package and datahub-ai-service. 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 ā this PR
- #21343
- #21344
- #21345
- #21346
- #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
Add the data helpers the tool ports build on.
- Size limits for tool output, overridable with the same environment
variables as mcp-server-datahub (DESCRIPTION_LENGTH_LIMIT,
QUERY_LENGTH_LIMIT, DOCUMENT_CONTENT_CHAR_LIMIT,
FIELD_DESCRIPTION_LENGTH_LIMIT, ...). A non-numeric or non-positive value
fails at startup with the variable's name. - truncate_with_ellipsis, including limits shorter than the suffix and a
"[+N chars]" marker. - arg_validation: StrList and friends accept a list that a client sent as
a JSON string or a bare value, while the published schema stays a single
array type ("" and "null" count as omitted). coerce_keyword_list also
splits comma-joined keywords. - execute_graphql raises ToolError with a message the model can act on
(rejected token, GMS unreachable, GraphQL errors); format_exception=False
keeps the SDK's raw GraphError for callers that act on error types.
datahub-ai-service's token check reuses its HTTP status helper.
Testing
Unit tests incl. published schema shape.
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