Skip to content
Back to search

cryo-mcp

A Python package for accessing Cryo datasets via Claude Code

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/z80dev--cryo-mcp/badge.svg)](/listings/z80dev--cryo-mcp)

HTML

<a href="/listings/z80dev--cryo-mcp"><img src="/api/listings/z80dev--cryo-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

This is not required if you will run the tool with `uvx` directly.

# install with UV (recommended)
uv tool install cryo-mcp

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 418 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Cryo MCP 🧊
  2. A Model Completion Protocol (MCP) server for the [Cryo](https://github.com/paradigmxyz/cryo) blockchain data extraction tool.
  3. Cryo MCP allows you to access Cryo's powerful blockchain data extraction capabilities via an API server that implements the MCP protocol, making it easy to query blockchain data from any MCP-compatible client.
  4. ## For LLM Users: SQL Query Workflow Guide
  5. When using this MCP server to run SQL queries on blockchain data, follow this workflow:
  6. 1. **Download data** with `query_dataset`:
  7. ```python
  8. result = query_dataset(
  9. dataset="blocks", # or "transactions", "logs", etc.
  10. blocks="15000000:15001000", # or use blocks_from_latest=100
  11. output_format="parquet" # important: use parquet for SQL
  12. )
  13. files = result.get("files", []) # Get the returned file paths
  14. ```
  15. 2. **Explore schema** with `get_sql_table_schema`:
  16. ```python
  17. # Check what columns are available in the file
  18. schema = get_sql_table_schema(files[0])
  19. # Now you can see all columns, data types, and sample data
  20. ```
  21. 3. **Run SQL** with `query_sql`:
  22. ```python
  23. # Option 1: Simple table reference (DuckDB will match the table name to file)
  24. sql_result = query_sql(
  25. query="SELECT block_number, timestamp, gas_used FROM blocks",
  26. files=files # Pass the files from step 1
  27. )
  28. # Option 2: Using read_parquet() with explicit file path
  29. sql_result = query_sql(
  30. query=f"SELECT block_number, timestamp, gas_used FROM read_parquet('{files[0]}')",
  31. files=files # Pass the files from step 1
  32. )
  33. ```
  34. Alternatively, use the combined approach with `query_blockchain_sql`:
  35. ```python
  36. # Option 1: Simple table reference
  37. result = query_blockchain_sql(
  38. sql_query="SELECT * FROM blocks",
  39. dataset="blocks",
  40. blocks_from_latest=100
  41. )
  42. # Option 2: Using read_parquet()
  43. result = query_blockchain_sql(
  44. sql_query="SELECT * FROM read_parquet('/path/to/file.parquet')", # Path doesn't matter
  45. dataset="blocks",
  46. blocks_from_latest=100
  47. )
  48. ```
  49. For a complete working example, see [examples/sql_workflow_example.py](examples/sql_workflow_example.py).
  50. ## Features
  51. - **Full Cryo Dataset Access**: Query any Cryo dataset through an API server
  52. - **MCP Integration**: Works seamlessly with MCP clients
  53. - **Flexible Query Options**: Support for all major Cryo filtering and output options
  54. - **Block Range Options**: Query specific blocks, latest block, or relative ranges
  55. - **Contract Filtering**: Filter data by contract address
  56. - **Latest Block Access**: Easy access to the latest Ethereum block data
  57. - **Multiple Output Formats**: JSON, CSV, and Parquet support
  58. - **Schema Information**: Get detailed dataset schemas and sample data
  59. - **SQL Queries**: Run SQL queries directly against downloaded blockchain data
  60. ## Installation (Optional)
  61. This is not required if you will run the tool with `uvx` directly.
  62. ```bash
  63. # install with UV (recommended)
  64. uv tool install cryo-mcp
  65. ```
  66. ## Requirements
  67. - Python 3.8+
  68. - uv
  69. - A working installation of [Cryo](https://github.com/paradigmxyz/cryo)
  70. - Access to an Ethereum RPC endpoint
  71. - DuckDB (for SQL query functionality)
  72. ## Quick Start
  73. ### Usage with Claude Code
  74. 1. Run `claude mcp add` for an interactive prompt.
  75. 2. Enter `uvx` as the command to run.
  76. 3. Enter `cryo-mcp --rpc-url <ETH_RPC_URL> [--data-dir <DATA_DIR>]` as the args
  77. 4. Alternatively, provide `ETH_RPC_URL` and `CRYO_DATA_DIR` as environment variables instead.
  78. New instances of `claude` will now have access to cryo as configured to hit your RPC endpoint and store data in the specified directory.
  79. ## Available Tools
  80. Cryo MCP exposes the following MCP tools:
  81. ### `list_datasets()`
  82. Returns a list of all available Cryo datasets.
  83. Example:
  84. ```python
  85. client.list_datasets()
  86. ```
  87. ### `query_dataset()`
  88. Query a Cryo dataset with various filtering options.
  89. Parameters:
  90. - `dataset` (str): The name of the dataset to query (e.g., 'blocks', 'transactions', 'logs')
  91. - `blocks` (str, optional): Block range specification (e.g., '1000:1010')
  92. - `start_block` (int, optional): Start block number (alternative to blocks)
  93. - `end_block` (int, optional): End block number (alternative to blocks)
  94. - `use_latest` (bool, optional): If True, query the latest block
  95. - `blocks_from_latest` (int, optional): Number of blocks from latest to include
  96. - `contract` (str, optional): Contract address to filter by
  97. - `output_format` (str, optional): Output format ('json', 'csv', 'parquet')
  98. - `include_columns` (list, optional): Columns to include alongside defaults
  99. - `exclude_columns` (list, optional): Columns to exclude from defaults
  100. Example:
  101. ```python
  102. # Get transactions from blocks 15M to 15.01M
  103. client.query_dataset('transactions', blocks='15M:15.01M')
  104. # Get logs for a specific contract from the latest 100 blocks
  105. client.query_dataset('logs', blocks_from_latest=100, contract='0x1234...')
  106. # Get just the latest block
  107. client.query_dataset('blocks', use_latest=True)
  108. ```
  109. ### `lookup_dataset()`
  110. Get detailed information about a specific dataset, including schema and sample data.
  111. Parameters:
  112. - `name` (str): The name of the dataset to look up
  113. - `sample_start_block` (int, optional): Start block for sample data
  114. - `sample_end_block` (int, optional): End block for sample data
  115. - `use_latest_sample` (bool, optional): Use latest block for sample
  116. - `sample_blocks_from_latest` (int, optional): Number of blocks from latest for sample
  117. Example:
  118. ```python
  119. client.lookup_dataset('logs')
  120. ```
  121. ### `get_latest_ethereum_block()`
  122. Returns information about the latest Ethereum block.
  123. Example:
  124. ```python
  125. client.get_latest_ethereum_block()
  126. ```
  127. ### SQL Query Tools
  128. Cryo MCP includes several tools for running SQL queries against blockchain data:
  129. ### `query_sql()`
  130. Run a SQL query against downloaded blockchain data.
  131. Parameters:
  132. - `query` (str): SQL query to execute
  133. - `files` (list, optional): List of parquet file paths to query. If None, will use all files in the data directory.
  134. - `include_schema` (bool, optional): Whether to include schema information in the result
  135. Example:
  136. ```python
  137. # Run against all available files
  138. client.query_sql("SELECT * FROM read_parquet('/path/to/blocks.parquet') LIMIT 10")
  139. # Run against specific files
  140. client.query_sql(
  141. "SELECT * FROM read_parquet('/path/to/blocks.parquet') LIMIT 10",
  142. files=['/path/to/blocks.parquet']
  143. )
  144. ```
  145. ### `query_blockchain_sql()`
  146. Query blockchain data using SQL, automatically downloading any required data.
  147. Parameters:
  148. - `sql_query` (str): SQL query to execute
  149. - `dataset` (str, optional): The dataset to query (e.g., 'blocks', 'transactions')
  150. - `blocks` (str, optional): Block range specification
  151. - `start_block` (int, optional): Start block number
  152. - `end_block` (int, optional): End block number
  153. - `use_latest` (bool, optional): If True, query the latest block
  154. - `blocks_from_latest` (int, optional): Number of blocks before the latest to include
  155. - `contract` (str, optional): Contract address to filter by
  156. - `force_refresh` (bool, optional): Force download of new data even if it exists
  157. - `include_schema` (bool, optional): Include schema information in the result
  158. Example:
  159. ```python
  160. # Automatically downloads blocks data if needed, then runs the SQL query
  161. client.query_blockchain_sql(
  162. sql_query="SELECT block_number, gas_used, timestamp FROM blocks ORDER BY gas_used DESC LIMIT 10",
  163. dataset="blocks",
  164. blocks_from_latest=100
  165. )
  166. ```
  167. ### `list_available_sql_tables()`
  168. List all available tables that can be queried with SQL.
  169. Example:
  170. ```python
  171. client.list_available_sql_tables()
  172. ```
  173. ### `get_sql_table_schema()`
  174. Get the schema for a specific parquet file.
  175. Parameters:
  176. - `file_path` (str): Path to the parquet file
  177. Example:
  178. ```python
  179. client.get_sql_table_schema("/path/to/blocks.parquet")
  180. ```
  181. ### `get_sql_examples()`
  182. Get example SQL queries for different blockchain datasets.
  183. Example:
  184. ```python
  185. client.get_sql_examples()
  186. ```
  187. ## Configuration Options
  188. When starting the Cryo MCP server, you can use these command-line options:
  189. - `--rpc-url URL`: Ethereum RPC URL (overrides ETH_RPC_URL environment variable)
  190. - `--data-dir PATH`: Directory to store downloaded data (overrides CRYO_DATA_DIR environment variable, defaults to ~/.cryo-mcp/data/)
  191. ## Environment Variables
  192. - `ETH_RPC_URL`: Default Ethereum RPC URL to use when not specified via command line
  193. - `CRYO_DATA_DIR`: Default directory to store downloaded data when not specified via command line
  194. ## Advanced Usage
  195. ### SQL Queries Against Blockchain Data
  196. Cryo MCP allows you to run powerful SQL queries against blockchain data, combining the flexibility of SQL with Cryo's data extraction capabilities:
  197. #### Two-Step SQL Query Flow
  198. You can split data extraction and querying into two separate steps:
  199. ```python
  200. # Step 1: Download data and get file paths
  201. download_result = client.query_dataset(
  202. dataset="transactions",
  203. blocks_from_latest=1000,
  204. output_format="parquet"
  205. )
  206. # Step 2: Use the file paths to run SQL queries
  207. file_paths = download_result.get("files", [])
  208. client.query_sql(
  209. query=f"""
  210. SELECT
  211. to_address as contract_address,
  212. COUNT(*) as tx_count,
  213. SUM(gas_used) as total_gas,
  214. AVG(gas_used) as avg_gas
  215. FROM read_parquet('{file_paths[0]}')
  216. WHERE to_address IS NOT NULL
  217. GROUP BY to_address
  218. ORDER BY total_gas DESC
  219. LIMIT 20
  220. """,
  221. files=file_paths
  222. )
  223. ```
  224. #### Combined SQL Query Flow
  225. For convenience, you can also use the combined function that handles both steps:
  226. ```python
  227. # Get top gas-consuming contracts
  228. client.query_blockchain_sql(
  229. sql_query="""
  230. SELECT
  231. to_address as contract_address,
  232. COUNT(*) as tx_count,
  233. SUM(gas_used) as total_gas,
  234. AVG(gas_used) as avg_gas
  235. FROM read_parquet('/path/to/transactions.parquet')
  236. WHERE to_address IS NOT NULL
  237. GROUP BY to_address
  238. ORDER BY total_gas DESC
  239. LIMIT 20
  240. """,
  241. dataset="transactions",
  242. blocks_from_latest=1000
  243. )
  244. # Find blocks with the most transactions
  245. client.query_blockchain_sql(
  246. sql_query="""
  247. SELECT
  248. block_number,
  249. COUNT(*) as tx_count
  250. FROM read_parquet('/path/to/transactions.parquet')
  251. GROUP BY block_number
  252. ORDER BY tx_count DESC
  253. LIMIT 10
  254. """,
  255. dataset="transactions",
  256. blocks="15M:16M"
  257. )
  258. # Analyze event logs by topic
  259. client.query_blockchain_sql(
  260. sql_query="""
  261. SELECT
  262. topic0,
  263. COUNT(*) as event_count
  264. FROM read_parquet('/path/to/logs.parquet')
  265. GROUP BY topic0
  266. ORDER BY event_count DESC
  267. LIMIT 20
  268. """,
  269. dataset="logs",
  270. blocks_from_latest=100
  271. )
  272. ```
  273. **Note**: For SQL queries, always use `output_format="parquet"` when downloading data to ensure optimal performance with DuckDB. When using `query_blockchain_sql`, you should refer to the file paths directly in your SQL using the `read_parquet()` function.
  274. ### Querying with Block Ranges
  275. Cryo MCP supports the full range of Cryo's block specification syntax:
  276. ```python
  277. # Using block numbers
  278. client.query_dataset('transactions', blocks='15000000:15001000')
  279. # Using K/M notation
  280. client.query_dataset('logs', blocks='15M:15.01M')
  281. # Using offsets from latest
  282. client.query_dataset('blocks', blocks_from_latest=100)
  283. ```
  284. ### Contract Filtering
  285. Filter logs and other data by contract address:
  286. ```python
  287. # Get all logs for USDC contract
  288. client.query_dataset('logs',
  289. blocks='16M:16.1M',
  290. contract='0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
  291. ```
  292. ### Column Selection
  293. Include only the columns you need:
  294. ```python
  295. # Get just block numbers and timestamps
  296. client.query_dataset('blocks',
  297. blocks='16M:16.1M',
  298. include_columns=['number', 'timestamp'])
  299. ```
  300. ## Development
  301. ### Project Structure
  302. ```
  303. cryo-mcp/
  304. ├── cryo_mcp/ # Main package directory
  305. │ ├── __init__.py # Package initialization
  306. │ ├── server.py # Main MCP server implementation
  307. │ ├── sql.py # SQL query functionality
  308. ├── tests/ # Test directory
  309. │ ├── test_*.py # Test files
  310. ├── pyproject.toml # Project configuration
  311. ├── README.md # Project documentation
  312. ```
  313. ### Run Tests
  314. `uv run pytest`
  315. ## License
  316. MIT
  317. ## Credits
  318. - Built on top of the amazing [Cryo](https://github.com/paradigmxyz/cryo) tool by Paradigm
  319. - Uses the [MCP protocol](https://github.com/mcp-team/mcp) for API communication

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.