# Bitquery MCP

> Bitquery gives your agent a single connection point to query real-time and historical data across 40+ blockchains like Ethereum, Solana, Polygon, and Bitcoin. You get deep analytical insights by running unified GraphQL queries without managing individual node infrastructure.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** graphql, web3, ethereum, solana, bitcoin, defi-analytics, on-chain-data

## Description

Running complex Web3 analysis used to mean jumping between dozens of terminals or paying for multiple specialized API keys. Now, you connect this MCP to your preferred AI client through Vinkius and stop worrying about blockchain connectivity. This tool lets your agent pull deep, cross-chain data using a unified GraphQL interface. You can run historical queries across many networks at once, perfect for auditing long-term trends. For live monitoring, it accesses real-time streaming data for transfers and smart contract events on EVM chains and Solana. Need to track liquidity or trade performance? Specialized cubes let you analyze DeFi activity directly. It's all about making the complexity of multi-chain data accessible via natural language conversation.

## Tools

### generate_token
Uses your Client ID and Secret to generate a secure OAuth2 access token needed for all subsequent queries.

### query_v1
Runs a GraphQL query against the historical API, ideal for deep dives into past block data across 40+ chains.

### query_v2
Executes advanced queries against the streaming API, supporting complex joins and real-time cubes like Transfers or DexTrades.

## Prompt Examples

**Prompt:** 
```
Execute a V1 query to get the last 5 blocks from the Bitcoin network.
```

**Response:** 
```
I've retrieved the latest 5 Bitcoin blocks using `query_v1`. The most recent block height is 834291 with 3,421 transactions. Would you like to see the details of a specific block?
```

**Prompt:** 
```
Use query_v2 to find the latest 10 DEX trades on Ethereum Mainnet.
```

**Response:** 
```
Fetching real-time DEX trades via `query_v2`... I found 10 recent trades on Uniswap V3 and Curve. The largest trade was 45.2 ETH for USDC. Should I analyze the price impact of these trades?
```

**Prompt:** 
```
Generate a new access token using my client ID 'cid_123' and secret 'sec_456'.
```

**Response:** 
```
I have successfully generated a new OAuth2 token using `generate_token`. You can now use this Bearer token for your subsequent GraphQL queries. Remember to keep this token secure.
```

## Capabilities

### Querying historical blockchain records
You execute a GraphQL query to pull specific transaction or block data from over 40 different blockchains.

### Monitoring live chain activity
Your agent accesses streaming data, allowing you to track transfers, contract calls, and events as they happen in real time for supported chains.

### Analyzing DeFi market metrics
You use specialized query cubes to calculate liquidity positions, trade volumes, and token performance across major decentralized exchanges.

### Inspecting smart contract interactions
Your agent analyzes the internal calls, events, and instructions recorded on a blockchain to understand how protocols interact.

## Use Cases

### Tracking a complex fund movement
A security researcher needs to follow funds that moved from Polygon, through an intermediary contract on BNB, and finally settled on Ethereum. The agent uses the `query_v2` tool to execute advanced joins, correlating all three chains' activity into one report.

### Auditing a token migration campaign
A data analyst needs to see if 1 million tokens moved from V1 on Ethereum last month. They use the `query_v1` tool to run a historical query, providing a single, auditable count that proves the movement.

### Monitoring arbitrage opportunities
A quantitative trader needs immediate data on price differences between exchanges. The agent uses the `query_v2` tool and specialized cubes to monitor real-time DEX trades across multiple major chains simultaneously.

### Verifying a smart contract interaction
A developer notices an unexpected call in a protocol. They use the MCP's inspection capabilities to analyze `Calls` and `Events`, pinpointing exactly which internal transaction triggered the anomaly for debugging.

## Benefits

- Cross-chain visibility means you don't need 40 individual APIs. You analyze Bitcoin, Ethereum, and Solana data streams side-by-side using a single connection point.
- Real-time monitoring via `query_v2` lets your agent track live transfers or smart contract events as they happen, so you catch issues immediately.
- The specialized DeFi cubes, like `DexTrades`, let you calculate complex market metrics—total liquidity, trade volume, etc.—without writing massive joins.
- Debugging is faster. Instead of leaving the IDE to check a blockchain explorer, your agent can run smart contract inspection tools directly in your chat window.
- Setup is streamlined. After generating an OAuth2 token with `generate_token`, you immediately start querying data using V1 or V2.

## How It Works

The bottom line is that you talk to your agent in plain English, and it handles all the complex steps of connecting, querying, and structuring the raw chain data for you.

1. First, use your client ID and secret with the `generate_token` tool to create an OAuth2 access token.
2. Next, you direct your agent to run a query using either the `query_v1` or `query_v2` tool, specifying the required GraphQL parameters.
3. The MCP executes the request against the blockchain data and returns structured results directly into your conversation window.

## Frequently Asked Questions

**How do I connect the Bitquery MCP to my workflow?**
You must first use the `generate_token` tool with your Client ID and Secret. This provides the secure OAuth2 token needed for all subsequent queries.

**Should I use `query_v1` or `query_v2`?**
Use `query_v1` when you need to analyze long-term, historical data. Use `query_v2` for anything happening right now, like live transfers or recent trades.

**Can I track multiple chains at once with Bitquery?**
Yes. The core strength of this MCP is its unified interface, allowing you to query and compare data points across 40+ blockchains simultaneously.

**What if my query involves complex joins?**
The `query_v2` tool supports advanced filtering and joining (like joinCalls), enabling you to link together different types of events—calls, transfers, or trades—in a single request.

**What is the purpose of the `generate_token` tool?**
This tool creates your necessary access credential. You must run this first; it generates the Bearer token that authenticates all future data requests to the MCP.