Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Merged
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
19 changes: 6 additions & 13 deletions internal/mcp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,15 @@ const (
agentuityToolCommand = "agentuity"
)

var agentuityToolArgs = []string{"mcp", "run"}
var agentuityToolEnv = map[string]string{}
var agentuityToolArgs = []any{"mcp", "run"}
var agentuityToolEnv = map[string]any{}
Comment on lines +24 to +25
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider the implications of relaxing type safety for global configuration variables.

While changing from []string to []any and map[string]string to map[string]any provides more flexibility for MCP configurations, it introduces potential runtime risks:

  1. Type Safety Loss: Compile-time type checking is reduced, potentially leading to runtime errors
  2. String Operations: Line 218 uses string concatenation ("--"+config.Transport) which assumes string types
  3. JSON Unmarshaling: When unmarshaling JSON into []any, numeric values might become float64 instead of expected types

Consider adding type validation or using a more structured approach:

-var agentuityToolArgs = []any{"mcp", "run"}
-var agentuityToolEnv = map[string]any{}
+var agentuityToolArgs = []any{"mcp", "run"}
+var agentuityToolEnv = map[string]any{}

+// Helper function to ensure string conversion
+func toStringSlice(args []any) []string {
+    result := make([]string, len(args))
+    for i, arg := range args {
+        result[i] = fmt.Sprintf("%v", arg)
+    }
+    return result
+}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In internal/mcp/config.go around lines 24 to 25, the change from []string to
[]any and map[string]string to map[string]any reduces type safety and risks
runtime errors, especially where string operations like concatenation assume
string types. To fix this, revert these variables to their original typed forms
or implement strict type validation and conversion before usage. Additionally,
ensure JSON unmarshaling handles type assertions properly to avoid float64
misinterpretation by defining structured types or adding explicit type checks.


type MCPClientApplicationConfig struct {
MacOS []string
Windows []string
Linux []string
}

func toPathArray(path string) []string {
if path == "" {
return []string{}
}
return []string{path}
}

type MCPClientConfig struct {
Name string
ConfigLocation string
Expand All @@ -49,17 +42,17 @@ type MCPClientConfig struct {
}

type MCPServerConfig struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Command string `json:"command"`
Args []any `json:"args,omitempty"`
Env map[string]any `json:"env,omitempty"`
}

type MCPConfig struct {
MCPServers map[string]MCPServerConfig `json:"mcpServers"`
filename string
}

func (c *MCPConfig) AddIfNotExists(name string, command string, args []string, env map[string]string) bool {
func (c *MCPConfig) AddIfNotExists(name string, command string, args []any, env map[string]any) bool {
if _, ok := c.MCPServers[name]; ok {
return false
}
Expand Down
Loading