Agent Sniper
io.github.nirholas由 GitHub 帳號 nirholas 發布v0.1.7更新於 Nov 4, 2026
Self-custodial pump.fun sniper: arm strategies, snipe, manage positions. Simulate by default.
概覽
自託管的 pump.fun 狙擊引擎,透過 MCP 提供:設定策略、強制買入、查看持倉並安排平倉,預設以模擬模式執行。
- 可以做什麼
- 設定、停用並列出交易策略,必須包含停損,SOL 會自動換算為 lamports
- 略過評分器,對所有已啟用的代理強制手動買入某個代幣
- 依代理與狀態篩選持倉,並安排平倉,由下一輪掃描賣出
- 查看引擎狀態:事件、候選、買入與賣出計數、已啟用策略數、佇列深度、網路與模式
- 適用情境
- 適合在本機執行 Solana pump.fun 狙擊循環,讓助理設定策略、手動觸發買入並平倉。建議先在 devnet 的模擬模式下試用,再考慮實盤。
- 執行需求
- 本機 Node.js 22 或更新版本,透過 npx 以 MCP stdio 方式啟動。實盤需要 SOLANA_RPC_URL(公用 RPC 會被拒絕),以及透過 SOLANA_SECRET_KEY 或各代理的 keystore 提供錢包金鑰。SNIPER_MODE 與 SNIPER_NETWORK 決定模擬或實盤、主網或 devnet。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Agent Sniper,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@three-ws/agent-sniper
A lightweight, embeddable pump.fun sniper engine for 3D AI agents. One trade
loop — feed a stream of new launches, score each against a per-agent strategy,
run the pre-trade guards, buy, then sweep open positions on an interval and exit
on stop-loss / take-profit / trailing-stop / timeout / sentiment-flip. It is
multi-agent and multi-user by construction (one wallet per agentId), and every
external dependency — wallet custody, persistence, RPC/venue, launch feed — is a
pluggable adapter, so the same engine runs locally with in-memory state or
hosted across thousands of tenants. The package ships with four faces over that
one engine: a library, a CLI, an MCP server, and an x402 paid HTTP
API.
Why — the adapter architecture
The engine is pure orchestration. It owns the decision pipeline; it owns nothing
about where the money, the data, or the chain live. Five adapter interfaces
(src/types.js) are the seams, and a default implementation ships for each:
Swap any one without touching the loop: a custodial KMS wallet instead of local
keys, a Postgres store instead of memory, a different launch feed, a different
venue. Implement the shape, pass it to createSniper(), done.
Optional Hooks (firewall assessSafety, oracleGate, onScreen, onBuy,
onSell, recordDecision) are best-effort cross-cutting callbacks — a throw is
swallowed and never aborts a trade, except onTip, which is a deliberate veto.
Install
Optional peers, installed only if you use the face that needs them:
Requires Node >= 22.
Quickstart (library)
The presets.local wiring is the zero-to-running path: in-memory store +
self-custody wallet + pump.fun client + web3 executor + PumpPortal feed. Run it
in simulate mode on devnet first — the engine scores, guards, and logs
every decision but never broadcasts.
A strategy must carry a stop_loss_pct — the engine refuses to arm a
strategy without one. SOL amounts on a strategy are expressed in lamports
(1 SOL = 1,000,000,000 lamports), as a string, number, or bigint.
createSniper(deps) is the lower-level constructor when you want to bring your
own adapters — pass { config, store, wallet, solana, executor, feed, hooks }.
presets.local is just one wiring of it.
CLI usage
The package installs an agent-sniper binary. Default mode is simulate — it
will not move funds until you pass --mode live (or set SNIPER_MODE=live),
which trades real funds.
Safety.
run/serve/mcpall start in simulate mode unless you opt into live explicitly. In live mode every armed strategy can spend up to itsdaily_budget_lamportsper UTC day. Read Safety & guardrails below before you flip the switch.
--strategy ./strategy.json loads a strategy (or array of strategies) as JSON.
A minimal file mirrors the object in the Quickstart — note stop_loss_pct is
required.
MCP server
agent-sniper mcp exposes the engine as an MCP stdio server. Every tool maps
1:1 onto a public engine/store method — no internals are reached around. The
server is unauthenticated and meant to run locally against your own wallet/RPC.
Wire it into an MCP client (Claude Desktop, Cursor, etc.):
createSniperMcpServer(deps) builds the fully-registered server without
connecting a transport, so you can construct it in a test and drive it over an
in-memory transport.
x402 paid HTTP API
agent-sniper serve (or import { serve } from '@three-ws/agent-sniper/api')
mounts the engine over HTTP. Reads are free; the four mutating endpoints are
gated behind x402 USDC micropayments via @three-ws/x402-server — the
middleware verifies the X-PAYMENT header against the facilitator, runs the
work, settles on-chain, and emits the receipt.
Prices are the defaults (USDC atomic units, 6 decimals); override via
deps.prices = { arm, snipe, disarm, close }.
Gating turns on when a merchant wallet is configured — deps.payTo.solana or the
X402_PAY_TO_SOLANA env (a Base lane is available via X402_PAY_TO_BASE). When
no payTo is set, the mutating routes still mount but answer 503, so the
server boots cleanly for local/dev without payment config.
The Solana lane also needs a facilitator sponsor fee-payer — set
X402_FEE_PAYER_SOLANA (or deps.feePayer). Without it the Solana lane
self-disables (falling back to the Base lane, or the 503 guard if that's the
only lane) rather than failing requests, and logs a one-time warning at boot.
Web console
serve also ships a built-in operator dashboard — a single, dependency-free
HTML file served from the same origin as the API, at / and /console. Open
http://localhost:8787 and you get a live control room:
- Live stats — buys, sells, candidates, armed strategies, in-flight queue and signal count, animated as they change, with time-since-last-signal.
- Positions table — every position with entry, current value, and colored P&L (unrealized total in the header), plus a one-click Close that schedules an exit through the normal sell path.
- Armed strategies — each policy with its stop-loss / take-profit / trailing tags, and a Disarm button.
- Arm a strategy and Manual snipe forms with inline validation.
- Live activity feed — the same engine screen events the CLI prints, streamed in with relative timestamps.
- Designed loading / empty / error states, toasts, keyboard shortcuts
(
ssnipe,nnew strategy,rrefresh,,settings,?help), a disconnected banner, and full mobile responsiveness.
Reads are free. The mutating controls (arm, snipe, disarm, close) are x402-paid for external callers — so to drive them from your own console without paying yourself, set an operator token:
Open Settings (⚙ or ,) in the console and paste the same token. It is sent as
X-Admin-Token (or Authorization: Bearer …), stored only in your browser, and
bypasses the x402 gate — while unauthenticated external agents still pay. Pass it
programmatically as deps.adminToken. Without a token set, the console is a
full-featured read-only monitor and mutations return 503 with guidance.
Multi-agent / multi-user
The engine is multi-tenant by design. The unit of isolation is the agentId:
- One wallet per agent. The
Walletadapter resolves a signingKeypairperagentId. Self-custody reads it (in order) from asecretsmap,SNIPER_WALLET_<AGENTID>env, a keystore directory of<agentId>.jsonfiles, or a single defaultSOLANA_SECRET_KEY. If an agent has no provisioned wallet,loadKeypairreturnsnulland the engine fails the trade cleanly — it never auto-provisions an unfunded wallet. - Custodial for hosted deployments.
createCustodialWallet({ resolve })takes a single asyncresolve(agentId, ctx)that decrypts a key from your own KMS/secret box on demand, with a short TTL cache so a long-lived process doesn't re-decrypt every trade. The cache is keyed per agent;clearCache()forces a re-resolve. - Per-agent caps. Each strategy carries its own
daily_budget_lamportsandmax_concurrent_positions. The guards enforce them per agent, independent of the platform-wide buy throttle. - Mandatory stop-loss.
getArmedStrategiesfilters out any strategy missingstop_loss_pct, so an agent can never run uncapped downside. - Idempotent claims prevent double-buys. Before a buy, the engine calls
Store.claimPositionto atomically reserve the(agent_id, mint, network)slot. A second event for the same slot returnsnulland is skipped.
3D agents
@three-ws/agent-sniper/agents is the presentation layer that lets a 3D AI
agent embody the sniper: avatar definitions, the canonical animation clip
library, and a desk-monitor visualization driven by the engine's onScreen
hook. Wire the hook to push live activity (Sniper online…, $SYM scored N — BUYING) onto the agent's monitor so the trading loop is something you can watch,
not just a log stream. The onScreen payload shape is { text, kind } with
kind in activity | trade.
Adapter reference
Implement any of these (src/types.js has the full JSDoc contracts) and pass it
to createSniper. Defaults live under src/adapters/.
The Store contract is the load-bearing one: getArmedStrategies,
countOpenPositions, getDailySpendLamports, claimPosition (atomic),
updatePosition, getOpenPositions, and optional recordSpend. See the
in-memory reference at src/adapters/store/memory.js.
Configuration
All SNIPER_* env vars (read by loadConfig, src/config.js). Explicit
overrides passed to createSniper/loadConfig always win. See .env.example.
Safety & guardrails
- Simulate by default. Every face starts in simulate mode. You opt into live trading explicitly.
- Mandatory stop-loss. A strategy without
stop_loss_pctis never armed. - Daily budget + concurrency caps. Per-agent
daily_budget_lamportsandmax_concurrent_positionsare enforced before any transaction is built (checkDailyBudgetLamports,checkConcurrency). - SOL fee headroom.
checkSolHeadroomkeeps ~0.012 SOL in the wallet so a snipe can't drain the account below the cost of the very next sell's fee. - Price-impact circuit breaker.
max_price_impact_pct(default 10) skips a buy whose quote impact is too high (checkPriceImpact; unset ⇒ no gate). - Live-RPC refusal. Live mode refuses to start on a public RPC — it requires a real endpoint so trades aren't silently dropped to rate limits.
- Optional firewall hook. The
assessSafetyhook runs after the quote and before broadcast; ablockverdict cancels the trade. - Mayhem exclusion.
createMayhemFilter({ connection?, rpcUrl?, strictOnUnknown?, retries?, retryDelayMs? })reads the bonding curve'sisMayhemMode(cached per mint) and skips pump.fun Mayhem-mode launches. As of 0.1.4 a pre-built web3Connection(for example a rotating multi-endpoint one) can be injected instead of a singlerpcUrl, and a null read retries with backoff (default 2 retries) before resolving "unknown", so a throttled provider can't starve a strict gate. The pureretryWhileNull(fn, { retries, delayMs })helper is exported too. - Global kill switch.
SNIPER_GLOBAL_KILL=true(orconfig.globalKill) halts every buy across every agent immediately.
Scaling beyond one process
claimPosition in the memory and sqlite stores is atomic within one
process — the memory store relies on JS being single-threaded; the sqlite
store on a single-writer transaction. Combined with the engine's bounded in-
process buy queue, that prevents double-buying the same (agent_id, mint, network) slot inside a single sniper instance.
Run two sniper processes against the same agent and that guarantee no longer
holds: nothing serializes the claim across processes. To scale horizontally,
back the Store with a database whose claimPosition is a genuinely atomic
insert-if-absent (e.g. a unique constraint on (agent_id, mint, network) with
INSERT … ON CONFLICT DO NOTHING RETURNING), so the reservation is decided by
the database, not by any one process. The Store contract documents exactly
this requirement.
Testing
Pure-logic and in-memory-adapter suites run with no network/RPC:
License
Apache-2.0. See LICENSE.
來源:packages/agent-sniper/README.md,提交 5927500
工具
0版本歷史
2- v0.1.7最新Sep 30, 2026
- v0.1.6Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分