Skip to content

fix(mcp-apps-middleware): forward auth headers to HTTP and SSE transports (#1862)#1966

Open
NathanTarbert wants to merge 6 commits into
mainfrom
fix/issue-1862-mcp-http-headers
Open

fix(mcp-apps-middleware): forward auth headers to HTTP and SSE transports (#1862)#1966
NathanTarbert wants to merge 6 commits into
mainfrom
fix/issue-1862-mcp-http-headers

Conversation

@NathanTarbert

Copy link
Copy Markdown
Contributor

Fixes #1862

Root cause

MCPAppsMiddleware proxies tools/call / resources/read to MCP servers via transports built from MCPClientConfig. Two gaps:

  1. MCPClientConfigHTTP had no headers field, so HTTP/OAuth/header-protected MCP servers were unreachable.
  2. Even MCPClientConfigSSE.headers (which existed) was never wired — all three transport-construction sites called new SSEClientTransport(url) / new StreamableHTTPClientTransport(url) with no options.

Fix

  • Add optional headers?: Record<string, string> to MCPClientConfigHTTP.
  • Add a single buildMCPTransport(config) helper that forwards headers to both transports via requestInit, and use it at all three construction sites (de-duplicating the identical blocks).
  • Include headers in getServerHash for both transport types so header-differentiated servers hash distinctly.

Tests added

__tests__/mcp-apps-middleware.test.ts (transport mocks extended to capture constructor options):

  • HTTP transport receives { requestInit: { headers } }
  • SSE transport receives { requestInit: { headers } } (previously dead path)
  • no options passed when no headers configured
  • getServerHash distinguishes HTTP servers differing only by headers

The two transport-wiring tests fail against the pre-fix code and pass with the fix.

Checklist

  • Failing tests written and confirmed failing before fix
  • Fix applied, tests pass (68 passed)
  • Package builds (nx run @ag-ui/mcp-apps-middleware:build)
  • Prettier clean
  • Minimal change, scoped to the issue

@NathanTarbert NathanTarbert requested a review from a team as a code owner June 15, 2026 16:01
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ag-ui-dojo Error Error Jul 1, 2026 5:05pm

Request Review

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Python Preview Packages

Version 0.0.0.dev1784136172 published to TestPyPI.

Warning: These packages are built from contributor code that may not yet have been vetted for correctness or security. Install at your own risk and do not use in production.

Install with uv

Add the TestPyPI index to your pyproject.toml:

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = true

Then install the packages you need:

# Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1784136172' --index testpypi

# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1784136172' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1784136172' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1784136172' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1784136172' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1784136172' --index testpypi

Install with pip

pip install \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  ag-ui-protocol==0.0.0.dev1784136172

Use --extra-index-url https://pypi.org/simple/ so pip can resolve
transitive dependencies (pydantic, fastapi, etc.) from real PyPI.


Commit: 853917e

@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ag-ui/a2a-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a-middleware@1966

@ag-ui/a2ui-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-middleware@1966

@ag-ui/event-throttle-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/event-throttle-middleware@1966

@ag-ui/mcp-apps-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-apps-middleware@1966

@ag-ui/mcp-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-middleware@1966

@ag-ui/a2a

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a@1966

@ag-ui/adk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/adk@1966

@ag-ui/ag2

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/ag2@1966

@ag-ui/agno

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/agno@1966

@ag-ui/aws-strands

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/aws-strands@1966

@ag-ui/claude-agent-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-agent-sdk@1966

@ag-ui/crewai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/crewai@1966

@ag-ui/langchain

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langchain@1966

@ag-ui/langgraph

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langgraph@1966

@ag-ui/llamaindex

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/llamaindex@1966

@ag-ui/mastra

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mastra@1966

@ag-ui/pydantic-ai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/pydantic-ai@1966

@ag-ui/vercel-ai-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/vercel-ai-sdk@1966

@ag-ui/watsonx

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/watsonx@1966

@ag-ui/a2ui-toolkit

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-toolkit@1966

create-ag-ui-app

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/create-ag-ui-app@1966

@ag-ui/client

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/client@1966

@ag-ui/core

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/core@1966

@ag-ui/encoder

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/encoder@1966

@ag-ui/proto

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/proto@1966

commit: 8848187

AlemTuzlak
AlemTuzlak previously approved these changes Jul 1, 2026
…lse green

The "passes no transport options when no headers are configured" test
asserted only `mockHTTPTransportOpts[0]` toBeUndefined, which also holds
when the HTTP transport is never constructed — a false green. Added
`expect(mockHTTPTransportCalls).toHaveLength(1)` (matching its sibling
tests at line 563) so the test proves the transport WAS built and built
with no options.

Call sites: mockHTTPTransportCalls (test-only spy array) — reset in
beforeEach, asserted-only; no production symbols changed.
@NathanTarbert NathanTarbert requested a review from AlemTuzlak July 15, 2026 13:07
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.

MCPClientConfigHTTP has no auth field — middleware can't reach OAuth/header-protected MCP servers (SSE config has headers, HTTP doesn't)

2 participants