Run SPARQL query
run_sparqlExecutes read-only SPARQL queries on selected biological RDF databases, returning CSV results for single- or cross-database analysis.
Instructions
Run a read-only SPARQL query on an RDF database. Correct results depend on get_MIE_file(database), read once per database before its first query: it carries the graph pins, literal types and join paths for that database's endpoint, each live-verified. A query written without them does not fail; it returns a wrong answer that looks right — well-formed rows, plausible magnitude, no error, no warning. Unpinned queries on these endpoints have been measured returning x2.84, x6.29 and x45,848 the correct row count, all in under 4 seconds, so speed and a clean result are not evidence of correctness; the graph pin is. TogoMCP_Usage_Guide lays out the workflow these results depend on; answers produced after reading it vary less between runs. On the benchmark, answers built from 3 or more consecutive run_sparql calls score ~1.1 points lower. Queries go to the SPARQL endpoint registered for database: RDF Portal (https://rdfportal.org/, operated by DBCLS) for most databases, and the databases' own public endpoints for glycosmos (https://ts.glycosmos.org/sparql); togovar (https://grch38.togovar.org/sparql); wikipathways (https://sparql.wikipathways.org/sparql); idsm (https://idsm.elixir-czech.cz/sparql/endpoint/idsm); lipidmaps (https://lipidmaps.org/sparql); swisslipids (https://beta.sparql.swisslipids.org/sparql); marpolbase (https://marchantia.info/sparql); rikenbrc_mouse, rikenbrc_cell, rikenbrc_dnabank, rikenbrc_plant, rikenbrc_jcm (https://knowledge.brc.riken.jp/sparql); riken_pmm (https://metabobank.riken.jp/sparql). database is required (valid values: uniprot, rhea, pubchem, pdb, chembl, chebi, reactome, ensembl, amrportal, mesh, go, taxonomy, mondo, nando, bacdive, mediadive, clinvar, pubmed, pubtator, ncbigene, medgen, ddbj, glycosmos, supercon, bgee, oma, brenda, hgnc, jpostdb, massbank, nbrc, mogplus, jcm, hco, mco, togovar, ontology, gwascatalog, fantabio, wikipathways, idsm, pubcasefinder, lipidmaps, swisslipids, bh26microbes, marpolbase, jogo, tismed, bmrb, lotus, cellosaurus, rikenbrc_mouse, rikenbrc_cell, rikenbrc_dnabank, rikenbrc_plant, rikenbrc_jcm, riken_pmm) and selects the endpoint for a single-database query. For a cross-database query on a shared endpoint, pass a member database plus endpoint_name (valid values: sib, pubchem, pdb, ebi, primary, ncbi, ddbj, glycosmos, nims, togovar, wikipathways, idsm, lipidmaps, swisslipids, microbes, marpolbase, rikenbrc, metabobank) or endpoint_url, which take priority over database. Invalid database/endpoint_name values fail immediately with a deterministic error; retrying the same value returns the same error. RETURNS the query results as a CSV-formatted string (first row is the header of SELECT variable names). An EMPTY result — no rows, or an aggregate that is 0 over an empty match — is prefixed with # comment lines diagnosing it. An empty result is not an endpoint failure, and it has two causes with opposite answers (the data is genuinely absent, or one triple pattern is wrong and the real answer is non-zero). The block names the probe that tells them apart.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>"
},
"name": "run_sparql"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Alias for `sparql_query`. Pass one or the other. | |
| database | Yes | Results depend on this database's MIE file (get_MIE_file with the same value): its graph pins, literal types and traps are what a query written without it gets silently wrong. Name of a single RDF database. Must be exactly one of: uniprot, rhea, pubchem, pdb, chembl, chebi, reactome, ensembl, amrportal, mesh, go, taxonomy, mondo, nando, bacdive, mediadive, clinvar, pubmed, pubtator, ncbigene, medgen, ddbj, glycosmos, supercon, bgee, oma, brenda, hgnc, jpostdb, massbank, nbrc, mogplus, jcm, hco, mco, togovar, ontology, gwascatalog, fantabio, wikipathways, idsm, pubcasefinder, lipidmaps, swisslipids, bh26microbes, marpolbase, jogo, tismed, bmrb, lotus, cellosaurus, rikenbrc_mouse, rikenbrc_cell, rikenbrc_dnabank, rikenbrc_plant, rikenbrc_jcm, riken_pmm. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead. | |
| endpoint_url | No | Direct SPARQL endpoint URL, for an endpoint not in the registry or for explicit control. Highest priority — overrides both `endpoint_name` and `database` (which is still required, and is then used only as a label). Must be a registered endpoint or a public http(s) one; internal addresses are refused. | |
| sparql_query | No | The SPARQL query to execute. Alias: `query`. PIN EVERY GRAPH: copy the FROM/GRAPH clause from this database's get_MIE_file examples. An unpinned pattern silently reads every co-hosted graph on the endpoint — it does not error, it returns inflated or foreign rows that look correct (measured: x2.84, x6.29, x45,848). DISTINCT does not fix it; only the graph pin does. | |
| endpoint_name | No | Endpoint name for cross-database queries. One of: sib, pubchem, pdb, ebi, primary, ncbi, ddbj, glycosmos, nims, togovar, wikipathways, idsm, lipidmaps, swisslipids, microbes, marpolbase, rikenbrc, metabobank. Use this when querying multiple databases on the same endpoint — pass it ALONGSIDE a member `database`, never instead of it. Overrides `database` for endpoint selection (priority: endpoint_url > endpoint_name > database). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |