Skip to content

Commit 27ef36c

Browse files
Merge pull request #324 from docker/slim/long-running-remote-client
Remote Clients should be long-lived
2 parents 34070a4 + 26d1396 commit 27ef36c

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

pkg/catalog/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,8 @@ type ServerConfig struct {
163163
Config map[string]any
164164
Secrets map[string]string
165165
}
166+
167+
// IsRemote returns true if this server is a remote MCP server (not a Docker container)
168+
func (sc *ServerConfig) IsRemote() bool {
169+
return sc.Spec.SSEEndpoint != "" || sc.Spec.Remote.URL != ""
170+
}

pkg/gateway/clientpool.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ func (cp *clientPool) UpdateRoots(ss *mcp.ServerSession, roots []*mcp.Root) {
6969
}
7070

7171
func (cp *clientPool) longLived(serverConfig *catalog.ServerConfig, config *clientConfig) bool {
72-
keep := config != nil && config.serverSession != nil && (serverConfig.Spec.LongLived || cp.LongLived)
73-
return keep
72+
// Must have a valid session to cache clients
73+
if config == nil || config.serverSession == nil {
74+
return false
75+
}
76+
77+
// Remote servers are always treated as long-lived since no container is involved
78+
if serverConfig.IsRemote() {
79+
return true
80+
}
81+
82+
// For Docker-based servers, respect the LongLived flag
83+
return serverConfig.Spec.LongLived || cp.LongLived
7484
}
7585

7686
func (cp *clientPool) AcquireClient(ctx context.Context, serverConfig *catalog.ServerConfig, config *clientConfig) (mcpclient.Client, error) {

0 commit comments

Comments
 (0)