multica-ai/multica · error

list agent mcp servers: %w

Error message

list agent mcp servers: %w

What it means

Thrown by `multica agent mcp list <agentID>` when GET /api/agents/{id}/mcp-servers fails. The wrapped error carries the HTTP cause: unknown agent ID (404), auth failure (401/403), or connectivity problems to the API server.

Source

Thrown at server/cmd/multica/cmd_agent_mcp.go:105

	path := "/api/agents/" + url.PathEscape(agentID) + "/mcp-servers"
	for _, part := range parts {
		path += "/" + url.PathEscape(part)
	}
	return path
}

func runAgentMcpList(cmd *cobra.Command, args []string) error {
	agentID := strings.TrimSpace(args[0])
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}
	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	var servers []workspaceMcpServer
	if err := client.GetJSON(ctx, agentMcpPath(agentID), &servers); err != nil {
		return fmt.Errorf("list agent mcp servers: %w", err)
	}
	return printWorkspaceMcpServers(cmd, servers)
}

func runAgentMcpAdd(cmd *cobra.Command, args []string) error {
	agentID, serverID := strings.TrimSpace(args[0]), strings.TrimSpace(args[1])
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}
	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	var servers []workspaceMcpServer
	body := map[string]any{"server_id": serverID}
	if err := client.PostJSON(ctx, agentMcpPath(agentID), body, &servers); err != nil {
		return fmt.Errorf("add agent mcp server: %w", err)
	}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Confirm the agent exists: multica agent list, then re-run with a fresh ID
  2. Fix auth/connectivity: check the CLI's server URL and token, re-login if expired
  3. Trim whitespace — the CLI trims args, but ensure you are not passing a labeled output like 'ID' column headers

Example fix

# before
multica agent mcp list abc123   # deleted agent
# after
multica agent list --output json | jq '.[].id'
multica agent mcp list <fresh-id>
Defensive patterns

Strategy: try-catch

Validate before calling

multica agent get "$AGENT_ID" >/dev/null 2>&1 || { echo "agent $AGENT_ID not found" >&2; exit 1; }
multica agent mcp list "$AGENT_ID"

Try / catch

In Go: var servers []workspaceMcpServer; if err := client.GetJSON(ctx, agentMcpPath(agentID), &servers); err != nil { return fmt.Errorf("list agent mcp servers: %w", err) } — inspect the wrapped error's HTTP status: 404 → bad agent ID, 401/403 → auth, network → retry.

Prevention

When it happens

Trigger: `multica agent mcp list <bad-id>`; agent deleted before the call; wrong API base URL or expired token; server down.

Common situations: Agent IDs stale after re-deploys that recreate agents; scripts iterating over IDs saved from an earlier run; environment mismatch between CLI config and where the agent lives.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/ec16714ed3b7d990. Report an issue: GitHub.