Skip to main content

A generic SQL query interface for MCAP robotics data via the Model Context Protocol

Project description

mcap-mcp-server

CI codecov PyPI Python License

A generic SQL query interface for MCAP robotics recording data via the Model Context Protocol.

Status: Alpha — Core implementation with all encoding decoders (JSON, Protobuf, ROS 1, ROS 2, FlatBuffers).

What It Does

Point this MCP server at a directory of MCAP files and query them with SQL — no database server, no ETL pipeline, no custom scripts.

MCAP files → mcap-mcp-server → DuckDB (in-memory) → SQL results

Works with Cursor, Claude Desktop, or any MCP-compatible client.

Quick Start

# Install
pip install mcap-mcp-server

# Or zero-install via uvx
uvx mcap-mcp-server --data-dir /path/to/recordings

MCP Client Configuration

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "mcap-query": {
      "command": "uvx",
      "args": ["mcap-mcp-server"],
      "env": {
        "MCAP_DATA_DIR": "/path/to/recordings"
      }
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "mcap-query": {
      "command": "uvx",
      "args": ["mcap-mcp-server"],
      "env": {
        "MCAP_DATA_DIR": "/path/to/recordings"
      }
    }
  }
}

Available Tools

Tool Description
list_recordings Discover MCAP files: names, sizes, durations, channels
get_schema Inspect SQL table names, column names and types for query planning
load_recording Decode MCAP data and load into DuckDB for SQL querying
query Execute SQL against loaded data (full DuckDB SQL including ASOF JOIN)

Typical Workflow

  1. Discover available recordings:

    → list_recordings
    
  2. Inspect the schema to plan queries:

    → get_schema file="session_001.mcap"
    
  3. Load data into DuckDB:

    → load_recording file="session_001.mcap"
    
  4. Query with SQL:

    SELECT timestamp_us, voltage, current
    FROM battery
    WHERE voltage < 22.0
    ORDER BY timestamp_us
    

Example Queries

-- Time-windowed statistics (1-second windows)
SELECT
  (timestamp_us / 1000000) as second,
  AVG(voltage) as avg_voltage,
  MIN(voltage) as min_voltage
FROM battery
GROUP BY second
ORDER BY second

-- Correlate battery with acceleration using ASOF JOIN
SELECT
  b.timestamp_us,
  b.voltage,
  i.linear_acceleration_x
FROM battery b
ASOF JOIN imu i ON b.timestamp_us >= i.timestamp_us

-- Compare across multiple loaded recordings
SELECT 'run1' as recording, AVG(voltage) as avg_v FROM r1_battery
UNION ALL
SELECT 'run2' as recording, AVG(voltage) as avg_v FROM r2_battery

-- Search metadata
SELECT * FROM _metadata WHERE key LIKE '%serial%'

Configuration

Environment Variables

Variable Default Description
MCAP_DATA_DIR . Root directory to scan for MCAP files
MCAP_RECURSIVE true Scan subdirectories recursively
MCAP_MAX_MEMORY_MB 2048 Max memory for loaded data (LRU eviction)
MCAP_QUERY_TIMEOUT_S 30 Max SQL query execution time
MCAP_DEFAULT_ROW_LIMIT 1000 Default result row limit
MCAP_MAX_ROW_LIMIT 10000 Maximum allowed row limit
MCAP_LOG_LEVEL INFO Server log level
MCAP_TRANSPORT stdio Transport: stdio or sse
MCAP_SSE_PORT 8080 Port for SSE transport
MCAP_FLATTEN_DEPTH 3 Max nesting depth for message flattening

Config File (optional)

Create mcap-mcp-server.toml:

[server]
data_dir = "/data/recordings"
recursive = true
transport = "stdio"

[limits]
max_memory_mb = 4096
query_timeout_s = 60
default_row_limit = 1000
max_row_limit = 50000

[decoder]
flatten_depth = 3

[logging]
level = "INFO"

Environment variables override config file values.

Supported Encodings

Encoding Install
JSON pip install mcap-mcp-server (built-in)
Protobuf pip install mcap-mcp-server[protobuf]
ROS 1 pip install mcap-mcp-server[ros1]
ROS 2 (CDR) pip install mcap-mcp-server[ros2]
FlatBuffers pip install mcap-mcp-server[flatbuffers]
All encodings pip install mcap-mcp-server[all]

Docker

docker run -d \
  -v /data/recordings:/data:ro \
  -e MCAP_DATA_DIR=/data \
  -e MCAP_TRANSPORT=sse \
  -p 8080:8080 \
  ghcr.io/turkenberg/mcap-mcp-server:latest

Development

git clone https://github.com/turkenberg/mcap_mcp_server.git
cd mcap_mcp_server
git submodule update --init
pip install -e ".[dev]"
pytest

License

GNU General Public License v3.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcap_mcp_server-0.2.0.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcap_mcp_server-0.2.0-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file mcap_mcp_server-0.2.0.tar.gz.

File metadata

  • Download URL: mcap_mcp_server-0.2.0.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcap_mcp_server-0.2.0.tar.gz
Algorithm Hash digest
SHA256 14c185715515aae74fb0d62a8bbe1d1cd15ee9247b0ae796cfb0fc9fd855a0ea
MD5 7142961020dd991f1bbb97fa88e357e4
BLAKE2b-256 475b8519a91279da47f5ac41f89a731860a1b27a5c3dec53a6dbb6cdafb0f0ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcap_mcp_server-0.2.0.tar.gz:

Publisher: ci.yml on turkenberg/mcap_mcp_server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcap_mcp_server-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcap_mcp_server-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32e4252fc15a76db84e73c8a1ec15d3adccb4f9248a4ea0e725d811188ebe8af
MD5 547aa6ffaa3ba04a0249120bc7bfed1e
BLAKE2b-256 a86d41e61dbbeb5b02486fc32977da8199b25deb876e302a7334d1580d3e7501

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcap_mcp_server-0.2.0-py3-none-any.whl:

Publisher: ci.yml on turkenberg/mcap_mcp_server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page