### Install CodeGraph and Dependencies Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Commands to clone the repository and execute the installation script for full feature support. ```bash git clone https://github.com/yourorg/codegraph-rust cd codegraph-rust ./install-codegraph-full-features.sh ``` -------------------------------- ### Configure and Start SurrealDB Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Instructions for starting a local SurrealDB instance for persistent or in-memory storage to support CodeGraph's graph and vector data. ```bash brew install surrealdb/tap/surreal surreal start --bind 0.0.0.0:3004 --user root --pass root file://$HOME/.codegraph/surreal.db ``` ```bash surreal start --bind 0.0.0.0:3004 --user root --pass root memory ``` -------------------------------- ### Install CodeGraph Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Commands to clone the repository and install the CodeGraph binary with all features enabled. ```bash git clone https://github.com/yourorg/codegraph-rust cd codegraph-rust ./install-codegraph-full-features.sh cargo install --path crates/codegraph-mcp-server --bin codegraph \ --all-features --features autoagents-lats --force ``` -------------------------------- ### Start SurrealDB Server Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Provides the command to start a SurrealDB server, which is required if testing with the `cloud-surrealdb` feature. This ensures the database is running and accessible for CodeGraph. ```bash # Start SurrealDB surreal start --bind 0.0.0.0:8000 --user root --pass root file://data/surreal.db ``` -------------------------------- ### Configure CodeGraph via Environment Variables Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/AI_PROVIDERS.md Examples of .env file configurations for various provider combinations including local Ollama, LM Studio, and remote Jina/OpenAI setups. These variables define database connections, embedding models, and LLM endpoints. ```bash CODEGRAPH_SURREALDB_URL=ws://localhost:3004 CODEGRAPH_SURREALDB_NAMESPACE=ouroboros CODEGRAPH_SURREALDB_DATABASE=codegraph CODEGRAPH_SURREALDB_USERNAME=root CODEGRAPH_SURREALDB_PASSWORD=root CODEGRAPH_EMBEDDING_PROVIDER=ollama CODEGRAPH_OLLAMA_URL=http://localhost:11434 CODEGRAPH_EMBEDDING_MODEL=hf.co/nomic-ai/nomic-embed-code-GGUF:Q4_K_M CODEGRAPH_LLM_PROVIDER=ollama CODEGRAPH_MODEL=qwen2.5-coder:14b ``` ```bash CODEGRAPH_EMBEDDING_PROVIDER=lmstudio CODEGRAPH_EMBEDDING_MODEL=jinaai/jina-embeddings-v3 CODEGRAPH_LLM_PROVIDER=lmstudio CODEGRAPH_MODEL=local-model ``` ```bash CODEGRAPH_EMBEDDING_PROVIDER=jina JINA_API_KEY=your_api_key_here CODEGRAPH_EMBEDDING_MODEL=jina-embeddings-v4 JINA_API_BASE=https://api.jina.ai/v1 CODEGRAPH_LLM_PROVIDER=openai OPENAI_API_KEY=your_api_key_here CODEGRAPH_MODEL=gpt-5.1-codex ``` -------------------------------- ### Rust CodeGraphAgentBuilder Setup Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/architecture/agent-context-gathering-flow.html Details the setup process for CodeGraphAgentBuilder, including LLM bridging, prompt plugins, memory management, and tool registration. ```rust // Creates CodeGraphChatAdapter for LLM bridging // Configures TierAwarePromptPlugin // Sets up SlidingWindowMemory (40 messages) // Registers 7 Arc-wrapped graph tools ``` -------------------------------- ### Architecture Analysis Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example query to get an overview of a project's architecture and main components, leveraging CodeGraph's agentic architecture analysis tool. ```text "Give me an overview of this project's architecture and main components" ``` -------------------------------- ### SurrealDB Schema Migration Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/schema/README.md Demonstrates how to create a schema migration in SurrealDB by defining a new migration file. This example adds a full-text search index to the `nodes` table and updates the `schema_versions` table to track the migration. ```surrealql -- Migration: Add full-text search to nodes -- Version: 2 -- Define analyzer for code search DEFINE ANALYZER code_analyzer TOKENIZERS class FILTERS ascii; -- Add full-text index DEFINE INDEX idx_nodes_name_fulltext ON TABLE nodes COLUMNS name FULLTEXT ANALYZER code_analyzer BM25 HIGHLIGHTS; -- Update schema version INSERT INTO schema_versions (version, description, applied_at) VALUES (2, 'Added full-text search capabilities', time::now()); ``` -------------------------------- ### Initialize SurrealDB Instance Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Starts the local SurrealDB instance required for storing the code graph data with persistent storage. ```bash surreal start --bind 0.0.0.0:3004 --user root --pass root file://$HOME/.codegraph/surreal.db ``` -------------------------------- ### Start CodeGraph Daemon to Watch Project Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph daemon in the background to watch a specified project directory for file changes and perform indexing. ```bash codegraph daemon start /path/to/project ``` -------------------------------- ### CI/CD Pipeline Integration for MCP Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md A GitHub Actions workflow configuration that installs dependencies, starts SurrealDB, builds the project, and executes MCP tests. ```yaml name: Test MCP Server on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install dependencies run: pip install -r requirements-test.txt - name: Start SurrealDB run: | surreal start --bind 0.0.0.0:3004 & sleep 2 - name: Build CodeGraph run: cargo build --release -p codegraph-mcp - name: Index test project run: ./target/release/codegraph index . - name: Run MCP tests env: CODEGRAPH_LLM_PROVIDER: ollama CODEGRAPH_MODEL: qwen2.5-coder:7b run: python3 test_mcp_tools.py ``` -------------------------------- ### Project-Level TOML Configuration Example (TOML) Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md An example of a project-level `.codegraph/config.toml` file. This file allows for overriding specific global configurations on a per-project basis, such as using a different embedding model or LLM provider. ```toml # Project-specific settings override global config [embedding] model = "jina-embeddings-v4" # Different model for this project dimension = 2048 [llm] provider = "anthropic" model = "claude-sonnet-4" ``` -------------------------------- ### Global TOML Configuration Example (TOML) Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md An example of a global `config.toml` file for CodeGraph, illustrating settings for embedding, LLM, reranking, database, server, performance, daemon, monitoring, and security. This file allows for comprehensive customization of CodeGraph's behavior. ```toml # Embedding Configuration [embedding] provider = "ollama" # ollama | lmstudio | jina | openai model = "qwen3-embedding:0.6b" # Model name for your provider dimension = 1024 # 384, 768, 1024, 1536, 2048, 2560, 3072, 4096 batch_size = 32 normalize_embeddings = true cache_enabled = true ollama_url = "http://localhost:11434" # lmstudio_url = "http://localhost:1234" # For LM Studio # LLM Configuration (for agentic tools) [llm] provider = "ollama" # ollama | anthropic | openai | xai | lmstudio model = "qwen3:4b" # Model for reasoning context_window = 32000 # Affects tier selection for prompts max_retries = 3 # Reranking (Optional - improves search quality) [rerank] provider = "jina" # jina | ollama model = "jina-reranker-v3" top_n = 10 candidates = 256 # Database Configuration [database] backend = "surrealdb" [database.surrealdb] connection = "ws://localhost:3004" namespace = "ouroboros" database = "codegraph" # username = "root" # password is best set via env: CODEGRAPH__DATABASE__SURREALDB__PASSWORD strict_mode = false auto_migrate = true # Server Configuration [server] host = "0.0.0.0" port = 3003 # Performance Tuning [performance] batch_size = 64 # Embedding batch size workers = 4 # Rayon thread count max_concurrent = 4 # Concurrent embedding requests max_texts_per_request = 256 # Daemon Configuration (for --watch mode) [daemon] auto_start_with_mcp = true # Auto-start when MCP server starts debounce_ms = 30 batch_timeout_ms = 200 exclude_patterns = ["**/node_modules/**", "**/target/**", "**/.git/**"] # Monitoring [monitoring] enabled = true metrics_enabled = true trace_enabled = false metrics_interval_secs = 60 # Security [security] require_auth = false rate_limit_per_minute = 1200 ``` -------------------------------- ### Context Building Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example query to gather all relevant context for implementing a new feature (rate limiting), using CodeGraph's agentic context builder tool. ```text "I need to add rate limiting to the API. Gather all relevant context." ``` -------------------------------- ### Agent Bootstrap Context Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Configure agents to start with lightweight project context for more efficient initial operations. ```APIDOC ## Agent Bootstrap Context Agents can be initialized with lightweight project context to improve the relevance and efficiency of their first tool calls. This is enabled via environment variables. ### Enabling Bootstrap Context - `CODEGRAPH_ARCH_BOOTSTRAP=true`: Includes a brief summary of top directories, the contents of `README.md`, and `CLAUDE.md` or `AGENTS.md`/`GEMINI.md` (if present) in the agent's initial context. - `CODEGRAPH_ARCH_PRIMER=""`: An optional custom primer text that can be injected into the agent's startup instructions, guiding it to focus on specific areas. ### Benefits - Faster and more relevant initial steps. - Reduced wasted graph and semantic queries. - Improved architecture answers, especially for large repositories. ### Notes - Bootstrap context is intentionally lightweight, providing a directory summary and key files, not a replacement for full graph queries. - The project context used for bootstrap is the same as that used for indexing (determined by `CODEGRAPH_PROJECT_ID` or the current working directory). ``` -------------------------------- ### Dependency Analysis Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example query to understand the impact of changing a specific class (UserService) on the codebase, using CodeGraph's agentic dependency analysis tool. ```text "What would be affected if I change the UserService class?" ``` -------------------------------- ### Optimize Build Performance on macOS Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Instructions to install LLVM and use the Makefile targets to leverage the lld linker for faster build times on macOS. ```bash brew install llvm make build-llvm make test-llvm ``` -------------------------------- ### Start CodeGraph Daemon Watching Project with Language Filters Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph daemon watching a project, but only indexes specified languages (e.g., Rust and TypeScript). ```bash codegraph daemon start /path/to/project --languages rust,typescript ``` -------------------------------- ### Build and Test NAPI Bindings Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Commands to install Node.js dependencies and build the NAPI bindings with specific feature flags. ```bash cd crates/codegraph-napi npm install npm run build ``` -------------------------------- ### Configure SurrealDB for CodeGraph Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Instructions to start the SurrealDB instance and apply the required schema for graph and vector storage. ```bash surreal start \ --bind 0.0.0.0:3004 \ --user root \ --pass root \ file://$HOME/.codegraph/surreal.db cd schema && ./apply-schema.sh surreal sql \ --endpoint ws://localhost:3004 \ --namespace ouroboros \ --database codegraph \ --username root \ --password root \ < schema/codegraph.surql surreal sql \ --endpoint ws://localhost:3004 \ --namespace ouroboros \ --database codegraph \ --username root \ --password root \ --command "INFO FOR DB;" ``` -------------------------------- ### CodeGraph TOML Configuration Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Example configuration file for defining embedding providers, LLM settings, database connections, and agent behavior. ```toml [embedding] provider = "ollama" model = "qwen3-embedding:0.6b" dimension = 1024 batch_size = 32 normalize_embeddings = true cache_enabled = true ollama_url = "http://localhost:11434" [llm] enabled = true provider = "anthropic" model = "claude-sonnet-4" context_window = 128000 max_retries = 3 [rerank] provider = "jina" model = "jina-reranker-v3" top_n = 10 candidates = 256 [database.surrealdb] connection = "ws://localhost:3004" namespace = "ouroboros" database = "codegraph" [indexing] tier = "fast" [daemon] auto_start_with_mcp = true debounce_ms = 30 exclude_patterns = ["**/node_modules/**", "**/target/**", "**/.git/**"] [agent] architecture = "react" timeout_secs = 300 max_steps = 15 ``` -------------------------------- ### API Surface Analysis Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example query to identify the public APIs exposed by a specific module (auth module), using CodeGraph's agentic API surface analysis tool. ```text "What public APIs does the auth module expose?" ``` -------------------------------- ### Development Setup for CodeGraph Configuration Source: https://github.com/jakedismo/codegraph-rust/blob/main/config/README.md Options for setting up CodeGraph configuration during development, including copying files to `~/.codegraph`, creating a symbolic link to the local config directory, or relying on the backward compatibility fallback. ```bash mkdir -p ~/.codegraph && cp config/*.toml ~/.codegraph/ ln -s $(pwd)/config ~/.codegraph ``` -------------------------------- ### Check CodeGraph Binary Availability Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Demonstrates how to verify if the CodeGraph binary is installed and accessible in the system's PATH, or how to specify a debug build for testing. This helps troubleshoot server startup failures. ```bash # Test if binary exists which codegraph # Or use debug build CODEGRAPH_BIN=./target/debug/codegraph python3 test_mcp_tools.py ``` -------------------------------- ### SurrealDB Example Query: Find Functions in File Source: https://github.com/jakedismo/codegraph-rust/blob/main/schema/README.md An example SurrealQL query to retrieve all nodes of type 'Function' located within a specific file path. This demonstrates basic filtering on the `nodes` table. ```surrealql SELECT * FROM nodes WHERE file_path = '/path/to/file.rs' AND node_type = 'Function'; ``` -------------------------------- ### Apply and Verify Database Schema Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Methods to apply the CodeGraph schema to a SurrealDB instance and verify the installation using the CLI. ```bash cd /path/to/codegraph-rust/schema ./apply-schema.sh --endpoint ws://localhost:3004 --namespace ouroboros --database codegraph --username root --password root ``` ```bash surreal sql --endpoint ws://localhost:3004 --namespace ouroboros --database codegraph --username root --password root < schema/codegraph.surql ``` ```bash surreal sql --endpoint ws://localhost:3004 --namespace ouroboros --database codegraph --username root --password root --command "INFO FOR DB;" ``` -------------------------------- ### Call Chain Analysis Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example query to trace the execution path from an HTTP request to a database query within the payment flow, using CodeGraph's agentic call chain analysis tool. ```text "Trace the execution path from HTTP request to database query in the payment flow" ``` -------------------------------- ### Invoking Tools Manually (MCP) Source: https://github.com/jakedismo/codegraph-rust/blob/main/crates/codegraph-mcp/README.md Demonstrates how to invoke tools manually using the standard JSON-RPC envelope for MCP requests. Includes an example for agentic_dependency_analysis. ```APIDOC ## POST /mcp/invoke ### Description Invokes a tool or agent within the CodeGraph system using the MCP protocol. ### Method POST ### Endpoint `/mcp/invoke` ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version, typically "2.0". - **id** (string) - Required - A unique identifier for the request. - **method** (string) - Required - The name of the method or tool to invoke (e.g., `agentic_dependency_analysis`). - **params** (object) - Required - An object containing the parameters for the specified method. - **query** (string) - Required - The natural language query or instruction for the agent. - **workspaceId** (string) - Optional - The ID of the workspace to operate within. ### Request Example ```json { "jsonrpc": "2.0", "id": "1", "method": "agentic_dependency_analysis", "params": { "query": "Analyze the dependency chain for the AgenticOrchestrator. What does it depend on?", "workspaceId": "default" } } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (string) - The ID of the request. - **result** (object) - The result of the tool invocation. - **reasoning** (string) - Step-by-step chain of thought. - **tool_call** (string) - The specific function or tool call made. - **analysis** (string) - A summary of the analysis in markdown or JSON format. - **components** (array) - Structured references to components. - **file_locations** (array) - Structured references to file paths and line numbers. #### Response Example ```json { "jsonrpc": "2.0", "id": "1", "result": { "reasoning": "The user wants to understand the dependencies of AgenticOrchestrator. I will use the get_transitive_dependencies tool.", "tool_call": "get_transitive_dependencies(AgenticOrchestrator)", "analysis": "The AgenticOrchestrator depends on several core libraries and internal modules...", "components": [...], "file_locations": [...] } } ``` ``` -------------------------------- ### Start CodeGraph Daemon Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Commands to initiate the CodeGraph daemon, either via the MCP server or as a standalone process, to enable automatic background re-indexing. ```bash # With MCP server (recommended) codegraph start stdio --watch # Standalone daemon codegraph daemon start /path/to/project --languages rust,typescript ``` -------------------------------- ### Build CodeGraph Binary Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Commands to build the CodeGraph binary with all features enabled, either using the provided installation script or via cargo directly. ```bash cd /path/to/codegraph-rust ./install-codegraph-full-features.sh ``` ```bash cargo install --path crates/codegraph-mcp-server --bin codegraph --all-features --features autoagents-lats --force ``` -------------------------------- ### CodeGraph Workflow Example: Understanding Codebase Source: https://github.com/jakedismo/codegraph-rust/blob/main/crates/codegraph-mcp-server/src/prompts/initial_instructions.md A workflow for gaining an understanding of a codebase's overall structure and main interfaces using CodeGraph tools. ```plaintext 1. agentic_architecture({"query": "overall structure"}) 2. agentic_context({"query": "main interfaces and entry points"}) ``` -------------------------------- ### Launch CodeGraph MCP Server via STDIO Source: https://github.com/jakedismo/codegraph-rust/blob/main/crates/codegraph-mcp/README.md Starts the CodeGraph MCP server using the STDIO transport, which is suitable for local MCP-compliant hosts like Claude Desktop. ```bash cargo run -p codegraph-mcp \ --features "ai-enhanced,embeddings-ollama,autoagents-experimental" \ -- start stdio ``` -------------------------------- ### GET /trace_call_chain Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/architecture/agent-context-gathering-flow.html Traces the execution flow from a starting function through all called functions. ```APIDOC ## GET /trace_call_chain ### Description Trace execution flow from a starting function through all called functions. ### Method GET ### Endpoint /trace_call_chain ### Parameters #### Query Parameters - **node_id** (String) - Required - Starting node - **max_depth** (i32) - Optional - Max trace depth (default: 5) ### Response #### Success Response (200) - **sequence** (Array) - Call sequence with file paths and line numbers #### Response Example { "sequence": [{"file": "main.rs", "line": 10, "function": "init"}] } ``` -------------------------------- ### Create a .env Configuration File Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Demonstrates how to create a `.env` file in the project root to configure CodeGraph settings, such as the LLM provider, model, and API keys. This is essential for setting up the environment. ```bash cat > .env << 'EOF' CODEGRAPH_LLM_PROVIDER=openai CODEGRAPH_MODEL=gpt-4o OPENAI_API_KEY=sk-your-key-here EOF ``` -------------------------------- ### Get Call Graph Depth (SurrealQL) Source: https://github.com/jakedismo/codegraph-rust/blob/main/schema/README.md Calculates the depth of a call graph recursively starting from a given function. This query traverses 'calls' edges to find all indirectly called functions. ```surrealql SELECT * FROM ( SELECT ->to.* FROM edges WHERE from = nodes:function_id AND edge_type = 'calls' ).*; ``` -------------------------------- ### Initialize and Customize CodeGraph User Configuration Source: https://github.com/jakedismo/codegraph-rust/blob/main/config/README.md Steps to initialize the `~/.codegraph` directory with default configurations and customize them for different environments like development or production. ```bash mkdir -p ~/.codegraph cp config/default.toml ~/.codegraph/ nano ~/.codegraph/default.toml cp ~/.codegraph/default.toml ~/.codegraph/development.toml cp ~/.codegraph/default.toml ~/.codegraph/production.toml ``` -------------------------------- ### Start CodeGraph Daemon in Foreground for Debugging Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph daemon in the foreground, which is useful for debugging purposes. It watches the specified project directory. ```bash codegraph daemon start /path/to/project --foreground ``` -------------------------------- ### Configure CodeGraph Agent Architecture (Bash) Source: https://github.com/jakedismo/codegraph-rust/blob/main/README.md Demonstrates how to start the CodeGraph CLI with different agent architectures using environment variables. This allows selection of the reasoning strategy, such as Rig for best performance, LATS for complex analysis, or the default ReAct. ```bash CODEGRAPH_AGENT_ARCHITECTURE=rig ./codegraph start stdio ./codegraph start stdio CODEGRAPH_AGENT_ARCHITECTURE=lats ./codegraph start stdio ``` -------------------------------- ### Start CodeGraph Daemon Watching Project with Exclusions Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph daemon watching a project while excluding specific directories like node_modules and target from indexing. ```bash codegraph daemon start /path/to/project \ --exclude "**/node_modules/**" \ --exclude "**/target/**" ``` -------------------------------- ### Install python-dotenv Dependency Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Provides the command to install the `python-dotenv` package, which is required for loading environment variables from a `.env` file. This is a common troubleshooting step for configuration issues. ```bash pip install python-dotenv ``` -------------------------------- ### Create Global Config Directory and File (Bash) Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md This snippet demonstrates how to create the necessary directory for the global CodeGraph configuration file and copy an example configuration file into it. It uses standard bash commands for directory creation and file copying. ```bash mkdir -p ~/.codegraph cp config/example.toml ~/.codegraph/config.toml ``` -------------------------------- ### Start CodeGraph MCP Server in HTTP Mode Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph MCP server in HTTP mode, listening on a specified host and port, with SSE streaming enabled for real-time updates. ```bash codegraph start http --host 127.0.0.1 --port 3000 ``` -------------------------------- ### Start CodeGraph MCP Server in STDIO Mode Watching Specific Directory Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph MCP server in STDIO mode, specifically watching a given directory for file changes. ```bash /full/path/to/codegraph start stdio --watch --watch-path /path/to/project ``` -------------------------------- ### Execute CodeGraph MCP Tools Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Demonstrates the execution of various CodeGraph MCP tools, including initialization, semantic search, vector search, and graph neighbor retrieval. It shows the expected JSON-RPC communication and output for each tool. ```bash python3 test_mcp_tools.py ``` -------------------------------- ### Code Search Query Example Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Example of a natural language query to find all places where authentication is handled within a codebase, utilizing CodeGraph's agentic code search tool. ```text "Find all places where authentication is handled in this codebase" ``` -------------------------------- ### Start CodeGraph MCP Server in STDIO Mode with Watch Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph MCP server in STDIO mode with file watching enabled. This mode automatically re-indexes files when changes are detected. ```bash /full/path/to/codegraph start stdio --watch ``` -------------------------------- ### Start CodeGraph MCP Server in STDIO Mode without Watch Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/INSTALLATION_GUIDE.md Starts the CodeGraph MCP server in STDIO mode without file watching. Manual re-indexing is required after making code changes. ```bash /full/path/to/codegraph start stdio ``` -------------------------------- ### Test CodeGraph with Different LLM and Embedding Providers Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Shows various command-line examples for testing CodeGraph with different LLM providers (OpenAI, Anthropic, Ollama, xAI) and embedding providers (Jina). This allows for comprehensive testing of provider integrations. ```bash # Test with OpenAI CODEGRAPH_LLM_PROVIDER=openai \ CODEGRAPH_MODEL=gpt-5-codex \ python3 test_mcp_tools.py # Test with Anthropic CODEGRAPH_LLM_PROVIDER=anthropic \ CODEGRAPH_MODEL=claude-haiku \ python3 test_mcp_tools.py # Test with local Ollama CODEGRAPH_LLM_PROVIDER=ollama \ CODEGRAPH_MODEL=qwen2.5-coder:14b \ python3 test_mcp_tools.py # Test with xAI Grok (2M context window!) CODEGRAPH_LLM_PROVIDER=xai \ CODEGRAPH_MODEL=grok-4-fast \ python3 test_mcp_tools.py # Test with Jina AI embeddings CODEGRAPH_EMBEDDING_PROVIDER=jina \ JINA_EMBEDDING_MODEL=jina-embeddings-v4 \ JINA_EMBEDDING_DIMENSION=2048 \ python3 test_mcp_tools.py ``` -------------------------------- ### Agent Architecture Selection Commands Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Shows bash commands for selecting the reasoning architecture for CodeGraph agentic tools, including Rig, ReAct, and LATS, and how to use bootstrap context for faster initial queries. ```bash # Rig framework - recommended for best performance with modern LLMs export CODEGRAPH_AGENT_ARCHITECTURE=rig codegraph start stdio --watch ``` ```bash # ReAct - fast single-pass reasoning (default) export CODEGRAPH_AGENT_ARCHITECTURE=react codegraph start stdio ``` ```bash # LATS - Language Agent Tree Search for complex multi-path exploration export CODEGRAPH_AGENT_ARCHITECTURE=lats codegraph start stdio ``` ```bash # With bootstrap context for faster first queries export CODEGRAPH_ARCH_BOOTSTRAP=true export CODEGRAPH_ARCH_PRIMER="Focus on authentication and API layer" codegraph start stdio --watch ``` -------------------------------- ### Trace Call Chain Tool Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Traces execution call chains starting from a function to map control flow. It requires a starting node ID and a maximum depth, returning the call chain and related information. ```json { "name": "trace_call_chain", "arguments": { "node_id": "nodes:a1b2c3d4", "max_depth": 5 } } ``` ```json { "tool": "trace_call_chain", "parameters": { "from_node": "nodes:a1b2c3d4", "max_depth": 5 }, "result": { "chain": [ { "depth": 0, "node": {"id": "nodes:a1b2c3d4", "name": "authenticate_user", "file_path": "src/auth/handler.rs"} }, { "depth": 1, "node": {"id": "nodes:e5f6g7h8", "name": "verify_password", "file_path": "src/auth/crypto.rs"} }, { "depth": 2, "node": {"id": "nodes:i9j0k1l2", "name": "argon2_verify", "file_path": "src/auth/crypto.rs"} } ], "total_depth": 2, "branches": 1 } } ``` -------------------------------- ### Apply SurrealDB Schema via CLI Source: https://github.com/jakedismo/codegraph-rust/blob/main/schema/README.md Demonstrates how to apply the SurrealDB schema definition file (`codegraph.surql`) to a SurrealDB instance using the SurrealDB CLI. This involves connecting to the database and redirecting the schema file's content. ```bash # Connect to your SurrealDB instance surreal sql --endpoint http://localhost:8000 --namespace your_namespace --database codegraph # Apply the schema < schema/codegraph.surql ``` ```bash # Using surrealist or web interface, paste the contents of codegraph.surql # Or use the SQL command directly: surreal sql --endpoint http://localhost:8000 \ --namespace your_namespace \ --database codegraph \ --auth-level root \ --username root \ --password root \ < schema/codegraph.surql ``` -------------------------------- ### GET /calculate_coupling Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/architecture/agent-context-gathering-flow.html Calculates afferent/efferent coupling and instability metrics for a node. ```APIDOC ## GET /calculate_coupling ### Description Calculate afferent/efferent coupling and instability metrics. ### Method GET ### Endpoint /calculate_coupling ### Parameters #### Query Parameters - **node_id** (String) - Required - Node to analyze ### Response #### Success Response (200) - **Ca** (i32) - Afferent coupling - **Ce** (i32) - Efferent coupling - **Instability** (float) - Ce / (Ca + Ce) #### Response Example { "Ca": 5, "Ce": 2, "Instability": 0.28 } ``` -------------------------------- ### Observability Tips Source: https://github.com/jakedismo/codegraph-rust/blob/main/crates/codegraph-mcp/README.md Provides guidance on monitoring and debugging the CodeGraph system, including log output and performance metrics. ```APIDOC ## Observability ### Tips for Monitoring - **Debug Mode**: Start the server with `--debug` to tee AutoAgents traces into `~/.codegraph/logs`. - **Structured Output**: Store the structured output emitted by each tool for regression testing. - **Performance Metrics**: The Python harness prints timing data (e.g., `26.6s` for `agentic_code_search`) to monitor throughput after changes to embeddings or providers. ``` -------------------------------- ### Verify NAPI Bindings with JavaScript Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md A JavaScript test script to verify semantic search, cloud configuration, and embedding statistics functionality. ```javascript import { semanticSearch, getCloudConfig, getEmbeddingStats } from './index.js'; const results = await semanticSearch('configuration management', { limit: 5, useCloud: false }); console.log(`Found ${results.totalCount} results`); const config = await getCloudConfig(); console.log('Cloud config:', config); const stats = await getEmbeddingStats(); console.log('Embedding stats:', stats); ``` -------------------------------- ### GET /get_transitive_dependencies Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/architecture/agent-context-gathering-flow.html Retrieves all transitive dependencies for a specific node up to a defined depth. ```APIDOC ## GET /get_transitive_dependencies ### Description Get all transitive dependencies of a code node up to specified depth. ### Method GET ### Endpoint /get_transitive_dependencies ### Parameters #### Query Parameters - **node_id** (String) - Required - Node to analyze (e.g., "nodes:123") - **edge_type** (String) - Optional - Calls, Imports, Uses, etc. (default: Calls) - **depth** (i32) - Optional - Max traversal depth (default: 3) ### Request Example GET /get_transitive_dependencies?node_id=nodes:123&depth=5 ### Response #### Success Response (200) - **dependencies** (Array) - List of transitive dependency nodes #### Response Example { "dependencies": ["nodes:456", "nodes:789"] } ``` -------------------------------- ### GET /get_reverse_dependencies Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/architecture/agent-context-gathering-flow.html Identifies all nodes that depend on the specified node, useful for impact analysis. ```APIDOC ## GET /get_reverse_dependencies ### Description Get all nodes that depend on the specified node. ### Method GET ### Endpoint /get_reverse_dependencies ### Parameters #### Query Parameters - **node_id** (String) - Required - Node to analyze - **edge_type** (String) - Optional - Dependency type (default: Calls) - **depth** (i32) - Optional - Max depth (default: 3) ### Request Example GET /get_reverse_dependencies?node_id=nodes:123 ### Response #### Success Response (200) - **dependents** (Array) - List of nodes that depend on the target node #### Response Example { "dependents": ["nodes:001", "nodes:002"] } ``` -------------------------------- ### Index Project with CodeGraph Source: https://github.com/jakedismo/codegraph-rust/blob/main/docs/TESTING.md Shows the command to index the current project using CodeGraph. This is necessary to populate the database with nodes, which is a prerequisite for operations like vector search. ```bash codegraph index . ``` -------------------------------- ### POST trace_call_chain Source: https://context7.com/jakedismo/codegraph-rust/llms.txt Traces execution call chains starting from a function to map control flow through the codebase. ```APIDOC ## POST trace_call_chain ### Description Traces execution call chains starting from a function to map control flow through the codebase. ### Method POST ### Endpoint trace_call_chain ### Parameters #### Request Body - **node_id** (string) - Required - The starting node identifier. - **max_depth** (integer) - Required - The maximum depth of the call chain to trace. ### Request Example { "node_id": "nodes:a1b2c3d4", "max_depth": 5 } ### Response #### Success Response (200) - **chain** (array) - Ordered list of nodes in the call chain. #### Response Example { "chain": [ {"depth": 0, "node": {"id": "nodes:a1b2c3d4", "name": "authenticate_user"}} ] } ``` -------------------------------- ### Analyze Query Performance (SurrealQL) Source: https://github.com/jakedismo/codegraph-rust/blob/main/schema/README.md Analyzes the execution plan of a SurrealQL query to identify potential performance bottlenecks. The EXPLAIN keyword shows how the database intends to execute the query. ```surrealql -- Analyze query performance EXPLAIN SELECT * FROM nodes WHERE node_type = 'Function'; ```