Skip to main content
Glama

sparql_query

Read-onlyIdempotent

Execute SPARQL SELECT queries against any SPARQL endpoint and retrieve results as a Markdown table or JSON array. Supports custom headers for authenticated endpoints and adjustable timeout for complex queries.

Instructions

Execute a SPARQL SELECT query against a SPARQL endpoint.

Runs a SELECT query and returns results as a Markdown table or JSON array.
Supports custom HTTP headers for authenticated endpoints.
For long-running queries (large datasets, complex joins), increase the
timeout parameter — default is 30s, maximum is 3600s (1 hour).

Args:
    params: Query parameters including endpoint URL, SPARQL query, timeout,
        output format, optional headers, and max rows limit.

Returns:
    Query results formatted as a Markdown table or JSON string.

Examples:
    >>> # Query Wikidata for items
    >>> sparql_query(SparqlQueryInput(
    ...     endpoint="https://query.wikidata.org/sparql",
    ...     query="SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . ?item rdfs:label ?itemLabel . FILTER(LANG(?itemLabel) = 'en') } LIMIT 5"
    ... ))
    "| `item` | `itemLabel` |

| --- | --- | | http://www.wikidata.org/entity/Q5 | human | ..."

    >>> # Query with authentication
    >>> sparql_query(SparqlQueryInput(
    ...     endpoint="https://my-endpoint.example.com/sparql",
    ...     query="SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10",
    ...     headers={"Authorization": "Bearer my-token"}
    ... ))

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds behavioral details: the tool runs SELECT queries, supports custom headers for authenticated endpoints, and allows timeout up to 3600 seconds. This adds value beyond annotations without contradiction.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement, followed by details and examples. It is slightly long due to the included code blocks, but each sentence adds value. The front-loading is appropriate.

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?

Given the complexity of the tool (SPARQL query, multiple parameters, optional headers), the description covers essential aspects: endpoint, query, timeout, output format, headers, and max rows. It does not explain error handling or rate limits, but the annotations and output schema (not shown) likely cover expected outcomes. Overall, it is sufficiently complete for an AI agent to use correctly.

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?

The input schema has detailed descriptions for each nested property, so the description's summary ('endpoint URL, SPARQL query, timeout, output format, optional headers, and max rows limit') adds little new meaning. The examples provide practical context but are not strictly parameter semantics. With schema coverage at 0% (as per context signal), the description could have compensated more, but the schema descriptions are present in the input_schema provided.

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?

The description clearly states 'Execute a SPARQL SELECT query against a SPARQL endpoint,' specifying the verb, resource, and differentiating from sibling tools (sparql_ask, sparql_construct, etc.). It also mentions output formats (Markdown table or JSON), leaving no ambiguity about the tool's function.

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?

The description provides usage context such as support for custom headers and timeout adjustment for long-running queries. However, it does not explicitly state when not to use this tool versus alternatives (e.g., sparql_ask for boolean queries), which would be helpful. The guidance on timeout and headers is clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daedalus/mcp-sparql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server