Skip to main content

MCP server for PyOxigraph

Project description

Oxigraph MCP Server

A Model Context Protocol (MCP) server for Oxigraph, a fast and lightweight RDF triple store with SPARQL support.

Oxigraph is a high-performance in-memory or file-based RDF graph database written in Rust. This MCP server provides a Claude-friendly wrapper for accessing PyOxigraph (the Python bindings for Oxigraph) through the Model Context Protocol.

Quickstart

Installation

uv pip install mcp-server-oxigraph

Minimal Claude Desktop Configuration

Add the following to your Claude Desktop MCP configuration:

"oxigraph": {
  "command": "uv",
  "args": ["run", "mcp-server-oxigraph"],
  "env": {}
}

Setting a Default Database (Optional)

To set a specific default database location, add the OXIGRAPH_DEFAULT_STORE environment variable:

"oxigraph": {
  "command": "uv",
  "args": ["run", "mcp-server-oxigraph"],
  "env": {
    "OXIGRAPH_DEFAULT_STORE": "~/.claude/my_knowledge_graph.oxigraph"
  }
}

Why Use Oxigraph MCP?

Oxigraph MCP is ideal for:

  • Quickly building knowledge bases: Store structured information in a queryable graph database
  • Prototyping semantic applications: Test data models and queries interactively
  • Schema development: Design and test RDF schemas and ontologies
  • Local data storage: Maintain persistent data without external services
  • SPARQL exploration: Experiment with complex SPARQL queries in an interactive environment

Features

This MCP server provides:

  • Direct PyOxigraph access: Clean, stateless wrapper for PyOxigraph functionality
  • Multiple store management: Create, open, and manage multiple file-based stores
  • Comprehensive RDF support: Work with all core RDF data types and operations
  • Full SPARQL implementation: Execute queries and updates with properly structured results
  • Rich serialization options: Support for all major RDF formats

About Oxigraph

Oxigraph is an open-source RDF triple store implemented in Rust. Key features include:

  • Fast in-memory or file-based storage using RocksDB
  • Full SPARQL 1.1 Query and Update support
  • Compliance with W3C standards
  • Support for various RDF serialization formats
  • Extremely low memory footprint compared to other graph databases

This MCP server uses PyOxigraph, the official Python bindings for Oxigraph.

Supported RDF Formats

The Oxigraph MCP server supports the following RDF serialization formats:

Format File Extension MIME Type Supports Named Graphs
Turtle .ttl text/turtle No
N-Triples .nt application/n-triples No
N-Quads .nq application/n-quads Yes
TriG .trig application/trig Yes
RDF/XML .rdf application/rdf+xml No
N3 .n3 text/n3 No

You can retrieve this information programmatically using the oxigraph_get_supported_formats() function.

Default Store Configuration

The server manages two types of default stores:

  1. System Default Store: Located at ~/.mcp-server-oxigraph/default.oxigraph
  2. User Default Store: Specified by setting the OXIGRAPH_DEFAULT_STORE environment variable

On startup, the server initializes both stores (if configured):

  • The system default store is always created
  • If a user default store is specified, it's also initialized
  • Operations will use the user default store if specified, otherwise the system default

You don't need to explicitly create or open these stores - they're automatically initialized when the server starts. All operations that don't specify a store path will use the appropriate default store.

Basic Usage Examples

Once configured, you can use the Oxigraph MCP tools in Claude to work with RDF data:

  1. Add RDF triples to the default store

    oxigraph_create_named_node(iri: "http://example.org/subject")
    oxigraph_create_named_node(iri: "http://example.org/predicate")
    oxigraph_create_literal(value: "Object value")
    oxigraph_create_quad(subject: subject, predicate: predicate, object: object)
    oxigraph_add(quad: quad)
    
  2. Query with SPARQL

    oxigraph_query(query: "SELECT * WHERE { ?s ?p ?o } LIMIT 10")
    
  3. Import and export RDF data in different formats

    oxigraph_parse(data: "@prefix ex: <http://example.org/> . ex:a ex:b ex:c .", format: "turtle")
    oxigraph_serialize(format: "ntriples")
    oxigraph_get_supported_formats()
    
  4. Create custom stores if needed

    oxigraph_create_store(store_path: "/path/to/my/custom.oxigraph")
    oxigraph_query(query: "SELECT * WHERE { ?s ?p ?o }", store_path: "/path/to/my/custom.oxigraph")
    

API Documentation

Store Management Functions

  • oxigraph_create_store: Create a new store (in-memory or file-based)
  • oxigraph_open_store: Open an existing file-based store
  • oxigraph_close_store: Close a store and remove it from the manager
  • oxigraph_backup_store: Create a backup of a store
  • oxigraph_restore_store: Restore a store from a backup
  • oxigraph_optimize_store: Optimize a store for better performance
  • oxigraph_list_stores: List all managed stores

Note: Most operations will work with the default store without needing to specify a store_path. For persistent storage, we recommend using the file path as the store_path for clarity.

RDF Data Model Functions

  • oxigraph_create_named_node: Create a NamedNode for use in RDF statements
  • oxigraph_create_blank_node: Create a BlankNode for use in RDF statements
  • oxigraph_create_literal: Create a Literal for use in RDF statements
  • oxigraph_create_quad: Create a Quad (triple with optional graph)
  • oxigraph_add: Add a quad to the store
  • oxigraph_add_many: Add multiple quads to the store
  • oxigraph_remove: Remove a quad from the store
  • oxigraph_remove_many: Remove multiple quads from the store
  • oxigraph_clear: Remove all quads from the store
  • oxigraph_quads_for_pattern: Query for quads matching a pattern

SPARQL Functions

  • oxigraph_query: Execute a SPARQL query against the store
  • oxigraph_update: Execute a SPARQL update against the store
  • oxigraph_query_with_options: Execute a SPARQL query with custom options
  • oxigraph_run_query: Run a SPARQL query or update against the store

Serialization Functions

  • oxigraph_parse: Parse RDF data and add to the store
  • oxigraph_serialize: Serialize the store to a string
  • oxigraph_import_file: Import RDF data from a file
  • oxigraph_export_graph: Export a graph to a file
  • oxigraph_get_supported_formats: Get a list of supported RDF formats

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_oxigraph-0.1.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_oxigraph-0.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_oxigraph-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_oxigraph-0.1.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mcp_server_oxigraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b63285e7b06fc96f88b54c63414a21bef8c641bfa4a1aa9337014e18a6b1793
MD5 aa85dc56d4a0101219d26bf065a4d795
BLAKE2b-256 66fe3f147824b29463d0d6eca25309b26057c34d61f93ea6646cf3271cade943

See more details on using hashes here.

File details

Details for the file mcp_server_oxigraph-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_oxigraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2147ce4e02b27051290e94b49b1abb4479fda0d35f47de2f25365d5ec384b364
MD5 1ad5428642f8210eb97a3c23e12356c3
BLAKE2b-256 d4c4b8a271dbe89f624bb794b99863ca758d6006f2fb6b7bcc17db1d7d876fca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page