run standalone server - stakwork/stakgraph GitHub Wiki

Stakgraph: Running the Standalone Server and Managing Graphs

This guide will walk you through spinning up the Neo4j database, configuring your environment, and using the standalone server to ingest, update, or clear your code graph.

1. Prerequisites

  • Docker is installed on your machine
  • Rust toolchain (for building/running the server)
  • (Optional) A GitHub Personal Access Token if you want to ingest private repositories

2. Start Neo4j with Docker

The project provides a docker-compose.yaml and a custom Dockerfile.neo4j for a ready-to-use Neo4j instance with plugins.

Step 1: Start Neo4j with Docker Compose

cd mcp
docker-compose up -d neo4j
  • Neo4j Browser: http://localhost:7474
  • Bolt port: 7687
  • Default credentials:
    • Username: neo4j
    • Password: testtest

3. Configure Environment Variables

export USE_LSP=false

For Local Repository

export REPO_PATH=/absolute/path/to/your/local/repo

For Remote Repository

export REPO_URL=https://github.com/youruser/yourrepo.git
export USERNAME=your_github_username         # Only needed for private repos
export PAT=your_github_pat                   # Only needed for private repos

Note: If both REPO_PATH and REPO_URL are set, the local path (REPO_PATH) takes priority

4. Run the Standalone Server

Build and run the server with Neo4j support:

cargo run --bin standalone --features neo4j

The server will listen on port 7777 by default.

5. Using the API Endpoints

You can interact with the server using curl or any HTTP client.

Ingest (Full Graph Build)

Builds the full graph from the latest state of your repo.

For local repo:

curl -X POST http://localhost:7777/ingest \
  -H "Content-Type: application/json" \
  -d '{"repo_path":"/Users/youruser/Projects/stakgraph"}'

For a remote public repo:

curl -X POST http://localhost:7777/ingest \
  -H "Content-Type: application/json" \
  -d '{"repo_url":"https://github.com/stakwork/stakgraph.git"}'

For a remote private repo:

curl -X POST http://localhost:7777/ingest \
  -H "Content-Type: application/json" \
  -d '{"repo_url":"https://github.com/youruser/yourprivaterepo.git","username":"yourusername","pat":"yourtoken"}'

Process (Incremental Update)

Updates the graph only if the repository has changed since the last ingest.

Example

curl -X POST http://localhost:7777/process \
  -H "Content-Type: application/json" \
  -d '{"repo_url":"https://github.com/stakwork/stakgraph.git"}'

Clear (Delete All Graph Data)

Clears all nodes and edges from the graph.

curl -X POST http://localhost:7777/clear

Example

Local Flow

export REPO_PATH=export REPO_PATH=/Users/Projects/stakgraph
cargo run --bin standalone --features neo4j
# In another terminal:
curl -X POST http://localhost:7777/process \
  -H "Content-Type: application/json" \
  -d '{"repo_path":"/Users/youruser/Projects/stakgraph"}'

Remote Flow

export REPO_URL="https://github.com/stakwork/stakgraph.git"
cargo run --bin standalone --features neo4j
# In another terminal:
curl -X POST http://localhost:7777/process \
  -H "Content-Type: application/json" \
  -d '{"repo_url":"https://github.com/stakwork/stakgraph.git"}'

Wait for a while, depending on the size of your repo.

Screenshot 2025-05-22 at 10 44 45 PM

Happy graphing! For more details, see the source code or open an issue.

⚠️ **GitHub.com Fallback** ⚠️