//! MCP Server module
//!
//! This module contains the MCP server implementation organized into logical submodules:
//! - `types`: All type definitions (OAuth, MCP protocol, tasks, elicitation, etc.)
//! - `storage`: Storage backend initialization functions
//! - `oauth`: OAuth 2.1 security and authentication functions
//! - `jsonrpc`: JSON-RPC server loop and request routing (includes embedding config handlers)
//! - `core`: Core MCP protocol handlers (initialize, list_tools, call_tool, shutdown)
//! - `tools`: Memory tool handlers (query_memory, analyze_patterns, etc.)
//! - `mcp`: MCP 2025-11-25 protocol handlers (completion, elicitation, tasks)

// Clippy suppressions for MCP server implementation
#![allow(clippy::doc_markdown)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::redundant_closure_for_method_calls)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::single_match_else)]
#![allow(clippy::match_same_arms)]
#![allow(clippy::similar_names)]
#![allow(clippy::unused_async)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::cast_sign_loss)]
#![allow(clippy::cast_possible_truncation)]
#![allow(clippy::cast_possible_wrap)]
#![allow(clippy::inefficient_to_string)]
#![allow(clippy::manual_string_new)]
#![allow(clippy::single_char_pattern)]
#![allow(clippy::explicit_iter_loop)]
#![allow(clippy::manual_let_else)]
#![allow(clippy::if_not_else)]
#![allow(clippy::default_trait_access)]
#![allow(clippy::struct_excessive_bools)]
#![allow(clippy::fn_params_excessive_bools)]

mod core;
mod handlers;
mod jsonrpc;
mod mcp;
pub(crate) mod oauth; // Always available (load_oauth_config is unconditionally compiled)
mod storage;
mod tools;
pub(crate) mod types;

// Re-export JSON-RPC types from memory_mcp for convenient access
#[allow(unused)]
pub use do_memory_mcp::jsonrpc::{JsonRpcError, JsonRpcRequest, JsonRpcResponse};

// Re-export OAuthConfig from library protocol module
#[allow(unused)]
pub use do_memory_mcp::protocol::OAuthConfig;

// Re-export types needed by other modules
#[allow(unused)]
pub use types::{
    ActiveElicitation, ActiveTask, CallToolParams, CallToolResult, Content, EmbeddingEnvConfig,
    RateLimitEnvConfig,
};

// Re-export all types and functions for convenient access (may be used by external consumers)
#[allow(unused)]
pub use core::*;
#[allow(unused)]
pub use jsonrpc::run_jsonrpc_server;
// Always export load_oauth_config (it's available without the oauth feature)
#[allow(unused)]
pub use oauth::load_oauth_config;
// Other oauth functions are gated behind the feature
#[cfg(feature = "oauth")]
#[allow(unused)]
pub use oauth::{
    check_scopes, create_www_authenticate_header, extract_bearer_token, validate_bearer_token,
};
#[allow(unused)]
pub use storage::initialize_memory_system;
#[allow(unused)]
pub use types::*;
