DocsGPT icon indicating copy to clipboard operation
DocsGPT copied to clipboard

MCP server modal: add custom headers (with encrypted storage)

Open AtharvDhiman opened this issue 1 month ago • 1 comments

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):

  • MCPTool already reads config["headers"] and sends them with every request (docsgpt/agents/tools/mcp_tool.py, self.custom_headers = config.get("headers", {})).
  • MCPServerModal.tsx has no way to set them, so this only works if someone writes the config by hand.
  • On save, /api/mcp_server/save stores the config with storage_config = config.copy(), so headers would be saved in plain text. API keys and bearer tokens are encrypted, but headers would not be.

What I'd like to build:

  1. A "Custom headers" section in the MCP modal (name/value rows, advanced section).
  2. Header values stored through the same encrypt_credentials path as the other secrets, and not shown again after saving (same behaviour as the saved API key).
  3. Backend validation: reject names/values with newlines, and don't let custom headers override Authorization when an auth type is already set.
  4. 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.

AtharvDhiman avatar Oct 24 '26 13:10 AtharvDhiman

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.

arc53-machine avatar Oct 24 '26 13:10 arc53-machine