mcp-tools 0.1.0

Rust MCP tools library
Documentation
//! Basic MCP Server Example
//!
//! This example shows how to create and run a basic MCP server
//! using the mcp-tools library.

use mcp_tools::{
    common::{McpServerBase, ServerConfig},
    servers::GitToolsServer,
    Result,
};
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize logging
    tracing_subscriber::fmt().with_env_filter("info").init();

    println!("Starting Basic MCP Server Example");

    // Create server configuration
    let config = ServerConfig {
        name: "example-git-server".to_string(),
        description: "Example Git Tools MCP Server".to_string(),
        version: "1.0.0".to_string(),
        host: "127.0.0.1".to_string(),
        port: 8080,
        max_connections: 10,
        request_timeout_secs: 60,
        log_requests: true,
        server_config: HashMap::new(),
    };

    // Create and initialize the server
    let mut server = GitToolsServer::new(config).await?;
    server.initialize().await?;

    // Get server capabilities
    let capabilities = server.get_capabilities().await?;
    println!(
        "Server initialized with {} tools:",
        capabilities.tools.len()
    );

    for tool in &capabilities.tools {
        println!(
            "  - {} ({}): {}",
            tool.name, tool.category, tool.description
        );
    }

    // Get server statistics
    let stats = server.get_stats().await?;
    println!("Server stats: {:?}", stats);

    println!("Server is ready! In a real application, you would:");
    println!("1. Start the MCP transport layer (HTTP/WebSocket/Stdio)");
    println!("2. Handle incoming MCP requests");
    println!("3. Route requests to the appropriate tools");
    println!("4. Return responses to clients");

    // Simulate running for a short time
    tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;

    // Shutdown the server
    server.shutdown().await?;
    println!("Server shutdown complete");

    Ok(())
}