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.
Explores blockchain subgraphs via a Docker MCP server. Use when querying NFT transfers, DEX swaps, or DeFi metrics from GraphQL endpoints.
/plugin marketplace add nschwermann/claude-tools/plugin install subgraph-explorer@claude-toolsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
README.mdreferences/graphql_patterns.mdscripts/check_mcp_status.shscripts/export_query.pyscripts/start_mcp_server.shscripts/stop_mcp_server.shThis 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.
Before using subgraph exploration features, ensure the MCP server is running:
bash scripts/start_mcp_server.sh
This starts the Docker container with:
http://localhost:8000 (for MCP communication)http://localhost:9091/metrics (for monitoring)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.
The MCP server runs in SSE mode and exposes the following tools via HTTP:
Registry-based tools:
list_subgraphs - List all configured subgraphssearch_subgraphs_by_keyword - Search subgraphs by keywordget_schema_by_id - Get GraphQL schema for a configured subgraphexecute_query_by_id - Execute query against a configured subgraphget_query_examples_by_id - Get query examples for a subgraphget_subgraph_guidance_by_id - Get subgraph-specific guidanceAd-hoc tools:
get_schema_by_url - Get schema from any GraphQL endpoint (no registry needed)execute_query_by_url - Execute query against any GraphQL endpoint (no registry needed)To interact with the MCP server, use the WebFetch tool to make HTTP requests to the SSE endpoint at http://localhost:8000.
When exploring subgraphs in the registry (subgraphs.json):
Step 1: List or Search
list_subgraphs to see all available subgraphssearch_subgraphs_by_keyword to find specific subgraphs by name/descriptionStep 2: Understand the Schema
get_schema_by_id to retrieve the GraphQL schemaget_query_examples_by_id for pre-built query templatesget_subgraph_guidance_by_id for subgraph-specific tipsStep 3: Execute Queries
execute_query_by_id to run GraphQL queriesreferences/graphql_patterns.md for common patternsStep 4: Export Useful Queries
scripts/export_query.py to save queries for project useFor exploring subgraphs not in the registry:
Direct URL Access:
get_schema_by_url with the GraphQL endpoint URLauth_header if authentication is requiredexecute_query_by_url to run queries directlyExample workflow:
get_schema_by_url(url="https://example.com/graphql")execute_query_by_url(url="https://example.com/graphql", query="...", variables={...})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 where clauses for specific criteria
query FilteredQuery($minValue: String!) {
entities(where: { value_gte: $minValue }, first: 100) {
id
value
timestamp
}
}
Optimize: Use aggregated fields instead of large arrays
contract.holders (pre-calculated count)tokens manuallyReference: See references/graphql_patterns.md for comprehensive query patterns including pagination, filtering, aggregation, and performance optimization.
Use the export utility to save discovered queries for project integration:
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 }
}
}
}
`;
python3 scripts/export_query.py queries/get_latest_swaps.py --format py --name get_latest_swaps
python3 scripts/export_query.py queries/latest_swaps.graphql --format graphql
python3 scripts/export_query.py queries/latest_swaps.json --format json --name GetLatestSwaps --variables '{"first": 100}'
DEX/Trading Subgraphs:
Swap - Individual trade transactionsPair - Trading pairs with liquidity and volumeToken - Token information and metadataDayData / PairDayData - Aggregated daily metricsNFT Subgraphs:
ERC721Transfer / ERC1155Transfer - NFT transfer eventsAccount - User accounts with balancesERC721Token / ERC1155Token - Individual NFT tokensERC721Contract - NFT collection contractsCommon Patterns:
id, timestamp, and blockNumber fieldspair { token0 { symbol } }) to navigate connectionstotalSupply, holders) provide pre-calculated statsTime-based Data:
(yesterday_value * hours_passed / 24) + today_valuePagination:
first parameter is typically 1000, recommended 100skip for offset-based paginationid_gt) for large datasetsPerformance:
Container won't start:
subgraphs.json exists in the subgraph-mcp directorydocker logs subgraph-mcp-serverServer not responding:
bash scripts/check_mcp_status.shConfiguration errors:
SUBGRAPH_MCP_PATH points to correct directorysubgraphs.json is valid JSONSchema introspection fails:
Query timeout:
first parameter valueType errors:
{"id": "0x123"}Empty results:
Docker Management:
start_mcp_server.sh - Start the MCP server in Dockerstop_mcp_server.sh - Stop the MCP servercheck_mcp_status.sh - Check server status and healthQuery Export:
export_query.py - Export GraphQL queries to various formats (JS, Python, GraphQL, JSON)graphql_patterns.md - Comprehensive guide to GraphQL query patterns for subgraphs
get_schema_by_id or get_schema_by_url firstget_query_examples_by_id for configured subgraphsget_subgraph_guidance_by_id for subgraph-specific tipshttp://localhost:9091/metrics) for server health