Skip to main content
Glama

CodeGraph CLI MCP Server

by Jakedismo
basic_server.rs1.67 kB
//! Basic example of running the CodeGraph API server //! //! This example demonstrates how to: //! - Initialize the API server with configuration //! - Set up the basic routes //! - Start the server on a specified port //! //! Run with: `cargo run --example basic_server` use codegraph_api::{create_router, AppState}; use codegraph_core::ConfigManager; use std::net::SocketAddr; use std::sync::Arc; use tokio::net::TcpListener; use tracing::{info, Level}; use tracing_subscriber; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // Initialize logging tracing_subscriber::fmt().with_max_level(Level::INFO).init(); info!("Starting CodeGraph API Server example..."); // Create configuration let config = Arc::new(ConfigManager::new()?); info!("Configuration loaded"); // Initialize application state let state = AppState::new(config).await?; info!("Application state initialized"); // Create the router with all routes let app = create_router(state); info!("Routes configured"); // Define the server address let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); info!("Server will listen on {}", addr); // Create TCP listener let listener = TcpListener::bind(addr).await?; info!("TCP listener bound successfully"); // Start the server info!("CodeGraph API server is running on http://{}", addr); info!("Try these endpoints:"); info!(" - Health check: http://{}/health", addr); info!(" - Metrics: http://{}/metrics", addr); info!(" - GraphQL playground: http://{}/graphiql", addr); axum::serve(listener, app).await?; Ok(()) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jakedismo/codegraph-rust'

If you have feedback or need assistance with the MCP directory API, please join our Discord server