Awesome-omni-skill subgraph-explorer
Explore and query blockchain subgraphs through a private MCP server running in Docker. Use this skill when exploring GraphQL subgraphs, querying blockchain data from subgraphs (NFT transfers, DEX swaps, DeFi metrics), examining subgraph schemas, or exporting discovered queries for project use. The skill manages Docker-based MCP server interaction and provides utilities for query development and export.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data-ai/subgraph-explorer" ~/.claude/skills/diegosouzapw-awesome-omni-skill-subgraph-explorer-bfaf56 && rm -rf "$T"
skills/data-ai/subgraph-explorer/SKILL.mdSubgraph Explorer
Overview
This skill enables exploration and querying of blockchain subgraphs through a private MCP server. It provides tools for managing the Docker-based server, exploring GraphQL schemas, executing queries against configured subgraphs, and exporting discovered queries for project integration.
Quick Start
Starting the MCP Server
Before using subgraph exploration features, ensure the MCP server is running:
bash scripts/start_mcp_server.sh
This starts the Docker container with:
- SSE endpoint:
(for MCP communication)http://localhost:8000 - Metrics endpoint:
(for monitoring)http://localhost:9091/metrics
Check server status:
bash scripts/check_mcp_status.sh
Stop the server:
bash scripts/stop_mcp_server.sh
Note: The scripts default to
~/Workspace/subgraph-mcp as the project path. Set SUBGRAPH_MCP_PATH environment variable to override.
MCP Server Connection
The MCP server runs in SSE mode and exposes the following tools via HTTP:
Registry-based tools:
- List all configured subgraphslist_subgraphs
- Search subgraphs by keywordsearch_subgraphs_by_keyword
- Get GraphQL schema for a configured subgraphget_schema_by_id
- Execute query against a configured subgraphexecute_query_by_id
- Get query examples for a subgraphget_query_examples_by_id
- Get subgraph-specific guidanceget_subgraph_guidance_by_id
Ad-hoc tools:
- Get schema from any GraphQL endpoint (no registry needed)get_schema_by_url
- Execute query against any GraphQL endpoint (no registry needed)execute_query_by_url
To interact with the MCP server, use the WebFetch tool to make HTTP requests to the SSE endpoint at
http://localhost:8000.
Core Workflows
1. Exploring Configured Subgraphs
When exploring subgraphs in the registry (
subgraphs.json):
Step 1: List or Search
- Use
to see all available subgraphslist_subgraphs - Use
to find specific subgraphs by name/descriptionsearch_subgraphs_by_keyword
Step 2: Understand the Schema
- Use
to retrieve the GraphQL schemaget_schema_by_id - Examine entity types, fields, and relationships
- Check
for pre-built query templatesget_query_examples_by_id - Review
for subgraph-specific tipsget_subgraph_guidance_by_id
Step 3: Execute Queries
- Use
to run GraphQL queriesexecute_query_by_id - Start with simple queries and iterate
- Apply pagination for large result sets
- Reference
for common patternsreferences/graphql_patterns.md
Step 4: Export Useful Queries
- Use
to save queries for project usescripts/export_query.py - Choose format: JavaScript, Python, GraphQL, or JSON
2. Ad-hoc Subgraph Exploration
For exploring subgraphs not in the registry:
Direct URL Access:
- Use
with the GraphQL endpoint URLget_schema_by_url - Optionally provide
if authentication is requiredauth_header - Use
to run queries directlyexecute_query_by_url
Example workflow:
- Get schema:
get_schema_by_url(url="https://example.com/graphql") - Analyze available entities and fields
- Build query based on schema
- Execute:
execute_query_by_url(url="https://example.com/graphql", query="...", variables={...})
3. Query Development Process
Iterative Query Building:
-
Start Simple: Query a single entity to understand data structure
query SimpleQuery { entity(id: "0x123") { id name } } -
Add Fields: Gradually add more fields as needed
query ExpandedQuery { entity(id: "0x123") { id name timestamp relatedData { field1 field2 } } } -
Apply Filters: Use
clauses for specific criteriawherequery FilteredQuery($minValue: String!) { entities(where: { value_gte: $minValue }, first: 100) { id value timestamp } } -
Optimize: Use aggregated fields instead of large arrays
- Prefer:
(pre-calculated count)contract.holders - Avoid: Counting all
manuallytokens
- Prefer:
Reference: See
references/graphql_patterns.md for comprehensive query patterns including pagination, filtering, aggregation, and performance optimization.
Exporting Queries
Use the export utility to save discovered queries for project integration:
JavaScript/TypeScript Export
python3 scripts/export_query.py queries/getLatestSwaps.js --format js --name GetLatestSwaps --description "Fetch latest DEX swaps"
Then paste your GraphQL query when prompted.
Output:
/** * Fetch latest DEX swaps */ export const GetLatestSwaps = ` query GetLatestSwaps($first: Int!) { swaps(first: $first, orderBy: timestamp, orderDirection: desc) { id timestamp amountUSD pair { token0 { symbol } token1 { symbol } } } } `;
Python Export
python3 scripts/export_query.py queries/get_latest_swaps.py --format py --name get_latest_swaps
GraphQL File Export
python3 scripts/export_query.py queries/latest_swaps.graphql --format graphql
JSON Export (with metadata)
python3 scripts/export_query.py queries/latest_swaps.json --format json --name GetLatestSwaps --variables '{"first": 100}'
Understanding Subgraph Data
Common Entity Types
DEX/Trading Subgraphs:
- Individual trade transactionsSwap
- Trading pairs with liquidity and volumePair
- Token information and metadataToken
/DayData
- Aggregated daily metricsPairDayData
NFT Subgraphs:
/ERC721Transfer
- NFT transfer eventsERC1155Transfer
- User accounts with balancesAccount
/ERC721Token
- Individual NFT tokensERC1155Token
- NFT collection contractsERC721Contract
Common Patterns:
- Most entities have
,id
, andtimestamp
fieldsblockNumber - Use relationship fields (e.g.,
) to navigate connectionspair { token0 { symbol } } - Aggregated fields (e.g.,
,totalSupply
) provide pre-calculated statsholders
Data Considerations
Time-based Data:
- Daily aggregates typically reset at midnight UTC
- For "today's" data, consider querying both current day and previous day
- Calculate partial day metrics:
(yesterday_value * hours_passed / 24) + today_value
Pagination:
- Maximum
parameter is typically 1000, recommended 100first - Use
for offset-based paginationskip - Use cursor-based pagination (
) for large datasetsid_gt
Performance:
- Avoid deep nesting of relationships
- Use aggregated fields when available
- Apply specific filters to reduce result sets
- Request only needed fields, not entire objects
Troubleshooting
MCP Server Issues
Container won't start:
- Check if ports 8000 or 9091 are already in use
- Verify
exists in the subgraph-mcp directorysubgraphs.json - View logs:
docker logs subgraph-mcp-server
Server not responding:
- Run:
bash scripts/check_mcp_status.sh - Verify Docker is running
- Check firewall settings for localhost access
Configuration errors:
- Verify
points to correct directorySUBGRAPH_MCP_PATH - Ensure
is valid JSONsubgraphs.json - Check subgraph URLs are accessible
Query Issues
Schema introspection fails:
- Verify the subgraph endpoint is accessible
- Check authentication headers if required
- Ensure the endpoint is a valid GraphQL API
Query timeout:
- Simplify the query (reduce nesting, fewer fields)
- Add more specific filters
- Reduce
parameter valuefirst - Use pagination for large datasets
Type errors:
- Check field types in schema (String vs Int vs BigInt)
- Ensure variable types match schema requirements
- Use quotes for String types in variables:
{"id": "0x123"}
Empty results:
- Verify entity IDs are correct (case-sensitive)
- Check filter conditions aren't too restrictive
- For time-based queries, verify timestamp format (usually Unix seconds)
- Confirm data exists in the subgraph (check subgraph sync status)
Resources
scripts/
Docker Management:
- Start the MCP server in Dockerstart_mcp_server.sh
- Stop the MCP serverstop_mcp_server.sh
- Check server status and healthcheck_mcp_status.sh
Query Export:
- Export GraphQL queries to various formats (JS, Python, GraphQL, JSON)export_query.py
references/
- Comprehensive guide to GraphQL query patterns for subgraphsgraphql_patterns.md- Pagination strategies
- Filtering patterns
- Aggregation techniques
- Performance optimization
- Common query scenarios
Tips
- Always start with schema exploration - Use
orget_schema_by_id
firstget_schema_by_url - Check for query examples - Use
for configured subgraphsget_query_examples_by_id - Read subgraph guidance - Use
for subgraph-specific tipsget_subgraph_guidance_by_id - Test queries incrementally - Build complex queries step by step
- Export working queries - Save successful queries for reuse in projects
- Monitor performance - Check metrics endpoint (
) for server healthhttp://localhost:9091/metrics - Use aggregated data - Prefer pre-calculated fields over manual aggregation
- Consider UTC timezone - Daily data typically resets at midnight UTC