pub mod clients;
pub mod common;
pub mod config;
pub mod servers;
pub mod utils;
pub use rmcp::{model::*, Error as McpError};
pub use common::*;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const DEFAULT_HOST: &str = "127.0.0.1";
pub const DEFAULT_PORT: u16 = 3000;
#[derive(Debug, thiserror::Error)]
pub enum McpToolsError {
#[error("CoderLib error: {0}")]
CoderLib(String),
#[error("MCP SDK error: {0}")]
McpSdk(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Initialization error: {0}")]
InitializationError(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Git error: {0}")]
Git(#[from] git2::Error),
#[error("Network error: {0}")]
Network(#[from] reqwest::Error),
#[error("Server error: {0}")]
Server(String),
#[error("Client error: {0}")]
Client(String),
}
pub type Result<T> = std::result::Result<T, McpToolsError>;
pub fn init_logging() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "mcp_tools=info,coderlib=info".into()),
)
.init();
Ok(())
}
pub fn info() -> McpToolsInfo {
McpToolsInfo {
name: "MCP Tools".to_string(),
version: VERSION.to_string(),
description: "Unified MCP Tools Crate powered by CoderLib".to_string(),
coderlib_version: "0.1.0".to_string(), features: get_enabled_features(),
}
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct McpToolsInfo {
pub name: String,
pub version: String,
pub description: String,
pub coderlib_version: String,
pub features: Vec<String>,
}
fn get_enabled_features() -> Vec<String> {
let mut features = Vec::new();
#[cfg(feature = "file-server")]
features.push("file-server".to_string());
#[cfg(feature = "git-server")]
features.push("git-server".to_string());
#[cfg(feature = "code-server")]
features.push("code-server".to_string());
#[cfg(feature = "web-server")]
features.push("web-server".to_string());
#[cfg(feature = "system-server")]
features.push("system-server".to_string());
#[cfg(feature = "cli-client")]
features.push("cli-client".to_string());
#[cfg(feature = "desktop-client")]
features.push("desktop-client".to_string());
features
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version() {
assert!(!VERSION.is_empty());
}
#[test]
fn test_info() {
let info = info();
assert_eq!(info.name, "MCP Tools");
assert!(!info.version.is_empty());
assert!(!info.description.is_empty());
}
#[test]
fn test_features() {
let features = get_enabled_features();
assert!(!features.is_empty());
}
}