docs(changelog): MCP server API token auth for headless and CI use#152
docs(changelog): MCP server API token auth for headless and CI use#152samgutentag wants to merge 1 commit into
Conversation
Add changelog entry for the Trunk MCP server accepting a Trunk org API token via the Authorization: Bearer header as an alternative to OAuth. Source eng PR: trunk-io/trunk2#3381 (merged 2026-04-08) Linear: TRUNK-18215 (no absorbed duplicates) Date basis: eng PR mergedAt Wired into all four sites: - changelog/2026-04-08-flaky-tests-mcp-api-token-auth.mdx (new entry) - docs.json (Changelog 2026 group) - changelog/index.mdx (April 2026) - flaky-tests/changelog.mdx (new April 2026 section) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Verification status (2026-05-29): Eng PR not merged. Hold.
Next: hold in draft. Re-run once #3918 merges and rolls out. (Prior verdict |
|
Code verification (2026-05-28): 5 confirmed / 0 contradicted / 0 ambiguous / 0 unverifiable All claims verified against the merged source in trunk2#3381 (
No contradictions. The entry's "API token" naming matches source exactly; the source never uses "API key" for this path. Source #1 — Authorization: Bearer header (confirmed)File: // Extract Bearer token from Authorization header
const authorizationHeader = request.header("Authorization");
if (!authorizationHeader) {
return unauthorized("Missing Authorization Header");
}
const [scheme = "", token] = authorizationHeader.split(" ");
if (!/^Bearer$/i.test(scheme) || !token) {
return unauthorized("Invalid Authorization Header");
}Reasoning: The server reads the Source #2 — org API token, not API key (confirmed)File: // Try to authenticate using an organization API token.
async function tryApiTokenAuth(
token: string,
): Promise<{ organizationId: string; orgSlug: string } | undefined> {
const servicesClient = await servicesPrismaClient();
const org = await servicesClient.organization.findFirst({
where: { DebuggerApiToken: token },Reasoning: The token is looked up against the Source #3 — JWT first, then API token fallback (confirmed)File: // Not a JWT at all (e.g., an API token) — fall through to API token lookup
if (
error instanceof jose.errors.JOSEError &&
error.message.includes("Invalid Compact JWS")
) {
// Step 2: Try API token authentication
const apiTokenResult = await tryApiTokenAuth(token);
if (apiTokenResult) {
return next(request, {
authMethod: "api-token",Reasoning: OAuth JWT verification runs first; only when the token fails JWT parsing ( Source #4 — endpoint URL (confirmed)File: {
"mcpServers": {
"trunk": {
"url": "https://mcp.trunk.io/mcp",
"headers": { "Authorization": "Bearer <your-trunk-api-token>" }
}
}
}Reasoning: The README's API-token client config block (added in this PR) matches the entry's JSON example verbatim, including the |
|
On hold until the MCP auth follow-up lands: trunk-io/trunk2#3918 ( The API-token auth path this entry documents is merged and live, but #3918 corrects how the server responds to malformed/unknown bearer tokens. Holding publication of this changelog entry until that fix is in production so the documented behavior matches. Re-run |
|
Verification status (May 30, 2026): Eng PR not merged. Hold.
Keep in draft. Re-run once trunk2#3918 is confirmed merged and the corrected 401 behavior is in production. Generated by Claude Code |
|
Verification status (May 31, 2026): The corresponding eng fix is still open; docs cannot merge until the feature ships.
Next action: wait for trunk2#3918 to merge, then re-verify and merge. Generated by Claude Code |
|
Verification status (June 1, 2026): Eng PR not merged. Hold.
Next: keep in draft. Re-run once trunk2#3918 merges and the corrected behavior is in production. PR is conflicting (shared changelog nav files); conflicts handled separately, not part of this verdict. Generated by Claude Code |
What shipped
The Trunk MCP server now accepts a Trunk organization API token via the standard
Authorization: Bearer <token>header as an alternative to OAuth. OAuth stays the default for interactive clients; the API token path covers CI jobs, scripts, and any client without an OAuth flow. The server tries the OAuth (JWT) path first, then falls back to looking the token up as an org API token, authenticating at the org level.Source
Four wired sites
changelog/2026-04-08-flaky-tests-mcp-api-token-auth.mdx— new entrydocs.json— added to the Changelog 2026 group (between 04-13 and 03-27)changelog/index.mdx— new<Update>under April 2026flaky-tests/changelog.mdx— new April 2026 section with the same<Update>Notes
Authorization: Bearer <token>against trunk2#3381.flaky-tests/reference/mcp-reference/. The feature itself is product-neutral (MCP tools span Flaky Tests setup, fix-flaky, framework detection), but Flaky Tests is the right home for now.🤖 Generated with Claude Code