Backlinks
Give an AI agent such as Claude Code or Cursor access to a LinkedDataHub instance, with the ldh Claude Code plugin or over MCP with Web-Algebra
Agents use the same HTTP API as the browser and the CLI, and act as a WebID: an agent can read and write only what its WebID is authorized to. There are two ways to connect one. The Claude Code plugin gives Claude Code skills for building on LinkedDataHub with the ldh CLI. Web-Algebra exposes LinkedDataHub operations to any Model Context Protocol (MCP) client as tools: creating containers and items, adding views, queries and charts, reading and writing RDF, and running SPARQL. Either way, an agent can build a working application in a dataspace: its classes, containers, views and charts are documents like any other.
The conventions agents should follow when writing to LinkedDataHub are in AGENTS.md. To ask questions about the data in a document from the browser instead, use the assistant.
Claude Code plugin¶
The ldh plugin ships with LinkedDataHub. Its marketplace is the LinkedDataHub repository, so Claude Code is told about it once and then installs the plugin from it. In Claude Code:
/plugin marketplace add AtomGraph/LinkedDataHub /plugin install ldh@linkeddatahub
The skills drive the ldh CLI, so they need a LinkedDataHub instance, the owner's WebID certificate and the CLI on the PATH (see installing the CLI). Claude loads a skill by itself when a request matches what it covers. To call one explicitly, type /ldh: followed by its name.
| Skill | Covers |
|---|---|
| ldh:dataspace | Provisioning a new dataspace on a self-hosted instance: the configuration files, the restart, and checking that it is up |
| ldh:dataset | The namespace ontology and its install, CSV and RDF imports, federation with remote SPARQL endpoints, and building a large dataset standalone and bulk-loading it |
| ldh:app | Documents, blocks, views and charts, and an app kept as a directory and installed with ldh push |
| ldh:package | A reusable package: an ontology and an XSLT stylesheet, published to a registry and imported with ldh packages add |
A request can span several skills, and Claude uses them in turn:
Here are products.csv and categories.csv. Model them with schema.org, import them into the inventory dataspace, and make each category's page list its products.
Web-Algebra over MCP¶
Web-Algebra expresses LinkedDataHub operations, SPARQL queries and Linked Data reads as plans that run as one unit, and its MCP server offers them as tools. Any MCP client can use it.
Prerequisites¶
- A running LinkedDataHub instance. The examples below assume the default local setup at https://localhost:4443/.
- The WebID certificate the agent will act as. For your own instance that is the owner certificate, ssl/owner/cert.pem, with the password from secrets/owner_cert_password.txt. The agent can do whatever that WebID is authorized to do.
- uv, which runs Web-Algebra without a separate install step.
Claude Code¶
Register Web-Algebra as an MCP server, run from the LinkedDataHub directory:
claude mcp add web-algebra \ --env CERT_PEM_PATH="$PWD/ssl/owner/cert.pem" \ --env CERT_PASSWORD="$(cat secrets/owner_cert_password.txt)" \ -- uv run --with web-algebra python -m web_algebra
Start claude and check that /mcp lists web-algebra as connected.
Cursor and Claude Desktop¶
Both read an mcpServers entry: ~/.cursor/mcp.json for Cursor, claude_desktop_config.json for Claude Desktop. Use absolute paths and the literal password, since these files are not run by a shell.
{
"mcpServers": {
"web-algebra": {
"command": "uv",
"args": ["run", "--with", "web-algebra", "python", "-m", "web_algebra"],
"env": {
"CERT_PEM_PATH": "/path/to/LinkedDataHub/ssl/owner/cert.pem",
"CERT_PASSWORD": "your-owner-cert-password"
}
}
}
}If the client cannot find uv, replace "uv" with its absolute path, as printed by which uv.
Streamable HTTP transport¶
Clients that connect to an MCP URL instead of launching a process can use Web-Algebra's HTTP server:
CERT_PEM_PATH="$PWD/ssl/owner/cert.pem" \ CERT_PASSWORD="$(cat secrets/owner_cert_password.txt)" \ uv run --with web-algebra uvicorn web_algebra.server:app
The MCP URL is http://127.0.0.1:8000/mcp. For Claude Code:
claude mcp add --transport http web-algebra http://127.0.0.1:8000/mcp.
The HTTP server does not authenticate its callers, and it holds your WebID certificate. Anyone who can reach the port acts as you. Keep it bound to 127.0.0.1, which is the default, and do not expose it on a network.
Try it¶
Ask the agent for something small that it has to declare rather than code. With the Northwind Traders demo installed, for example:
Create a container for new offers in my dataspace, add a 20% discount offer for three Beverages products, and add a chart of the offer prices.
Then open https://localhost:4443/ in the browser. The container, the items and the chart are there, and you can keep editing them by hand — the agent and you work on the same documents.