use crate::mcp_pmcp::analyze_handlers::{
AnalyzeBigOTool, AnalyzeComplexityTool, AnalyzeDagTool, AnalyzeDeadCodeTool,
AnalyzeDeepContextTool, AnalyzeSatdTool,
};
use crate::mcp_pmcp::context_handlers::{GenerateContextTool, GitTool, ScaffoldProjectTool};
use crate::mcp_pmcp::handlers::{
RefactorGetStateTool, RefactorNextIterationTool, RefactorStartTool, RefactorStopTool,
};
use crate::mcp_pmcp::pdmt_handler::PdmtTool;
use crate::mcp_pmcp::quality_handlers::QualityGateTool;
use crate::mcp_pmcp::quality_proxy_handler::QualityProxyTool;
use crate::mcp_server::state_manager::StateManager;
use pmcp::{Server, ServerCapabilities, ToolCapabilities};
use std::sync::Arc;
use tokio::sync::Mutex;
use tracing::info;
pub struct SimpleUnifiedServer {
state_manager: Arc<Mutex<StateManager>>,
}
impl SimpleUnifiedServer {
pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
Ok(Self {
state_manager: Arc::new(Mutex::new(StateManager::new())),
})
}
pub async fn run(&self) -> Result<(), Box<dyn std::error::Error>> {
info!("Starting PMAT Simple Unified MCP server (pmcp SDK)");
let server = Server::builder()
.name("paiml-mcp-agent-toolkit")
.version(env!("CARGO_PKG_VERSION"))
.capabilities(ServerCapabilities {
tools: Some(ToolCapabilities { list_changed: None }),
..Default::default()
})
.tool("analyze_complexity", AnalyzeComplexityTool)
.tool("analyze_satd", AnalyzeSatdTool)
.tool("analyze_dead_code", AnalyzeDeadCodeTool)
.tool("analyze_dag", AnalyzeDagTool)
.tool("analyze_deep_context", AnalyzeDeepContextTool)
.tool("analyze_big_o", AnalyzeBigOTool)
.tool(
"refactor.start",
RefactorStartTool::new(self.state_manager.clone()),
)
.tool(
"refactor.nextIteration",
RefactorNextIterationTool::new(self.state_manager.clone()),
)
.tool(
"refactor.getState",
RefactorGetStateTool::new(self.state_manager.clone()),
)
.tool(
"refactor.stop",
RefactorStopTool::new(self.state_manager.clone()),
)
.tool("quality_gate", QualityGateTool)
.tool("quality_proxy", QualityProxyTool)
.tool("pdmt_deterministic_todos", PdmtTool::new())
.tool("git_operation", GitTool)
.tool("generate_context", GenerateContextTool)
.tool("scaffold_project", ScaffoldProjectTool)
.build()?;
info!("PMAT Simple Unified MCP server ready with 18 core tools, listening on stdio");
server.run_stdio().await?;
info!("PMAT Simple Unified MCP server shutting down");
Ok(())
}
}
impl Default for SimpleUnifiedServer {
fn default() -> Self {
Self::new().expect("Failed to create simple unified server")
}
}
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}