使用说明
MCP加密服务器
模型上下文协议(MCP)服务器,从CoinGecko API提供比特币和加密货币数据。
特性
- 所有加密货币资源:通过以下方式获取市值排名前100的加密货币
crypto://all - 比特币详细信息工具:获取全面的比特币市场数据,包括价格、市值、交易量和历史数据
- 加密货币搜索工具:按名称或符号搜索任何加密货币
- 加密货币市场摘要提示:获取顶级加密货币、最大赢家或输家的快速摘要
- 实时数据:所有数据都是从CoinGecko API实时获取的
安装
- 克隆存储库:
git clone <repository-url>
cd mcp-bitcoin
- 安装依赖项:
npm install
- 构建项目:
npm run build
用法
发展模式
npx @modelcontextprotocol/inspector node dist/index.js
这将在您的本地主机中打开MCP检查器
在Claude桌面上进行测试
- 打开克劳德桌面→ 偏好设置→ 开发者→ 编辑配置
- 将此配置添加到claude_desktop_config.json文件中
"bitcoin": {
"command": "node",
"args": [
<path_to_your_project_root>
]
}
- 重新启动claude桌面
- 尝试以下查询:“今天获取加密货币的前5名赢家”,“获取比特币详细信息”,“对比比特币和以太坊”
MCP资源
服务器提供一种资源:
所有加密货币
- 统一资源标识符:
crypto://all - 描述:市值排名前100的加密货币
- 数据:包含关键市场指标的加密货币列表,包括:
- 名称和符号
- 当前价格
- 市值和排名
- 24小时价格变动百分比
- 总体积
- 图片网址
MCP工具
服务器提供以下工具:
获取比特币详细信息
- 名字:
get_bitcoin_details - 描述获取最新的比特币市场数据和统计
- 参数:无
- 退货:详细的比特币市场数据
按名称获取加密货币
- 名字:
get_crypto_by_name - 描述:按名称或符号搜索加密货币数据
- 参数:
name(string):加密货币的名称或符号
- 退货:与搜索词匹配的筛选结果
获取所有加密货币
- 名字:
get_all_cryptos - 描述:获得市值前100的加密货币
- 参数:无
- 退货:所有具有市场数据的顶级加密货币
MCP提示
服务器提供以下提示:
加密货币市场概述
- 名字:
crypto_market_summary - 描述:总结顶级加密货币或最大的推动者
- 参数:
type(枚举):选择摘要类型:"top5"-市值排名前5的加密货币"gainers"-24小时内涨幅最大的5家公司"losers"-24小时内最大的五大输家
- 退货:包含选定加密货币信息的摘要数据
API数据结构
服务器以以下格式返回数据:
interface BitcoinData {
id: string;
symbol: string;
name: string;
image: string;
current_price: number;
market_cap: number;
market_cap_rank: number;
total_volume: number;
price_change_24h: number;
price_change_percentage_24h: number;
high_24h: number;
low_24h: number;
circulating_supply: number;
total_supply: number;
max_supply: number;
ath: number;
ath_change_percentage: number;
ath_date: string;
atl: number;
atl_change_percentage: number;
atl_date: string;
last_updated: string;
}
数据源
所有加密货币数据均来自 CoinGecko API,为数千种加密货币提供实时市场数据。
MCP服务器实现
此服务器使用具有以下结构的官方MCP SDK:
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new McpServer({
name: 'mcp-bitcoin-server',
version: '1.0.0',
});
// Register resources, tools, and prompts
server.resource("cryptocurrencies", "crypto://all", {...});
server.tool("get_bitcoin_details", "...", {}, async () => {...});
server.prompt("crypto_market_summary", "...", {...}, async (args) => {...});
// Connect to transport
const transport = new StdioServerTransport();
await server.connect(transport);
依赖项
@modelcontextprotocol/sdk:用于服务器实现的最新MCP SDKaxios:API请求的HTTP客户端zod:MCP资源、工具和提示的模式验证