@@ -21,6 +21,7 @@ type Gateway struct {
21
21
docker docker.Client
22
22
configurator Configurator
23
23
clientPool * clientPool
24
+ mcpServer * server.MCPServer
24
25
health health.State
25
26
}
26
27
@@ -90,7 +91,7 @@ func (g *Gateway) Run(ctx context.Context) error {
90
91
}
91
92
toolCallbacks := interceptors .Callbacks (g .LogCalls , g .BlockSecrets , customInterceptors )
92
93
93
- mcpServer : = server .NewMCPServer (
94
+ g . mcpServer = server .NewMCPServer (
94
95
"Docker AI MCP Gateway" ,
95
96
"2.0.1" ,
96
97
server .WithToolHandlerMiddleware (toolCallbacks ),
@@ -103,7 +104,7 @@ func (g *Gateway) Run(ctx context.Context) error {
103
104
}),
104
105
)
105
106
106
- if err := g .reloadConfiguration (ctx , mcpServer , configuration ); err != nil {
107
+ if err := g .reloadConfiguration (ctx , configuration ); err != nil {
107
108
return fmt .Errorf ("loading configuration: %w" , err )
108
109
}
109
110
@@ -124,7 +125,7 @@ func (g *Gateway) Run(ctx context.Context) error {
124
125
continue
125
126
}
126
127
127
- if err := g .reloadConfiguration (ctx , mcpServer , configuration ); err != nil {
128
+ if err := g .reloadConfiguration (ctx , configuration ); err != nil {
128
129
logf ("> Unable to list capabilities: %s" , err )
129
130
continue
130
131
}
@@ -143,22 +144,22 @@ func (g *Gateway) Run(ctx context.Context) error {
143
144
switch strings .ToLower (g .Transport ) {
144
145
case "stdio" :
145
146
log ("> Start stdio server" )
146
- return g .startStdioServer (ctx , mcpServer , os .Stdin , os .Stdout )
147
+ return g .startStdioServer (ctx , os .Stdin , os .Stdout )
147
148
148
149
case "sse" :
149
150
log ("> Start sse server on port" , g .Port )
150
- return g .startSseServer (ctx , mcpServer , ln )
151
+ return g .startSseServer (ctx , ln )
151
152
152
153
case "streaming" :
153
154
log ("> Start streaming server on port" , g .Port )
154
- return g .startStreamingServer (ctx , mcpServer , ln )
155
+ return g .startStreamingServer (ctx , ln )
155
156
156
157
default :
157
158
return fmt .Errorf ("unknown transport %q, expected 'stdio', 'sse' or 'streaming" , g .Transport )
158
159
}
159
160
}
160
161
161
- func (g * Gateway ) reloadConfiguration (ctx context.Context , mcpServer * server. MCPServer , configuration Configuration ) error {
162
+ func (g * Gateway ) reloadConfiguration (ctx context.Context , configuration Configuration ) error {
162
163
// Which servers are enabled in the registry.yaml?
163
164
serverNames := configuration .ServerNames ()
164
165
if len (serverNames ) == 0 {
@@ -178,12 +179,12 @@ func (g *Gateway) reloadConfiguration(ctx context.Context, mcpServer *server.MCP
178
179
179
180
// Update the server's capabilities.
180
181
g .health .SetUnhealthy ()
181
- mcpServer .SetTools (capabilities .Tools ... )
182
- mcpServer .SetPrompts (capabilities .Prompts ... )
183
- mcpServer .SetResources (capabilities .Resources ... )
184
- mcpServer .RemoveAllResourceTemplates ()
182
+ g . mcpServer .SetTools (capabilities .Tools ... )
183
+ g . mcpServer .SetPrompts (capabilities .Prompts ... )
184
+ g . mcpServer .SetResources (capabilities .Resources ... )
185
+ g . mcpServer .RemoveAllResourceTemplates ()
185
186
for _ , v := range capabilities .ResourceTemplates {
186
- mcpServer .AddResourceTemplate (v .ResourceTemplate , v .Handler )
187
+ g . mcpServer .AddResourceTemplate (v .ResourceTemplate , v .Handler )
187
188
}
188
189
g .health .SetHealthy ()
189
190
0 commit comments