Skip to content

fix(ai): Accept header for docs-tools MCP endpoint#1334

Merged
N2D4 merged 5 commits intodevfrom
fix/ai-docs-tools-accept-header
Apr 15, 2026
Merged

fix(ai): Accept header for docs-tools MCP endpoint#1334
N2D4 merged 5 commits intodevfrom
fix/ai-docs-tools-accept-header

Conversation

@mantrakp04
Copy link
Copy Markdown
Collaborator

@mantrakp04 mantrakp04 commented Apr 14, 2026

Summary

Production requests to https://mcp.stack-auth.com/api/internal/docs-tools were returning 406 with Not Acceptable: Client must accept both application/json and text/event-stream because postDocsToolAction only set Content-Type.

Change

Set Accept: application/json, text/event-stream on the fetch to match the MCP-style JSON-RPC handler.

Testing

  • Verified against mcp.stack-auth.com: without this header → 406; with it → request passes Accept validation (no longer 406).

Made with Cursor

Summary by CodeRabbit

  • Refactor
    • Updated API request handling to improve content negotiation for doc tools responses, enabling support for multiple response formats.

The internal docs-tools URL on mcp.stack-auth.com validates Accept and
returns 406 unless the client advertises both application/json and
text/event-stream. Add the combined Accept header to postDocsToolAction
so AI documentation tools work in production.

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 14, 2026 02:39
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
3 Building Building Preview, Comment Apr 15, 2026 4:36am
3-1776188452445-5Jus Canceled Canceled Apr 15, 2026 4:36am
stack-auth-hosted-components Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-backend Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-dashboard Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-demo Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-docs Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-preview-backend Ready Ready Preview, Comment Apr 15, 2026 4:36am
stack-preview-dashboard Ready Ready Preview, Comment Apr 15, 2026 4:36am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ca9fe64-39dd-4baf-96f2-a091b112b386

📥 Commits

Reviewing files that changed from the base of the PR and between f78b60b and 13ec595.

📒 Files selected for processing (1)
  • apps/backend/src/lib/ai/tools/docs.ts

📝 Walkthrough

Walkthrough

An HTTP POST request to the docs-tools API endpoint now includes an Accept header alongside Content-Type, indicating the client can handle both JSON and server-sent event responses for improved content negotiation.

Changes

Cohort / File(s) Summary
Accept Header Addition
apps/backend/src/lib/ai/tools/docs.ts
Added Accept header to HTTP POST request advertising support for application/json and text/event-stream response types.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • N2D4

Poem

🐰 A header hops in with grace,
Accept and Content-Type embrace,
JSON flows or streams take flight,
Client speaks its appetite so bright! 📡

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: adding an Accept header to the docs-tools MCP endpoint, which is the primary fix in this pull request.
Description check ✅ Passed The description is well-structured with clear sections (Summary, Change, Testing) that explain the problem, solution, and verification, though it exceeds the minimal template requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ai-docs-tools-accept-header

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 14, 2026

Greptile Summary

Adds the Accept: application/json, text/event-stream header to the postDocsToolAction fetch call, fixing a 406 response from the MCP-style JSON-RPC endpoint at mcp.stack-auth.com that validates clients declare support for both content types. The change is minimal and correctly targets the root cause.

Confidence Score: 5/5

  • This PR is safe to merge — it's a one-line targeted fix for a production 406 error with no side effects.
  • The change is minimal, well-reasoned, and directly addresses the root cause. The server validates the Accept header but continues to return JSON, so the existing res.json() parsing remains correct. No new logic paths, no regressions.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/backend/src/lib/ai/tools/docs.ts Adds Accept: "application/json, text/event-stream" header to the internal docs-tools fetch call, fixing a 406 Not Acceptable error from the MCP-style JSON-RPC endpoint that validates this header.

Sequence Diagram

sequenceDiagram
    participant AI as AI Tool (docs.ts)
    participant MCP as mcp.stack-auth.com<br/>/api/internal/docs-tools

    Note over AI,MCP: Before fix
    AI->>MCP: "POST /api/internal/docs-tools<br/>Content-Type: application/json"
    MCP-->>AI: "406 Not Acceptable<br/>(missing Accept header)"

    Note over AI,MCP: After fix
    AI->>MCP: "POST /api/internal/docs-tools<br/>Content-Type: application/json<br/>Accept: application/json, text/event-stream"
    MCP-->>AI: 200 OK (JSON response)
    AI->>AI: res.json() → DocsToolHttpResult
Loading

Reviews (1): Last reviewed commit: "fix(ai): send Accept header for docs-too..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes production 406 responses from the docs-tools MCP endpoint by aligning the backend HTTP client’s Accept header with the MCP server’s content-negotiation requirements.

Changes:

  • Add Accept: application/json, text/event-stream to the postDocsToolAction fetch request so requests pass MCP Accept validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mantrakp04 mantrakp04 requested a review from N2D4 April 15, 2026 04:32
@N2D4 N2D4 merged commit 74f2df9 into dev Apr 15, 2026
30 of 33 checks passed
@N2D4 N2D4 deleted the fix/ai-docs-tools-accept-header branch April 15, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants