Skip to content

Conversation

@gkrdy
Copy link
Contributor

@gkrdy gkrdy commented Dec 23, 2025

  • Add headersJson field to mcp_servers schema
  • Update TypeScript types to include headersJson
  • Add HTTP Headers editor UI (reusing EnvVarsEditor component)
  • Pass headers to StreamableHTTPClientTransport via requestInit
  • Generate database migration for headers_json column

Fixes #1609


Summary by cubic

Add per-server HTTP headers for HTTP-based MCP servers so requests can include auth or custom headers. Includes settings UI, schema updates, and runtime support; fixes #1609.

  • New Features

    • Headers editor in MCP settings for HTTP servers (uses the same editor UI as env vars).
    • Persist headers in mcp_servers.headers_json; IPC and TypeScript types updated.
    • Send headers via StreamableHTTPClientTransport using requestInit.headers.
  • Migration

    • Run database migrations to add headers_json to mcp_servers.

Written for commit 15ffed8. Summary will update on new commits.


Note

Introduces configurable HTTP headers for HTTP-transport MCP servers, wired end-to-end across DB, IPC, UI, and runtime.

  • Schema & Types: Add headers_json to mcp_servers (migration 0021), update Drizzle schema and IPC types/handlers to persist and update headers
  • Runtime: Forward saved headers to StreamableHTTPClientTransport via requestInit.headers
  • UI: Refactor env var editor into generic KeyValueEditor; add "Headers" editor for HTTP servers and keep env vars for stdio
  • Tests & Dev tools: New e2e test that spawns a fake HTTP MCP server requiring Authorization; add server script, README, and snapshot

Written by Cursor Bugbot for commit 15ffed8. This will update automatically on new commits. Configure here.

- Add headersJson field to mcp_servers schema
- Update TypeScript types to include headersJson
- Add HTTP Headers editor UI (reusing EnvVarsEditor component)
- Pass headers to StreamableHTTPClientTransport via requestInit
- Generate database migration for headers_json column

Fixes dyad-sh#1609
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 9 files

@wwwillchen
Copy link
Collaborator

@BugBot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

Copy link
Collaborator

@wwwillchen wwwillchen left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Could you add an e2e test case? You can see our existing mcp test here: https://github.com/dyad-sh/dyad/blob/main/e2e-tests/mcp.spec.ts

info on e2e tests: https://github.com/dyad-sh/dyad/blob/main/CONTRIBUTING.md#testing

if you can also rebase, i'll kick off the CI run. thanks!

{s.transport === "http" && (
<div className="mt-3">
<div className="text-sm font-medium mb-2">Headers</div>
<EnvVarsEditor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's rename this component to KeyValueEditor since we're using it for both env and headers.

<div className="text-sm font-medium mb-2">Headers</div>
<EnvVarsEditor
serverId={s.id}
envJson={s.headersJson}
Copy link
Collaborator

Choose a reason for hiding this comment

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

just call this json

<div className="mt-3">
<div className="text-sm font-medium mb-2">Headers</div>
<EnvVarsEditor
serverId={s.id}
Copy link
Collaborator

Choose a reason for hiding this comment

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

just id?

Copy link
Contributor Author

@gkrdy gkrdy Dec 27, 2025

Choose a reason for hiding this comment

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

I will update PR shortly with the suggested changes

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

This PR adds support for custom HTTP headers to HTTP-based MCP servers, enabling authentication and custom header configuration. The implementation follows the repository's established patterns for IPC, database schema, and UI components.

Key Changes:

  • Database migration adds headers_json column to mcp_servers table
  • TypeScript types updated to include headersJson field across McpServer, CreateMcpServer, and McpServerUpdate interfaces
  • IPC handlers (mcp:create-server and mcp:update-server) persist headers to database
  • UI generalized EnvVarsEditor to KeyValueEditor for reuse with both environment variables and headers
  • Headers editor shown only for HTTP transport servers
  • Runtime passes headers to StreamableHTTPClientTransport via requestInit.headers
  • Comprehensive e2e test validates Authorization header functionality with mock HTTP server

Implementation Quality:
The PR demonstrates good software engineering practices: proper type safety, code reuse through component generalization, thorough testing with a dedicated mock server, and consistent adherence to the existing IPC patterns documented in the repository guidelines.

Confidence Score: 5/5

  • This PR is safe to merge with no blocking issues
  • Clean implementation with proper type safety, database migration, comprehensive testing, and adherence to repository patterns. All changes are focused and well-integrated across the stack (DB → IPC → UI → runtime).
  • No files require special attention

Important Files Changed

Filename Overview
src/db/schema.ts Adds headersJson field to mcpServers schema with proper typing as nullable JSON
src/ipc/handlers/mcp_handlers.ts Updates create and update handlers to persist headersJson field to database
src/ipc/utils/mcp_manager.ts Passes stored headers to StreamableHTTPClientTransport via requestInit.headers
src/components/settings/ToolsMcpSettings.tsx Refactors EnvVarsEditor to KeyValueEditor for reuse; adds Headers editor for HTTP transport servers
e2e-tests/mcp.spec.ts Adds comprehensive test for HTTP transport with Authorization header validation

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as ToolsMcpSettings
    participant IPC as IpcClient
    participant Handler as mcp_handlers
    participant DB as Database
    participant Manager as McpManager
    participant Transport as StreamableHTTPClientTransport
    participant Server as HTTP MCP Server

    User->>UI: Configure HTTP MCP server
    User->>UI: Add Authorization header
    UI->>UI: Parse headers with arrayToJsonObject
    UI->>IPC: updateServer({id, headersJson})
    IPC->>Handler: mcp:update-server
    Handler->>DB: UPDATE mcp_servers SET headers_json
    DB-->>Handler: Success
    Handler-->>IPC: Updated server
    IPC-->>UI: Success
    UI->>User: Show success toast

    Note over User,Server: Later: Using the MCP server

    User->>UI: Send prompt requiring tool
    UI->>Manager: getClient(serverId)
    Manager->>DB: SELECT * FROM mcp_servers WHERE id
    DB-->>Manager: Server config with headersJson
    Manager->>Manager: Extract headers from headersJson
    Manager->>Transport: new StreamableHTTPClientTransport(url, {requestInit: {headers}})
    Transport-->>Manager: Transport instance
    Manager->>Transport: experimental_createMCPClient({transport})
    Transport->>Server: POST /message (with Authorization header)
    Server-->>Transport: JSON-RPC response
    Transport-->>Manager: MCP client
    Manager-->>UI: Client ready
    UI->>User: Execute tool call
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. src/db/schema.ts, line 219-222 (link)

    logic: Migration file deleted in commit 0cc53d1. The headers_json column requires a migration (drizzle/0019_thin_union_jack.sql was removed). Run npm run db:generate and restore the migration, or users will encounter runtime errors when the schema doesn't match the database.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@wwwillchen
Copy link
Collaborator

@BugBot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

🎭 Playwright Test Results

❌ Some tests failed

OS Passed Failed Flaky Skipped
🍎 macOS 230 1 2 75
🪟 Windows 229 3 1 75

Summary: 459 passed, 4 failed, 3 flaky, 150 skipped

Failed Tests

🍎 macOS

  • version_integrity.spec.ts > version integrity (git native)
    • Error: expect(string).toMatchSnapshot(expected) failed

🪟 Windows

  • context_manage.spec.ts > manage context - smart context
    • Error: expect(string).toMatchSnapshot(expected) failed
  • context_manage.spec.ts > manage context - smart context - auto-includes only
    • Error: expect(string).toMatchSnapshot(expected) failed
  • supabase_migrations.spec.ts > supabase migrations
    • Error: ENOENT: no such file or directory, scandir 'C:\Users\RUNNER~1\AppData\Local\Temp\dyad-e2e-tests-1767382965564\dyad-apps\bright-narwhal-soar\sup...

⚠️ Flaky Tests

🍎 macOS

  • setup.spec.ts > setup ai provider (passed after 1 retry)
  • visual_editing.spec.ts > edit style of one selected component (passed after 1 retry)

🪟 Windows

  • setup.spec.ts > setup ai provider (passed after 1 retry)

📊 View full report

await po.selectChatMode("agent");
// Wait for chat input to be ready
await po.getChatInput().waitFor({ state: "visible" });
await po.sendPrompt("[call_tool=calculator_add_2]", {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't think this e2e test is actually calling the MCP server - i don't see the MCP consent dialog being shown when i run it locally.

see

lastMessage.content.includes("[call_tool=calculator_add]")

@wwwillchen wwwillchen closed this Jan 21, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add headers to http MCP settings

2 participants