use agentic_tools_mcp::OutputMode;
use agentic_tools_mcp::RegistryServer;
use agentic_tools_mcp::ServiceExt;
use agentic_tools_mcp::stdio;
use std::sync::Arc;
mod config;
mod error;
mod logging;
mod server;
mod token_tracker;
mod tools;
mod types;
mod version;
use server::OrchestratorServerHandle;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
#[cfg(feature = "test-support")]
{
let _ = OrchestratorServerHandle::from_server_unshared;
std::mem::drop(
OrchestratorServerHandle::new().acquire_or_recover_with(|| async {
anyhow::bail!("test-support lint reference only")
}),
);
}
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.add_directive(tracing::Level::INFO.into()),
)
.with_writer(std::io::stderr)
.init();
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
let orchestrator = Arc::new(OrchestratorServerHandle::new());
let registry = tools::build_registry(&orchestrator);
eprintln!(
"opencode-orchestrator-mcp started ({} tools; embedded server is lazy-initialized on first tool call)",
registry.len(),
);
let server = RegistryServer::new(Arc::new(registry))
.with_info("opencode-orchestrator-mcp", env!("CARGO_PKG_VERSION"))
.with_output_mode(OutputMode::Structured);
let transport = stdio();
let service = server.serve(transport).await?;
service.waiting().await?;
Ok(())
}