Repository navigation
feat(rdf): query a namespace with read-only SPARQL, from the API, the app and MCP - #84
Merged
Merged
Conversation
… app and MCP
GET/POST /api/v1/namespaces/{name}/sparql runs SELECT, ASK, CONSTRUCT or
DESCRIBE over the namespace's graph (SPARQL JSON results, or RDF). SERVICE
and FROM are refused and graph loading is off, so a query never reaches
outside the archive. Agents get the same as the MCP tool `sparql`; the
Collection page gets a SPARQL dialog.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtRigWmLLWqBHqWmJ8CvA1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Before: a namespace's linked data could be exported and imported, but there was no way to query it.
After: members can run SPARQL SELECT, ASK, CONSTRUCT or DESCRIBE queries over a namespace's graph. This works through
GETorPOST /api/v1/namespaces/{name}/sparql, through a new SPARQL dialog on the Collection page (with an example query and a results table), and through the MCP toolsparql, so agents can ask questions like "which entities appear in the most recordings".Queries never reach outside the archive.
SERVICEandFROMare refused, rdflib's graph loading is switched off, and updates are not accepted. SELECT is capped at 10,000 rows.How:
rdf.sparqlandrdf.check_querylive inapp/domain/rdf.py. The routes are inapp/api/v1/routes/rdf.py, the tool is inapp/api/mcp_tools.py, andSparqlDialogis incomponents/iiif/rdf.tsx. Docs are indocs/rdf.md. Refine later: the graph is rebuilt for every query and there is no query timeout yet.Tests:
test_rdf.py::test_sparql,test_mcp.py::test_sparqland the jest SPARQL dialog test. The full backend suite passes (401), except the known environmental LibreOffice test. jest (575), eslint and tsc pass. The client was regenerated withmake openapi.🤖 Generated with Claude Code
https://claude.ai/code/session_01RtRigWmLLWqBHqWmJ8CvA1
Generated by Claude Code