bevy_brp_mcp 0.22.2

MCP server for Bevy Remote Protocol (BRP) integration
//! `world.mutate_components` tool - Mutate component fields

use bevy_brp_mcp_macros::ParamStruct;
use bevy_brp_mcp_macros::ResultStruct;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;

use crate::brp_tools::Port;

/// Parameters for the `world.mutate_components` tool
#[derive(Clone, Deserialize, Serialize, JsonSchema, ParamStruct)]
pub struct MutateComponentsParams {
    /// The entity ID containing the component to mutate
    pub entity: u64,

    /// The fully-qualified type name of the component to mutate
    pub component: String,

    /// The new value for the mutation path
    pub value: Value,

    /// The path to the field within the component (e.g., 'translation.x')
    #[serde(default)]
    pub path: String,

    /// The BRP port (default: 15702)
    #[serde(default)]
    pub port: Port,
}

/// Result for the `world.mutate_components` tool
#[derive(Serialize, ResultStruct)]
#[brp_result(enhanced_errors = true)]
pub struct MutateComponentsResult {
    /// The raw BRP response data (empty for mutate)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[to_result(skip_if_none)]
    pub result: Option<Value>,

    /// Message template for formatting responses
    #[to_message(message_template = "Mutated {component} for entity {entity}")]
    pub message_template: String,
}