rudof_mcp
The rudof_mcp crate provides an implementation of an MCP (Model Context Protocol) server that exposes the core functionality of the rudof library.
It is built using the rmcp SDK.
MCP Transport Types
The Rudof MCP server supports two configurable transport mechanisms:
-
stdio(default): The client launches the MCP server as a subprocess. The server reads JSON-RPC messages from standard input (stdin) and writes responses to standard output (stdout). -
streamable-http: The server runs as an independent process capable of handling multiple concurrent client connections. This transport uses HTTPPOSTandGETrequests and can optionally leverage Server-Sent Events (SSE) to stream multiple server messages.The Rudof MCP server allows configuring:
-
Bind address
-
Port
-
Route name
-
Allowed networks It also implements the security requirements defined by the MCP specification:
-
Origin Validation
-
Protocol Version Validation
-
Session Management
-
MCP Capabilities
The Rudof MCP server exposes the following capabilities:
| Capability | Description |
|---|---|
tools | 10 tools for validation, querying, and data operations |
prompts | Guided templates for common workflows |
resources | Access to RDF data and format metadata |
resource templates | URI template for accessing RDF data in any supported format |
logging | Real-time log notifications with level filtering |
completions | Argument completion for prompts and resources |
Available Tools
The MCP server provides 10 tools grouped by functionality.
Data Management
| Tool | Description |
|---|---|
load_rdf_data_from_sources | Load RDF data from URLs, files, raw text, or SPARQL endpoints |
export_rdf_data | Serialize RDF data into multiple formats (Turtle, JSON-LD, N-Triples, etc.) |
export_plantuml | Generate a PlantUML diagram of the RDF graph |
export_image | Generate SVG or PNG visualizations of the RDF graph |
⚠️ IMPORTANT: The
export_imagetool require plantuml.jar. Set thePLANTUMLenvironment variable to its path before using them.
Node Inspection
| Tool | Description |
|---|---|
node_info | Retrieve information about a node (incoming and outgoing arcs) |
Query
| Tool | Description |
|---|---|
execute_sparql_query | Execute SPARQL queries (SELECT, CONSTRUCT, ASK, DESCRIBE) |
ShEx Tools
| Tool | Description |
|---|---|
validate_shex | Validate RDF data against a ShEx schema |
check_shex | Verify whether a ShEx schema is well-formed |
show_shex | Parse and display ShEx schemas with optional analysis |
SHACL Tools
| Tool | Description |
|---|---|
validate_shacl | Validate RDF data against a SHACL schema |
Available Prompts
The MCP server includes guided templates for common workflows:
| Prompt | Description |
|---|---|
explore_rdf_node | Interactive guide for exploring RDF nodes and their relationships |
analyze_rdf_data | Comprehensive guide for analyzing RDF data structure and quality |
validation_guide | Step-by-step guide for validating RDF data with ShEx or SHACL |
Available Resources
The server exposes resources for accessing RDF data and format metadata.
Current RDF Data
rudof://current-data— Turtle format (listed resource)
Additional formats are accessible via the resource template rudof://current-data/{format}, where {format} is one of: turtle, ntriples, rdfxml, jsonld, trig, nquads, n3.
Format Information
rudof://formats/rdf— Supported RDF formatsrudof://formats/shex— Supported ShEx formatsrudof://formats/shacl— Supported SHACL formatsrudof://formats/node-modes— Node inspection modesrudof://formats/query-types— Supported SPARQL query typesrudof://formats/query-results— Query result formatsrudof://formats/shex-validation-result— ShEx validation result formatsrudof://formats/shacl-validation-result— SHACL validation result formatsrudof://formats/validation-reader-modes— Reader modes (strict/lax)rudof://formats/shex-validation-sort-options— ShEx result sorting optionsrudof://formats/shacl-validation-sort-options— SHACL result sorting options
Usage
We can run Rudof MCP using different transport types depending on the environment (CLI tools, IDE extensions, or HTTP clients).
Run Rudof MCP using Stdio transport
#![allow(unused)] fn main() { use rudof_mcp::{run_mcp, McpConfig}; run_mcp(McpConfig::default())?; }
Run Rudof MCP using HTTP transport (localhost only)
#![allow(unused)] fn main() { use rudof_mcp::{run_mcp, McpConfig, TransportType}; let config = McpConfig { transport: TransportType::StreamableHTTP, bind_address: Some("127.0.0.1".to_string()), port: Some(8080), route_path: Some("mcp".to_string()), allowed_networks: None, // Defaults to localhost only }; run_mcp(config)?; }
Run Rudof MCP using HTTP transport with custom allowed networks
#![allow(unused)] fn main() { use rudof_mcp::{run_mcp, McpConfig, TransportType}; let config = McpConfig { transport: TransportType::StreamableHTTP, bind_address: Some("0.0.0.0".to_string()), port: Some(9000), route_path: Some("mcp".to_string()), allowed_networks: Some(vec![ "127.0.0.1".to_string(), "192.168.1.0/24".to_string(), "::1".to_string(), ]), }; run_mcp(config)?; }
Run Rudof MCP asynchronously (inside an existing Tokio runtime)
#![allow(unused)] fn main() { use rudof_mcp::{run_mcp_async, McpConfig, TransportType}; let config = McpConfig { transport: TransportType::StreamableHTTP, bind_address: Some("127.0.0.1".to_string()), port: Some(8080), route_path: Some("mcp".to_string()), allowed_networks: None, }; tokio::spawn(async move { run_mcp_async(config).await.unwrap(); }); }
Dependencies
This crate primarily depends on:
rmcp— Rust MCP SDK for protocol implementationrudof_lib— Core Rudof library for RDF operationsaxum— Modern HTTP server for Streamable HTTP transporttokio— High-performance asynchronous runtimeipnetwork— IP address and network parsing and validation
Documentation
The crate documentation can be found here.