Skip to main content

database_mcp_server/
server.rs

1//! Shared MCP server utilities.
2//!
3//! Provides helper functions used by per-backend handler implementations.
4
5use rmcp::model::{ErrorData, Implementation, ServerCapabilities, ServerInfo};
6
7/// Converts a displayable error into an MCP [`ErrorData`].
8pub fn map_error(e: impl std::fmt::Display) -> ErrorData {
9    ErrorData::internal_error(e.to_string(), None)
10}
11
12/// Returns the shared [`ServerInfo`] for all handler implementations.
13///
14/// Provides consistent server identity, capabilities, and instructions
15/// across all database backends.
16#[must_use]
17pub fn server_info() -> ServerInfo {
18    ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
19        .with_server_info(Implementation::new(
20            env!("CARGO_PKG_NAME"),
21            env!("CARGO_PKG_VERSION"),
22        ))
23        .with_instructions(
24            "Database MCP Server - provides database exploration and query tools for MySQL, MariaDB, PostgreSQL, and SQLite",
25        )
26}