Agent Financial Advisor
RemoteAbout Agent Financial Advisor
Agent Financial Advisor provides deterministic, sourced compliance, risk, tax, and performance checks for AI trading and advisory agents. Its tools cover trade decisions, position sizing, portfolio and strategy reviews, suitability, and options risk.
Key features
- 01Current US rules with dates and sources
- 02Pre-trade compliance and risk checks
- 03Position sizing methods with caps
- 04Tax lot planning and wash-sale scans
- 05Portfolio and strategy audits
- 06Suitability and options risk checks
Use cases
- 01Checking buying power and trading restrictions before an order
- 02Sizing a position against a chosen risk method
- 03Planning tax lots and reviewing wash-sale exposure
- 04Auditing portfolio risk or strategy performance
MCP support
It exposes advisory tools to MCP clients through a streamable-HTTP MCP connection at `/mcp`. Tools include `rules_digest`, `pre_trade_check`, `position_size`, `tax_lot_plan`, `portfolio_review`, `strategy_audit`, `suitability_check`, and `options_risk_check`.
Configuration
Remote servers need no local install. Pick your client, then copy the config or install in one click.
https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcpclaude mcp add --transport http mytomclinic-agent-financial-advisor https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp{"mcpServers":{"mytomclinic-agent-financial-advisor":{"type":"http","url":"https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp"}}}Open in Cursor{"servers":{"mytomclinic-agent-financial-advisor":{"type":"http","url":"https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp"}}}Open in VS Code{"mcpServers":{"mytomclinic-agent-financial-advisor":{"type":"http","url":"https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp"}}}{"mcpServers":{"mytomclinic-agent-financial-advisor":{"serverUrl":"https://agent-financial-advisor.agent-financial-advisor.workers.dev/mcp"}}}Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.
Tools
7| Parameter | Type | Required | Description |
|---|---|---|---|
| topic | enum | No | intraday_margin | legacy_pdt | reg_t | settlement | cash_account | short_sale | wash_sale | holding_period | reg_bi |
Details
From the project READMEAgent 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
| Tool | Price | Does |
|---|---|---|
rules_digest | free | Current US trading/margin/settlement/tax rules with effective dates and sources |
pre_trade_check | $0.005 | Buying 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.005 | Fixed-fractional, volatility-target or fractional-Kelly sizing with caps |
tax_lot_plan | $0.02 | FIFO/LIFO/HIFO/min-tax lot selection, ST/LT split, wash sales, loss harvesting scan |
portfolio_review | $0.05 | Weights, HHI, sector/asset-class exposure, rebalance trades, Sharpe/Sortino/drawdown/VaR/beta |
strategy_audit | $0.10 | Trade stats, t-stat, Probabilistic and Deflated Sharpe Ratio, overfitting red flags |
suitability_check | $0.03 | Reg BI / fiduciary suitability review with a hashed audit memo |
options_risk_check | $0.01 | Covered/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 test
npm start # http://localhost:8787 (payments off until PAY_TO is set)
Try it:
curl localhost:8787/llms.txt
curl -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
| Method | Path | |
|---|---|---|
| GET | /, /llms.txt | Agent-readable overview |
| GET | /v1/tools, /openapi.json, /pricing, /.well-known/x402 | Discovery |
| POST | /v1/tools/{name} | Run a tool |
| POST | /mcp | MCP JSON-RPC |
| POST | /v1/keys | Free API key |
| GET | /v1/keys/me | Key balance |
| POST | /v1/credits?pack=5|20|100 | Buy credits with x402 |
| GET | /v1/audit | Your tamper-evident audit log: every keyed paid call, hash-chained and server-signed (?since_seq=) |
| POST | /v1/audit/verify | Verify audit entries' hashes, signatures and chain |
| GET | /stats | Public aggregate usage: calls, paid calls, keys issued, revenue (no identities; cached 10 min) |
| GET | /admin/revenue | Revenue and usage (ADMIN_TOKEN) |
Configuration (env vars)
| Var | Default | |
|---|---|---|
PAY_TO | unset | USDC receiving address. Unset = free preview, no payments |
X402_NETWORK | base-sepolia | base for real money |
CDP_API_KEY_JSON | unset | Secret: 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_URL | CDP if a key is set, else https://x402.org/facilitator | Override the facilitator |
FACILITATOR_AUTH | unset | Static Authorization header for a non-CDP facilitator |
X402_MIN_USD | 0.01 | Minimum pay-per-call x402 price (credits pay list price) |
FREE_DAILY_CALLS / FREE_DAILY_ANON | 25 / 5 | Free tier |
ADMIN_TOKEN | unset | For /admin/revenue |
DATA_DIR | ./data | Node store and ledger |
PUBLIC_URL | request host | Used 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.
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 hooks
src/server.js Node entry
src/worker.js Cloudflare Workers entry (KV store)
src/billing/ free tier, API keys, credits, x402, ledger
src/tools/ the advisory tools
src/lib/regs.js rule table with sources (reviewed weekly)
src/lib/calendar.js NYSE calendar
test/ node --test suites
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.