8000 feat(rdf): query a namespace with read-only SPARQL, from the API, the app and MCP by adeelahmad · Pull Request #84 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(rdf): query a namespace with read-only SPARQL, from the API, the app and MCP - #84

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-s9qndz
Oct 3, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-s9qndz

Conversation

@adeelahmad
Copy link
8000 Copy Markdown
Owner

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 GET or POST /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 tool sparql, so agents can ask questions like "which entities appear in the most recordings".

Queries never reach outside the archive. SERVICE and FROM are refused, rdflib's graph loading is switched off, and updates are not accepted. SELECT is capped at 10,000 rows.

How: rdf.sparql and rdf.check_query live in app/domain/rdf.py. The routes are in app/api/v1/routes/rdf.py, the tool is in app/api/mcp_tools.py, and SparqlDialog is in components/iiif/rdf.tsx. Docs are in docs/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_sparql and 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 with make openapi.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RtRigWmLLWqBHqWmJ8CvA1


Generated by Claude Code

… 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
@adeelahmad
adeelahmad merged commit e7f07e8 into main Oct 3, 2026
0 of 5 checks passed
@adeelahmad adeelahmad self-assigned this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0