Skip to content

Commit bb208bf

Browse files
Copilotpelikhan
andcommitted
Filter out safe-inputs and safe-outputs from MCP gateway
- Gateway now ignores safe-inputs and safe-outputs MCP servers - These are internal workflow servers, not external servers to proxy - Added filtering logic in parseGatewayConfig function - Logs when filtering out internal servers - Added 2 comprehensive tests: * TestParseGatewayConfig_FiltersInternalServers * TestParseGatewayConfig_OnlyInternalServers - All 39 CLI tests passing (2 new tests added) - Recompiled all 121 workflows This addresses the requirement that safe-inputs and safe-outputs should be excluded from the gateway, which only processes external MCP servers. Co-authored-by: pelikhan <[email protected]>
1 parent 4f0f153 commit bb208bf

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

pkg/cli/mcp_gateway_command.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ func parseGatewayConfig(data []byte) (*MCPGatewayConfig, error) {
273273
}
274274

275275
gatewayLog.Printf("Successfully parsed JSON configuration")
276+
277+
// Filter out internal workflow MCP servers (safe-inputs and safe-outputs)
278+
// These are used internally by the workflow and should not be proxied by the gateway
279+
filteredServers := make(map[string]MCPServerConfig)
280+
for name, serverConfig := range config.MCPServers {
281+
if name == "safe-inputs" || name == "safe-outputs" {
282+
gatewayLog.Printf("Filtering out internal workflow server: %s", name)
283+
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Filtering out internal workflow server: %s", name)))
284+
continue
285+
}
286+
filteredServers[name] = serverConfig
287+
}
288+
config.MCPServers = filteredServers
289+
276290
return &config, nil
277291
}
278292

pkg/cli/mcp_gateway_command_test.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,84 @@ func TestMergeConfigs_EmptyOverride(t *testing.T) {
422422
t.Error("Port should be kept from base")
423423
}
424424
}
425+
426+
func TestParseGatewayConfig_FiltersInternalServers(t *testing.T) {
427+
// Create a config with safe-inputs, safe-outputs, and other servers
428+
configJSON := `{
429+
"mcpServers": {
430+
"safe-inputs": {
431+
"command": "node",
432+
"args": ["/tmp/gh-aw/safe-inputs/mcp-server.cjs"]
433+
},
434+
"safe-outputs": {
435+
"command": "node",
436+
"args": ["/tmp/gh-aw/safeoutputs/mcp-server.cjs"]
437+
},
438+
"github": {
439+
"command": "gh",
440+
"args": ["aw", "mcp-server", "--toolsets", "default"]
441+
},
442+
"custom-server": {
443+
"command": "custom-command",
444+
"args": ["arg1"]
445+
}
446+
},
447+
"gateway": {
448+
"port": 8080
449+
}
450+
}`
451+
452+
config, err := parseGatewayConfig([]byte(configJSON))
453+
if err != nil {
454+
t.Fatalf("Failed to parse config: %v", err)
455+
}
456+
457+
// Verify that safe-inputs and safe-outputs are filtered out
458+
if _, exists := config.MCPServers["safe-inputs"]; exists {
459+
t.Error("safe-inputs should be filtered out")
460+
}
461+
462+
if _, exists := config.MCPServers["safe-outputs"]; exists {
463+
t.Error("safe-outputs should be filtered out")
464+
}
465+
466+
// Verify that other servers are kept
467+
if _, exists := config.MCPServers["github"]; !exists {
468+
t.Error("github server should be kept")
469+
}
470+
471+
if _, exists := config.MCPServers["custom-server"]; !exists {
472+
t.Error("custom-server should be kept")
473+
}
474+
475+
// Verify server count
476+
if len(config.MCPServers) != 2 {
477+
t.Errorf("Expected 2 servers after filtering, got %d", len(config.MCPServers))
478+
}
479+
}
480+
481+
func TestParseGatewayConfig_OnlyInternalServers(t *testing.T) {
482+
// Create a config with only safe-inputs and safe-outputs
483+
configJSON := `{
484+
"mcpServers": {
485+
"safe-inputs": {
486+
"command": "node",
487+
"args": ["/tmp/gh-aw/safe-inputs/mcp-server.cjs"]
488+
},
489+
"safe-outputs": {
490+
"command": "node",
491+
"args": ["/tmp/gh-aw/safeoutputs/mcp-server.cjs"]
492+
}
493+
}
494+
}`
495+
496+
config, err := parseGatewayConfig([]byte(configJSON))
497+
if err != nil {
498+
t.Fatalf("Failed to parse config: %v", err)
499+
}
500+
501+
// Verify that all internal servers are filtered out, resulting in 0 servers
502+
if len(config.MCPServers) != 0 {
503+
t.Errorf("Expected 0 servers after filtering internal servers, got %d", len(config.MCPServers))
504+
}
505+
}

0 commit comments

Comments
 (0)