Skip to main content

KAPSARC Data Portal MCP Server

An MCP server that connects LLMs to the KAPSARC Data Portal — search, query, export, and visualize energy and economic datasets via the Opendatasoft Explore API v2.1.

Tools

Data Tools

Tool Description
search_datasets Free-text search of KAPSARC datasets
get_dataset Full metadata and field definitions for a dataset
get_records Query records with ODSQL filters
get_record Retrieve a single record by ID
get_dataset_facets Categorical field values and counts
get_catalog_facets Portal-wide themes, keywords, publishers
export_dataset Export without 100-record limit (JSON/CSV)
get_dataset_attachments List documentation/file attachments
export_catalog Bulk export all dataset metadata
list_export_formats Check available export formats

Visualization Tools

Tool Description
visualize_dataset Fetch data and render a branded chart image
visualize_data Render a chart from pre-fetched records (no API call)
visualize_comparison Multi-series comparison charts (e.g. country vs country)

All charts are returned as PNG images with official KAPSARC branding — logo, color palette, and source attribution. Chart types are auto-detected from data shape, or can be explicitly set to: bar, hbar, line, pie, or scatter.

Example Charts

Bar Chart — Top Oil Producers

Bar Chart

Line Chart — Time Series

Line Chart

Pie Chart — Energy Mix

Pie Chart

Multi-Line — Production Comparison

Multi-Line Chart

Scatter Plot — GDP vs Energy

Scatter Chart

Horizontal Bar — Energy by Sector

Horizontal Bar Chart

Electricity Prices

Electricity Prices

Renewable Energy Capacity

Renewables Capacity

GCC Power Generation Mix

GCC Power Mix

Multi-Bar — CO2 Emissions

CO2 Emissions

Solar Irradiance vs Capacity Factor

Solar Scatter

Renewable Share of Electricity

Renewable Share Trend

Hydrogen Production Costs

Hydrogen Costs

Brent Crude Oil Price

Brent Crude Price

Saudi Arabia GDP Composition

Saudi GDP Composition

Installation

Quick Start

uvx kapsarc-mcp-server

Or install with pip:

pip install kapsarc-mcp-server
kapsarc-mcp-server

Claude Code

claude mcp add kapsarc-data -- uvx kapsarc-mcp-server

Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "kapsarc-data": {
      "command": "uvx",
      "args": ["kapsarc-mcp-server"]
    }
  }
}

Development

git clone https://github.com/MHDhazmi/kapsarc-mcp-server.git
cd kapsarc-mcp-server
uv sync
uv run kapsarc-mcp-server

Configuration

Set the KAPSARC_API_KEY environment variable to authenticate with the KAPSARC API. This is optional — most datasets are publicly accessible without a key.

export KAPSARC_API_KEY="your-api-key"

Development

# Unit tests (no network needed)
uv run pytest tests/test_charts.py -v

# Integration tests (hits live KAPSARC API)
uv run pytest tests/test_main.py -v

# Regenerate example chart images
uv run python examples/generate_examples.py

License

MIT

Metadata

Release files for kapsarc-mcp-server 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kapsarc-mcp-server 0.1.0
File Size Uploaded Provenance
kapsarc_mcp_server-0.1.0.tar.gz 904.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kapsarc-mcp-server 0.1.0
File Interpreter ABI Platform
kapsarc_mcp_server-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 967.1 kB

Release files / kapsarc_mcp_server-0.1.0.tar.gz

Download URL kapsarc_mcp_server-0.1.0.tar.gz
Size 904.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d41e2700b3b2552d63289cd4ce2641e8a53d875cd74e5c54674a751bfd30db37
BLAKE2b-256 checksum
How to use checksums
beaea0adfebba05804a8d6c302de8511ac7ed004011fe7b2966104a4e333a847
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / kapsarc_mcp_server-0.1.0-py3-none-any.whl

Download URL kapsarc_mcp_server-0.1.0-py3-none-any.whl
Size 63.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e2e583edba45cb85b5a23d146e9119d721a218a97142ac4a0f517cd1a51617c
BLAKE2b-256 checksum
How to use checksums
7951967931c1969cf6bc665ad79362342d7f8e6e9340d48436532e954d7557e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Security for kapsarc-mcp-server 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page