query
Pack: wikidata-sparql · Endpoint: https://gateway.pipeworx.io/wikidata-sparql/mcp
Run a SPARQL query against the Wikidata Query Service. Returns JSON bindings by default.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
sparql | string | yes | SPARQL query text |
format | string | no | json (default) | xml | csv | tsv | text/html |
Example call
Arguments
{
"sparql": "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" } } LIMIT 10"
}
curl
curl -X POST https://gateway.pipeworx.io/wikidata-sparql/mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"query","arguments":{"sparql":"SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" } } LIMIT 10"}}}'
TypeScript (@pipeworx/sdk)
import { Pipeworx } from '@pipeworx/sdk';
const pipeworx = new Pipeworx();
const result = await pipeworx.call('query', {
"sparql": "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" } } LIMIT 10"
});
More examples
{
"sparql": "SELECT ?country ?countryLabel ?population WHERE { ?country wdt:P31 wd:Q3624078 . ?country wdt:P1082 ?population . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" } } ORDER BY DESC(?population)",
"format": "csv"
}
Response shape
Full JSON Schema
{
"oneOf": [
{
"type": "object",
"properties": {
"head": {
"type": "object",
"properties": {
"vars": {
"type": "array",
"items": {
"type": "string"
},
"description": "Variable names in query results"
}
}
},
"results": {
"type": "object",
"properties": {
"bindings": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"description": "Query result bindings"
}
}
}
},
"description": "JSON format SPARQL results"
},
{
"type": "object",
"properties": {
"format": {
"type": "string",
"description": "Response format (xml, csv, tsv, or text/html)"
},
"body": {
"type": "string",
"description": "Raw response body"
}
},
"description": "Non-JSON format response"
}
]
}
Connect
Add this to your MCP client config, or use one-click install buttons:
{
"mcpServers": {
"wikidata-sparql": {
"url": "https://gateway.pipeworx.io/wikidata-sparql/mcp"
}
}
}
See Getting Started for client-specific install steps.