Skip to main content

vibe_graph_mcp/
lib.rs

1//! MCP (Model Context Protocol) server for Vibe-Graph.
2//!
3//! Exposes the Vibe-Graph codebase analysis capabilities as MCP tools,
4//! enabling LLM-powered agents to query code structure, analyze impact,
5//! and understand dependencies.
6//!
7//! ## Gateway Mode (Recommended)
8//!
9//! The gateway mode allows multiple projects to be served through a single
10//! MCP endpoint. Run `vg serve --mcp` from any project directory - it will
11//! either start a gateway or register with an existing one.
12//!
13//! ```rust,no_run
14//! use vibe_graph_mcp::gateway::{GatewayState, run_gateway, DEFAULT_GATEWAY_PORT};
15//! use tokio_util::sync::CancellationToken;
16//!
17//! #[tokio::main]
18//! async fn main() -> anyhow::Result<()> {
19//!     let cancel = CancellationToken::new();
20//!     let state = GatewayState::new(cancel);
21//!     run_gateway(state, DEFAULT_GATEWAY_PORT).await?;
22//!     Ok(())
23//! }
24//! ```
25//!
26//! ## Single-Project Mode (Legacy)
27//!
28//! For backwards compatibility, single-project mode is still supported:
29//!
30//! ```rust,no_run
31//! use vibe_graph_mcp::VibeGraphMcp;
32//! use vibe_graph_ops::Store;
33//! use std::sync::Arc;
34//!
35//! #[tokio::main]
36//! async fn main() -> anyhow::Result<()> {
37//!     let store = Store::new(".");
38//!     let graph = store.load_graph()?.expect("No graph found");
39//!     
40//!     let server = VibeGraphMcp::new(store, Arc::new(graph), ".".into());
41//!     server.run_stdio().await?;
42//!     Ok(())
43//! }
44//! ```
45//!
46//! ## Tools
47//!
48//! - `list_projects` - List all registered projects (gateway mode)
49//! - `search_nodes` - Search for nodes by name/path pattern
50//! - `get_dependencies` - Get incoming/outgoing edges for a node
51//! - `impact_analysis` - Analyze which nodes are impacted by changes
52//! - `get_git_changes` - Get current uncommitted git changes
53//! - `get_node_context` - Get a node and its neighbors for context
54//! - `list_files` - List files in the graph with filters
55
56#[cfg(feature = "http-server")]
57pub mod gateway;
58
59mod server;
60mod tools;
61mod types;
62
63pub use server::VibeGraphMcp;
64pub use types::*;