Build with AI Agents
Steps to connect AI agents to Pyth market data with the Pyth MCP server and MCP Skills
This guide covers steps to connect AI agents to Pyth market data with the Pyth MCP server and MCP Skills.
MCP Server
The Pyth MCP server gives AI assistants direct, structured access to Pyth market data through the Model Context Protocol. You can discover feeds, fetch real-time and historical prices, replay every update in a short window, and generate chart-ready candles, all within a single conversation.
MCP endpoint: https://mcp.pyth.network/mcp — no self-hosting required.
Tools
| Category | Tool | Description | API key |
|---|---|---|---|
| Discovery | get_symbols | Find feeds by text, asset type, instrument type or futures chain | Optional |
| Real-time | get_latest_price | Latest prices for up to 100 feeds | Yes |
| Historical | get_historical_price | Prices at one point in time for up to 50 feeds | Yes |
| Historical | get_price_range | Every price update in a window of up to 60 seconds | Yes |
| Charting | get_candlestick_data | OHLC candles for one feed (up to 500 per response) | Yes |
| Utility | convert_date_to_timestamp | Convert a date to Unix seconds and microseconds | No |
Price tools accept full symbols (Crypto.BTC/USD) or plain pairs (BTC/USD). A plain pair resolves to the live spot feed when there is one, otherwise to the only other live match. resolved_symbols in the response shows what each input resolved to.
API Key
Every user brings their own Pyth Pro API key; the hosted server has none of its own. See Acquire an API Key.
Give the server your key in one of three ways. A key passed on a call overrides a configured one.
- In your MCP client's configuration (recommended): your client sends the key as an
Authorization: Bearer <key>header on every request. The Setup tabs below show how for each client. - As an environment variable, for a local server: set
PYTH_PRO_ACCESS_TOKENin the server'senvblock. - On each call: the
access_tokenparameter. Your assistant asks for the key when none is configured.
Configure the key in your client rather than pasting it into chat, and keep it out of config files you commit or share.
get_symbols works without a key. With a key, it also lists feeds visible only to Pro keys and marks each feed entitled: true or false: whether your key can query that feed.
Setup
- Endpoint:
https://mcp.pyth.network/mcp - Transport: Streamable HTTP
- Auth: connecting needs no key; the price tools use your key, sent as an
Authorization: Bearerheader
Replace YOUR_API_KEY with your Pyth Pro API key.
Add Server
claude mcp add --transport http pyth https://mcp.pyth.network/mcp \
--header "Authorization: Bearer YOUR_API_KEY"This adds Pyth only to the folder you run the command in. To use it in every project, add --scope user; any project you open can then call the price tools with your key.
Verify
claude mcp listTool Reference
Every price tool also takes an optional access_token. Leave it out when your client sends the key.
get_symbols
Search and list Pyth Pro feeds.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | No | Text filter, e.g. BTC, gold, AAPL |
asset_type | string | No | crypto, crypto-index, crypto-redemption-rate, fx, equity, metal, rates, interest-rate, nav, commodity, funding-rate, eco, kalshi |
instrument_type | string | No | spot, future, perp, rate, index, nav |
symbol_chain_id | string | No | Futures chain, exact match (e.g. VX for all VIX futures) |
include_inactive | boolean | No | Include retired feeds. Default false |
verbose | boolean | No | Return every catalog field (trading schedules, market sessions, corporate actions). Default false |
limit | number | No | Default 50, max 200 |
offset | number | No | Default 0 |
- Each feed has a
state. Onlystablefeeds return prices;betaandcoming_soonfeeds are listed but cannot be queried yet. - With a key, each feed carries
entitled, and the list includes feeds visible only to Pro keys.
get_latest_price
Fetch the latest prices for one or more feeds.
| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | No* | BTC/USD or Crypto.BTC/USD |
price_feed_ids | number[] | No* | Feed IDs from get_symbols |
channel | string | No | real_time, fixed_rate@50ms, fixed_rate@200ms or fixed_rate@1000ms. Default fixed_rate@200ms |
properties | string[] | No | Fields to return (see below) |
* At least one of symbols or price_feed_ids is required.
- Up to
100feeds per request. If bothsymbolsandprice_feed_idsare sent, only the IDs are used. properties:price,bestBidPrice,bestAskPrice,exponent,publisherCount,confidence,fundingRate,fundingTimestamp,fundingRateInterval,marketSession,emaPrice,emaConfidence,feedUpdateTimestamp. The default is the first six plusmarketSessionandfeedUpdateTimestamp.- Prices are integers with an
exponent. Each response also carriesdisplay_*values (display_price,display_bid,display_ask,display_confidence,display_ema_price,display_ema_confidence,display_funding_rate) with the exponent applied.
get_historical_price
Get prices at a single historical timestamp.
| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | No* | BTC/USD or Crypto.BTC/USD |
price_feed_ids | number[] | No* | Feed IDs |
timestamp | number | Yes | Unix seconds, milliseconds, or microseconds |
channel | string | No | Same values as get_latest_price |
* At least one of symbols or price_feed_ids is required.
- Up to
50feeds per request. If both are sent, only the IDs are used. - The timestamp is aligned down to the channel's update interval.
Historical data is available from April 2025 onward.
get_price_range
Return every price update for one or more feeds within a short window, such as the seconds around a liquidation or a news event.
| Parameter | Type | Required | Description |
|---|---|---|---|
symbols | string[] | No* | BTC/USD or Crypto.BTC/USD |
price_feed_ids | number[] | No* | Feed IDs |
start | number | Yes | Window start: Unix seconds, milliseconds, or microseconds |
end | number | Yes | Window end, at most 60 seconds after start |
limit | number | No | Rows per page. Default 100, max 500 |
after | string | No | next_cursor from the previous page |
channel | string | No | Same values as get_latest_price |
* At least one of symbols or price_feed_ids is required. Up to 50 feeds.
- When
has_moreistrue, call again with the same arguments andafterset tonext_cursor.
get_candlestick_data
Fetch OHLC candlestick data for a single feed.
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | BTC/USD or Crypto.BTC/USD |
resolution | string | Yes | 1, 5, 15, 30, 60, 120, 240, 360, 720, D, W, M |
from | number | Yes | Start time (Unix seconds) |
to | number | Yes | End time (Unix seconds) |
channel | string | No | Same values as get_latest_price |
frommust be earlier thanto.- Up to
500candles per response; larger results come back withtruncated: true. - For funding-rate feeds, candles chart the mark price. Use
get_latest_priceorget_historical_pricefor the funding rate itself.
convert_date_to_timestamp
Convert a date to Unix timestamps for the other tools. No key needed.
| Parameter | Type | Required | Description |
|---|---|---|---|
date_string | string | Yes | ISO 8601, e.g. 2026-01-01 or 2026-01-01T14:30:00Z. Dates without a timezone are read as UTC |
Troubleshooting
"This tool requires your Pyth Pro access token"
- Cause: No key reached the server.
- Fix: Configure the key in your client (see Setup), then restart or reconnect the client. Or pass it as
access_token.
Invalid or expired key
- Cause: The server rejected the key (HTTP 401).
- Fix: Check that the header reads exactly
Authorization: Bearer <key>, or get a new key from Acquire an API Key.
Not entitled to a feed
- Cause: Your key is valid, but your plan does not include the feed (HTTP 403). The error names the entitlement group it needs.
- Fix: Run
get_symbolswith your key and pick feeds withentitled: true.
Symbol not found or ambiguous
- Fix: Use the full symbol or a feed ID from
get_symbols. For an ambiguous pair, the error lists the matching feeds.
Feed listed in missing_feed_ids
- Cause:
get_latest_priceorget_historical_pricereturned no price for the feed. The feed is not live yet (betaorcoming_soon), or the channel is faster than the feed'smin_channel. - Fix: Check the feed's
stateandmin_channelinget_symbols, or use a slower channel.
No historical data
- Fix: Use timestamps from April 2025 onward, and not in the future.
Truncated candles
- Symptom: Response includes
truncated: true - Fix: Narrow the time range or use a larger resolution.
Local Development
Optionally run the MCP server locally:
git clone https://github.com/pyth-network/pyth-crosschain.git
cd pyth-crosschain
pnpm install
pnpm --filter @pythnetwork/mcp buildThen configure your client with stdio transport. The local server reads your key from PYTH_PRO_ACCESS_TOKEN:
{
"mcpServers": {
"pyth": {
"command": "node",
"args": ["<path-to-repo>/apps/mcp/dist/index.js"],
"env": {
"PYTH_PRO_ACCESS_TOKEN": "YOUR_API_KEY"
}
}
}
}MCP Skills
MCP Skills are pre-built prompt templates that teach AI assistants specific workflows using the Pyth MCP server. Instead of figuring out which tools to call and how to combine them, you can describe what you want in natural language and the skill handles the rest.
Skills work with Claude Code and are installed alongside the MCP server. Each skill listed below includes example prompts you can try directly in your AI assistant.
Skills require the Pyth MCP server to be configured first. Every skill that fetches prices also needs your Pyth Pro API key, configured as described in MCP Server setup.
Installation
Skills are Claude Code slash commands that live in your project's .claude/skills/ directory. Each skill is a folder containing a SKILL.md file.
Prerequisites
- Claude Code installed
- Pyth MCP server configured with your API key
Setup
Clone the repository
git clone https://github.com/pyth-network/pyth-crosschain.gitCopy skills to your project
Copy the skills directory into your project's .claude/ folder:
cp -r pyth-crosschain/apps/mcp/skills/ your-project/.claude/skills/Your project structure should look like:
your-project/
└── .claude/
└── skills/
├── pyth-alert-conditions/
│ └── SKILL.md
├── pyth-cross-asset-comparison/
│ └── SKILL.md
├── pyth-fx-converter/
│ └── SKILL.md
├── ... (9 skills total)
└── references/
└── common.mdUse a skill
In Claude Code, invoke any skill with a slash command:
/pyth-alert-conditions Is BTC above $100k?
/pyth-fx-converter Convert 1000 EUR to JPY
/pyth-portfolio-tracker I hold 2 BTC and 50 ETHOr simply describe what you want — Claude Code will automatically select the appropriate skill based on your question.
You can also install individual skills by copying only the specific skill folders you need. Copy references/ with them, because every skill links to references/common.md.
Available Skills
| Skill | Category | Description | API Key Required |
|---|---|---|---|
| Price Alerts | Market Data | One-time price threshold and percentage change checks | Yes |
| Cross-Asset Comparison | Market Data | Compare performance across assets via normalization | Yes |
| Volatility Analysis | Market Data | Annualized volatility, ATR, and risk comparison | Yes |
| FX Converter | Financial | Currency conversion with direct pairs or USD cross rates | Yes |
| Portfolio Tracker | Financial | Portfolio value, allocation, and P&L tracking | Yes |
| Funding Rate Monitor | Financial | Perpetual futures funding rates and sentiment | Yes |
| Data Export | Data & Integration | Export price data as CSV, JSON, or Markdown | Yes, except feed catalog exports |
| Time-Series Snapshots | Data & Integration | Historical prices at specific dates | Yes |
| Integration Helper | Data & Integration | Developer onboarding for Pyth feeds and IDs | Only for live prices |
Market Data
Price Alerts
Evaluates one-time price conditions — checks if prices are above or below thresholds, if assets have moved by a percentage, or if prices are near period highs or lows. These are point-in-time checks, not persistent alerts.
How it works: Decomposes your question into the data needed, fetches it, evaluates the condition, and answers YES or NO with supporting numbers.
What you can ask:
- "Is BTC above $100k?"
- "Has ETH dropped 5% today?"
- "Is gold near its weekly high?"
- "Has SOL changed more than 10% since June 1?"
- "Is the BTC bid-ask spread above $10?"
Try it:
"Is gold near its weekly high?"
The assistant fetches this week's daily candles and the current price, computes the weekly high from the candle data, and tells you how close the current price is as a percentage.
Cross-Asset Comparison
Compares price performance across multiple assets by normalizing OHLC data to a common baseline. Converts absolute prices to relative performance so you can compare assets at different price scales (e.g., BTC at 2k).
How it works: Fetches candlestick data for each asset over the same time range, divides each close by the first close (1.0 = starting point), and computes period returns.
What you can ask:
- "Compare Bitcoin vs Gold this quarter"
- "ETH vs SOL performance over the last 30 days"
- "EUR/USD vs GBP/USD over the past week"
- "Which performed better this month: BTC, ETH, or SOL?"
Try it:
"Compare Bitcoin vs Gold this quarter"
The assistant fetches daily candles for both assets, normalizes each series, and presents a side-by-side table showing that, for example, BTC returned +12.4% while Gold returned +4.2%.
Volatility Analysis
Analyzes price volatility using candlestick data. Computes annualized volatility from close-to-close returns, average true range (ATR), and daily range metrics.
How it works: Fetches candlestick data, calculates daily returns, then computes standard deviation and annualizes it (using 365 days for crypto, 252 for equities/FX).
What you can ask:
- "How volatile is SOL?"
- "Compare the volatility of BTC, ETH, and AAPL"
- "What's the average daily range of gold?"
- "Is ETH more volatile than BTC?"
Try it:
"Compare the volatility of BTC, ETH, and AAPL"
The assistant fetches 30 days of daily candles for each, computes annualized volatility and ATR, and presents a comparison table showing relative risk levels.
Financial Workflows
FX Converter
Converts currencies using Pyth FX and crypto price feeds. Supports fiat-to-fiat, crypto-to-fiat, and historical rate conversions.
How it works: The assistant uses a direct pair, such as EUR/JPY, when Pyth has one live. Otherwise it converts through USD and reads each pair's direction: EUR/USD is dollars per euro, and USD/JPY is yen per dollar.
What you can ask:
- "Convert 1000 EUR to JPY"
- "How much is 5 BTC in EUR?"
- "What was the GBP/JPY rate last Friday?"
- "Convert 500 USD to GBP"
Try it:
"Convert 1000 EUR to JPY"
The assistant finds the live EUR/JPY pair, fetches its rate (e.g., 161.19), and returns: 1000 EUR = 161,190 JPY.
Portfolio Tracker
Tracks a portfolio of assets with current prices, allocation percentages, and P&L calculations. Supports cost-basis and date-based P&L.
How it works: Discovers feeds, batches all assets into a single price call (up to 100 feeds), then computes value, allocation, and optionally compares against historical reference prices.
What you can ask:
- "What's my portfolio worth? I hold 2 BTC, 50 ETH, and 1000 SOL"
- "Show gold, silver, and platinum prices"
- "How has my portfolio performed since last month?"
- "What's the allocation breakdown of my crypto holdings?"
Try it:
"What's my portfolio worth? I hold 2 BTC, 50 ETH, and 1000 SOL"
The assistant fetches all three prices in one call and returns a table with each asset's value and your total portfolio value with allocation percentages.
Funding Rate Monitor
Monitors perpetual futures funding rates to gauge market sentiment. Positive rates indicate long-biased (bullish) markets, negative rates indicate short-biased (bearish) markets.
How it works: Discovers funding rate feeds using the funding-rate asset type, fetches current rates, and tracks how a rate has changed by sampling it with historical price snapshots.
What you can ask:
- "What are the current BTC and ETH funding rates?"
- "Show me all funding rates sorted by magnitude"
- "How has the BTC funding rate changed this week?"
- "Which assets have the highest funding rates right now?"
Try it:
"What are the current BTC and ETH funding rates?"
The assistant fetches both rates and presents them with sentiment labels — for example, BTC at +0.012% (slightly long-biased) and ETH at +0.035% (moderately long-biased).
Data & Integration
Data Export
Exports Pyth price data in CSV, JSON, or Markdown table format. Handles OHLC exports, feed catalog dumps, historical snapshots, and current price tables.
How it works: Fetches all requested data first (with pagination if needed), then formats the complete dataset. Caps exports at 1000 rows.
What you can ask:
- "Export BTC daily OHLC for the last 30 days as CSV"
- "Give me all crypto feeds as JSON"
- "Show current prices for BTC, ETH, and gold as a Markdown table"
- "Export the full feed catalog"
Try it:
"Export BTC daily OHLC for the last 30 days as CSV"
The assistant fetches daily candlestick data and formats it with headers:
timestamp,open,high,low,close,volumefollowed by one row per day.
Time-Series Snapshots
Fetches price snapshots at specific historical timestamps. Generates timestamp series (monthly, weekly, quarterly) and retrieves prices for each date.
How it works: Generates Unix timestamps for your requested dates, then calls the historical price API once per timestamp with up to 50 feeds per call. For continuous data (more than ~20 points), suggests candlestick data instead.
What you can ask:
- "What was BTC at the start of each month this year?"
- "Show me ETH and SOL prices every Monday for the last 4 weeks"
- "Get quarterly gold prices since April 2025"
Try it:
"What was BTC at the start of each month this year?"
The assistant generates timestamps for April 1, May 1, June 1, etc. (data starts April 2025), fetches each snapshot, and presents a table of monthly prices.
Integration Helper
Guides developers on integrating Pyth price feeds. Explains feed discovery, symbol formats, ID types, price exponents, and data channels.
How it works: Understands your integration context (language, chain, use case), uses feed discovery to find specific feeds, and explains the symbol/ID/exponent/channel system.
What you can ask:
- "How do I use Pyth in my trading bot?"
- "What's the feed ID for AAPL?"
- "What asset types does Pyth support?"
- "How does Pyth Pro work?"
- "How do pricing channels work?"
Try it:
"What's the feed ID for AAPL?"
The assistant searches for AAPL and returns the symbol (
Equity.US.AAPL/USD), the Pyth Pro numeric feed ID, and the exponent for price conversion.