github-mcp 0.1.3

GitHub v3 REST API MCP server, generated by mcpify.
Documentation
// GitHub v3 REST API MCP server — generated by mcpify. Do not hand-edit.

use std::collections::HashMap;
use std::time::Duration;

use github_mcp::auth::auth_manager::AuthManager;
use github_mcp::core::api_url_builder::build_api_url;
use github_mcp::core::config_manager::load_config;
use github_mcp::core::config_schema::Transport;

pub async fn run() -> anyhow::Result<()> {
    let config = load_config(serde_json::Map::new())?;
    let mut auth_manager = AuthManager::new(config.auth_method);
    let mut headers = auth_manager
        .apply_auth_headers(HashMap::new(), "GET", &config.url, Transport::Stdio, None)
        .await?;
    headers.insert(
        "Accept".to_string(),
        "application/vnd.github+json".to_string(),
    );
    headers.insert(
        "User-Agent".to_string(),
        format!("github-mcp/{}", env!("CARGO_PKG_VERSION")),
    );

    let url = build_api_url(&config.url, "/", &[])?;
    let client = reqwest::Client::new();
    let mut request = client
        .get(&url)
        .timeout(Duration::from_millis(config.timeout_ms));
    for (key, value) in headers {
        request = request.header(key, value);
    }

    match request.send().await {
        Ok(response) if response.status().is_success() => {
            println!("connection OK");
            Ok(())
        }
        Ok(response) => {
            anyhow::bail!("connection failed: HTTP {}", response.status());
        }
        Err(err) => {
            eprintln!("connection failed: {err}");
            std::process::exit(1);
        }
    }
}