ST

Stardog MCP Server: Semantic AI Knowledge Graph

Deliver trusted, contextual answers for humans and agents with your enterprise knowledge graph using Stardog's MCP server and Semantic AI platform.

Quick Install
npx -y @stardog-union/stardog-cloud-mcp

Overview

The Stardog MCP Server implements a Model Context Protocol (MCP) adapter that connects large language models and agent frameworks to your Stardog knowledge graph and Semantic AI platform. It exposes a concise, machine-readable set of tools and contextual data so LLMs and agents can discover available capabilities, request provenance-rich context, and execute graph-backed operations safely and consistently.

This server is useful when you need trustworthy, contextual answers that combine LLM reasoning with authoritative enterprise knowledge: it centralizes context assembly (semantic search, SPARQL, metadata), provides standardized tool descriptions for agents, and returns responses with provenance and routing information so downstream systems and humans can validate results.

Features

  • Implements MCP-style tool and context discovery for LLMs and agents
  • Bridges LLMs with Stardog knowledge graphs (SPARQL, reasoning, metadata)
  • Semantic retrieval and vector/embedding integration for contextual search
  • Standardized tool descriptions and capabilities (name, inputs, outputs, permissions)
  • Provenance, source citations, and metadata included in responses
  • Configurable via environment variables and Docker for easy deployment
  • REST endpoints for registering tools, requesting context, and health checks
  • Logging, basic auth / token support and pluggable adapter points for custom auth

Installation / Configuration

Prerequisites: Docker and Docker Compose or a JVM (if building from source). Example steps use Docker.

Clone the repository and run with Docker:

git clone https://github.com/stardog-union/stardog-cloud-mcp.git
cd stardog-cloud-mcp
docker build -t stardog-mcp .
docker run -p 8080:8080 \
  -e STARDOG_URL="https://stardog.example.com" \
  -e STARDOG_USER="admin" \
  -e STARDOG_PASSWORD="secret" \
  -e MCP_PORT="8080" \
  -e LOG_LEVEL="info" \
  stardog-mcp

Or use docker-compose (example compose snippet):

version: "3.7"
services:
  mcp:
    image: stardog-mcp:latest
    ports:
      - "8080:8080"
    environment:
      - STARDOG_URL=https://stardog.example.com
      - STARDOG_USER=admin
      - STARDOG_PASSWORD=secret
      - MCP_PORT=8080

Common environment variables

VariableDescriptionExample
STARDOG_URLBase URL for Stardog serverhttps://stardog.example.com
STARDOG_USERStardog usernameadmin
STARDOG_PASSWORDStardog passwordsecret
MCP_PORTPort the MCP server listens on8080
LOG_LEVELLogging verbosity (debug/info/warn/error)info
JWT_SECRETSecret for signing tokens (optional)abc123

After starting, confirm health:

curl http://localhost:8080/health
# Expect JSON status response

Available Resources

The server exposes REST endpoints that agents and developer tools use to discover capabilities and request context. Typical endpoints include:

  • GET /mcp/tools — list registered tools (name, description, schema)
  • POST /mcp/tools — register or update a tool
  • POST /mcp/context — request assembled context for a query or tool invocation
  • GET /health — basic health check

Example: register a tool (curl)

curl -X POST http://localhost:8080/mcp/tools \
  -H "Content-Type: application/json" \
  -d '{
    "name": "stardog-sparql",
    "description": "Run parameterized SPARQL queries against the knowledge graph",
    "inputs": {"query": "string"},
    "outputs": {"results": "json"},
    "permissions": ["query:read"]
  }'

Example: request context (curl)

curl -X POST http://localhost:8080/mcp/context \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "stardog-sparql",
    "prompt": "Find active employees with expertise in graph databases",
    "maxContext": 5
  }'

Responses typically include contextual documents, vector-scores, endpoint hints, and source citations to support trustworthy LLM output.

Use Cases

  • Conversational enterprise assistant: Combine LLM generation with Stardog-backed facts (employee records, product ontologies). The agent queries /mcp/tools and /mcp/context to assemble reliable evidence before answering.
  • Retrieval-Augmented Generation (RAG) with provenance: Use semantic retrieval to collect top-N knowledge graph nodes and passages, attach citations, and feed the assembled context to an LLM for an auditable answer.
  • Automated workflows and agents: Expose graph operations (SPARQL queries, updates, reasoning calls) as MCP tools so agents can plan and execute multi-step tasks (data validation, remediation) with policy checks.
  • Compliance and audit trails: Every context assembly and tool invocation returns metadata and sources, which you can log or store for later audits and traceability.

Getting Started Tips

  • Start by registering a minimal set of tools for read-only operations (SPARQL query tool, semantic search tool).
  • Configure selective permissions and limit write tools in production environments.
  • Use small context sizes initially and tune retrieval parameters (maxContext, similarity thresholds) based on retrieval quality.
  • Integrate with your existing authentication (JWT, OAuth) via the server’s adapter hooks to enforce enterprise access controls.

For developers new to the project, review the repository’s example requests and adapter templates to add custom tools or modify context assembly strategies. The MCP server is intended as a lightweight, extensible bridge between LLM-based agents and Stardog-powered knowledge.