Skip to content

SSEClientTransport's custom header support seems inconsistent #317

Open
@jordan-wright

Description

@jordan-wright

Describe the bug

👋 Hi there!

I've been trying to use Roo to integrate with custom MCP servers behind a corporate proxy. The proxy requires that a custom Host header is set for the connection to work.

It seems as though there may be two problems to report:

Problem 1: _startOrAuth doesn't seem to pass along the custom headers

I noticed that the initial call to the /sse endpoint did not contain any custom headers - even ones that were not forbidden (such as X-This-Works: true).

I believe it's due to this code not evaluating the headers set in this._requestInit?.headers. This seems to be handled correctly further down in send() here. And, sure enough, I do see the headers in the call to /messages.

Problem 2: The use of fetch makes it so the Host header cannot be overridden

It seems as though the use of the native fetch API does not allow the Host header to be set.

Take this with a grain of salt, since I'm not a strong JS/TS dev, but thinking through solutions I happened to see that Roo does support custom headers for their OpenAI compatible client API. This calls the OpenAI SDK which appears to use node-fetch, and node-fetch claims it supports custom headers. Maybe that would be an option? But honestly, whatever works for y'all works for me.

To Reproduce
Steps to reproduce the behavior:

  1. I've setup the following configuration in Roo:
{
    "my-mcp": {
        "headers": {
             "Host": "my.host",
             "X-Working": "yes"
        },
       "url": "http://localhost:8080",
       "disabled": false,
       "alwaysAllow": []
    }
}

When I save the file while running Wireshark, I can see the call to /sse as having host: localhost:8080 and no X-Working header. The subsequent call to /messages has host: localhost:8080 and X-Working: yes.

Expected behavior

I would expect that if I set a custom Host header that it would pass through the requests made to the downstream MCP server.

Logs

N/A - I'm afraid I don't have strong logs to share here!

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions