mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-27 10:04:48 -07:00
39 lines
942 B
Rust
39 lines
942 B
Rust
use axum::Router;
|
|
use brk_interface::Interface;
|
|
use brk_rmcp::transport::{
|
|
StreamableHttpServerConfig,
|
|
streamable_http_server::{StreamableHttpService, session::local::LocalSessionManager},
|
|
};
|
|
|
|
use log::info;
|
|
|
|
use crate::MCP;
|
|
|
|
pub trait MCPRoutes {
|
|
fn add_mcp_routes(self, interface: &'static Interface<'static>, mcp: bool) -> Self;
|
|
}
|
|
|
|
impl<T> MCPRoutes for Router<T>
|
|
where
|
|
T: Clone + Send + Sync + 'static,
|
|
{
|
|
fn add_mcp_routes(self, interface: &'static Interface<'static>, mcp: bool) -> Self {
|
|
if !mcp {
|
|
return self;
|
|
}
|
|
|
|
let service = StreamableHttpService::new(
|
|
move || Ok(MCP::new(interface)),
|
|
LocalSessionManager::default().into(),
|
|
StreamableHttpServerConfig {
|
|
stateful_mode: false,
|
|
..Default::default()
|
|
},
|
|
);
|
|
|
|
info!("Setting MCP...");
|
|
|
|
self.nest_service("/mcp", service)
|
|
}
|
|
}
|