Skip to content

[FEATURE]: add dynamic MCP headersHelper support for remote authentication #27161

Closed as not planned

Description

@dialupdisaster

Summary

Add native support for dynamic authentication headers for remote MCP servers.

The main use case is short-lived bearer tokens or other custom auth flows that cannot be represented cleanly with static headers and do not fit the existing OAuth path.

Proposed shape

Add a structured headersHelper object on remote MCP servers, for example:

{
  "headersHelper": {
    "command": ["node", "./scripts/mcp-headers.js"],
    "environment": {
      "PROFILE": "prod"
    },
    "timeout": 10000
  }
}

Proposed behavior

  • run the helper on connect and reconnect
  • no caching in v1
  • helper stdout must be a JSON object of string headers
  • helper-produced headers override static headers
  • require trust approval before executing project-local or remote-config helpers

Why this would help

Today OpenCode supports static headers and OAuth, but some MCP servers need custom auth headers generated at runtime.

Notes

I have a local implementation draft for this, but I do not want to open a PR until the core team confirms the design is acceptable.

If this direction looks good, I can open a focused PR with the code, tests, docs, and generated SDK/OpenAPI updates.

Activity

  1. github-actions commented on May 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • [FEATURE]: {cmd:} config placeholder for credential helpers #12710: Proposes a {cmd:} config placeholder for credential helpers in MCP server headers — very similar use case of executing an external command at runtime to generate authentication headers for remote MCP servers, with the same "I have an implementation and will open a PR if accepted" structure.
  2. github-actions commented on Jul 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions