fix(mcp-sparql): supporta endpoint Virtuoso (dati.camera.it) — usa execute_sparql() al posto di SparqlSource.fetch()#409
Merged
Conversation
…per supportare endpoint Virtuoso Il tool MCP toolkit_sparql_query usava SparqlSource.fetch() con accept_format='csv', che invia Accept: text/csv. Su endpoint Virtuoso (es. dati.camera.it) questo header non viene riconosciuto e il server restituisce RDF/XML, che SparqlSource._parse_response() non supporta. Sostituito con execute_sparql() di lab-connectors, che usa Accept: application/sparql-results+json,application/json (riconosciuto da Virtuoso) e ha parser XML fallback per SPARQL Results XML.
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.
Problema
Il tool MCP
toolkit_sparql_queryfalliva su endpoint SPARQL Virtuoso che non riconosconoAccept: text/csv(es.dati.camera.it). Il server rispondeva con RDF/XML, non parsabile daSparqlSource._parse_response().Causa
mcp_sparql_query()usavaSparqlSource.fetch(accept_format="csv"), che invia richieste conAccept: text/csv,text/plain;q=0.5. Su Virtuoso (es. Camera dei Deputati) questo header non viene riconosciuto come formato SPARQL results valido → risposta in RDF/XML →DownloadError.Fix
Sostituito
SparqlSource.fetch()conexecute_sparql()dilab_connectors.http.sparql, che:Accept: application/sparql-results+json,application/json— riconosciuto da VirtuosoFile modificato:
toolkit/mcp/scout_ops.pyTest
dati.cultura.gov.itSELECT ?g COUNT(*) ... GROUP BY ?g LIMIT 3dati.camera.itSELECT ?g COUNT(*) ... GROUP BY ?g LIMIT 3dati.camera.itSuite: 18/18 toolkit · 309/309 lab-connectors
Impatto downstream
Nessuno — il contratto pubblico del tool MCP (
toolkit_sparql_query) è invariato: stessi parametri input, stesso formato output.Note
dati.cultura.gov.itera un falso allarme (lendpoint funziona già, linventory SO era fallito per timeout transiente).