remote-mcp-kernel 0.1.0-alpha.7

A microkernel-based MCP (Model Context Protocol) server with OAuth authentication and multiple transport protocols
Documentation
//! Simple test to verify custom router functionality works correctly
//!
//! This is a minimal test that creates a server, attaches custom routers,
//! and verifies the router can be built without errors.

use axum::{Router, response::Json, routing::get};
use oauth_provider_rs::{GitHubOAuthProvider, OAuthProvider, provider_trait::OAuthProviderConfig};
use remote_mcp_kernel::microkernel::{
    GitHubMicrokernelServer, MicrokernelServer, core::CustomRouterConfig,
};
use serde_json::json;

/// Simple health check endpoint
async fn health_check() -> Json<serde_json::Value> {
    Json(json!({
        "status": "healthy",
        "service": "test"
    }))
}

/// Simple API endpoint
async fn api_status() -> Json<serde_json::Value> {
    Json(json!({
        "api": "working",
        "version": "1.0"
    }))
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("๐Ÿงช Testing custom router functionality...");

    // Create OAuth provider
    let github_config = OAuthProviderConfig::with_oauth_config(
        "test_client_id".to_string(),
        "test_client_secret".to_string(),
        "http://localhost:8080/oauth/callback".to_string(),
        "read:user".to_string(),
        "github".to_string(),
    );

    let github_oauth_provider = GitHubOAuthProvider::new_github(github_config);
    let oauth_provider = OAuthProvider::new(
        github_oauth_provider,
        oauth_provider_rs::http_integration::config::OAuthProviderConfig::default(),
    );

    // Create custom routers
    let health_router = Router::new().route("/health", get(health_check));

    let api_router = Router::new().route("/status", get(api_status));

    // Build microkernel server with custom routers
    let microkernel: GitHubMicrokernelServer = MicrokernelServer::new()
        .with_oauth_provider(oauth_provider)
        .with_custom_router(health_router)
        .with_custom_router_config(api_router, CustomRouterConfig::with_prefix("/api"));

    // Test that the router can be built
    let router = microkernel.build_router()?;
    println!("โœ… Router built successfully!");

    // Print available endpoints
    println!("\n๐Ÿ“‹ Server would have these endpoints:");
    println!("  OAuth:");
    println!("    GET  /oauth/login");
    println!("    GET  /oauth/callback");
    println!("    POST /oauth/token");
    println!("  Custom:");
    println!("    GET  /health");
    println!("    GET  /api/status");

    println!("\n๐ŸŽ‰ Custom router functionality is working correctly!");
    println!("   The server can be built and all routers are properly attached.");

    Ok(())
}