-
Notifications
You must be signed in to change notification settings - Fork 19.8k
feat: add MCP server headers support #22718 #24760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add MCP server headers support #22718 #24760
Conversation
|
Thanks for the PR, @Nov1c444 is reviewing this, however please link an existing issue or create a new issue in the description. |
…vices - Added 'headers' argument to ToolProviderMCPApi for server requests. - Updated ToolProviderApiEntity to include 'headers' field. - Modified MCPToolProvider to handle decrypted headers. - Enhanced MCPToolManageService to manage headers during provider updates and requests. - Created migration to add 'headers' column to tool_mcp_providers table.
afc31c8 to
83a809e
Compare
…out parameters - Modified test assertions in TestMCPToolManageService to verify the inclusion of 'headers', 'timeout', and 'sse_read_timeout' parameters in mock interactions.
…before reconnecting - Added creation of MCP provider in multiple test cases of TestMCPToolManageService to ensure proper provider ID is used during reconnection tests. - Updated assertions to reflect the use of the created MCP provider ID instead of a hardcoded value.
|
Could you please submit the frontend code together? |
Sorry, I accidentally forgot to submit the frontend code when resolving the conflict earlier. |
- Enhanced MCPModal to include a headers input field for additional HTTP headers. - Updated state management to handle headers in edit mode. - Modified types to include headers in ToolParameter and MCPServerDetail. - Added translations for headers in English, Japanese, and Chinese. - Updated API service functions to support headers in MCP creation and updates.
|
I have a question: when it comes to changes in migration versions, isn't it easy to have conflicts in different branches? |
That's indeed the case. We haven't found a better solution for this yet. We also have a dev environment, and during certain feature development, the migrations in dev become very troublesome due to various branch merges. One rather tricky approach is that we can first merge only the migrations into the main branch, and then merge the code logic into the main branch after it's completed. However, this is also very inflexible. |
…port - Updated MCPToolProvider to include 'encrypted_headers' and 'masked_headers' fields for secure header management. - Modified API entities and services to handle encryption and decryption of headers. - Adjusted MCPModal and related components to utilize masked headers for improved security in the UI. - Added translations for masked headers in English and Chinese.
…ling - Refactored `decrypted_headers` and `masked_headers` properties in MCPToolProvider to use `dict[str, Any]` type hints for better type safety. - Adjusted header processing logic to streamline the creation of dynamic configurations. - Updated ToolTransformService to utilize `masked_headers` and retain `decrypted_headers` for original header access.
…provider migration - Deleted the comment on the 'encrypted_headers' column in the migration file for tool_mcp_providers. - This change simplifies the migration script while maintaining the column's functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for custom HTTP headers in MCP (Model Context Protocol) tool providers, enabling 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.
- Backend API enhancement to support headers parameter in MCP tool provider endpoints
- Database schema update with encrypted headers storage and proper encryption/decryption handling
- Frontend UI component for managing custom headers in the MCP tool configuration modal
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| web/service/use-tools.ts | Added headers parameter to MCP creation and update service calls |
| web/i18n/zh-Hans/tools.ts | Added Chinese translations for headers-related UI text |
| web/i18n/en-US/tools.ts | Added English translations for headers-related UI text |
| web/app/components/tools/types.ts | Added headers and masked_headers types to Collection and MCPServerDetail |
| web/app/components/tools/mcp/modal.tsx | Enhanced MCP modal with headers input functionality and state management |
| web/app/components/tools/mcp/headers-input.tsx | New component for managing custom headers with add/remove functionality |
| api/tests/.../test_mcp_tools_manage_service.py | Updated tests to include headers, timeout, and sse_read_timeout parameters |
| api/services/tools/tools_transform_service.py | Added timeout, sse_read_timeout, and headers to provider transformation |
| api/services/tools/mcp_tools_manage_service.py | Enhanced service with header encryption/decryption and MCP client integration |
| api/models/tools.py | Added encrypted_headers column and decryption/masking properties |
| api/migrations/...add_headers_to_mcp_provider.py | Database migration to add encrypted_headers column |
| api/migrations/...add_workflow_app_log_run_id_index.py | Updated down_revision reference for migration chain |
| api/core/tools/mcp_tool/provider.py | Updated provider to use decrypted headers from database |
| api/core/tools/entities/api_entities.py | Added timeout, sse_read_timeout, and headers fields to API entity |
| api/controllers/console/workspace/tool_providers.py | Added headers parameter support in MCP provider endpoints |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Nov1c444
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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 #22718
Key Changes
headersparameter support in MCP tool provider creation and update endpointsheaderscolumn totool_mcp_providerstable with proper encryption/decryptionHeadersInputcomponent for managing custom headers in the MCP tool configuration modalTechnical Details
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint godsTesting
The changes include:
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.