Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/talkincode/hyperliquid-mcp-python/copilot-instructionsgit clone --depth 1 https://github.com/talkincode/hyperliquid-mcp-pythonWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01525 | $0.01525 |
| Opus 5 | $0.00763 | $0.00763 |
| Sonnet 5 | $0.00305 | $0.00305 |
| Haiku 4.5 | $0.00153 | $0.00153 |
Grade A, and why
hyperliquid-mcp-python copilot-instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.
HyperLiquid MCP Server - AI 编程指南
项目概述
这是一个模型上下文协议 (MCP) 服务器,为AI助手提供HyperLiquid交易功能。架构采用服务层模式,FastMCP处理MCP协议,专门的服务层负责HyperLiquid API交互。
核心架构:
main.py: FastMCP服务器,包含工具定义和配置管理services/hyperliquid_services.py: 核心交易逻辑和HyperLiquid SDK集成- 全局单例模式: 服务实例初始化一次,在所有工具调用中重复使用
- 异步优先: 所有工具都是异步的,尽管底层SDK是同步的
关键实现模式
配置管理
应用使用三模式配置系统:
- 环境变量 (
HYPERLIQUID_PRIVATE_KEY,HYPERLIQUID_TESTNET,HYPERLIQUID_ACCOUNT_ADDRESS) .env文件(相同变量名)config.json文件,使用snake_case键名 (private_key,testnet,account_address)
模式: 始终先检查环境变量,然后检查配置文件,最后抛出带有有用设置说明的错误。
订单大小 vs 美元价值
关键: 所有交易函数中的 size 参数代表代币数量,而非美元价值。
- ✅
0.1表示 0.1 个 SOL 代币 - ❌
20.0误认为是 $20
使用 calculate_token_amount_from_dollars() 进行转换。这是最常见的用户错误。
OCO(一取消其他)订单分组
不同场景使用不同的订单分组:
- 新仓位的止盈止损:
place_bracket_order()使用normalTpSl分组 - 现有仓位的止盈止损:
set_position_tpsl()使用positionTpSl分组 - 自定义批量订单: 重写
_bulk_orders_with_grouping()方法设置适当分组
市场操作
- 开仓: 使用
market_open_position()→ 调用exchange.market_open() - 平仓: 使用
market_close_position()→ 激进的IOC订单,设置reduce_only=True - 常规交易: 使用
place_limit_order()进行标准限价订单
服务层架构
服务初始化模式
global hyperliquid_service: Optional[HyperliquidServices] = None
def initialize_service():
global hyperliquid_service
if hyperliquid_service is None:
config = get_config()
hyperliquid_service = HyperliquidServices(
private_key=config.private_key,
testnet=config.testnet,
account_address=config.account_address
)
在工具函数中使用服务前,始终调用 initialize_service()。
自定义SDK扩展
HyperliquidServices 类扩展了官方SDK:
- 自定义批量订单:
_bulk_orders_with_grouping()正确设置OCO分组 - 仓位检测: 自动检测TP/SL订单的仓位大小和方向
- 滑点定价:
_slippage_price()用于激进市场订单 - 统一错误处理: 所有方法的一致返回格式
工具设计模式
返回格式标准化
所有工具返回:
{
"success": bool,
"data"/"order_result"/"bulk_result": Any, # 成功数据
"error": str, # 失败时的错误描述
# 其他上下文字段
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 141 lines · 1,525 tokens per session scan A 7c4357e6c133
hyperliquid-mcp-python copilot-instructions.md is an instructions file published in the GitHub repository talkincode/hyperliquid-mcp-python (3 stars, last pushed 8mo ago), licensed MIT. It adds 1,525 tokens to every session, about $0.0076 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
finance-skills CLAUDE.md
Instructions for himself65/finance-skills, covering claude.md, project overview, repository structure, how skills work and skill.md format.
pumpfun-bonkfun-bot CLAUDE.md
Instructions for chainstacklabs/pumpfun-bonkfun-bot, covering agent guide, ground rules, layout, naming inside learning-examples/ and commands.
alpaca-trade-api-js AGENTS.md
Instructions for alpacahq/alpaca-trade-api-js, covering agents.md, conventions, commands, releases & changelog (changesets) and automated release flow on master.
tradememory-protocol AGENTS.md
Instructions for mnemox-ai/tradememory-protocol, covering tradememory protocol — agent context, project rules, recent changes and current status.
polymarket-alpha-bot CLAUDE.md
Instructions for chainstacklabs/polymarket-alpha-bot, covering claude.md, commands, development, pipeline and seed data.
LLM-TradeBot backend.instructions.md
Instructions for EthanAlgoX/LLM-TradeBot, a project described as: A multi-agent AI trading system using LLMs to optimize strategies and adapt to market conditions in real-time.