use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use sacp_proxy::McpServer;
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct EchoInput {
message: String,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct EchoOutput {
result: String,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct EmptyInput {}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct SessionInfoOutput {
acp_url: String,
}
fn main() {
let _server = McpServer::new()
.instructions("A simple MCP server with echo and session info tools")
.tool_fn(
"echo",
"Echoes back the input message with session information",
async |input: EchoInput, context| {
Ok(EchoOutput {
result: format!("ACP {}: Echo: {}", context.acp_url(), input.message),
})
},
|f, args, cx| Box::pin(f(args, cx)),
)
.tool_fn(
"get_session_info",
"Returns information about the current session",
async |_input: EmptyInput, context| {
Ok(SessionInfoOutput {
acp_url: context.acp_url(),
})
},
|f, args, cx| Box::pin(f(args, cx)),
);
println!("MCP server created successfully!");
println!("Tools available:");
println!(" - echo: Echoes back messages with session info");
println!(" - get_session_info: Returns current session ID");
println!();
println!("This is a demonstration - use with sacp-proxy to serve over ACP.");
}