use rmcp::handler::server::wrapper::{Json, Parameters};
use rmcp::{schemars, tool, tool_router};
use serde::{Deserialize, Serialize};
use crate::mcp::query;
use crate::mcp::server::GitPawMcpServer;
#[derive(Debug, Deserialize, schemars::JsonSchema)]
pub struct GetIntentParams {
pub branch_id: String,
}
#[derive(Serialize, schemars::JsonSchema)]
pub struct IntentsResponse {
pub intents: Vec<query::intents::Intent>,
}
#[derive(Serialize, schemars::JsonSchema)]
pub struct IntentResponse {
pub intent: Option<query::intents::Intent>,
}
#[derive(Serialize, schemars::JsonSchema)]
pub struct ConflictsResponse {
pub conflicts: Vec<query::conflicts::Conflict>,
}
#[tool_router(router = coordination_router, vis = "pub(crate)")]
impl GitPawMcpServer {
#[tool(
description = "List all active agent coordination intents for this repository's session. \
Each intent carries branch_id, files, summary, published_at, and \
valid_for_seconds. Returns an empty list when no broker/session is active."
)]
pub(crate) fn get_intents(&self) -> Json<IntentsResponse> {
Json(IntentsResponse {
intents: query::intents::active_intents(&self.ctx),
})
}
#[tool(description = "Look up a single agent's active intent by branch_id. \
Returns { \"intent\": null } when no matching active intent exists.")]
pub(crate) fn get_intent(
&self,
Parameters(p): Parameters<GetIntentParams>,
) -> Json<IntentResponse> {
Json(IntentResponse {
intent: query::intents::intent_for(&self.ctx, &p.branch_id),
})
}
#[tool(
description = "List all currently-detected coordination conflicts between agents (forward \
overlaps on declared files/regions). Each carries shape, branches, files, \
and detected_at. Returns an empty list when no broker/session is active."
)]
pub(crate) fn get_conflicts(&self) -> Json<ConflictsResponse> {
Json(ConflictsResponse {
conflicts: query::conflicts::conflicts(&self.ctx),
})
}
}