Skip to content

Production-ready AI agent for loan servicing and collections in financial services.

License

Notifications You must be signed in to change notification settings

ArcadeAI/loanops-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoanOps AI

Production-ready AI agent for loan servicing and collections in financial services. Built with Arcade (MCP runtime with auth, governance, and audit) and YugabyteDB (distributed PostgreSQL with pgvector).

An autonomous agent that handles the daily workflow of a Customer Success Manager — portfolio health checks, delinquency analysis, recovery pattern search via vector embeddings, personalized borrower outreach, report generation, and fraud escalation — all through governed tool calls with delegated OAuth and full audit trails.

LoanOps AI

Why This Exists

Enterprise AI agents in banking and financial services face two infrastructure gaps:

  1. The data gap — Agents need transactions, vector search, analytics, and session memory in one database. Not stitched together from separate systems.
  2. The tool gap — APIs wrapped in MCP are not agent-ready tools. Agents act on behalf of humans — they need delegated auth, scoped permissions, and governance built into the runtime.

LoanOps AI demonstrates how to solve both with YugabyteDB (distributed SQL + pgvector for agentic data access patterns) and Arcade (the MCP runtime that handles tool execution, just-in-time OAuth, and policy enforcement simultaneously).

Architecture

                             ┌── YugabyteDB Tools (4 custom domain tools)
                             │
┌──────────┐   ┌──────────┐  ├── Gmail (send as the user via OAuth)
│  LoanOps │   │  Arcade  │  │
│  AI Chat │──▶│   MCP    │──├── Google Docs (generate reports)
│ (Vercel) │   │ Gateway  │  │
└──────────┘   │          │  ├── Slack (escalate alerts)
               │  Auth    │  │
               │  Gov.    │  └── Linear (create tasks)
               └──────────┘

All tools — custom YugabyteDB tools and third-party integrations — are accessed through a single Arcade MCP Gateway. The application never imports service-specific SDKs. One auth layer, one governance layer, one audit trail across every tool.

Tech Stack

Layer Technology
Frontend Next.js 16, TypeScript, Tailwind CSS, shadcn/ui
LLM Orchestration Vercel AI SDK v6 (ai, @ai-sdk/anthropic, @ai-sdk/mcp)
LLM Anthropic Claude (claude-sonnet-4-20250514)
Tool Runtime Arcade MCP Gateway — delegated OAuth, policy enforcement, contextual access hooks, audit logging
Database YugabyteDB — distributed PostgreSQL with pgvector for vector similarity search
Custom MCP Server Python, arcade-mcp-server SDK
Protocol Model Context Protocol (MCP) — Streamable HTTP transport

Security Model

Arcade enforces three layers of security on every tool call:

  • Policy enforcement — Contextual Tool Access filters which tools each user can invoke, based on identity provider rules
  • Delegated OAuth — Just-in-time authentication at the moment of action. The agent sends emails as the user via their own OAuth credentials. No service accounts. Credentials never touch the LLM.
  • Governance hooks — Pre-execution input validation, prompt injection scanning, post-execution PII redaction, and complete audit trail exportable to SIEM via OpenTelemetry

Quick Start

Prerequisites

  • Node.js 18+, Python 3.10+, Docker

1. Clone and install

git clone <repo-url> loanops-ai && cd loanops-ai
make install

2. Start the database

make setup

Starts YugabyteDB in Docker, loads the schema, and seeds realistic financial data: 500 borrowers, 800 loans across 5 types (personal, mortgage, auto, business, line of credit), 50k+ payments with delinquency patterns, 100 recovery case narratives with pre-baked pgvector embeddings (1536-dim, OpenAI text-embedding-3-small), and 15 fraud signals.

3. Run the app

make dev

Opens at http://localhost:3000 in mock mode with a pre-loaded demo conversation. No API keys required to see the UI.

4. Connect to Arcade (live mode)

a. Expose YugabyteDB via ngrok:

ngrok tcp 5433

b. Deploy the custom MCP server to Arcade Cloud:

arcade login
arcade secret set YUGABYTEDB_URL="postgresql://yugabyte:yugabyte@<ngrok-host>:<ngrok-port>/yugabyte"
arcade secret set OPENAI_API_KEY="sk-..."
cd tools && uv sync && arcade deploy -e src/loanops/server.py

c. Create an MCP Gateway in the Arcade Dashboard. Select your loanops_yugabytedb tools alongside Gmail, Google Docs, Google Calendar, Slack, and Linear.

d. Configure your .env:

ANTHROPIC_API_KEY=sk-ant-...
ARCADE_API_KEY=arc_...
ARCADE_GATEWAY_URL=https://api.arcade.dev/mcp/<your-gateway>
ARCADE_USER_ID=you@arcade.dev
YUGABYTEDB_URL=postgresql://yugabyte:yugabyte@localhost:5433/yugabyte

Restart make dev. The app auto-detects live mode when Arcade credentials are configured.

Custom YugabyteDB Tools

Domain-specific tools that encode loan servicing business logic. The agent speaks the domain, not SQL. The database is protected — the LLM never sees or writes raw queries.

Tool Description
get_portfolio_summary Multi-table aggregation: active loans, outstanding balance, DPD 30/60/90+ buckets, average credit score, missed payments
analyze_delinquencies CTE with payment consistency scoring, recovery likelihood ranking, and fraud signal cross-reference
semantic_search_recovery_patterns pgvector cosine similarity search over embedded recovery case narratives
get_borrower_360 Scatter-gather across 4 tables: borrower profile, loan history, payment ledger, fraud signals

Demo Scenarios

Prompt What Happens
"Give me today's portfolio health check" Agent calls get_portfolio_summary — multi-table aggregation on YugabyteDB
"Show me delinquent borrowers to follow up with" Agent calls analyze_delinquencies — CTE with recovery scoring + fraud cross-ref
"What recovery approaches worked for a first-time business delinquency?" Agent calls semantic_search_recovery_patterns — pgvector cosine similarity
"Send a payment reminder to Maria Santos" Agent looks up borrower on YugabyteDB, then sends personalized email via Gmail using delegated OAuth
"Generate my daily briefing for my manager Sarah" Agent creates a structured Google Doc with portfolio summary, actions taken, and fraud flags
"Flag Robert Keane — his income docs look suspicious" Agent creates a Slack alert and a Linear task with full fraud signal details

Demo Characters (hardcoded in seed data)

Name Pattern Outstanding Key Detail
Maria Santos Reliable late payer $12,400 Always pays 5-12 days late
James Chen Occasional miss $34,200 One prior miss, quickly resolved
Apex Industrial LLC First-ever delinquency $287,000 Business account, 22 DPD
Robert Keane Deteriorating + fraud $18,900 OPEN income mismatch signal

Project Structure

loanops-ai/
├── web/                        # Next.js frontend + API routes
│   ├── src/app/                # Pages, /api/chat (Vercel AI SDK), /api/db
│   ├── src/components/         # Chat, Tool Panel, Architecture, DB Explorer
│   └── src/lib/                # MCP client, Claude config, tool registry
├── tools/                      # Custom YugabyteDB MCP server (Python)
│   └── src/loanops/server.py   # 4 tools, deployed to Arcade Cloud
├── database/                   # Schema, seed data, pre-baked embeddings
│   ├── schema.sql              # DDL: borrowers, loans, payments, recovery_history (VECTOR), fraud_signals
│   ├── seed_data.py            # Realistic financial data generator
│   └── embeddings.json         # 100 pre-computed 1536-dim vectors
├── docker-compose.yml          # YugabyteDB (distributed PostgreSQL)
├── Makefile
└── .env.example

Commands

Command Description
make install Install all dependencies
make setup Start YugabyteDB, load schema, seed data with pgvector embeddings
make dev Start Next.js dev server
make deploy Deploy custom MCP server to Arcade Cloud
make clean Tear down Docker volumes

Resources

About

Production-ready AI agent for loan servicing and collections in financial services.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published