Skip to main content

database_mcp_server/
server.rs

1//! Shared MCP server utilities.
2//!
3//! Provides [`server_info`] used by per-backend
4//! [`ServerHandler`](rmcp::ServerHandler) implementations and the
5//! binary crate's `ServerHandler` wrapper.
6
7use rmcp::model::{Implementation, ServerCapabilities, ServerInfo};
8
9/// Hardcoded product name matching the root binary crate.
10const NAME: &str = "database-mcp";
11
12/// The current version, derived from the workspace `Cargo.toml` at compile time.
13const VERSION: &str = env!("CARGO_PKG_VERSION");
14
15/// Human-readable title for the MCP server.
16const TITLE: &str = "Database MCP Server";
17
18/// Website URL, derived from the workspace `Cargo.toml` at compile time.
19const HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
20
21/// Returns the shared [`ServerInfo`] for all server implementations.
22///
23/// Builds base [`Implementation`] metadata (name, version, title, URL).
24/// Backend handlers extend this with a backend-specific description
25/// and instructions via the public fields on [`ServerInfo`].
26#[must_use]
27pub fn server_info() -> ServerInfo {
28    let capabilities = ServerCapabilities::builder().enable_tools().build();
29
30    let server_info = Implementation::new(NAME, VERSION)
31        .with_title(TITLE)
32        .with_website_url(HOMEPAGE);
33
34    ServerInfo::new(capabilities).with_server_info(server_info)
35}