Agent Financial Advisor

io.github.mytomclinicPublished by GitHub account mytomclinicv0.1.0Updated Oct 24, 2026

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

VerifiedStreamable HTTPWeb executableFinanceSecurity & Monitoring

Overview

AI-generated overview

Remote MCP server giving trading agents compliance, risk, tax and performance checks — pre-trade rules, position sizing, tax lots, portfolio review and…

What you can do
  • Look up current US trading, margin, settlement and tax rules with effective dates and sources
  • Screen a proposed order for buying power, settlement, margin, short-sale, wash-sale, concentration and liquidity issues
  • Size positions by fixed-fractional risk, volatility targeting or fractional Kelly, and plan tax-lot selection or loss harvesting
  • Review a portfolio for weights, concentration, exposure, rebalance trades and risk metrics, and audit a strategy's trade list for overfitting
  • Check an options book for margin, approval level, assignment and pin risk, and run a suitability review with an audit memo
When to use it
Use it when an assistant places, sizes or advises on US equity or options trades and needs rule-based guardrails before acting, or when you want independent risk, tax and performance analysis of a portfolio or backtest.
Requirements
Remote streamable-HTTP endpoint; no local install. A free tier exists, and an API key can be obtained through the free get_api_key tool or sent as an Authorization Bearer header. Paid tools are billed per call via x402 USDC payments.
Before you install
Most tools charge per call in USDC, so an agent can spend money; credits are bought with x402 and mainnet payments use real funds. Output is informational analysis, not investment advice, and rules may change. The optional advisor_memo tool sends trade and portfolio details to Anthropic's Claude API and is capped by a daily spend limit.

Installation

In SourceWeft

  1. Open Agent Financial Advisor in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Web executable via Streamable HTTP. Remote servers run from the web runtime once configured in a workspace.

Use with an agent

Paste this prompt into Claude Code, Codex, Cursor or another agent — or into SourceWeft chat. The agent reads this server's install guide, shows you its publisher, endpoint and sign-in, and adds it to your client once you agree. Keys never go into a command.

Read https://sourceweft.com/mcp/io.github.mytomclinic%2Fagent-financial-advisor/install.md and connect the MCP server it describes to my client. Before changing any config, show me its publisher, endpoint and sign-in method and wait for my OK. Never put an API key in a command or in a file I would commit; ask me where it should come from.

Read the install guide the agent follows

Other MCP clients

Add this to your client's mcpServers config.

{
  "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

Source: README.md at commit 9006933

Tools

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.

Parameterstopic

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.

Parametersorderrequiredmarketpolicyaccountrequired

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.

Parametersatrsideequityrequiredmethodrequiredavg_winavg_losslot_sizerisk_pctwin_rateannual_volstop_priceentry_pricerequired+5 more

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.

Parameterslotsrequiredmodesellas_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.

Parameterscashlimitsreturnstargetsholdingsrequiredrebalance_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.

Parameterstradesreturnsn_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.

Parametersclientrequiredproductsallocationrequiredannual_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.

Parameterslegsrequiredas_ofpolicyaccountrequiredunderlyingrequired

Version history

1
  1. v0.1.0LatestOct 12, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 daysRequired25 pts
  • Auth declaredRequired10 pts
  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

    Declare a license in the repository or the registry entry.