Examples

Working code for the most common FundOS agent patterns.

Example 1 — Morning risk briefing agent (Python)

A daily script that pulls a live context briefing, checks for open risk alerts, and prints a prioritised summary. Run this as a cron job or trigger it from Claude Code.

import httpx
from datetime import datetime

FUNDOS_URL = "https://kela.com/mcp"
TOKEN = "your-token"

headers = {"Authorization": f"Bearer {TOKEN}"}


def morning_briefing():
    # Get full context first — covers pending actions, active deals,
    # LP changes, open risk alerts, and upcoming capital calls.
    ctx = call_tool("fundos_get_agent_context", {"lookback_days": 1})

    # Check for urgent items
    alerts = call_tool("fundos_list_risk_alerts", {"open": True})

    open_calls = ctx["data"]["open_capital_calls"]
    pending    = ctx["data"]["pending_actions"]

    print(f"[{datetime.now():%Y-%m-%d %H:%M}] Morning briefing")
    print(f"  Risk alerts:       {len(alerts['data'])}")
    print(f"  Open capital calls:{len(open_calls)}")
    print(f"  Pending approvals: {len(pending)}")

    if alerts["data"]:
        print("\n  Open alerts:")
        for a in alerts["data"][:5]:
            print(f"  - {a['name']}: {a['status']} (severity {a.get('breach_severity','—')})")


def call_tool(name: str, args: dict) -> dict:
    r = httpx.post(
        f"{FUNDOS_URL}/message",
        headers=headers,
        json={
            "jsonrpc": "2.0",
            "method": "tools/call",
            "params": {"name": name, "arguments": args},
            "id": 1,
        },
        timeout=30,
    )
    r.raise_for_status()
    return r.json()["result"]


morning_briefing()

Example 2 — Webhook handler (Python / Flask)

A minimal Flask endpoint that receives FundOS webhook events, verifies the HMAC-SHA256 signature, and routes action.approval_required events to a Slack notification.

from flask import Flask, request, jsonify
import hmac
import hashlib
import requests  # pip install requests

app = Flask(__name__)
WEBHOOK_SECRET = "your-webhook-secret"   # from POST /api/v1/webhooks/ response
SLACK_WEBHOOK  = "https://hooks.slack.com/services/..."


def verify_signature(raw_body: bytes, header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(
        secret.encode(),
        raw_body,
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(expected.encode(), header.encode())


@app.route("/fundos-webhook", methods=["POST"])
def handle_webhook():
    raw = request.get_data()
    sig = request.headers.get("X-FundOS-Signature", "")

    if not verify_signature(raw, sig, WEBHOOK_SECRET):
        return jsonify({"error": "invalid signature"}), 401

    event = request.json
    etype = event.get("event")

    if etype == "action.approval_required":
        action = event["data"]
        msg = (
            f":bell: *FundOS action needs approval*\n"
            f"Kind: `{action['kind']}`\n"
            f"Run: {action['run_id']}\n"
            f"Review: https://kela.com/fundos/agent/runs/{action['run_id']}"
        )
        requests.post(SLACK_WEBHOOK, json={"text": msg})

    elif etype == "credit.low":
        d = event["data"]
        requests.post(SLACK_WEBHOOK, json={
            "text": f":warning: FundOS credit balance low: {d['balance']} credits remaining"
        })

    return jsonify({"received": True})

Example 3 — Claude Code session prompt

Start a Claude Code session and type this prompt. Claude Code will connect via OAuth, pull live fund data, and return a structured briefing with proposed actions for your review.

Connect to FundOS MCP then:
1. Call fundos_get_agent_context — read the full briefing
2. Call fundos_list_risk_alerts — show me any open alerts
3. For any covenant approaching breach, call
   fundos_check_covenant with a stress test scenario
4. Summarise what needs my attention today and propose
   any actions for my approval
What happens: Claude Code opens a browser window to authorize with FundOS via OAuth PKCE. Once authorized, it calls the three tools sequentially, interprets the results, and returns a natural-language briefing — with any proposed actions queued in your FundOS dashboard for one-click approval.

More patterns

See the CLAUDE.md file for five additional end-to-end workflow patterns:

  • LP fundraising follow-up
  • Diligence on an inbound deck
  • Risk dashboard refresh
  • Capital-call ILPA notice
  • T+0 affirmation chase (HF Ops)

The Tools reference lists all 47 tools with parameters, tier, and cost.