Skip to content

Commit f23cdc0

Browse files
authored
fixes client configuration issues with streamable http (#852)
1 parent 3483e43 commit f23cdc0

File tree

5 files changed

+61
-16
lines changed

5 files changed

+61
-16
lines changed

cmd/thv/app/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func addRunningMCPsToClient(ctx context.Context, clientName string) error {
274274
// Update each configuration file
275275
for _, clientConfig := range filteredClientConfigs {
276276
// Update the MCP server configuration with locking
277-
if err := client.Upsert(clientConfig, name, url); err != nil {
277+
if err := client.Upsert(clientConfig, name, url, transportType); err != nil {
278278
logger.Warnf("Warning: Failed to update MCP server configuration in %s: %v", clientConfig.Path, err)
279279
continue
280280
}

pkg/client/config.go

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ const (
4848

4949
// mcpClientConfig represents a configuration path for a supported MCP client.
5050
type mcpClientConfig struct {
51-
ClientType MCPClient
52-
Description string
53-
RelPath []string
54-
SettingsFile string
55-
PlatformPrefix map[string][]string
56-
MCPServersPathPrefix string
57-
Extension Extension
51+
ClientType MCPClient
52+
Description string
53+
RelPath []string
54+
SettingsFile string
55+
PlatformPrefix map[string][]string
56+
MCPServersPathPrefix string
57+
Extension Extension
58+
SupportedTransportTypesMap map[types.TransportType]string
59+
IsTransportTypeFieldSupported bool
5860
}
5961

6062
var supportedClientIntegrations = []mcpClientConfig{
@@ -72,6 +74,12 @@ var supportedClientIntegrations = []mcpClientConfig{
7274
},
7375
MCPServersPathPrefix: "/mcpServers",
7476
Extension: JSON,
77+
SupportedTransportTypesMap: map[types.TransportType]string{
78+
types.TransportTypeStdio: "stdio",
79+
types.TransportTypeSSE: "sse",
80+
types.TransportTypeStreamableHTTP: "http",
81+
},
82+
IsTransportTypeFieldSupported: true,
7583
},
7684
{
7785
ClientType: Cline,
@@ -87,6 +95,11 @@ var supportedClientIntegrations = []mcpClientConfig{
8795
},
8896
MCPServersPathPrefix: "/mcpServers",
8997
Extension: JSON,
98+
SupportedTransportTypesMap: map[types.TransportType]string{
99+
types.TransportTypeSSE: "sse",
100+
types.TransportTypeStdio: "stdio",
101+
},
102+
IsTransportTypeFieldSupported: false,
90103
},
91104
{
92105
ClientType: VSCodeInsider,
@@ -102,6 +115,12 @@ var supportedClientIntegrations = []mcpClientConfig{
102115
},
103116
MCPServersPathPrefix: "/mcp/servers",
104117
Extension: JSON,
118+
SupportedTransportTypesMap: map[types.TransportType]string{
119+
types.TransportTypeStdio: "stdio",
120+
types.TransportTypeSSE: "sse",
121+
types.TransportTypeStreamableHTTP: "http",
122+
},
123+
IsTransportTypeFieldSupported: true,
105124
},
106125
{
107126
ClientType: VSCode,
@@ -117,6 +136,12 @@ var supportedClientIntegrations = []mcpClientConfig{
117136
"windows": {"AppData", "Roaming"},
118137
},
119138
Extension: JSON,
139+
SupportedTransportTypesMap: map[types.TransportType]string{
140+
types.TransportTypeStdio: "stdio",
141+
types.TransportTypeSSE: "sse",
142+
types.TransportTypeStreamableHTTP: "http",
143+
},
144+
IsTransportTypeFieldSupported: true,
120145
},
121146
{
122147
ClientType: Cursor,
@@ -125,6 +150,14 @@ var supportedClientIntegrations = []mcpClientConfig{
125150
MCPServersPathPrefix: "/mcpServers",
126151
RelPath: []string{".cursor"},
127152
Extension: JSON,
153+
SupportedTransportTypesMap: map[types.TransportType]string{
154+
types.TransportTypeStdio: "stdio",
155+
types.TransportTypeSSE: "sse",
156+
types.TransportTypeStreamableHTTP: "http",
157+
},
158+
// Adding type field is not explicitly required though, Cursor auto-detects and is able to
159+
// connect to both sse and streamable-http types
160+
IsTransportTypeFieldSupported: true,
128161
},
129162
{
130163
ClientType: ClaudeCode,
@@ -133,6 +166,12 @@ var supportedClientIntegrations = []mcpClientConfig{
133166
MCPServersPathPrefix: "/mcpServers",
134167
RelPath: []string{},
135168
Extension: JSON,
169+
SupportedTransportTypesMap: map[types.TransportType]string{
170+
types.TransportTypeStdio: "stdio",
171+
types.TransportTypeSSE: "sse",
172+
types.TransportTypeStreamableHTTP: "http",
173+
},
174+
IsTransportTypeFieldSupported: true,
136175
},
137176
}
138177

@@ -200,12 +239,18 @@ func FindClientConfigs() ([]ConfigFile, error) {
200239
// for a `type` field, but Cursor and others do not. This allows us to
201240
// build up more complex MCP server configurations for different clients
202241
// without leaking them into the CMD layer.
203-
func Upsert(cf ConfigFile, name string, url string) error {
204-
if cf.ClientType == VSCode || cf.ClientType == VSCodeInsider || cf.ClientType == ClaudeCode {
205-
return cf.ConfigUpdater.Upsert(name, MCPServer{Url: url, Type: "sse"})
242+
func Upsert(cf ConfigFile, name string, url string, transportType string) error {
243+
for i := range supportedClientIntegrations {
244+
if cf.ClientType != supportedClientIntegrations[i].ClientType {
245+
continue
246+
}
247+
mappedTransportType, ok := supportedClientIntegrations[i].SupportedTransportTypesMap[types.TransportType(transportType)]
248+
if supportedClientIntegrations[i].IsTransportTypeFieldSupported && ok {
249+
return cf.ConfigUpdater.Upsert(name, MCPServer{Url: url, Type: mappedTransportType})
250+
}
251+
return cf.ConfigUpdater.Upsert(name, MCPServer{Url: url})
206252
}
207-
208-
return cf.ConfigUpdater.Upsert(name, MCPServer{Url: url})
253+
return nil
209254
}
210255

211256
// GenerateMCPServerURL generates the URL for an MCP server

pkg/client/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func TestSuccessfulClientConfigOperations(t *testing.T) {
286286
testURL := "http://localhost:9999/sse#test-server"
287287

288288
for _, cf := range configs {
289-
err := Upsert(cf, testServer, testURL)
289+
err := Upsert(cf, testServer, testURL, types.TransportTypeSSE.String())
290290
require.NoError(t, err, "Should be able to add MCP server to %s config", cf.ClientType)
291291

292292
// Read the file and verify the server was added

pkg/client/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (m *defaultManager) addRunningMCPsToClient(ctx context.Context, clientType
138138
url := GenerateMCPServerURL(transportType, transport.LocalhostIPv4, port, name)
139139

140140
// Update the MCP server configuration with locking
141-
if err := Upsert(*clientConfig, name, url); err != nil {
141+
if err := Upsert(*clientConfig, name, url, transportType); err != nil {
142142
logger.Warnf("Warning: Failed to update MCP server configuration in %s: %v", clientConfig.Path, err)
143143
continue
144144
}

pkg/runner/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func updateClientConfigurations(containerName string, containerLabels map[string
300300
for _, clientConfig := range clientConfigs {
301301
logger.Infof("Updating client configuration: %s", clientConfig.Path)
302302

303-
if err := client.Upsert(clientConfig, containerName, url); err != nil {
303+
if err := client.Upsert(clientConfig, containerName, url, transportType); err != nil {
304304
fmt.Printf("Warning: Failed to update MCP server configuration in %s: %v\n", clientConfig.Path, err)
305305
continue
306306
}

0 commit comments

Comments
 (0)