git_paw/mcp/tools/
coordination.rs1use rmcp::handler::server::wrapper::{Json, Parameters};
7use rmcp::{schemars, tool, tool_router};
8use serde::{Deserialize, Serialize};
9
10use crate::mcp::query;
11use crate::mcp::server::GitPawMcpServer;
12
13#[derive(Debug, Deserialize, schemars::JsonSchema)]
15pub struct GetIntentParams {
16 pub branch_id: String,
18}
19
20#[derive(Serialize, schemars::JsonSchema)]
22pub struct IntentsResponse {
23 pub intents: Vec<query::intents::Intent>,
25}
26
27#[derive(Serialize, schemars::JsonSchema)]
29pub struct IntentResponse {
30 pub intent: Option<query::intents::Intent>,
32}
33
34#[derive(Serialize, schemars::JsonSchema)]
36pub struct ConflictsResponse {
37 pub conflicts: Vec<query::conflicts::Conflict>,
39}
40
41#[tool_router(router = coordination_router, vis = "pub(crate)")]
42impl GitPawMcpServer {
43 #[tool(
45 description = "List all active agent coordination intents for this repository's session. \
46 Each intent carries branch_id, files, summary, published_at, and \
47 valid_for_seconds. Returns an empty list when no broker/session is active."
48 )]
49 pub(crate) fn get_intents(&self) -> Json<IntentsResponse> {
50 Json(IntentsResponse {
51 intents: query::intents::active_intents(&self.ctx),
52 })
53 }
54
55 #[tool(description = "Look up a single agent's active intent by branch_id. \
57 Returns { \"intent\": null } when no matching active intent exists.")]
58 pub(crate) fn get_intent(
59 &self,
60 Parameters(p): Parameters<GetIntentParams>,
61 ) -> Json<IntentResponse> {
62 Json(IntentResponse {
63 intent: query::intents::intent_for(&self.ctx, &p.branch_id),
64 })
65 }
66
67 #[tool(
69 description = "List all currently-detected coordination conflicts between agents (forward \
70 overlaps on declared files/regions). Each carries shape, branches, files, \
71 and detected_at. Returns an empty list when no broker/session is active."
72 )]
73 pub(crate) fn get_conflicts(&self) -> Json<ConflictsResponse> {
74 Json(ConflictsResponse {
75 conflicts: query::conflicts::conflicts(&self.ctx),
76 })
77 }
78}