MCP server modal: add custom headers (with encrypted storage)
Hi! While reading through #2702 I noticed one leftover from the "out of scope" note there, and I'd like to check with you before writing any code.
What I found (on current main):
MCPToolalready readsconfig["headers"]and sends them with every request (docsgpt/agents/tools/mcp_tool.py,self.custom_headers = config.get("headers", {})).MCPServerModal.tsxhas no way to set them, so this only works if someone writes the config by hand.- On save,
/api/mcp_server/savestores the config withstorage_config = config.copy(), soheaderswould be saved in plain text. API keys and bearer tokens are encrypted, but headers would not be.
What I'd like to build:
- A "Custom headers" section in the MCP modal (name/value rows, advanced section).
- Header values stored through the same
encrypt_credentialspath as the other secrets, and not shown again after saving (same behaviour as the saved API key). - Backend validation: reject names/values with newlines, and don't let custom headers override
Authorizationwhen an auth type is already set. - Tests for the modal and the save route, plus the translation keys for all locales.
Questions before I start:
- Is this something you want in the MCP modal, or is it left out on purpose?
- Is encrypting the header values the right direction, or would you rather keep them in the config as plain text?
- Any headers you'd want blocked (for example
Host,Content-Length)?
If it sounds good I'll open a PR with screenshots. Happy to change the approach if you prefer something different.
This is already tracked in #3122: https://github.com/arc53/DocsGPT/issues/3122. Its open PR #3159 also proposes encrypted header storage, hidden saved values, and header validation.
Please add any remaining requirements or questions to #3122 and coordinate with @asadmulani5 before starting a separate PR.
Automated triage. A maintainer will follow up.