mcp-crypto-price 3.0.4 → 3.2.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.
@@ -16,4 +16,9 @@ export const SERVER_CONFIG = {
16
16
  name: "mcp-crypto-price",
17
17
  version: readVersion(),
18
18
  };
19
- export const CACHE_TTL = 60000; // 1 minute cache
19
+ export const CACHE_TTL = 60000; // default fallback (ms)
20
+ /** Returns the active cache TTL in ms, reading CACHE_TTL_SECONDS from env at call time. */
21
+ export function getCacheTtl() {
22
+ const s = parseInt(process.env.CACHE_TTL_SECONDS ?? '60', 10);
23
+ return Number.isFinite(s) && s >= 10 ? s * 1000 : CACHE_TTL;
24
+ }
package/dist/http.js CHANGED
@@ -37,6 +37,13 @@ const serverCard = {
37
37
  },
38
38
  required: ['symbol'],
39
39
  },
40
+ annotations: {
41
+ title: 'Get Crypto Price',
42
+ readOnlyHint: true,
43
+ destructiveHint: false,
44
+ idempotentHint: true,
45
+ openWorldHint: true,
46
+ },
40
47
  },
41
48
  {
42
49
  name: 'get-market-analysis',
@@ -48,6 +55,13 @@ const serverCard = {
48
55
  },
49
56
  required: ['symbol'],
50
57
  },
58
+ annotations: {
59
+ title: 'Get Market Analysis',
60
+ readOnlyHint: true,
61
+ destructiveHint: false,
62
+ idempotentHint: true,
63
+ openWorldHint: true,
64
+ },
51
65
  },
52
66
  {
53
67
  name: 'get-historical-analysis',
@@ -56,11 +70,29 @@ const serverCard = {
56
70
  type: 'object',
57
71
  properties: {
58
72
  symbol: { type: 'string', description: 'Cryptocurrency symbol or name (e.g. BTC or Bitcoin)' },
59
- interval: { type: 'string', enum: ['m5', 'm15', 'm30', 'h1', 'h2', 'h6', 'h12', 'd1'], default: 'h1' },
60
- days: { type: 'number', minimum: 1, maximum: 30, default: 7 },
73
+ interval: {
74
+ type: 'string',
75
+ enum: ['m5', 'm15', 'm30', 'h1', 'h2', 'h6', 'h12', 'd1'],
76
+ default: 'h1',
77
+ description: 'Data interval: m1=1min, m5=5min, m15=15min, m30=30min, h1=1hr, h2=2hr, h6=6hr, h12=12hr, d1=daily',
78
+ },
79
+ days: {
80
+ type: 'number',
81
+ minimum: 1,
82
+ maximum: 30,
83
+ default: 7,
84
+ description: 'Number of days of historical data to retrieve (1-30)',
85
+ },
61
86
  },
62
87
  required: ['symbol'],
63
88
  },
89
+ annotations: {
90
+ title: 'Get Historical Analysis',
91
+ readOnlyHint: true,
92
+ destructiveHint: false,
93
+ idempotentHint: true,
94
+ openWorldHint: true,
95
+ },
64
96
  },
65
97
  {
66
98
  name: 'get-top-assets',
@@ -68,9 +100,22 @@ const serverCard = {
68
100
  inputSchema: {
69
101
  type: 'object',
70
102
  properties: {
71
- limit: { type: 'number', minimum: 1, maximum: 50, default: 10 },
103
+ limit: {
104
+ type: 'number',
105
+ minimum: 1,
106
+ maximum: 50,
107
+ default: 10,
108
+ description: 'Number of top assets to return, ranked by market cap (1-50)',
109
+ },
72
110
  },
73
111
  },
112
+ annotations: {
113
+ title: 'Get Top Assets',
114
+ readOnlyHint: true,
115
+ destructiveHint: false,
116
+ idempotentHint: true,
117
+ openWorldHint: true,
118
+ },
74
119
  },
75
120
  ],
76
121
  resources: [
package/dist/index.js CHANGED
@@ -10,12 +10,23 @@ export const configSchema = z.object({
10
10
  COINCAP_API_KEY: z
11
11
  .string()
12
12
  .optional()
13
- .describe("API key for CoinCap v3 API (required). Free tier available at https://pro.coincap.io/dashboard"),
13
+ .describe("API key for CoinCap v3 API. Free tier available at https://pro.coincap.io/dashboard"),
14
+ CACHE_TTL_SECONDS: z
15
+ .number()
16
+ .int()
17
+ .min(10)
18
+ .max(3600)
19
+ .default(60)
20
+ .optional()
21
+ .describe("How long to cache API responses in seconds (default: 60). Lower values return fresher data; higher values reduce API usage."),
14
22
  });
15
23
  export function createServer({ config, }) {
16
24
  if (config?.COINCAP_API_KEY && !process.env.COINCAP_API_KEY) {
17
25
  process.env.COINCAP_API_KEY = config.COINCAP_API_KEY;
18
26
  }
27
+ if (config?.CACHE_TTL_SECONDS != null) {
28
+ process.env.CACHE_TTL_SECONDS = String(config.CACHE_TTL_SECONDS);
29
+ }
19
30
  const server = new McpServer({
20
31
  name: SERVER_CONFIG.name,
21
32
  version: SERVER_CONFIG.version,
@@ -28,36 +39,60 @@ export function createServer({ config, }) {
28
39
  });
29
40
  server.registerTool("get-crypto-price", {
30
41
  title: "Get Crypto Price",
31
- description: "Get current price and 24h stats for a cryptocurrency",
42
+ description: "Get real-time price, 24-hour change percentage, trading volume, and market cap for any cryptocurrency by symbol or name.",
32
43
  inputSchema: GetPriceArgumentsSchema.shape,
33
- annotations: { readOnlyHint: true, openWorldHint: true },
44
+ annotations: {
45
+ title: "Get Crypto Price",
46
+ readOnlyHint: true,
47
+ destructiveHint: false,
48
+ idempotentHint: true,
49
+ openWorldHint: true,
50
+ },
34
51
  }, async (args, _extra) => {
35
52
  const result = await handleGetPrice(args);
36
53
  return result;
37
54
  });
38
55
  server.registerTool("get-market-analysis", {
39
56
  title: "Get Market Analysis",
40
- description: "Get detailed market analysis including top exchanges and volume distribution",
57
+ description: "Get detailed market analysis for a cryptocurrency including the top 5 exchanges by volume, price per exchange, and volume distribution percentages.",
41
58
  inputSchema: GetMarketAnalysisSchema.shape,
42
- annotations: { readOnlyHint: true, openWorldHint: true },
59
+ annotations: {
60
+ title: "Get Market Analysis",
61
+ readOnlyHint: true,
62
+ destructiveHint: false,
63
+ idempotentHint: true,
64
+ openWorldHint: true,
65
+ },
43
66
  }, async (args, _extra) => {
44
67
  const result = await handleGetMarketAnalysis(args);
45
68
  return result;
46
69
  });
47
70
  server.registerTool("get-historical-analysis", {
48
71
  title: "Get Historical Analysis",
49
- description: "Get historical price analysis with customizable timeframe",
72
+ description: "Get historical price data for a cryptocurrency with trend analysis including period high/low, price change percentage, and volatility metrics over a customizable timeframe.",
50
73
  inputSchema: GetHistoricalAnalysisSchema.shape,
51
- annotations: { readOnlyHint: true, openWorldHint: true },
74
+ annotations: {
75
+ title: "Get Historical Analysis",
76
+ readOnlyHint: true,
77
+ destructiveHint: false,
78
+ idempotentHint: true,
79
+ openWorldHint: true,
80
+ },
52
81
  }, async (args, _extra) => {
53
82
  const result = await handleGetHistoricalAnalysis(args);
54
83
  return result;
55
84
  });
56
85
  server.registerTool("get-top-assets", {
57
86
  title: "Get Top Assets",
58
- description: "Get top cryptocurrencies ranked by market cap",
87
+ description: "Get the top cryptocurrencies ranked by market cap, with real-time price, 24-hour change percentage, and market cap for each asset.",
59
88
  inputSchema: GetTopAssetsSchema.shape,
60
- annotations: { readOnlyHint: true, openWorldHint: true },
89
+ annotations: {
90
+ title: "Get Top Assets",
91
+ readOnlyHint: true,
92
+ destructiveHint: false,
93
+ idempotentHint: true,
94
+ openWorldHint: true,
95
+ },
61
96
  }, async (args, _extra) => {
62
97
  const result = await handleGetTopAssets(args);
63
98
  return result;
Binary file
@@ -1,4 +1,4 @@
1
- import { COINCAP_API_BASE, CACHE_TTL } from '../config/index.js';
1
+ import { COINCAP_API_BASE, getCacheTtl } from '../config/index.js';
2
2
  import { AssetsResponseSchema, HistoricalDataSchema, MarketsResponseSchema } from './schemas.js';
3
3
  const API_KEY_ERROR_MESSAGE = 'CoinCap API key is required. The v2 API has been sunset and all requests now use the v3 API, which requires an API key.\n\n' +
4
4
  'A free tier is available! Get your API key at: https://pro.coincap.io/dashboard\n\n' +
@@ -19,7 +19,7 @@ function getCachedData(key) {
19
19
  if (!entry)
20
20
  return null;
21
21
  const now = Date.now();
22
- if (now - entry.timestamp > CACHE_TTL) {
22
+ if (now - entry.timestamp > getCacheTtl()) {
23
23
  cache.delete(key);
24
24
  return null;
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-crypto-price",
3
- "version": "3.0.4",
3
+ "version": "3.2.0",
4
4
  "description": "A Model Context Protocol (MCP) server that provides real-time cryptocurrency data and analysis through CoinCap's API. Features include price tracking, market analysis, and historical trends.",
5
5
  "license": "MIT",
6
6
  "author": {
Binary file