Free Crypto News MCP Server
- 项目简介
- 该仓库实现了一个基于 MCP 的服务器端,能够向客户端暴露工具列表并执行工具调用,此外还提供了一个 HTTP/SSE 传输层,便于通过网络与本地客户端进行 JSON-RPC 风格的通信。核心逻辑在 mcp 目录下,使用了 MCP 的官方 SDK 来构建服务端。
- 服务器通过 Node.js 启动,支持两种连接方式:标准输入/输出(stdio,适用于桌面端模型如 Claude Desktop)以及 HTTP/SSE(适用于 ChatGPT Developer Mode 等 HTTP 客户端)。
- 主要功能点
- MCP 核心能力
- 注册与暴露工具(Tools),包括工具名称、描述、输入模式等元信息,客户端可查询工具列表并发起调用。
- 根据 MCP 请求(ListTools、CallTool 等)返回规范化的 JSON-RPC 响应。
- 传输协议
- stdio 传输:node mcp/index.js
- HTTP/SSE 传输:node mcp/index.js --http,更适合云端/远程客户端
- 工具执行能力
- 服务器内置对外部 API 的调用封装(如 get_crypto_news、search_crypto_news、get_defi_news 等),通过 CallTool 请求执行并返回结果。
- 兼容与扩展
- 使用 MCP SDK 提供的工具描述和请求格式,便于后续接入更多 LM/LLM 客户端。
- MCP 核心能力
- 安装步骤
- 克隆仓库并进入项目目录
- 安装依赖
- 启动服务器:
- stdio 模式(默认):node mcp/index.js
- HTTP/SSE 模式:node mcp/index.js --http
- 服务器配置(面向 MCP 客户端的启动信息,JSON 格式,非代码) { "server": { "name": "free-crypto-news", "version": "1.0.0", "description": "MCP server for Free Crypto News", "transport": "stdio|http", "startCommand": "node", "startArgs": ["mcp/index.js"] }, "transports": [ { "type": "stdio", "enabled": true, "notes": "标准输入/输出模式,适用于本地开发或桌面端模型" }, { "type": "http", "enabled": true, "notes": "HTTP/SSE 模式,适用于云端或远程客户端", "args": ["--http"] } ], "tools": [ { "name": "get_crypto_news", "description": "Latest crypto news from 7 major sources", "annotations": { "readOnlyHint": true } }, { "name": "search_crypto_news", "description": "Search crypto news by keywords", "annotations": { "readOnlyHint": true } }, { "name": "get_defi_news", "description": "DeFi-specific news", "annotations": { "readOnlyHint": true } }, { "name": "get_bitcoin_news", "description": "Bitcoin-specific news", "annotations": { "readOnlyHint": true } }, { "name": "get_breaking_news", "description": "Breaking crypto news (last 2 hours)", "annotations": { "readOnlyHint": true } }, { "name": "get_news_sources", "description": "List available news sources", "annotations": { "readOnlyHint": true } }, { "name": "get_trending_topics", "description": "Trending crypto topics with sentiment", "annotations": { "readOnlyHint": true } } ] }
- 基本使用方法
- 启动后,客户端可以通过 MCP 的 ListTools 请求获取工具列表,并通过 CallTool 请求调用具体工具。
- 例如:
- 列出工具:通过 MCP 客户端发送 ListTools 请求,获取工具集合及其描述。
- 调用工具:选择需要的工具名称(如 get_crypto_news),提供相应参数(如 limit、source 等),服务器执行并返回结果。
- 传输方式说明
- stdio:直接通过进程的输入输出与 MCP 客户端交互,适合桌面型模型或本地调试。
- HTTP/SSE:通过 HTTP 请求/事件流进行通信,兼容更广泛的网络环境。
- 运行与接入注意事项
- 服务器实现了工具执行的内部封装,将外部 Crypto API 调用暴露为 MCP Tool。
- MCP 客户端无需实现底层网络细节,只需要按照 MCP 标准发送 ListTools/CallTool 请求即可获得响应。