rudof mcp

rudof mcp starts rudof as an MCP (Model Context Protocol) server. Any MCP client can use its features: an AI assistant, an IDE extension or your own program.

rudof mcp

This starts the server with the stdio transport. The client starts rudof as a subprocess, and both send JSON-RPC messages through standard input and output.

The other transport is streamable-http. The server runs on its own and serves several clients over HTTP POST and GET. It can stream messages back with Server-Sent Events. By default, it listens on 127.0.0.1:8000, at the route /rudof.

Exporting RDF data to PlantUML, SVG or PNG needs plantuml.jar on disk and the PLANTUML environment variable pointing at it. Set it in the client configuration (see Connecting a client) or in the environment the server is started from.

What the server offers

CapabilityFeature
tools13 tools for validation, querying, data and session operations
promptsGuided templates for common workflows
resourcesAccess to the loaded RDF data and to the external-resolver kinds
resource templatesURI template for reading the data in any supported format
loggingLog notifications with level filtering
completionsArgument completions for prompts and resources

Tools

Data management:

ToolDescription
load_rdf_data_from_sourcesLoad RDF data from URLs, files, raw text, or SPARQL endpoints. With data_format: "html", it reads the RDF of the microdata, the RDFa and the JSON-LD in HTML pages. html_extraction selects microdata, rdfa, jsonld or any
export_rdf_dataSerialize RDF data to a format such as Turtle, JSON-LD or N-Triples
export_plantumlGenerate a PlantUML diagram of the RDF graph
export_imageGenerate an SVG or PNG visualization of the RDF graph

Node inspection and query:

ToolDescription
node_infoShow information about a node (outgoing and incoming arcs)
execute_sparql_queryExecute SPARQL queries (SELECT, CONSTRUCT, ASK)

ShEx and SHACL:

ToolDescription
validate_shexValidate RDF data against a ShEx schema
check_shexCheck if a ShEx schema is well-formed
generate_datatriple_count, the generated data (Turtle), and the shapemap of every generated node, ready for validate_shex. From a PG-Schema, also property_graph and type_map. With violations, the violations report, and rdf_violations for the RDF version of a property graph
show_shexSerialize a ShEx schema, with optional statistics and dependencies
validate_shaclValidate RDF data against a SHACL schema

Session management:

ToolDescription
reset_session_stateClear session state (all, or specific targets like data/shex/shacl/…)
get_rudof_versionReport the rudof version this MCP server is running
manage_prefixesShow or manage the session’s default prefixes (list/add/remove/rename/copy), mirroring the shell’s prefixes command
generate_dataGenerate synthetic data from a ShEx, SHACL or PG-Schema schema. It can add controlled violations, with the report of what a validator must find. The data is loaded into the session for validation

The data of a session stays loaded until the session ends or reset_session_state clears it. Each load_rdf_data_from_sources call merges new data into it.

The server resolves a relative file path against the working directory where the client started it. To use files in other folders, pass absolute paths, or run a filesystem MCP server next to this one.

Prompts

PromptDescription
explore_rdf_nodeInteractive guide for exploring RDF node information and relationships
analyze_rdf_dataComprehensive guide for analyzing RDF data structure and quality
validation_guideStep-by-step guide for validating RDF data against ShEx or SHACL schemas

Tool parameters and results

A parameter can have a fixed set of values, such as an RDF format, a validation mode or a sort order. The input schema of the tool lists these values. A client reads them from tools/list and does not have to guess.

Each tool answers with both halves of an MCP tool result:

  • structuredContent has the facts, in the output schema of the tool. RDF terms are typed, not rendered as text. A term is an IRI, a blank node, a literal with its datatype and language tag, or an RDF 1.2 triple term.
  • content has a short summary of the facts. The rendered report also has its own field in structuredContent: report for the validators, and results for the other tools.
ToolWhat structuredContent carries
validate_shaclconforms, counts_by_severity, the rendered report, and one entry per result. Each entry has the focus node, severity, constraint component, path, value, source shape, messages and nested sh:detail results
validate_shexconforms, counts by status, one entries item per (node, shape) pair with the validator’s reason, and the rendered report
execute_sparql_queryquery_type, plus bindings (variables and one row per solution, keyed by variable name) for a SELECT or boolean for an ASK
node_infooutgoing_arcs and incoming_arcs, each arc with its direction, depth, predicate and the term at its far end, plus stats
show_shexschema, and statistics / dependencies when asked for with show_statistics / show_dependencies
check_shexwell_formed, and the checker’s report. A schema that is not well-formed is an answer, not a tool error

Resources

The loaded RDF data is readable as a resource:

  • rudof://current-data, in Turtle (the listed resource).
  • rudof://current-data/{format}, the resource template, where {format} is one of turtle, ntriples, rdfxml, jsonld, trig, nquads, n3.

One more resource describes a validate_shex parameter:

  • rudof://shex/external-resolvers, the external-shape resolver kinds the tool accepts.

Changing MCP server settings

Transport type

--transport (or -t) takes stdio (the default) or streamable-http:

rudof mcp --transport streamable-http

The options below only apply to streamable-http.

Bind address

--bind (or -b) is the network interface the server listens on. It defaults to 127.0.0.1, reachable from this machine only, which is also the safest choice:

rudof mcp --transport streamable-http --bind 0.0.0.0

With 0.0.0.0 or ::, the server is reachable from every network interface. Use firewall rules with it. --allowed-host is then required: with a wildcard address, the server cannot know the name that clients will use. Until you add your own names, it accepts only loopback Host headers.

Port and route

--port (or -p) defaults to 8000. --route (or -r) defaults to /rudof and must start with a /:

rudof mcp --transport streamable-http --port 9000 --route /rdfserver

Allowed origins and hosts

The MCP specification requires an HTTP server to validate two request headers, and rudof configures both.

Origin: the browser origins that can call the server. An origin is a (scheme, host, port) triple, as RFC 6454 defines. By default, the server accepts only loopback origins (http://localhost:*, http://127.0.0.1:*, http://[::1]:* and their https forms). A request with another Origin gets 403 Forbidden. A request with no Origin header (curl, a CLI client, server to server) skips this rule.

To set your own list, use --allowed-origin (or -o), with commas or several times. Each entry needs a scheme, and must have an explicit port or :*:

rudof mcp --transport streamable-http -o https://app.example.com:443 -o http://localhost:*

Host: the names that clients can use to reach the server. This rule stops DNS rebinding attacks. The server always accepts loopback, and adds a specific --bind address automatically. For a wildcard address, give the names with --allowed-host (or -H):

rudof mcp --transport streamable-http --bind 0.0.0.0 -H rdf.example.com

The three options control different things:

  • --bind: the network interface where the server listens.
  • --allowed-origin: the web origins that can call it (browser clients).
  • --allowed-host: the names that it answers to (protection against DNS rebinding).

You can combine them. For example, this command serves port 8080 at /rdf, for the name rdf.example.com on the local network, and for one web application:

rudof mcp --transport streamable-http --bind 0.0.0.0 --port 8080 --route /rdf -H rdf.example.com -o https://app.example.com:443

Keeping the data of a containerized server

If the container of a server is created again for each tool call, the loaded data is lost. To prevent this, if the folder of the state file exists, the server writes the data there and reads it again at startup. The file is /app/state/data.json, so you only need to mount a volume at /app/state/. RUDOF_MCP_STATE_PATH sets another path.

Connecting a client

Any MCP client can use the server. The examples below use Claude Desktop. The entries go in the MCP servers section of its configuration file.

Over stdio, the client launches the server itself:

"rudof": {
  "command": "/path/to/rudof.exe",
  "args": [ "mcp" ],
  "env": {
      "PLANTUML": "/path/to/plantuml.jar"
   },
  "enabled": true
}

Over streamable-http, the server has to be running already (for example with rudof mcp --transport streamable-http), and the client reaches it through mcp-remote, which needs Node.js:

"rudof": {
  "command": "npx",
  "args": [
    "mcp-remote",
    "http://localhost:8000/rudof",
    "--transport",
    "http-first"
  ],
  "enabled": true
}

Prompt examples

Once connected, you drive rudof in natural language. The data can be loaded inline, from a file or from a URL:

Import the following RDF data into the graph:

prefix : <http://example.org/>
prefix schema: <http://schema.org/>

:a schema:name  "Alice" ;
   :status      :Active ;
   schema:knows :a, :b  .

:b schema:name  "Bob"    ;
   :status      :Waiting ;
   schema:knows :c       .

:c schema:name  "Carol"  .

:d schema:name  23      .

:e schema:name  "Emily" ;
   schema:knows :d      .

With the data loaded, you can explore a node, export the graph to another serialization (JSON-LD, Turtle, …) or to a visualization (PlantUML, SVG, PNG):

I'd like to explore the RDF node ':a' and see all its relationships in the loaded graph.
Export the current RDF graph to JSON-LD format.
Export the current RDF graph to PNG.

Queries can be given as SPARQL:

Run the following SPARQL query on the current RDF graph:

prefix : <http://example.org/>
prefix schema: <http://schema.org/>

select ?person ?name ?status where {
  ?person schema:name ?name ;
          :status ?status .
}

or described in words, leaving the client to write the query:

For each person, return the total number of people they know either directly or indirectly with a relationship degree of 2, that is, they know someone who knows that person.

Validation works the same way with a ShEx schema:

Validate the current RDF graph against the following ShEx schema:

prefix : <http://example.org/>
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

:Person {
  schema:name xsd:string ;
  :status [:Active :Waiting]? ;
  schema:knows @:Person *
}

or with a SHACL shapes graph:

Validate the current RDF graph against this SHACL schema:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/> .

ex:PersonShape a sh:NodeShape ;
  sh:targetClass schema:Person ;
  sh:property [
    sh:path schema:name ;
    sh:datatype xsd:string ;
    sh:minCount 1 ;
  ] .

A schema can also be checked on its own, without any data loaded:

Check if the following ShEx schema is valid:

prefix : <http://example.org/>
:Shape { :property . }

Options

$ rudof mcp --help
Export rudof as an MCP server

Usage: rudof mcp [OPTIONS]

Options:
  -t, --transport <TRANSPORT>
          Transport type: stdio (for CLI/IDE) or streamable-http (for web clients)

          Possible values:
          - stdio:           Standard input/output transport (for local CLI usage)
          - streamable-http: HTTP with Server-Sent Events transport (for network usage)

          [default: stdio]

  -b, --bind <ADDRESS>
          Bind address for the streamable-http transport. Examples: 127.0.0.1 (localhost IPv4), 0.0.0.0 (all IPv4 interfaces), ::1 (localhost IPv6), :: (all IPv6 interfaces). Default: 127.0.0.1 for security

          [default: 127.0.0.1]

  -p, --port <PORT>
          Port number (only used with the streamable-http transport)

          [default: 8000]

  -r, --route <PATH>
          Route path for the MCP endpoint (only used with the streamable-http transport)

          [default: /rudof]

  -o, --allowed-origin [<ORIGIN>...]
          Browser origin allowed to call the server (only used with the streamable-http transport). Can be comma-separated or specified multiple times. Each entry needs a scheme and should carry an explicit port or ':*'. Examples: http://localhost:*, https://app.example.com:443. If not specified, only loopback origins are allowed

  -H, --allowed-host [<HOST>...]
          Host authority clients may use to reach the server, on top of loopback (only used with the streamable-http transport). Can be comma-separated or specified multiple times. Required when binding to all interfaces. Examples: example.com, example.com:8080, 10.0.0.5

  -h, --help
          Print help (see a summary with '-h')