Skip to main content
Glama

Run SPARQL query

run_sparql
Read-only

Executes 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

NameRequiredDescriptionDefault
queryNoAlias for `sparql_query`. Pass one or the other.
databaseYesResults 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_urlNoDirect 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_queryNoThe 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_nameNoEndpoint 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

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv2.34.1
    • changedInput schema / properties / database / description
      Previous value: -"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, hco, mco, togovar, ontology, gwascatalog. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."New value: +"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."
    • changedInput schema / properties / endpoint_name / description
      Previous value: -"Endpoint name for cross-database queries. One of: sib, pubchem, pdb, ebi, primary, ncbi, ddbj, glycosmos, nims, togovar. Use this when querying multiple databases on the same endpoint."New value: +"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)."
    • changedInput schema / properties / endpoint_url / description
      Previous value: -"Direct SPARQL endpoint URL. Use this for explicit control over the endpoint."New value: +"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."
    • changedInput schema / properties / query / description
      Previous value: -"Alias for `sparql_query`."New value: +"Alias for `sparql_query`. Pass one or the other."
    • changedInput schema / properties / sparql_query / description
      Previous value: -"The SPARQL query to execute. Alias: `query`."New value: +"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."
  2. Changed1 schema field changedv2.0.1
    • changedInput schema / properties / database / description
      Previous value: -"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, hco, mco, togovar, ontology. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."New value: +"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, hco, mco, togovar, ontology, gwascatalog. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."
  3. Changed7 schema fields changedv2.0.0
    • removedInput schema / properties / database / default
      Removed value: -""
    • changedInput schema / properties / database / description
      Previous value: -"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. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."New value: +"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, hco, mco, togovar, ontology. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."
    • removedInput schema / properties / db
      Removed value: -{
      -  "default": "",
      -  "type": "string"
      -}
    • removedInput schema / properties / dbname
      Removed value: -{
      -  "default": "",
      -  "type": "string"
      -}
    • changedInput schema / properties / endpoint_name / description
      Previous value: -"Endpoint name for cross-database queries. One of: sib, pubchem, pdb, ebi, primary, ncbi, ddbj, glycosmos, nims. Use this when querying multiple databases on the same endpoint."New value: +"Endpoint name for cross-database queries. One of: sib, pubchem, pdb, ebi, primary, ncbi, ddbj, glycosmos, nims, togovar. Use this when querying multiple databases on the same endpoint."
    • addedInput schema / properties / query / description
      Added value: +"Alias for `sparql_query`."
    • addedInput schema / required
      Added value: +[
      +  "database"
      +]
  4. Changed1 schema field changedv0.1.1
    • changedInput schema / properties / database / description
      Previous value: -"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. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."New value: +"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. Do NOT pass an endpoint group name here (e.g. 'ebi', 'sib') — those go in endpoint_name instead."
  5. First observedv0.1.0

TDQS

A4.2/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only supply readOnlyHint and openWorldHint; the description goes far beyond them by disclosing the silent-failure mode (unpinned graphs return plausible but inflated rows with no error), the measured inflation factors, that speed and clean results are not evidence of correctness, that invalid database/endpoint_name values fail deterministically, and that empty results are prefixed with '#' diagnostic comments rather than signalling endpoint failure. This is exactly the behavioral context annotations cannot carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loading is good — the correctness warning and prerequisite come first. But the body is bloated: the entire valid-database list and endpoint_name list are repeated from the schema, the x2.84/x6.29/x45,848 measurements appear twice (description and sparql_query property), and the closing benchmark claim about '3 or more consecutive run_sparql calls' scoring lower reads as an extraneous aside that does not help an agent decide how to call the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex multi-endpoint query tool this is largely complete: prerequisites, endpoint routing, empty-result interpretation, error determinism and return format (CSV with header row) are all covered, and an output schema exists so return values need not be spelled out. Missing are operational bounds such as timeouts, result-size caps or rate limits, which matter for a tool that fans out to a dozen public endpoints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description mostly restates schema content verbatim — the full database enum and the full endpoint_name enum are duplicated word-for-word from the properties. The one genuine addition beyond the schema is the per-database endpoint routing table (rdfportal.org vs glycosmos/togovar/wikipathways/rikenbrc endpoints), which is useful but not enough to lift it above baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource+scope: 'Run a read-only SPARQL query on an RDF database.' It then distinguishes itself from siblings by naming get_MIE_file as a mandatory prerequisite and TogoMCP_Usage_Guide as the workflow reference, so an agent knows this is the raw-query tool rather than a structured search helper.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Strong explicit guidance: read get_MIE_file once per database before the first query, consult TogoMCP_Usage_Guide, and choose database vs endpoint_name vs endpoint_url depending on single- vs cross-database scope, with a stated priority order. The gap is that it never says when to prefer the higher-level sibling searches (search_uniprot_entity, togoid_*, etc.) over hand-written SPARQL, so the choice among alternatives is only half-covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.