@pythfeeds/mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/index.js +57 -0
- package/package.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @pythfeeds/mcp
|
|
2
|
+
|
|
3
|
+
MCP server for the [PythFeeds API](https://pythfeeds.com/developers) — gives AI agents (Claude Desktop, Claude Code, Cursor, …) live **Pyth oracle prices** and crypto market data as tools.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
`get_price` · `get_prices` · `list_feeds` · `get_coins` · `get_coin` · `get_ohlc` · `get_global`
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
Get an API key at [pythfeeds.com/developers](https://pythfeeds.com/developers), then add the server to your MCP client.
|
|
11
|
+
|
|
12
|
+
**Claude Desktop / Claude Code** (`claude_desktop_config.json` or `.mcp.json`):
|
|
13
|
+
|
|
14
|
+
> The npm package is not published yet — until it is, point `command` at a
|
|
15
|
+
> local checkout of this folder (works identically):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"pythfeeds": {
|
|
21
|
+
"command": "node",
|
|
22
|
+
"args": ["/path/to/sdks/mcp/index.js"],
|
|
23
|
+
"env": { "PYTHFEEDS_API_KEY": "pf_live_xxx" }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Once published to npm, the zero-install form becomes available:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"pythfeeds": {
|
|
35
|
+
"command": "npx",
|
|
36
|
+
"args": ["-y", "@pythfeeds/mcp"],
|
|
37
|
+
"env": { "PYTHFEEDS_API_KEY": "pf_live_xxx" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then ask your agent things like *"What's the live BTC price?"* or *"Compare ETH and SOL prices and 7-day OHLC."*
|
|
44
|
+
|
|
45
|
+
## Env
|
|
46
|
+
| Var | Default |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `PYTHFEEDS_API_KEY` | — (required) |
|
|
49
|
+
| `PYTHFEEDS_API_URL` | `https://pythfeeds.com/api/v1` |
|
|
50
|
+
|
|
51
|
+
MIT licensed. Prices are real-time Pyth oracle data served via PythFeeds' Pyth Pro access.
|
package/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// PythFeeds MCP server — exposes the PythFeeds API as Model Context Protocol
|
|
3
|
+
// tools so AI agents (Claude, etc.) can pull live Pyth oracle prices + market
|
|
4
|
+
// data. Configure with PYTHFEEDS_API_KEY (get one at pythfeeds.com/developers).
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
const API = (process.env.PYTHFEEDS_API_URL || "https://pythfeeds.com/api/v1").replace(/\/$/, "");
|
|
10
|
+
const KEY = process.env.PYTHFEEDS_API_KEY || "";
|
|
11
|
+
|
|
12
|
+
if (!KEY) {
|
|
13
|
+
console.error("[pythfeeds-mcp] Warning: PYTHFEEDS_API_KEY is not set — calls will be rejected. Get a key at https://pythfeeds.com/developers");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function call(path, params) {
|
|
17
|
+
const url = new URL(API + path);
|
|
18
|
+
if (params) for (const [k, v] of Object.entries(params)) if (v != null) url.searchParams.set(k, String(v));
|
|
19
|
+
const res = await fetch(url.toString(), { headers: { "x-api-key": KEY, accept: "application/json" } });
|
|
20
|
+
let body = {};
|
|
21
|
+
try { body = await res.json(); } catch { /* non-JSON */ }
|
|
22
|
+
if (!res.ok) throw new Error(body.error || `HTTP ${res.status}`);
|
|
23
|
+
return body;
|
|
24
|
+
}
|
|
25
|
+
const ok = (data) => ({ content: [{ type: "text", text: JSON.stringify(data, null, 2) }] });
|
|
26
|
+
|
|
27
|
+
const server = new McpServer({ name: "pythfeeds", version: "1.0.0" });
|
|
28
|
+
|
|
29
|
+
server.tool("get_price", "Live Pyth oracle price for one symbol (e.g. BTC, ETH, SOL). Returns price, confidence, exponent and publish time.",
|
|
30
|
+
{ symbol: z.string().describe("Asset symbol, e.g. BTC") },
|
|
31
|
+
async ({ symbol }) => ok(await call(`/price/${encodeURIComponent(symbol)}`)));
|
|
32
|
+
|
|
33
|
+
server.tool("get_prices", "Live Pyth oracle prices for multiple symbols in one call.",
|
|
34
|
+
{ symbols: z.array(z.string()).describe("Symbols, e.g. ['BTC','ETH','SOL']") },
|
|
35
|
+
async ({ symbols }) => ok(await call("/prices", { symbols: symbols.join(",") })));
|
|
36
|
+
|
|
37
|
+
server.tool("list_feeds", "Search the Pyth feed catalog (feed IDs + asset types).",
|
|
38
|
+
{ query: z.string().optional().describe("Filter, e.g. 'btc'") },
|
|
39
|
+
async ({ query }) => ok(await call("/feeds", query ? { query } : undefined)));
|
|
40
|
+
|
|
41
|
+
server.tool("get_coins", "Top cryptocurrencies by market cap with 24h/7d change.",
|
|
42
|
+
{ page: z.number().optional(), per_page: z.number().optional() },
|
|
43
|
+
async ({ page, per_page }) => ok(await call("/coins", { page: page ?? 1, per_page: per_page ?? 50 })));
|
|
44
|
+
|
|
45
|
+
server.tool("get_coin", "Full market detail for one coin by id (e.g. 'bitcoin').",
|
|
46
|
+
{ id: z.string().describe("Coin id, e.g. bitcoin") },
|
|
47
|
+
async ({ id }) => ok(await call(`/coins/${encodeURIComponent(id)}`)));
|
|
48
|
+
|
|
49
|
+
server.tool("get_ohlc", "OHLC candles for a coin. days in {1,7,14,30,90,180,365} (paid plans: also 730, 1825).",
|
|
50
|
+
{ id: z.string(), days: z.number().optional() },
|
|
51
|
+
async ({ id, days }) => ok(await call(`/coins/${encodeURIComponent(id)}/ohlc`, { days: days ?? 7 })));
|
|
52
|
+
|
|
53
|
+
server.tool("get_global", "Global market cap, 24h volume and BTC dominance.", {}, async () => ok(await call("/global")));
|
|
54
|
+
|
|
55
|
+
const transport = new StdioServerTransport();
|
|
56
|
+
await server.connect(transport);
|
|
57
|
+
console.error("[pythfeeds-mcp] ready");
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pythfeeds/mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for the PythFeeds API — give AI agents live Pyth oracle prices & market data.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "pythfeeds-mcp": "index.js" },
|
|
7
|
+
"files": ["index.js", "README.md"],
|
|
8
|
+
"keywords": ["mcp", "model-context-protocol", "pyth", "pythfeeds", "crypto", "prices", "ai", "agent"],
|
|
9
|
+
"homepage": "https://pythfeeds.com/developers",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"engines": { "node": ">=18" },
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
14
|
+
"zod": "^3.23.0"
|
|
15
|
+
}
|
|
16
|
+
}
|