# HyperLiquid MCP Server
[](https://github.com/talkincode/hyperliquid-mcp-python/actions/workflows/ci.yml)
[](https://badge.fury.io/py/hyperliquid-mcp-python)
[](https://pypi.org/project/hyperliquid-mcp-python/)
[](https://opensource.org/licenses/MIT)
基于 FastMCP 的 HyperLiquid 交易 MCP 服务器。为 AI 助手提供与 HyperLiquid 永续合约和现货交易平台交互的工具。
> **致谢**: 本项目 Fork 自 [GigabrainGG/hyperliquid-mcp](https://github.com/GigabrainGG/hyperliquid-mcp),感谢原作者的出色工作!
## 功能特性
### 交易工具
- [x] **市价订单**:使用 HyperLiquid 原生函数优化的开仓和平仓
- [x] **限价订单**:支持 reduce-only 和自定义订单 ID 追踪
- [x] **括号订单**:一键创建带止盈止损的新仓位(OCO 行为)
- [x] **订单管理**:按 ID 或客户端 ID 取消订单、批量取消、修改订单
- [x] **仓位管理**:查看仓位、平仓(全部或部分)、获取盈亏信息
- [x] **高级止盈止损**:为现有仓位设置 OCO 止盈止损
### 账户管理
- [x] **余额信息**:获取账户余额和保证金详情
- [x] **仓位跟踪**:监控所有开仓及未实现盈亏
- [x] **交易历史**:查询成交记录和交易历史
- [x] **杠杆控制**:为不同资产更新杠杆设置
- [x] **资金划转**:在现货和合约账户间转移资金
### 市场数据
- [x] **实时价格**:获取当前市场数据,包括买卖价差
- [x] **订单簿**:获取可配置深度的实时订单簿数据
- [x] **资金费率**:访问历史资金费率信息
### 实用工具
- [x] **账户总览**:获取账户综合概览
- [x] **美元转换**:根据当前价格计算代币数量
- [x] **仓位管理**:专用的现有仓位管理工具
## 快速开始
### 方式 1:使用 uvx(推荐)🚀
**最简单的方式** - 无需安装,直接运行:
```bash
# 查看帮助
uvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp --help
# 启动 HTTP 服务器
uvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp start
# 启动 stdio 服务器(用于 MCP 客户端)
uvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp stdio
```
> **为什么要指定 `--python 3.13`?**
> 依赖包 `ckzg` 目前只提供到 Python 3.13 的预编译包,Python 3.14 还不支持。指定版本可以避免编译错误。
### 方式 2:本地开发安装
```bash
# 克隆仓库
git clone https://github.com/talkincode/hyperliquid-mcp-python.git
cd hyperliquid-mcp-python
# 安装依赖(uv 会自动处理编译)
uv sync
# 配置
cp .env.example .env # 然后编辑 .env 文件
# 或设置环境变量
export HYPERLIQUID_PRIVATE_KEY="0x..."
export HYPERLIQUID_TESTNET="true" # 强烈建议先用测试网!
# 运行
uv run hyperliquid-mcp # HTTP 模式(默认 127.0.0.1:8080)
uv run hyperliquid-mcp stdio # stdio 模式(用于 MCP 客户端)
uv run hyperliquid-mcp --help # 查看帮助
```
### 方式 3:pip 安装(需要 Python 3.10-3.13)
```bash
# 使用 pip(需要 Python 3.10-3.13)
pip install hyperliquid-mcp-python
# 运行
hyperliquid-mcp --help
```
> **注意**: 包要求 Python 3.10-3.13。Python 3.14 还不支持。
## 配置
创建 `.env` 文件或设置环境变量:
```bash
HYPERLIQUID_PRIVATE_KEY=0x... # 必填
HYPERLIQUID_TESTNET=true # 可选,默认: false
HYPERLIQUID_ACCOUNT_ADDRESS= # 可选,自动从私钥派生
```
⚠️ **安全提示**:绝不提交 `.env` 文件。先用测试网。建议使用 API 钱包 https://app.hyperliquid.xyz/API
## 使用方法
### 方式 1:使用 Makefile(推荐)⭐
```bash
# 查看所有可用命令
make help
# 安装依赖
make install
# 查看配置
make config
# 快速验证(连接+余额+地址)
make test-quick
# 启动 HTTP 服务器
make run-http
# 启动 stdio 服务器(用于 MCP 客户端)
make run-stdio
```
### 方式 2:直接使用命令
```bash
# 已安装的包(推荐)
hyperliquid-mcp # HTTP 服务器(默认)
hyperliquid-mcp stdio # stdio 模式(用于 MCP 客户端)
hyperliquid-mcp --help # 显示帮助
# 本地开发
uv run hyperliquid-mcp
uv run hyperliquid-mcp stdio
```
### MCP 客户端集成 (Claude Desktop)
添加到 `~/Library/Application Support/Claude/claude_desktop_config.json`:
**推荐配置(本地安装)**
```json
{
"mcpServers": {
"hyperliquid": {
"command": "uv",
"args": [
"--directory",
"/path/to/hyperliquid-mcp",
"run",
"hyperliquid-mcp",
"stdio"
],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "0x...",
"HYPERLIQUID_TESTNET": "true"
}
}
}
}
```
**如果全局安装成功**
```json
{
"mcpServers": {
"hyperliquid": {
"command": "hyperliquid-mcp",
"args": ["stdio"],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "0x...",
"HYPERLIQUID_TESTNET": "true"
}
}
}
}
```
The server will start and display configuration information:
```
HyperLiquid MCP Server starting...
Network: Mainnet
Account: 0x1234567890abcdef1234567890abcdef12345678
Logs will be written to: /path/to/hyperliquid_mcp.log
```
## 可用工具
### 快速示例
```python
# 账户信息
get_account_balance()
get_open_positions()
get_account_summary()
# 交易 - 新仓位
market_open_position("BTC", "buy", 0.1) # 市价单
place_limit_order("BTC", "buy", 0.1, 45000) # 限价单
place_bracket_order("BTC", "buy", 0.1, 45000, 47000, 43000) # 入场 + 止盈止损
# 交易 - 管理现有仓位
market_close_position("BTC") # 平仓
set_take_profit_stop_loss("BTC", tp_price=47000, sl_price=43000) # 设置止盈止损
# 订单管理
cancel_order("BTC", order_id)
cancel_all_orders("BTC")
# 市场数据
get_market_data("BTC")
get_orderbook("BTC", depth=20)
# 实用工具
calculate_token_amount_from_dollars("SOL", 20.0) # 将 $20 转换为 SOL 代币数量
update_leverage("BTC", 10, cross_margin=True)
```
⚠️ **重要**:`size` 参数是**代币数量**,不是美元金额!
- ✅ 正确:`market_open_position("SOL", "buy", 0.133)` # 0.133 个 SOL 代币
- ❌ 错误:`market_open_position("SOL", "buy", 20.0)` 误以为是 $20
使用 `calculate_token_amount_from_dollars()` 将美元转换为代币数量。
## 常见用例
```python
# 基础交易流程
calc = calculate_token_amount_from_dollars("SOL", 50.0) # 将 $50 转换为代币
market_open_position("SOL", "buy", calc["token_amount"]) # 开仓
set_take_profit_stop_loss("SOL", tp_price=160, sl_price=140) # 设置止盈止损
market_close_position("SOL") # 准备好时平仓
# 括号订单(一键入场 + 止盈止损)
calc = calculate_token_amount_from_dollars("ETH", 100.0)
place_bracket_order("ETH", "buy", calc["token_amount"], 3000, 3200, 2900)
# 投资组合管理
summary = get_account_summary()
update_leverage("BTC", 5, True)
transfer_between_spot_and_perp(5000, True)
```
## 返回格式
所有工具返回标准化响应:
```json
{"success": true, "data": {...}} // 成功
{"success": false, "error": "..."} // 错误
```
日志写入 `hyperliquid_mcp.log`。
## 测试工具
项目包含一套完整的测试脚本,帮助你验证配置和快速上手。
### 使用 Makefile(推荐)⭐
```bash
# 运行所有只读测试
make test-all
# 快速验证
make test-quick
# 运行特定测试
make test-market # 市场数据测试
make test-account # 账户信息测试
make test-balance # 余额检查
make test-orderbook # 订单簿测试
make test-funding # 资金费率历史
make test-calculator # 价格计算器
make test-address # 地址验证
# 列出所有可用测试
make list-tests
# 查看测试帮助
make test-help
```
### 手动运行测试
```bash
# 基础连接测试
uv run python test_scripts/test_connection.py
# 检查所有账户余额(现货 + 合约)
uv run python test_scripts/check_all_balances.py
# 交互式测试工具(推荐)⭐
uv run python test_scripts/interactive_test.py
# 或使用测试套件脚本
./test_scripts/run_tests.sh all
```
更多测试工具和详细说明,请查看 [test_scripts/README.md](test_scripts/README.md)
## 故障排除
- **Size 参数**:使用代币数量,不是美元。用 `calculate_token_amount_from_dollars()` 转换
- **客户端订单 ID**:必须是 128 位十六进制字符串(如 `0x1234...`)
- **未找到仓位**:设置止盈止损前确保仓位存在
- **网络**:先用测试网:`HYPERLIQUID_TESTNET=true`
- **API 钱包**:如使用 API 钱包,需在 `.env` 中设置 `HYPERLIQUID_ACCOUNT_ADDRESS` 为主账号地址
## 相关链接
- [HyperLiquid 文档](https://hyperliquid.gitbook.io/hyperliquid-docs/)
- [FastMCP](https://fastmcp.com)
- [MCP 协议](https://github.com/anthropics/mcp)
## 免责声明
仅供学习使用。先在测试网测试。加密货币交易涉及重大风险。
Raw data
{
"_id": null,
"home_page": null,
"name": "hyperliquid-mcp-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.10",
"maintainer_email": null,
"keywords": "ai, crypto, fastmcp, hyperliquid, mcp, perpetuals, trading",
"author": null,
"author_email": "jettwang <jamiesun.net@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c0/f3/aea2af98b5f4229359c2a018c2965ef8c27a7b309d6401c9375e03d98ace/hyperliquid_mcp_python-0.1.8.tar.gz",
"platform": null,
"description": "# HyperLiquid MCP Server\n\n[](https://github.com/talkincode/hyperliquid-mcp-python/actions/workflows/ci.yml)\n[](https://badge.fury.io/py/hyperliquid-mcp-python)\n[](https://pypi.org/project/hyperliquid-mcp-python/)\n[](https://opensource.org/licenses/MIT)\n\n\u57fa\u4e8e FastMCP \u7684 HyperLiquid \u4ea4\u6613 MCP \u670d\u52a1\u5668\u3002\u4e3a AI \u52a9\u624b\u63d0\u4f9b\u4e0e HyperLiquid \u6c38\u7eed\u5408\u7ea6\u548c\u73b0\u8d27\u4ea4\u6613\u5e73\u53f0\u4ea4\u4e92\u7684\u5de5\u5177\u3002\n\n> **\u81f4\u8c22**: \u672c\u9879\u76ee Fork \u81ea [GigabrainGG/hyperliquid-mcp](https://github.com/GigabrainGG/hyperliquid-mcp)\uff0c\u611f\u8c22\u539f\u4f5c\u8005\u7684\u51fa\u8272\u5de5\u4f5c\uff01\n\n## \u529f\u80fd\u7279\u6027\n\n### \u4ea4\u6613\u5de5\u5177\n\n- [x] **\u5e02\u4ef7\u8ba2\u5355**\uff1a\u4f7f\u7528 HyperLiquid \u539f\u751f\u51fd\u6570\u4f18\u5316\u7684\u5f00\u4ed3\u548c\u5e73\u4ed3\n- [x] **\u9650\u4ef7\u8ba2\u5355**\uff1a\u652f\u6301 reduce-only \u548c\u81ea\u5b9a\u4e49\u8ba2\u5355 ID \u8ffd\u8e2a\n- [x] **\u62ec\u53f7\u8ba2\u5355**\uff1a\u4e00\u952e\u521b\u5efa\u5e26\u6b62\u76c8\u6b62\u635f\u7684\u65b0\u4ed3\u4f4d\uff08OCO \u884c\u4e3a\uff09\n- [x] **\u8ba2\u5355\u7ba1\u7406**\uff1a\u6309 ID \u6216\u5ba2\u6237\u7aef ID \u53d6\u6d88\u8ba2\u5355\u3001\u6279\u91cf\u53d6\u6d88\u3001\u4fee\u6539\u8ba2\u5355\n- [x] **\u4ed3\u4f4d\u7ba1\u7406**\uff1a\u67e5\u770b\u4ed3\u4f4d\u3001\u5e73\u4ed3\uff08\u5168\u90e8\u6216\u90e8\u5206\uff09\u3001\u83b7\u53d6\u76c8\u4e8f\u4fe1\u606f\n- [x] **\u9ad8\u7ea7\u6b62\u76c8\u6b62\u635f**\uff1a\u4e3a\u73b0\u6709\u4ed3\u4f4d\u8bbe\u7f6e OCO \u6b62\u76c8\u6b62\u635f\n\n### \u8d26\u6237\u7ba1\u7406\n\n- [x] **\u4f59\u989d\u4fe1\u606f**\uff1a\u83b7\u53d6\u8d26\u6237\u4f59\u989d\u548c\u4fdd\u8bc1\u91d1\u8be6\u60c5\n- [x] **\u4ed3\u4f4d\u8ddf\u8e2a**\uff1a\u76d1\u63a7\u6240\u6709\u5f00\u4ed3\u53ca\u672a\u5b9e\u73b0\u76c8\u4e8f\n- [x] **\u4ea4\u6613\u5386\u53f2**\uff1a\u67e5\u8be2\u6210\u4ea4\u8bb0\u5f55\u548c\u4ea4\u6613\u5386\u53f2\n- [x] **\u6760\u6746\u63a7\u5236**\uff1a\u4e3a\u4e0d\u540c\u8d44\u4ea7\u66f4\u65b0\u6760\u6746\u8bbe\u7f6e\n- [x] **\u8d44\u91d1\u5212\u8f6c**\uff1a\u5728\u73b0\u8d27\u548c\u5408\u7ea6\u8d26\u6237\u95f4\u8f6c\u79fb\u8d44\u91d1\n\n### \u5e02\u573a\u6570\u636e\n\n- [x] **\u5b9e\u65f6\u4ef7\u683c**\uff1a\u83b7\u53d6\u5f53\u524d\u5e02\u573a\u6570\u636e\uff0c\u5305\u62ec\u4e70\u5356\u4ef7\u5dee\n- [x] **\u8ba2\u5355\u7c3f**\uff1a\u83b7\u53d6\u53ef\u914d\u7f6e\u6df1\u5ea6\u7684\u5b9e\u65f6\u8ba2\u5355\u7c3f\u6570\u636e\n- [x] **\u8d44\u91d1\u8d39\u7387**\uff1a\u8bbf\u95ee\u5386\u53f2\u8d44\u91d1\u8d39\u7387\u4fe1\u606f\n\n### \u5b9e\u7528\u5de5\u5177\n\n- [x] **\u8d26\u6237\u603b\u89c8**\uff1a\u83b7\u53d6\u8d26\u6237\u7efc\u5408\u6982\u89c8\n- [x] **\u7f8e\u5143\u8f6c\u6362**\uff1a\u6839\u636e\u5f53\u524d\u4ef7\u683c\u8ba1\u7b97\u4ee3\u5e01\u6570\u91cf\n- [x] **\u4ed3\u4f4d\u7ba1\u7406**\uff1a\u4e13\u7528\u7684\u73b0\u6709\u4ed3\u4f4d\u7ba1\u7406\u5de5\u5177\n\n## \u5feb\u901f\u5f00\u59cb\n\n### \u65b9\u5f0f 1\uff1a\u4f7f\u7528 uvx\uff08\u63a8\u8350\uff09\ud83d\ude80\n\n**\u6700\u7b80\u5355\u7684\u65b9\u5f0f** - \u65e0\u9700\u5b89\u88c5\uff0c\u76f4\u63a5\u8fd0\u884c\uff1a\n\n```bash\n# \u67e5\u770b\u5e2e\u52a9\nuvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp --help\n\n# \u542f\u52a8 HTTP \u670d\u52a1\u5668\nuvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp start\n\n# \u542f\u52a8 stdio \u670d\u52a1\u5668\uff08\u7528\u4e8e MCP \u5ba2\u6237\u7aef\uff09\nuvx --python 3.13 --from hyperliquid-mcp-python hyperliquid-mcp stdio\n```\n\n> **\u4e3a\u4ec0\u4e48\u8981\u6307\u5b9a `--python 3.13`?**\n> \u4f9d\u8d56\u5305 `ckzg` \u76ee\u524d\u53ea\u63d0\u4f9b\u5230 Python 3.13 \u7684\u9884\u7f16\u8bd1\u5305\uff0cPython 3.14 \u8fd8\u4e0d\u652f\u6301\u3002\u6307\u5b9a\u7248\u672c\u53ef\u4ee5\u907f\u514d\u7f16\u8bd1\u9519\u8bef\u3002\n\n### \u65b9\u5f0f 2\uff1a\u672c\u5730\u5f00\u53d1\u5b89\u88c5\n\n```bash\n# \u514b\u9686\u4ed3\u5e93\ngit clone https://github.com/talkincode/hyperliquid-mcp-python.git\ncd hyperliquid-mcp-python\n\n# \u5b89\u88c5\u4f9d\u8d56\uff08uv \u4f1a\u81ea\u52a8\u5904\u7406\u7f16\u8bd1\uff09\nuv sync\n\n# \u914d\u7f6e\ncp .env.example .env # \u7136\u540e\u7f16\u8f91 .env \u6587\u4ef6\n# \u6216\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\nexport HYPERLIQUID_PRIVATE_KEY=\"0x...\"\nexport HYPERLIQUID_TESTNET=\"true\" # \u5f3a\u70c8\u5efa\u8bae\u5148\u7528\u6d4b\u8bd5\u7f51\uff01\n\n# \u8fd0\u884c\nuv run hyperliquid-mcp # HTTP \u6a21\u5f0f\uff08\u9ed8\u8ba4 127.0.0.1:8080\uff09\nuv run hyperliquid-mcp stdio # stdio \u6a21\u5f0f\uff08\u7528\u4e8e MCP \u5ba2\u6237\u7aef\uff09\nuv run hyperliquid-mcp --help # \u67e5\u770b\u5e2e\u52a9\n```\n\n### \u65b9\u5f0f 3\uff1apip \u5b89\u88c5\uff08\u9700\u8981 Python 3.10-3.13\uff09\n\n```bash\n# \u4f7f\u7528 pip\uff08\u9700\u8981 Python 3.10-3.13\uff09\npip install hyperliquid-mcp-python\n\n# \u8fd0\u884c\nhyperliquid-mcp --help\n```\n\n> **\u6ce8\u610f**: \u5305\u8981\u6c42 Python 3.10-3.13\u3002Python 3.14 \u8fd8\u4e0d\u652f\u6301\u3002\n\n## \u914d\u7f6e\n\n\u521b\u5efa `.env` \u6587\u4ef6\u6216\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\n\n```bash\nHYPERLIQUID_PRIVATE_KEY=0x... # \u5fc5\u586b\nHYPERLIQUID_TESTNET=true # \u53ef\u9009\uff0c\u9ed8\u8ba4: false\nHYPERLIQUID_ACCOUNT_ADDRESS= # \u53ef\u9009\uff0c\u81ea\u52a8\u4ece\u79c1\u94a5\u6d3e\u751f\n```\n\n\u26a0\ufe0f **\u5b89\u5168\u63d0\u793a**\uff1a\u7edd\u4e0d\u63d0\u4ea4 `.env` \u6587\u4ef6\u3002\u5148\u7528\u6d4b\u8bd5\u7f51\u3002\u5efa\u8bae\u4f7f\u7528 API \u94b1\u5305 https://app.hyperliquid.xyz/API\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u65b9\u5f0f 1\uff1a\u4f7f\u7528 Makefile\uff08\u63a8\u8350\uff09\u2b50\n\n```bash\n# \u67e5\u770b\u6240\u6709\u53ef\u7528\u547d\u4ee4\nmake help\n\n# \u5b89\u88c5\u4f9d\u8d56\nmake install\n\n# \u67e5\u770b\u914d\u7f6e\nmake config\n\n# \u5feb\u901f\u9a8c\u8bc1\uff08\u8fde\u63a5+\u4f59\u989d+\u5730\u5740\uff09\nmake test-quick\n\n# \u542f\u52a8 HTTP \u670d\u52a1\u5668\nmake run-http\n\n# \u542f\u52a8 stdio \u670d\u52a1\u5668\uff08\u7528\u4e8e MCP \u5ba2\u6237\u7aef\uff09\nmake run-stdio\n```\n\n### \u65b9\u5f0f 2\uff1a\u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\n\n```bash\n# \u5df2\u5b89\u88c5\u7684\u5305\uff08\u63a8\u8350\uff09\nhyperliquid-mcp # HTTP \u670d\u52a1\u5668\uff08\u9ed8\u8ba4\uff09\nhyperliquid-mcp stdio # stdio \u6a21\u5f0f\uff08\u7528\u4e8e MCP \u5ba2\u6237\u7aef\uff09\nhyperliquid-mcp --help # \u663e\u793a\u5e2e\u52a9\n\n# \u672c\u5730\u5f00\u53d1\nuv run hyperliquid-mcp\nuv run hyperliquid-mcp stdio\n```\n\n### MCP \u5ba2\u6237\u7aef\u96c6\u6210 (Claude Desktop)\n\n\u6dfb\u52a0\u5230 `~/Library/Application Support/Claude/claude_desktop_config.json`\uff1a\n\n**\u63a8\u8350\u914d\u7f6e\uff08\u672c\u5730\u5b89\u88c5\uff09**\n\n```json\n{\n \"mcpServers\": {\n \"hyperliquid\": {\n \"command\": \"uv\",\n \"args\": [\n \"--directory\",\n \"/path/to/hyperliquid-mcp\",\n \"run\",\n \"hyperliquid-mcp\",\n \"stdio\"\n ],\n \"env\": {\n \"HYPERLIQUID_PRIVATE_KEY\": \"0x...\",\n \"HYPERLIQUID_TESTNET\": \"true\"\n }\n }\n }\n}\n```\n\n**\u5982\u679c\u5168\u5c40\u5b89\u88c5\u6210\u529f**\n\n```json\n{\n \"mcpServers\": {\n \"hyperliquid\": {\n \"command\": \"hyperliquid-mcp\",\n \"args\": [\"stdio\"],\n \"env\": {\n \"HYPERLIQUID_PRIVATE_KEY\": \"0x...\",\n \"HYPERLIQUID_TESTNET\": \"true\"\n }\n }\n }\n}\n```\n\nThe server will start and display configuration information:\n\n```\nHyperLiquid MCP Server starting...\nNetwork: Mainnet\nAccount: 0x1234567890abcdef1234567890abcdef12345678\nLogs will be written to: /path/to/hyperliquid_mcp.log\n```\n\n## \u53ef\u7528\u5de5\u5177\n\n### \u5feb\u901f\u793a\u4f8b\n\n```python\n# \u8d26\u6237\u4fe1\u606f\nget_account_balance()\nget_open_positions()\nget_account_summary()\n\n# \u4ea4\u6613 - \u65b0\u4ed3\u4f4d\nmarket_open_position(\"BTC\", \"buy\", 0.1) # \u5e02\u4ef7\u5355\nplace_limit_order(\"BTC\", \"buy\", 0.1, 45000) # \u9650\u4ef7\u5355\nplace_bracket_order(\"BTC\", \"buy\", 0.1, 45000, 47000, 43000) # \u5165\u573a + \u6b62\u76c8\u6b62\u635f\n\n# \u4ea4\u6613 - \u7ba1\u7406\u73b0\u6709\u4ed3\u4f4d\nmarket_close_position(\"BTC\") # \u5e73\u4ed3\nset_take_profit_stop_loss(\"BTC\", tp_price=47000, sl_price=43000) # \u8bbe\u7f6e\u6b62\u76c8\u6b62\u635f\n\n# \u8ba2\u5355\u7ba1\u7406\ncancel_order(\"BTC\", order_id)\ncancel_all_orders(\"BTC\")\n\n# \u5e02\u573a\u6570\u636e\nget_market_data(\"BTC\")\nget_orderbook(\"BTC\", depth=20)\n\n# \u5b9e\u7528\u5de5\u5177\ncalculate_token_amount_from_dollars(\"SOL\", 20.0) # \u5c06 $20 \u8f6c\u6362\u4e3a SOL \u4ee3\u5e01\u6570\u91cf\nupdate_leverage(\"BTC\", 10, cross_margin=True)\n```\n\n\u26a0\ufe0f **\u91cd\u8981**\uff1a`size` \u53c2\u6570\u662f**\u4ee3\u5e01\u6570\u91cf**\uff0c\u4e0d\u662f\u7f8e\u5143\u91d1\u989d\uff01\n\n- \u2705 \u6b63\u786e\uff1a`market_open_position(\"SOL\", \"buy\", 0.133)` # 0.133 \u4e2a SOL \u4ee3\u5e01\n- \u274c \u9519\u8bef\uff1a`market_open_position(\"SOL\", \"buy\", 20.0)` \u8bef\u4ee5\u4e3a\u662f $20\n\n\u4f7f\u7528 `calculate_token_amount_from_dollars()` \u5c06\u7f8e\u5143\u8f6c\u6362\u4e3a\u4ee3\u5e01\u6570\u91cf\u3002\n\n## \u5e38\u89c1\u7528\u4f8b\n\n```python\n# \u57fa\u7840\u4ea4\u6613\u6d41\u7a0b\ncalc = calculate_token_amount_from_dollars(\"SOL\", 50.0) # \u5c06 $50 \u8f6c\u6362\u4e3a\u4ee3\u5e01\nmarket_open_position(\"SOL\", \"buy\", calc[\"token_amount\"]) # \u5f00\u4ed3\nset_take_profit_stop_loss(\"SOL\", tp_price=160, sl_price=140) # \u8bbe\u7f6e\u6b62\u76c8\u6b62\u635f\nmarket_close_position(\"SOL\") # \u51c6\u5907\u597d\u65f6\u5e73\u4ed3\n\n# \u62ec\u53f7\u8ba2\u5355\uff08\u4e00\u952e\u5165\u573a + \u6b62\u76c8\u6b62\u635f\uff09\ncalc = calculate_token_amount_from_dollars(\"ETH\", 100.0)\nplace_bracket_order(\"ETH\", \"buy\", calc[\"token_amount\"], 3000, 3200, 2900)\n\n# \u6295\u8d44\u7ec4\u5408\u7ba1\u7406\nsummary = get_account_summary()\nupdate_leverage(\"BTC\", 5, True)\ntransfer_between_spot_and_perp(5000, True)\n```\n\n## \u8fd4\u56de\u683c\u5f0f\n\n\u6240\u6709\u5de5\u5177\u8fd4\u56de\u6807\u51c6\u5316\u54cd\u5e94\uff1a\n\n```json\n{\"success\": true, \"data\": {...}} // \u6210\u529f\n{\"success\": false, \"error\": \"...\"} // \u9519\u8bef\n```\n\n\u65e5\u5fd7\u5199\u5165 `hyperliquid_mcp.log`\u3002\n\n## \u6d4b\u8bd5\u5de5\u5177\n\n\u9879\u76ee\u5305\u542b\u4e00\u5957\u5b8c\u6574\u7684\u6d4b\u8bd5\u811a\u672c\uff0c\u5e2e\u52a9\u4f60\u9a8c\u8bc1\u914d\u7f6e\u548c\u5feb\u901f\u4e0a\u624b\u3002\n\n### \u4f7f\u7528 Makefile\uff08\u63a8\u8350\uff09\u2b50\n\n```bash\n# \u8fd0\u884c\u6240\u6709\u53ea\u8bfb\u6d4b\u8bd5\nmake test-all\n\n# \u5feb\u901f\u9a8c\u8bc1\nmake test-quick\n\n# \u8fd0\u884c\u7279\u5b9a\u6d4b\u8bd5\nmake test-market # \u5e02\u573a\u6570\u636e\u6d4b\u8bd5\nmake test-account # \u8d26\u6237\u4fe1\u606f\u6d4b\u8bd5\nmake test-balance # \u4f59\u989d\u68c0\u67e5\nmake test-orderbook # \u8ba2\u5355\u7c3f\u6d4b\u8bd5\nmake test-funding # \u8d44\u91d1\u8d39\u7387\u5386\u53f2\nmake test-calculator # \u4ef7\u683c\u8ba1\u7b97\u5668\nmake test-address # \u5730\u5740\u9a8c\u8bc1\n\n# \u5217\u51fa\u6240\u6709\u53ef\u7528\u6d4b\u8bd5\nmake list-tests\n\n# \u67e5\u770b\u6d4b\u8bd5\u5e2e\u52a9\nmake test-help\n```\n\n### \u624b\u52a8\u8fd0\u884c\u6d4b\u8bd5\n\n```bash\n# \u57fa\u7840\u8fde\u63a5\u6d4b\u8bd5\nuv run python test_scripts/test_connection.py\n\n# \u68c0\u67e5\u6240\u6709\u8d26\u6237\u4f59\u989d\uff08\u73b0\u8d27 + \u5408\u7ea6\uff09\nuv run python test_scripts/check_all_balances.py\n\n# \u4ea4\u4e92\u5f0f\u6d4b\u8bd5\u5de5\u5177\uff08\u63a8\u8350\uff09\u2b50\nuv run python test_scripts/interactive_test.py\n\n# \u6216\u4f7f\u7528\u6d4b\u8bd5\u5957\u4ef6\u811a\u672c\n./test_scripts/run_tests.sh all\n```\n\n\u66f4\u591a\u6d4b\u8bd5\u5de5\u5177\u548c\u8be6\u7ec6\u8bf4\u660e\uff0c\u8bf7\u67e5\u770b [test_scripts/README.md](test_scripts/README.md)\n\n## \u6545\u969c\u6392\u9664\n\n- **Size \u53c2\u6570**\uff1a\u4f7f\u7528\u4ee3\u5e01\u6570\u91cf\uff0c\u4e0d\u662f\u7f8e\u5143\u3002\u7528 `calculate_token_amount_from_dollars()` \u8f6c\u6362\n- **\u5ba2\u6237\u7aef\u8ba2\u5355 ID**\uff1a\u5fc5\u987b\u662f 128 \u4f4d\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\uff08\u5982 `0x1234...`\uff09\n- **\u672a\u627e\u5230\u4ed3\u4f4d**\uff1a\u8bbe\u7f6e\u6b62\u76c8\u6b62\u635f\u524d\u786e\u4fdd\u4ed3\u4f4d\u5b58\u5728\n- **\u7f51\u7edc**\uff1a\u5148\u7528\u6d4b\u8bd5\u7f51\uff1a`HYPERLIQUID_TESTNET=true`\n- **API \u94b1\u5305**\uff1a\u5982\u4f7f\u7528 API \u94b1\u5305\uff0c\u9700\u5728 `.env` \u4e2d\u8bbe\u7f6e `HYPERLIQUID_ACCOUNT_ADDRESS` \u4e3a\u4e3b\u8d26\u53f7\u5730\u5740\n\n## \u76f8\u5173\u94fe\u63a5\n\n- [HyperLiquid \u6587\u6863](https://hyperliquid.gitbook.io/hyperliquid-docs/)\n- [FastMCP](https://fastmcp.com)\n- [MCP \u534f\u8bae](https://github.com/anthropics/mcp)\n\n## \u514d\u8d23\u58f0\u660e\n\n\u4ec5\u4f9b\u5b66\u4e60\u4f7f\u7528\u3002\u5148\u5728\u6d4b\u8bd5\u7f51\u6d4b\u8bd5\u3002\u52a0\u5bc6\u8d27\u5e01\u4ea4\u6613\u6d89\u53ca\u91cd\u5927\u98ce\u9669\u3002\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "HyperLiquid MCP Server with FastMCP - Trading tools and account management",
"version": "0.1.8",
"project_urls": {
"Bug Tracker": "https://github.com/talkincode/hyperliquid-mcp-python/issues",
"Documentation": "https://github.com/talkincode/hyperliquid-mcp-python#readme",
"Homepage": "https://github.com/talkincode/hyperliquid-mcp-python",
"Repository": "https://github.com/talkincode/hyperliquid-mcp-python"
},
"split_keywords": [
"ai",
" crypto",
" fastmcp",
" hyperliquid",
" mcp",
" perpetuals",
" trading"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d42828df27a3dc71fe010d8ae44fb321bbeda6e54483c7d1bd821b999ec33780",
"md5": "8df5ff1fc40ec37cc30500690f107877",
"sha256": "17a07ddd77a8f178ccc855478eafa2b12b01bee8b4cc628a452abed18ec9e8c3"
},
"downloads": -1,
"filename": "hyperliquid_mcp_python-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8df5ff1fc40ec37cc30500690f107877",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.10",
"size": 21916,
"upload_time": "2025-10-28T08:39:51",
"upload_time_iso_8601": "2025-10-28T08:39:51.651000Z",
"url": "https://files.pythonhosted.org/packages/d4/28/28df27a3dc71fe010d8ae44fb321bbeda6e54483c7d1bd821b999ec33780/hyperliquid_mcp_python-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c0f3aea2af98b5f4229359c2a018c2965ef8c27a7b309d6401c9375e03d98ace",
"md5": "fd778e20027b21709c1591182879cb16",
"sha256": "76bb06959fd62557a2cda1adf912af2b39291395c8c9a38767e29dfab58fdd64"
},
"downloads": -1,
"filename": "hyperliquid_mcp_python-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "fd778e20027b21709c1591182879cb16",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.10",
"size": 218904,
"upload_time": "2025-10-28T08:39:52",
"upload_time_iso_8601": "2025-10-28T08:39:52.840533Z",
"url": "https://files.pythonhosted.org/packages/c0/f3/aea2af98b5f4229359c2a018c2965ef8c27a7b309d6401c9375e03d98ace/hyperliquid_mcp_python-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-28 08:39:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "talkincode",
"github_project": "hyperliquid-mcp-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hyperliquid-mcp-python"
}