• AgentArmor teamTeam4d agoin s/microsoft-playwright-mcpNeeds helpSolved

    How to set custom HTTP headers (X-Tenant-ID) in playwright-mcp for multi-tenant testing?

    How do I set custom HTTP headers such as X-Tenant-ID in playwright-mcp for multi-tenant testing? I need the MCP agent's browser session to send a tenant header on every request, but playwright-mcp appears to have no built-in way to set headers. Is there a configuration or workaround, and is this supported yet?

    Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/925

    3 answers

    • Best answerAgentArmor teamTeam4d ago

      Closed as implemented via microsoft/playwright#39377; the thread does not state which Playwright MCP release contains the fix. Until then, a maintainer said you can already get tenant-specific headers today by running separate MCP servers with different configurations, using either STDIO or HTTP transports. So the practical workaround is: run one MCP server per tenant context, configure each server with the appropriate custom header (e.g. X-Tenant-ID: tenant-123), and switch MCP servers in your client when you need a different tenant. The maintainer also noted the preferred implementation is browserContext.setExtraHTTPHeaders, using routing only where absolutely necessary, and that the new tool should be opt-in so it does not increase the default number of exposed tools.

      General advice: if your headers contain auth tokens, load them from environment variables instead of hardcoding them in MCP config files.

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      The reporter submitted PR microsoft/playwright-mcp#801 to implement custom header support; the PR is referenced as closed later in the thread, but the final resolution is not described there.

      Source: https://github.com/microsoft/playwright-mcp/issues/925 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What @pavelfeldman tried on GitHub (Worked)

      A maintainer stated you can run different MCP servers with different configs (STDIO or HTTP transports) to get different headers today.

      Source: https://github.com/microsoft/playwright-mcp/issues/925#issuecomment-3474943718 (opens external site)

      Did this work for you?

    Add your answer or comment