Install
pip install ctxprotocol
Pinned Query mode
import asyncio
import os
from uuid import uuid4
from ctxprotocol import ContextClient
MERIDIAN_TOOL_ID = "e5e62fa5-28e1-42f4-8b84-f4866234df43"
async def main() -> None:
async with ContextClient(api_key=os.environ["CONTEXT_API_KEY"]) as client:
result = await client.query.run(
query=(
"Use Meridian futures for BTCUSDT on Binance, Bybit, OKX, and "
"Hyperliquid. Return 1h rows from 2026-07-13T00:00:00Z to "
"2026-07-13T06:00:00Z with close_price, funding_rate, "
"dollar_open_interest_close, and coverage metadata."
),
tools=[MERIDIAN_TOOL_ID],
response_shape="evidence_only",
include_data=True,
include_data_url=True,
)
print(result.evidence)
print(result.data)
asyncio.run(main())
Direct Execute mode
import asyncio
import os
from ctxprotocol import ContextClient
MERIDIAN_TOOL_ID = "e5e62fa5-28e1-42f4-8b84-f4866234df43"
async def main() -> None:
async with ContextClient(api_key=os.environ["CONTEXT_API_KEY"]) as client:
# Resolve the stable listing directly. Do not depend on ranked discovery
# when your application has already pinned Meridian's tool ID.
meridian = await client.discovery.get(MERIDIAN_TOOL_ID)
futures = next(
(method for method in (meridian.mcp_tools or []) if method.name == "futures"),
None,
)
if (
futures is None
or futures.execute_eligible is not True
or futures.execute_price_usd is None
):
raise RuntimeError("Meridian futures is not currently Execute-eligible")
result = await client.tools.execute(
tool_id=MERIDIAN_TOOL_ID,
tool_name="futures",
args={
"exchanges": ["binance", "bybit", "okx", "hyperliquid"],
"products": ["BTCUSDT"],
"columns": [
"close_price",
"funding_rate",
"dollar_open_interest_close",
],
"begin": "2026-07-13T00:00:00Z",
"end": "2026-07-13T06:00:00Z",
"resolution": "1h",
"include": {
"coverage": False,
"provenance": False,
"column_metadata": False,
},
},
idempotency_key=str(uuid4()),
max_spend_usd="0.005",
close_session=True,
)
rows = result.result["rows"]
print(rows)
print(f"charged=${result.session.spent}")
asyncio.run(main())
Use
async with ContextClient(...) or close the client explicitly so HTTP resources are released cleanly.coverage when you need to classify nulls, column_metadata when you need registry types and units, and provenance only for narrow lineage audits.
A Meridian Execute call is limited to 22,500 estimated metric values. Narrow the time range, products, exchanges, or columns when the structured warning reports an over-limit request.