Comunica
Comunica MCP SPARQL
Improving the Accuracy of AI Agents
using SPARQL-based Access to Decentralized Knowledge Graphs
QR to paper
Full paper

Why AI Agents + Knowledge Graphs?

  • LLMs hallucinate and generate plausible but incorrect answers based solely on training data.
  • Knowledge Graphs provide accurate, structured, live data (DBpedia, Wikidata, Solid pods, …).
  • Model Context Protocol (MCP) lets AI agents call external tools at runtime without retraining.
  • Goal: expose any Knowledge Graph via a SPARQL-based MCP interface using Comunica.

AI Agent Querying Knowledge Graphs

🤖 AI Agent (LLM) Claude · Copilot · ChatGPT MCP call SPARQL results Comunica MCP SPARQL SPARQL 1.2 · Federation · Link Traversal SPARQL queries 🌐 DBpedia SPARQL 📚 Wikidata SPARQL 🔒 Solid Pod + auth 🔗 Linked Data RDF docs 🗄️ Other KGs HDT · TPF

How It Works

Requires only a single config change:

{
  "mcpServers": {
    "comunica": {
      "command": "npx",
      "args": ["-y", "@comunica/mcp-sparql",
               "--mode", "stdio"]
    }
  }
}

Works with any MCP client, such as Claude Desktop, GitHub Copilot, VS Code, …

MCP Tools Exposed to AI Agents

query-sparql

Execute SPARQL queries over one or more remote sources: SPARQL endpoints, Linked Data docs, Solid pods, TPF interfaces, HDT files. Supports updates, federation, HTTP proxies, and authentication.

query-sparql-rdf

Execute SPARQL queries over a serialized RDF dataset as a string. Accepts any RDF media type (Turtle, JSON-LD, N-Triples, …).

Also: mcp-sparql-solid, mcp-sparql-link-traversal, mcp-sparql-file, mcp-sparql-hdt

Preliminary Findings

  • LLMs effectively query DBpedia and Wikidata (internalized during pretraining).
  • LLMs struggle with less-known KGs (UniProt, DBLP) unless explicitly guided.
  • LLMs can hallucinate SPARQL endpoint URLs and fail at federated queries.
  • "What movies do Brad Pitt and DiCaprio both star in?"
    → Claude alone: 1 answer. With Comunica MCP: 2 accurate answers via DBpedia.
  • Future: KG discovery, schema tools, guided federation.

Conclusion

  • Connects AI agents to one or more KGs via SPARQL.
  • Towards trustworthy, explainable agentic AI.
  • Open-source (MIT), on npm: @comunica/mcp-sparql
QR to npm
npmjs.com/@comunica/mcp-sparql