pulseengine_mcp_server/
builder_trait.rs1use crate::McpBackend;
7
8pub trait McpServerBuilder: McpBackend + Sized {
10 fn with_defaults() -> Self
12 where
13 Self: Default,
14 {
15 Self::default()
16 }
17
18 fn configure_stdio_logging() {
20 #[cfg(feature = "stdio-logging")]
21 {
22 use tracing_subscriber::{
23 EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt,
24 };
25
26 let filter_layer = EnvFilter::try_from_default_env()
27 .or_else(|_| EnvFilter::try_new("info"))
28 .unwrap();
29
30 let fmt_layer = fmt::layer()
31 .with_writer(std::io::stderr)
32 .with_target(false)
33 .with_file(false)
34 .with_line_number(false)
35 .with_thread_ids(false)
36 .with_thread_names(false);
37
38 tracing_subscriber::registry()
39 .with(filter_layer)
40 .with(fmt_layer)
41 .try_init()
42 .unwrap_or(()); }
44
45 #[cfg(not(feature = "stdio-logging"))]
46 {
47 eprintln!("Warning: stdio logging configuration requires 'stdio-logging' feature");
48 eprintln!(
49 "Add to Cargo.toml: pulseengine-mcp-macros = {{ version = \"*\", features = [\"stdio-logging\"] }}"
50 );
51 eprintln!("And: tracing-subscriber = \"0.3\"");
52 }
53 }
54}
55
56pub type McpService<B> = B;