spicedb-mcp-server
An MCP server that enables LLMs to interact with SpiceDB for permission management, including querying, managing, and understanding permission systems via the SpiceDB HTTP API.
README
SpiceDB MCP Server
[!CAUTION] This is an experimental MCP server. This is only intended for educational purposes so use at your own risk.
A Model Context Protocol (MCP) server that connects to SpiceDB via its HTTP API for permission management. This server enables LLMs like Claude to interact with your SpiceDB instance to query, manage, and understand your permission system.
Features
[!NOTE] Everything in this repo was almost entirely created by Claude 3.5 Sonnet. Any quirks, unusual patterns, or potential errors are direct artifacts of LLM-based generation.
-
Resources:
- Schema retrieval with associated object definition resources
- Relationship queries with interactive relationship resources
- Object definitions with detailed type information
-
Tools:
- Read schema with object definition resources
- Read relationships with relationship resources
- Check permissions with detailed authorization traces and explanations
- Look up resources by subject with permission context
- Look up subjects by resource with permission details
- Write relationships with validation
Prerequisites
- Node.js 16+
- SpiceDB instance
- SpiceDB API key
Installation
-
Clone this repository:
git clone https://github.com/authzed/spicedb-mcp-server.git cd spicedb-mcp-server -
Install dependencies:
npm install # or yarn install -
Configure your environment:
Create a
.envfile with your SpiceDB connection details:# SpiceDB HTTP API endpoint (the default port for HTTP API is typically 8443) SPICEDB_ENDPOINT=http://localhost:8443 # or for TLS: https://spicedb.example.com SPICEDB_API_KEY=your-api-key-here SPICEDB_USE_TLS=false -
Build the server:
npm run build # or yarn build
Usage
Running Directly
Run the server from the command line:
node build/index.js
# or
npm start
# or
yarn start
Integrating with Claude for Desktop
-
Edit your Claude for Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json -
Add the SpiceDB MCP server to the
mcpServerssection:
{
"mcpServers": {
"spicedb": {
"command": "node",
"args": [
"/path/to/spicedb-mcp-server/build/index.js"
],
"env": {
"SPICEDB_ENDPOINT": "http://localhost:8443",
"SPICEDB_API_KEY": "your-api-key-here",
"SPICEDB_USE_TLS": "false"
}
}
}
}
-
Restart Claude for Desktop
-
View logs for Claude Desktop and SpiceDB MCP
macOS:
/Users/<your username>/Library/Logs/Claude/mcp-server-spicedb.logand/Users/<your username>/Library/Logs/Claude/mcp.log
Examples
[!NOTE] A SpiceDB instance with a schema and relationship data should be running with the flag
--http-enabled
Example Commands for Claude
Check a permission:
"Does user:alice have the permission view on document:report1?"
Find all resources a subject can access:
"What documents can user:bob read?"
Find all subjects that can access a resource:
"Who has edit permission on project:website?"
Analyze schema:
"Can you explain the permission system schema?"
Setup test scenarios
"Setup the following scenario by writing the appropriate relationships: there is a new role "auditor" and user jared has that role"
Preview compliance operations
"The project pied_piper is now deprecated. Find all users who have some form of access to it and create a comprehensive list of users and their access"
API Reference
Resources
spicedb://schema- Get the current schema, returns both schema text and object definition resourcesspicedb://relationships/{resourceType?}/{resourceId?}/{relation?}/{subjectType?}/{subjectId?}/{subjectRelation?}- Query relationships with optional filtersspicedb://definition/{objectType}- Get detailed definition for a specific object type
Tools
read-schema- Retrieves the current schema with object definition resourcesread-relationships- Queries relationships based on filter parameters, returns both text output and relationship resourcescheck-permission- Checks if a subject has a specific permission on a resource with debug tracing and explanations of the authorization decisionlookup-resources- Finds resources where a subject has a specific permission, optimized for array response formatslookup-subjects- Finds subjects with a specific permission on a resource, optimized for array response formatswrite-relationship- Creates, updates, or deletes a relationship with validation
Prompts
lookup-resources-for-subject- Finds resources a subject can accesslookup-subjects-for-resource- Finds subjects that can access a resourceexplain-permission-check- Explains a permission check resultanalyze-schema- Analyzes the current permission schema
Relationship Format
Relationships in SpiceDB are formatted as:
resourceType:resourceId#relation@subjectType:subjectId[#subjectRelation]
This format combines:
- Resource:
resourceType:resourceId(the object being accessed) - Relation:
#relation(the relationship type) - Subject:
subjectType:subjectId(the actor accessing the resource) - Optional subject relation:
#subjectRelation(for computed subjects)
Examples:
document:report#viewer@user:alice- User alice is a viewer of the report documentproject:website#admin@group:engineering#member- Members of the engineering group are admins of the website projectresource:promserver#viewer@usergroup:engineering#member- Members of the engineering user group are viewers of the promserver resource
MCP Connection Lifecycle
The SpiceDB MCP server implements the full Model Context Protocol connection lifecycle:
-
Initialization Request: When a client connects, it sends an
initializerequest containing:- Protocol version
- Client information (name, version)
- Client capabilities
-
Server Response: The server responds with:
- Protocol version
- Server information (name, version)
- Server capabilities (resources, tools, prompts, etc.)
-
Initialization Confirmation: The client sends an
initializednotification to confirm the connection. -
Message Exchange: Normal operation begins with the exchange of requests and responses.
-
Termination: When the client disconnects, the server cleans up resources.
The server logs details about this lifecycle to stderr, which you can observe when running the server directly.
Server Capabilities
This server provides the following capabilities:
- Resources: Exposes schema, relationships, and definitions as readable and navigable resources
- Tools: Provides tools for interacting with SpiceDB with rich responses including resources
- Prompts: Offers template prompts for common permission-related tasks and analysis
- Debug Tracing: Includes detailed authorization decision traces and explanations
- Response Formats: Support for both legacy and array-based SpiceDB API response formats
- Logging: Provides structured logging for troubleshooting and monitoring
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.