multica-ai/multica · error

update agent mcp server: %w

Error message

update agent mcp server: %w

What it means

Thrown by `multica agent mcp enable|disable <agentID> <serverID>` when PUT /api/agents/{id}/mcp-servers/{serverID}/enabled with {enabled: bool} fails. The wrapped error usually means the agent-server pair does not exist (the server was never attached to this agent), or an auth/connectivity failure.

Source

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

}

func runAgentMcpDisable(cmd *cobra.Command, args []string) error {
	return setAgentMcpEnabled(cmd, args, false)
}

func setAgentMcpEnabled(cmd *cobra.Command, args []string, enabled bool) 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{"enabled": enabled}
	if err := client.PutJSON(ctx, agentMcpPath(agentID, serverID, "enabled"), body, &servers); err != nil {
		return fmt.Errorf("update agent mcp server: %w", err)
	}
	return printWorkspaceMcpServers(cmd, servers)
}

func runAgentMcpRemove(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
	if err := client.DeleteJSONResponse(ctx, agentMcpPath(agentID, serverID), &servers); err != nil {
		return fmt.Errorf("remove agent mcp server: %w", err)
	}
	return printWorkspaceMcpServers(cmd, servers)

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check current attachments: multica agent mcp list <agent-id>
  2. Attach first if missing: multica agent mcp add <agent-id> <server-id>, then enable/disable
  3. Fix auth/connectivity if the wrapped error indicates 401/403 or network failure

Example fix

# before
multica agent mcp enable <agent-id> <server-id>   # not attached
# after
multica agent mcp add <agent-id> <server-id>
multica agent mcp enable <agent-id> <server-id>
Defensive patterns

Strategy: validation

Validate before calling

multica agent mcp list "$AGENT_ID" --output json | jq -e --arg s "$SERVER_ID" 'map(.id) | index($s)' >/dev/null \
  || { echo "server not attached; add it first" >&2; exit 1; }
multica agent mcp enable "$AGENT_ID" "$SERVER_ID"

Prevention

When it happens

Trigger: Running enable/disable on a serverID that was never added to the agent; agent or server deleted after attachment; expired token or unreachable API.

Common situations: Toggling a workspace-level server ID forgetting it must first be attached per-agent; state drift between what a script assumes is attached and what the API has.

Related errors


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