SimpleFunctions Agent Reference
Prediction market intelligence engine. Your agent reads thesis state, injects observations, and reacts to edge changes. The backend handles news scanning, price monitoring, and evaluation automatically every 15 minutes.
Venues: Kalshi + Polymarket. All prices in cents (0-100).
Connect
MCP (recommended for Claude Code, Cursor, Cline)
claude mcp add simplefunctions --url https://simplefunctions.dev/api/mcp/mcp
For Cursor/Cline, add to MCP config:
{"mcpServers": {"simplefunctions": {"url": "https://simplefunctions.dev/api/mcp/mcp"}}}
CLI
npm install -g @spfunctions/cli
sf setup # interactive wizard, 2 min
Every command supports --json for machine-readable output.
REST API
Base URL: https://simplefunctions.dev. Auth: Authorization: Bearer sf_live_xxx.
Core Workflow
No thesis needed — start here
# Global market snapshot — movers, expiring, milestones, liquidity
sf context --json
# LLM-enhanced knowledge search — markets + content + synthesized answer
sf query "iran oil" --json
With a thesis — richer context
# 1. READ — thesis state (causal tree, edges, orderbook, evaluation)
sf context <id> --json
# 2. WRITE — inject your observations
sf signal <id> "Iran deploys coastal missiles near Hormuz" --type news
# 3. REACT — force deep analysis when something big happens
sf evaluate <id>
For efficient polling, use the delta endpoint instead of full context:
GET /api/thesis/:id/changes?since=2026-03-23T00:00:00Z
# Nothing changed: {"changed": false} — 50 bytes
# Changed: {"changed": true, "confidence": 0.89, "confidenceDelta": 0.02, ...}
MCP Tools (25)
| Tool | What it does | Auth |
|---|---|---|
get_context | Without thesisId: global market snapshot. With thesisId: thesis-specific context | Optional |
query | LLM-enhanced prediction market knowledge search (Kalshi + Polymarket + X + traditional + content) | No |
list_theses | All theses with status, confidence, position count | Yes |
create_thesis | Create thesis, run formation (causal tree + market scan + edges) | Yes |
inject_signal | Feed an observation into the thesis signal queue | Yes |
trigger_evaluation | Force immediate evaluation with heavy model | Yes |
augment_tree | Review suggested nodes from evaluations, merge into causal tree | Yes |
what_if | Override node probabilities, see edge impact (zero LLM cost) | Yes |
scan_markets | Search Kalshi + Polymarket by keyword | No |
explore_public | Browse published theses | No |
create_strategy | Define trading strategy with entry/exit/sizing rules | Yes |
list_strategies | List strategies for a thesis | Yes |
update_strategy | Update strategy parameters or status | Yes |
get_milestones | Upcoming Kalshi calendar events | No |
get_forecast | P50/P75/P90 market distribution | Yes |
get_settlements | Settled contracts with realized P&L | Yes |
get_balance | Account balance | Yes |
get_orders | Current resting orders | Yes |
get_fills | Recent trade executions | Yes |
get_markets | Traditional market prices (SPY, VIX, Treasury, Gold, Oil via Databento) | No |
get_schedule | Exchange trading hours and status | No |
search_x | Search X discussions — posts, sentiment, volume, news | No |
x_volume | Discussion volume trend — timeseries, velocity, peak detection | No |
x_news | X news stories — headlines, summaries, ticker mentions | No |
x_account | Recent posts from a specific X account | No |
Tools marked "No" work without an API key. get_context works both ways.
CLI Commands (42)
Thesis
| Command | Description |
|---|---|
sf list [--json] | List all theses |
sf get <id> [--json] | Full thesis details |
sf context <id> [--json] | Thesis snapshot — primary read endpoint for agents |
sf create "thesis text" [--async] | Create new thesis (sync waits for formation) |
sf signal <id> "content" [--type news] | Inject signal (types: news, user_note, external, price_move, upcoming_event) |
sf evaluate <id> | Trigger deep evaluation (heavy model) |
sf augment <id> [--dry-run] | Review + merge suggested causal tree nodes |
sf prompt [id] | Get dynamic system prompt with live thesis state |
sf publish <id> --slug <slug> | Publish thesis publicly |
sf unpublish <id> | Remove from public |
Markets
| Command | Description |
|---|---|
sf scan "keywords" | Search Kalshi + Polymarket (no auth needed) |
sf scan --series TICKER | Browse series events + prices |
sf scan --market TICKER | Single market detail |
sf book <ticker> [ticker2...] | Orderbook depth, spread, liquidity for specific markets |
sf book --poly "oil price" | Search + show Polymarket orderbooks |
sf edges [--json] | Top edges across all theses |
sf whatif <id> --set "n1=0.1" | What-if scenario (zero LLM cost) |
sf liquidity [topic] | Orderbook scanner across 18 topics |
sf explore [slug] | Browse public theses (no auth) |
sf forecast <eventTicker> | P50/P75/P90 market distribution |
sf milestones | Upcoming Kalshi calendar events |
Portfolio
| Command | Description |
|---|---|
sf positions | Kalshi + Polymarket positions with thesis edge overlay |
sf balance | Account balance |
sf orders | Resting orders |
sf fills | Recent trade fills |
sf settlements | Settled contracts with P&L |
sf performance | P&L over time with sparklines |
sf dashboard | Interactive Bloomberg-style TUI (j/k navigate, Enter detail, l liquidity, w what-if) |
sf feed [--hours 24] | Evaluation history stream |
Trading (requires sf setup --enable-trading)
| Command | Description |
|---|---|
sf buy <ticker> <qty> --price <cents> | Buy contracts (3s countdown) |
sf sell <ticker> <qty> --price <cents> | Sell contracts |
sf cancel [orderId] | Cancel order(s) |
sf rfq <ticker> <qty> | Request for quote (large orders) |
Query & X
| Command | Description |
|---|---|
sf query "gold price" | LLM-enhanced knowledge search — Kalshi + Polymarket + X + traditional + content |
sf query "fed rate" --json | JSON output for agents |
sf x "oil" | Search X discussions — posts, sentiment, themes |
sf x-volume "oil" | Discussion volume trend with histogram |
sf x-news "oil" | X news stories with ticker mentions |
sf x-account @zerohedge | Recent posts from a specific account |
Other
| Command | Description |
|---|---|
sf setup | Interactive config wizard |
sf agent [id] | Interactive agent (natural language + 25 tools) |
sf telegram | Telegram bot for monitoring |
sf schedule | Exchange status |
sf announcements | Exchange announcements |
sf history <ticker> | Historical market data |
REST API Endpoints
All require Authorization: Bearer sf_live_xxx unless noted.
Thesis
| Method | Endpoint | Description |
|---|---|---|
POST | /api/thesis/create[?sync=true] | Create thesis. Sync waits up to 5 min. |
GET | /api/thesis/:id/context | Thesis snapshot (primary read endpoint) |
GET | /api/thesis/:id/changes?since=ISO | Lightweight delta check (~50 bytes if no change) |
POST | /api/thesis/:id/signal | Inject signal. Body: {"type":"news","content":"...","source":"agent"} |
POST | /api/thesis/:id/evaluate | Force evaluation (heavy model, up to 2 min) |
POST | /api/thesis/:id/augment[?dryRun=true] | Review + merge suggested tree nodes |
GET | /api/thesis/:id/prompt[?sections=thesis,edges&maxLength=3000] | Dynamic system prompt |
GET | /api/thesis | List all theses |
PATCH | /api/thesis/:id | Update status, webhookUrl, metadata |
DELETE | /api/thesis/:id | Delete thesis |
Feed & Prompt
| Method | Endpoint | Description |
|---|---|---|
GET | /api/feed?hours=24&limit=200 | Evaluation history stream |
GET | /api/prompt[?maxLength=4000] | Combined prompt for all active theses |
Public (no auth)
| Method | Endpoint | Description |
|---|---|---|
GET | /api/public/theses | List published theses |
GET | /api/public/thesis/:slug | Full public thesis data |
Context Response Shape
GET /api/thesis/:id/context returns:
{
"thesisId": "f582bf76-...",
"thesis": "Trump cannot exit the Iran war gracefully...",
"status": "active",
"confidence": 0.82,
"causalTree": {
"rootClaim": "...",
"nodes": [
{"id": "n1", "label": "...", "probability": 0.85, "importance": 0.3, "depth": 0, "childCount": 3}
]
},
"edges": [
{
"marketId": "KXRECSSNBER-26",
"market": "Will there be a recession in 2026?",
"venue": "kalshi",
"direction": "yes",
"marketPrice": 34,
"thesisPrice": 55,
"edge": 21,
"executableEdge": 20,
"orderbook": {"bidPrice": 33, "askPrice": 35, "spread": 2, "bidDepth": 814, "askDepth": 500, "liquidityScore": "high"}
}
],
"lastEvaluation": {
"summary": "...",
"confidenceDelta": 0.10,
"updatedNodes": [{"nodeId": "n3", "previousProbability": 0.6, "newProbability": 0.75, "reason": "..."}]
},
"suggestedTreeExtensions": [
{"label": "...", "description": "...", "parentNodeId": "n2", "estimatedProbability": 0.7}
],
"trackRecord": {
"hitRate": 67,
"edgesTracked": 49,
"movedToward": 33,
"movedAway": 16,
"avgMovement": 3,
"bestEdge": {"market": "...", "delta": 21},
"worstEdge": {"market": "...", "delta": -12}
}
}
What The Backend Does Automatically
The heartbeat engine runs every 15 minutes for each active thesis. Your agent does NOT need to do any of this:
- News scan — 3 targeted queries (including one adversarial/contrarian). Filters with cheap LLM. Never excludes contradictory news.
- Price rescan — Live prices from Kalshi API + Polymarket CLOB. Injects changes >= 3 cents.
- Orderbook enrichment — Bid/ask/depth for edges with |edge| > 5 cents.
- Evaluation — LLM evaluates signals against causal tree. Checks kill conditions first. Updates node probabilities and confidence.
- Track record — Computes hit rate and injects into next evaluation as feedback loop.
- Edge discovery — Daily (6 UTC): scans for new markets matching thesis.
- Tree augmentation — Weekly (Monday 6 UTC): reviews suggested nodes, merges accepted ones (append-only).
- Settlement sync — Checks settled contracts, records realized returns.
- Strategy review — Reviews strategies against updated edges.
Edge diagnosis types
Each edge is classified as: consensus_gap (market/thesis disagree), attention_gap (market hasn't reacted), timing_gap (short vs long term), or risk_premium (fear/greed premium).
Kill conditions
Before every evaluation: "Does any event fundamentally break a core assumption?" If yes, flags prominently.
Rules for Agents
- Don't poll prices — the heartbeat does it every 15 min
- Don't search news — the heartbeat does it with adversarial queries
- Do inject observations immediately —
inject_signalwith typeuser_noteornews - Only call
evaluatefor breaking events — routine evaluation is automatic - Use
what_ifbefore trades — zero LLM cost scenario analysis - Call
get_positionsbefore discussing trades — positions are local (Kalshi private key), backend can't see them - Use
/changesfor polling — 100x smaller than full context - Use short thesis IDs — first 8 chars work everywhere (e.g.
f582bf76)
Writing good theses
- Be specific and directional: "Oil stays above $100 for 6 months" not "Oil prices"
- Include timeframe: helps match contracts
- One thesis = one view: don't mix unrelated predictions
Signal types
| Type | When to use |
|---|---|
news | External events, articles, data releases |
user_note | Your agent's own analysis or observations |
external | Signals from other systems |
price_move | Auto-injected by heartbeat (>= 3 cent change) |
upcoming_event | Auto-injected by heartbeat (Kalshi milestone matching edges) |
Interactive Agent
sf agent [id] launches a natural language session with 25 tools. Supports TUI mode (default) and plain mode (--plain for pipes).
Slash commands: /tree, /edges, /pos, /eval, /buy TICKER QTY PRICE, /sell, /cancel, /switch <id>, /compact, /model <name>, /exit.
Sessions persist at ~/.sf/sessions/. Use --new for fresh session.
Telegram Bot
sf telegram --token TOKEN — runs locally, credentials stay on your machine.
Commands: /context, /positions, /edges, /balance, /orders, /eval, /list, /switch.
Natural language works too — same tools as sf agent. Auto-pushes confidence alerts every 60s.
Webhook
Configure when creating thesis: {"rawThesis": "...", "webhookUrl": "https://..."}
POSTs on confidence changes >= 5% and non-hold position recommendations.