Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/runtime/materialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,12 @@ func mcpConfigEntries(servers []domain.MCPServerDefinition) (map[string]any, err
}
} else {
entry["command"] = m.Command
entry["args"] = m.Args
// A nil slice would render as "args": null, which Claude Code
// rejects by silently skipping the whole server (including the
// gate MCP). Omit args when empty, as the Codex renderer does.
if len(m.Args) > 0 {
entry["args"] = m.Args
}
if cwd := MCPRuntimeWorkingDirectory(m); cwd != "" {
entry["cwd"] = cwd
}
Expand Down
36 changes: 36 additions & 0 deletions internal/runtime/materialize_mcp_args_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package runtime

import (
"encoding/json"
"strings"
"testing"

"agentflow/internal/domain"
)

// Claude Code skips a stdio MCP server whose args is null, which hid the gate
// MCP (submit_gate_result) from SOP nodes. Empty args must not render as null.
func TestMCPConfigEntriesOmitsEmptyArgs(t *testing.T) {
entries, err := mcpConfigEntries([]domain.MCPServerDefinition{
{ID: "gate", Command: ".agentflow/gate-mcp"},
{ID: "tool", Command: "node", Args: []string{"server.js", "--stdio"}},
})
if err != nil {
t.Fatal(err)
}
data, err := json.Marshal(entries)
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(data), "null") {
t.Fatalf("MCP config must not contain null values: %s", data)
}
gate, _ := entries["gate"].(map[string]any)
if _, ok := gate["args"]; ok {
t.Fatalf("server without args must omit args: %+v", gate)
}
tool, _ := entries["tool"].(map[string]any)
if args, _ := tool["args"].([]string); len(args) != 2 || args[0] != "server.js" || args[1] != "--stdio" {
t.Fatalf("server args lost: %+v", tool)
}
}