Agent Financial Advisor

io.github.mytomclinic由 GitHub 账号 mytomclinic 发布v0.1.0更新于 Oct 24, 2026

Compliance, risk, tax and audit checks for AI trading agents: pre-trade, sizing, wash sales, Reg BI.

已验证Streamable HTTP可网页运行金融安全与监控

概览

AI 生成的概览

远程 MCP 服务器,为交易智能体提供合规、风险、税务与绩效检查:盘前规则、仓位计算、税批次、组合复盘与策略审计。

可以做什么
  • 查询当前美国交易、保证金、结算与税务规则,附生效日期与来源
  • 在提交订单前检查购买力、现金账户结算、日内保证金、卖空、洗售、集中度与流动性等问题
  • 按固定比例风险、波动率目标或分数凯利计算仓位,并规划税批次选择或亏损收割
  • 复盘组合的权重、集中度、行业与资产类别敞口、再平衡交易及风险指标,并审计策略交易记录是否过拟合
  • 检查期权持仓的保证金、审批等级、指派与钉住风险,并执行适当性审查并生成审计备忘
适用场景
当助手需要下单、计算仓位或就美国股票与期权交易给出建议,并希望在行动前获得基于规则的约束时使用;也适合需要对组合或回测做独立风险、税务与绩效分析的情况。
运行要求
远程 streamable-HTTP 端点,无需本地安装。提供免费额度,可通过免费的 get_api_key 工具获取 API 密钥,或以 Authorization Bearer 请求头发送。付费工具按次通过 x402 USDC 支付计费。
安装前请注意
多数工具按次以 USDC 收费,智能体可能因此产生支出;额度通过 x402 购买,主网支付使用真实资金。输出仅为信息性分析,不构成投资建议,规则也可能变化。可选的 advisor_memo 工具会把交易与组合详情发送给 Anthropic 的 Claude API,并受每日支出上限约束。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Agent Financial Advisor,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.mytomclinic%2Fagent-financial-advisor/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "agent-financial-advisor": {
      "type": "http",
      "url": "https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp"
    }
  }
}

README

Agent Financial Advisor

The compliance officer, risk manager, tax advisor and performance auditor for AI agents that trade and advise. Agents call it before they act; it answers with sourced, deterministic checks and charges a small fee per call.

Tools

ToolPriceDoes
rules_digestfreeCurrent US trading/margin/settlement/tax rules with effective dates and sources
pre_trade_check$0.005Buying power, cash-account violations, intraday margin (post-PDT), Reg SHO, wash sales, concentration, risk-to-stop, liquidity, spread, fat finger, leverage, market hours
position_size$0.005Fixed-fractional, volatility-target or fractional-Kelly sizing with caps
tax_lot_plan$0.02FIFO/LIFO/HIFO/min-tax lot selection, ST/LT split, wash sales, loss harvesting scan
portfolio_review$0.05Weights, HHI, sector/asset-class exposure, rebalance trades, Sharpe/Sortino/drawdown/VaR/beta
strategy_audit$0.10Trade stats, t-stat, Probabilistic and Deflated Sharpe Ratio, overfitting red flags
suitability_check$0.03Reg BI / fiduciary suitability review with a hashed audit memo
advisor_memo$0.10, paid onlyRuns the checks above on a planned trade, options position or portfolio, then Claude writes a go / no-go memo with risks, required changes, rules cited and an audit note. Never looser than the rule checks
options_risk_check$0.01Covered/cash-secured/spread/naked classification, FINRA 4210 margin, cash-account limits, approval level, dividend early assignment, pin risk, auto-exercise, max loss, net Greeks

Drop-in code (Alpaca order guard, MCP client configs, x402 paying client): examples/.

Run locally (Node 20+, no dependencies)

npm testnpm start         # http://localhost:8787  (payments off until PAY_TO is set)

Try it:

curl localhost:8787/llms.txtcurl -X POST localhost:8787/v1/tools/position_size -H "content-type: application/json" \  -d '{"equity":50000,"entry_price":100,"stop_price":95,"method":"fixed_fractional"}'

MCP clients: point a streamable-HTTP MCP connection at http://localhost:8787/mcp. For the keyed free tier and credits, send Authorization: Bearer <key>, use /mcp?key=<key>, or have the agent call the free get_api_key tool, which binds a new key to the MCP session. Add ?src=<name> to any URL to attribute usage in /stats.

Endpoints

MethodPath
GET/, /llms.txtAgent-readable overview
GET/v1/tools, /openapi.json, /pricing, /.well-known/x402Discovery
POST/v1/tools/{name}Run a tool
POST/mcpMCP JSON-RPC
POST/v1/keysFree API key
GET/v1/keys/meKey balance
POST/v1/credits?pack=5|20|100Buy credits with x402
GET/v1/auditYour tamper-evident audit log: every keyed paid call, hash-chained and server-signed (?since_seq=)
POST/v1/audit/verifyVerify audit entries' hashes, signatures and chain
GET/statsPublic aggregate usage: calls, paid calls, keys issued, revenue (no identities; cached 10 min)
GET/admin/revenueRevenue and usage (ADMIN_TOKEN)

Configuration (env vars)

VarDefault
PAY_TOunsetUSDC receiving address. Unset = free preview, no payments
X402_NETWORKbase-sepoliabase for real money
CDP_API_KEY_JSONunsetSecret: the downloaded CDP key file. When set, payments go through the Coinbase CDP facilitator (needed for mainnet). CDP_API_KEY_ID + CDP_API_KEY_SECRET also work
FACILITATOR_URLCDP if a key is set, else https://x402.org/facilitatorOverride the facilitator
FACILITATOR_AUTHunsetStatic Authorization header for a non-CDP facilitator
X402_MIN_USD0.01Minimum pay-per-call x402 price (credits pay list price)
FREE_DAILY_CALLS / FREE_DAILY_ANON25 / 5Free tier
ADMIN_TOKENunsetFor /admin/revenue
ANTHROPIC_API_KEYunsetSecret: turns on advisor_memo (Claude Sonnet 5.5). Unset = the tool answers 503 and charges nothing
MEMO_DAILY_CAP_USD3Daily Claude spend cap for advisor_memo; past it the tool pauses until 00:00 UTC
DATA_DIR./dataNode store and ledger
PUBLIC_URLrequest hostUsed in payment requirements

Deploy (free)

Cloudflare Workers: npx wrangler kv namespace create AFA_KV, put the id in wrangler.toml, then npx wrangler deploy.

Real USDC: npx wrangler secret put CDP_API_KEY_JSON < secrets/cdp_api_key.json, set X402_NETWORK = "base" in wrangler.toml, deploy.

advisor_memo: npx wrangler secret put ANTHROPIC_API_KEY < secrets/anthropic-key.txt.

Payments (x402)

Speaks x402 v2: a 402 carries a base64 PAYMENT-REQUIRED header (CAIP-2 network, e.g. eip155:8453), clients pay with PAYMENT-SIGNATURE, and the settlement comes back in PAYMENT-RESPONSE. v1 clients (X-PAYMENT, body accepts) still work.

End-to-end test on the test network: npm i --no-save viem && node scripts/e2e-payment.mjs <server url> --fund.

Layout

src/app.js            fetch-style router: REST, MCP, billing hookssrc/server.js         Node entrysrc/worker.js         Cloudflare Workers entry (KV store)src/billing/          free tier, API keys, credits, x402, ledgersrc/tools/            the advisory toolssrc/lib/regs.js       rule table with sources (reviewed weekly)src/lib/calendar.js   NYSE calendartest/                 node --test suites

来源:README.md,提交 9006933

工具

8

rules_digest

Current trading rules digest

Free. The current US trading, margin, settlement and tax rules an agent must follow, with effective dates and sources. Includes changes your training data may predate, such as the June 2026 replacement of the Pattern Day Trader rule. Price: free.

输入参数topic

pre_trade_check

Pre-trade compliance and risk check

Run an order past a compliance officer and risk manager before sending it to the broker. Checks buying power, cash-account settlement violations, FINRA intraday margin (post-PDT) or legacy PDT limits, Reg SHO short-sale rules, wash-sale exposure, position concentration, per-trade risk versus stop, liquidity, spread, fat-finger prices, leverage and market hours. Returns approve / approve_with_warnings / reject with reasons and a resized quantity when useful. Price: $0.005.

输入参数order必填marketpolicyaccount必填

position_size

Position sizing

Size a position the way a risk manager would: fixed-fractional risk to a stop, volatility targeting (ATR or annualized vol), or fractional Kelly from your edge statistics. Applies a max-position cap and round lots, and explains the binding constraint. Price: $0.005.

输入参数atrsideequity必填method必填avg_winavg_losslot_sizerisk_pctwin_rateannual_volstop_priceentry_price必填另有 5 个

tax_lot_plan

Tax lot selection and wash-sale check

Act as the tax advisor for a sale: compares FIFO, LIFO, HIFO and minimum-tax lot selection, splits short- and long-term gains, estimates tax, flags wash sales, and notes lots about to turn long-term. With mode=harvest it scans positions for tax-loss harvesting. Price: $0.02.

输入参数lots必填modesellas_ofpricessymboltax_ratesmin_harvest_lossrecent_transactions

portfolio_review

Portfolio review

A periodic advisor review of a portfolio: weights, concentration (HHI and effective number of holdings), sector and asset-class exposure, drift from targets with the trades to rebalance, and, given return history, volatility, Sharpe, Sortino, drawdown, VaR/CVaR and beta. Ends with prioritized findings. Price: $0.05.

输入参数cashlimitsreturnstargetsholdings必填rebalance_bandrisk_free_rateperiods_per_yearbenchmark_returns

strategy_audit

Strategy audit and overfitting check

An independent performance auditor for a trading strategy or backtest. From a trade list and/or periodic returns it computes win rate, expectancy, profit factor, streaks, Sharpe/Sortino/drawdown, and tests whether the edge is real: t-stat, Probabilistic Sharpe Ratio and the Deflated Sharpe Ratio that corrects for how many variants you tried. Returns a verdict and red flags. Price: $0.1.

输入参数tradesreturnsn_trialsstarting_equityperiods_per_yeartrial_sharpe_variance

suitability_check

Best-interest suitability review

The compliance review a robo-advisor or advisory agent should run before recommending a portfolio to a person: compares the proposal with the client's age, horizon, risk tolerance, liquidity needs and experience under Reg BI / fiduciary standards, flags complex products, and returns a timestamped, hashed suitability memo for the audit file. Price: $0.03.

输入参数client必填productsallocation必填annual_fee_pctmax_single_position_pct

options_risk_check

Options risk and margin check

Check an options book (existing or proposed legs) the way a broker's options desk would: covered, cash-secured, spread or naked; margin requirement under FINRA Rule 4210; cash-account limits; required approval level; early-assignment risk around ex-dividend dates; pin risk; auto-exercise of expiring in-the-money longs and the capital it needs; max loss; and net Greeks. Returns approve / approve_with_warnings / reject with reasons. Price: $0.01.

输入参数legs必填as_ofpolicyaccount必填underlying必填

版本历史

1
  1. v0.1.0最新Oct 12, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。