[PR #24760] feat: add MCP server headers support #22718 #30777

Closed
opened 2026-02-21 20:48:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24760

State: closed
Merged: Yes


Summary

This PR adds support for custom HTTP headers in MCP (Model Context Protocol) tool providers, allowing users to configure additional authentication or configuration headers when connecting to MCP servers. This enhancement improves the flexibility of MCP tool integration by supporting various authentication methods and server-specific requirements.

close https://github.com/langgenius/dify/issues/22718

Key Changes

  • Backend API Enhancement: Added headers parameter support in MCP tool provider creation and update endpoints
  • Database Schema Update: Added headers column to tool_mcp_providers table with proper encryption/decryption
  • Service Layer Updates: Enhanced MCP tool management service to handle custom headers
  • Frontend UI Component: New HeadersInput component for managing custom headers in the MCP tool configuration modal

Technical Details

  • Headers are stored as encrypted JSON in the database for security
  • Backward compatible - existing MCP providers continue to work without headers
  • Headers are automatically included in all MCP server requests
  • Proper validation and error handling for malformed headers

Screenshots

Before After
image image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Testing

The changes include:

  • Unit tests for the new header functionality

Breaking Changes

None. This is a backward-compatible enhancement that adds optional functionality.

Dependencies

No new external dependencies were added. The implementation uses existing encryption utilities and database infrastructure.


Note: This PR addresses the need for custom authentication headers in MCP tool providers, which is particularly useful for enterprise deployments requiring specific security headers or API keys.

**Original Pull Request:** https://github.com/langgenius/dify/pull/24760 **State:** closed **Merged:** Yes --- ## Summary This PR adds support for custom HTTP headers in MCP (Model Context Protocol) tool providers, allowing users to configure additional authentication or configuration headers when connecting to MCP servers. This enhancement improves the flexibility of MCP tool integration by supporting various authentication methods and server-specific requirements. close https://github.com/langgenius/dify/issues/22718 ### Key Changes - **Backend API Enhancement**: Added `headers` parameter support in MCP tool provider creation and update endpoints - **Database Schema Update**: Added `headers` column to `tool_mcp_providers` table with proper encryption/decryption - **Service Layer Updates**: Enhanced MCP tool management service to handle custom headers - **Frontend UI Component**: New `HeadersInput` component for managing custom headers in the MCP tool configuration modal ### Technical Details - Headers are stored as encrypted JSON in the database for security - Backward compatible - existing MCP providers continue to work without headers - Headers are automatically included in all MCP server requests - Proper validation and error handling for malformed headers ## Screenshots | Before | After | |--------|-------| |<img width="545" height="624" alt="image" src="https://github.com/user-attachments/assets/3502eb51-e44a-49b2-9b12-ef858ded90fd" /> | <img width="528" height="776" alt="image" src="https://github.com/user-attachments/assets/05f5739d-eebf-4fd3-988d-676ef93df569" /> | ## Checklist - [x] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods ## Testing The changes include: - Unit tests for the new header functionality ## Breaking Changes None. This is a backward-compatible enhancement that adds optional functionality. ## Dependencies No new external dependencies were added. The implementation uses existing encryption utilities and database infrastructure. --- **Note**: This PR addresses the need for custom authentication headers in MCP tool providers, which is particularly useful for enterprise deployments requiring specific security headers or API keys.
yindo added the pull-request label 2026-02-21 20:48:12 -05:00
yindo closed this issue 2026-02-21 20:48:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30777