codeprism_mcp_server/
lib.rs

1//! CodePrism MCP Server
2//!
3//! This crate provides an MCP (Model Context Protocol) server implementation
4//! built on the official Rust SDK. It exposes CodePrism's code analysis
5//! capabilities through the standardized MCP protocol.
6//!
7//! # Architecture
8//!
9//! The server is organized into several modules:
10//! - `server`: Core MCP server implementation
11//! - `tools`: MCP tool implementations (core, search, analysis, workflow)
12//! - `config`: Configuration management
13//! - `error`: Error types and handling
14//!
15//! # Usage
16//!
17//! The server can be run as a standalone binary or embedded in other applications.
18//! It supports stdio transport for communication with MCP clients.
19
20pub mod config;
21pub mod error;
22pub mod response;
23pub mod server;
24pub mod tools;
25
26#[cfg(test)]
27mod integration_test;
28
29pub use config::Config;
30pub use error::{Error, Result};
31pub use server::CodePrismMcpServer;
32
33/// The current version of the CodePrism MCP Server
34pub const VERSION: &str = env!("CARGO_PKG_VERSION");
35
36/// The name of the MCP server for identification
37pub const SERVER_NAME: &str = "codeprism-mcp-server";
38
39/// The MCP protocol version this server implements
40pub const MCP_VERSION: &str = "2025-06-18";
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_can_import_rmcp_crate() {
48        // Test that we can import the rmcp crate - specific types will be explored in task #159
49        extern crate rmcp;
50
51        // Basic verification that the constants are defined correctly
52        assert_eq!(SERVER_NAME, "codeprism-mcp-server");
53        assert_eq!(MCP_VERSION, "2025-06-18");
54    }
55
56    #[tokio::test]
57    async fn test_server_creation() {
58        // Test that we can create a server instance with default configuration
59        let config = Config::default();
60        let server = CodePrismMcpServer::new(config).await;
61        assert!(server.is_ok(), "Server creation should succeed");
62
63        let server = server.unwrap();
64        assert_eq!(server.config().server().name, "codeprism-mcp-server");
65    }
66
67    #[tokio::test]
68    async fn test_server_info() {
69        // Test that server info is correctly configured
70        use rmcp::{model::ProtocolVersion, ServerHandler};
71
72        let config = Config::default();
73        let server = CodePrismMcpServer::new(config).await.unwrap();
74
75        let info = server.get_info();
76        assert_eq!(info.protocol_version, ProtocolVersion::V_2024_11_05);
77        assert_eq!(info.server_info.name, "codeprism-mcp-server");
78        assert!(info.instructions.is_some(), "Should have value");
79        assert!(info.capabilities.tools.is_some(), "Should have value");
80    }
81
82    // Additional tests moved to integration_test.rs module
83}