lending-MCP

lending-MCP

An MCP server that allows starting an iwoca business finance application from within a ChatGPT conversation, supporting drafting, submitting, and checking status of applications.

Category
访问服务器

README

iwoca ChatGPT MCP — Proof of Concept

A small Node/TypeScript MCP server that lets a user start an iwoca business finance application entirely from inside a ChatGPT conversation.

The server exposes three tools over the Model Context Protocol's Streamable HTTP transport so it can be installed as a ChatGPT MCP app:

Tool Purpose
draft_application Validate the applicant's details and store a draft row. Returns a draft ID and a human-readable summary.
submit_application Promote a draft to submitted, mint a mock IW-100001-style reference and return a secure (mock) upload URL.
get_application_status Look up the current status for a reference. Auto-progresses Submitted → Under Review → Documents Requested over time to make the demo feel alive.

⚠️ This is a proof of concept. It performs no underwriting, KYC, AML, credit, document, or CRM integration. The upload URL is a placeholder on demo.iwoca.app.

Tech stack

  • Node.js ≥ 20, TypeScript (ESM)
  • @modelcontextprotocol/sdk (Streamable HTTP server transport)
  • Fastify + @fastify/cors
  • Zod for input validation
  • better-sqlite3 for persistence (single applications table)
  • Optional Docker image

Project layout

iwoca-poc/
  src/
    mcp.ts                       # Shared MCP server factory + tool registration
    server.ts                    # HTTP entry point (Streamable HTTP, for ChatGPT)
    stdio.ts                     # stdio entry point (for the MCP Inspector)
    database.ts                  # SQLite schema and connection
    validation.ts                # Zod schemas + error formatter
    tools/
      draftApplication.ts
      submitApplication.ts
      getApplicationStatus.ts
    services/
      applicationService.ts      # Draft / submit / status logic
  package.json
  tsconfig.json
  Dockerfile
  README.md

Running locally

npm install
npm run dev        # tsx watch, hot-reload
# or
npm run build && npm start

The server listens on http://0.0.0.0:3000 by default. Environment variables:

Variable Default Description
PORT 3000 HTTP port.
HOST 0.0.0.0 Bind address.
IWOCA_DB_PATH data/iwoca.sqlite SQLite file path (parent dir auto-created).
LOG_LEVEL info Fastify log level.

Test it with the MCP Inspector (recommended)

The fastest way to exercise the tools — no ChatGPT account or public URL needed. The MCP Inspector is a local web UI that connects to the server and lets you call each tool by hand.

npm install
npm run inspector

npm run inspector builds the project and launches the Inspector pointed at the stdio entry point (node dist/stdio.js) — it spawns the server for you, so there's nothing else to start. The command prints a URL (with a pre-filled auth token); open it in your browser, click Connect, then walk the flow:

  1. Open the Tools tab and click List Tools — you should see draft_application, submit_application, get_application_status.
  2. Run draft_application with the applicant fields → copy the returned draft_id.
  3. Run submit_application with that draft_id and confirmed: true → note the IW-##### reference and the secure upload URL.
  4. Run get_application_status with that reference to see the status (and, after ~30s between checks, the automatic progression).

Prefer a manual stdio session without the UI? npm run dev:stdio runs the stdio server directly so you can pipe newline-delimited JSON-RPC into it.

Endpoints

  • POST /mcp — JSON-RPC requests (MCP Streamable HTTP).
  • GET /mcp — SSE stream for server → client messages (per session).
  • DELETE /mcp — Tear down a session.
  • GET /healthz — Liveness probe; returns server name, version, and tool list.

The transport requires the standard MCP headers:

  • Accept: application/json, text/event-stream
  • Mcp-Session-Id: <session-id> after the first initialize call.

Docker

docker build -t iwoca-mcp .
docker run -p 3000:3000 -v $PWD/data:/app/data iwoca-mcp

Smoke test (curl)

# 1. Initialise a session — capture the mcp-session-id response header.
curl -i -X POST http://localhost:3000/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize",
       "params":{"protocolVersion":"2025-06-18","capabilities":{},
                 "clientInfo":{"name":"curl","version":"0"}}}'

SID=<paste mcp-session-id>

# 2. Send the initialized notification.
curl -X POST http://localhost:3000/mcp \
  -H "content-type: application/json" \
  -H "accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SID" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

# 3. Draft an application.
curl -X POST http://localhost:3000/mcp \
  -H "content-type: application/json" \
  -H "accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SID" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{
        "name":"draft_application","arguments":{
          "first_name":"Jane","last_name":"Doe",
          "company_name":"Acme Bakery Ltd",
          "amount_requested":50000,"annual_turnover":350000,
          "use_of_funds":"Buy a new oven and hire 2 staff",
          "funds_duration":"12 months",
          "email":"jane@acmebakery.co.uk","phone":"+44 7700 900123"}}}'

# 4. Submit using the draft_id from the previous response.
curl -X POST http://localhost:3000/mcp \
  -H "content-type: application/json" \
  -H "accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SID" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{
        "name":"submit_application","arguments":{
          "draft_id":"<draft_id>","confirmed":true}}}'

# 5. Check status with the returned IW-#### reference.
curl -X POST http://localhost:3000/mcp \
  -H "content-type: application/json" \
  -H "accept: application/json, text/event-stream" \
  -H "mcp-session-id: $SID" \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{
        "name":"get_application_status","arguments":{
          "application_reference":"IW-100001"}}}'

Connecting from ChatGPT

In ChatGPT, add the MCP server's public URL (https://<your-host>/mcp) as a Streamable HTTP MCP connector. ChatGPT will then naturally:

  1. Ask the user for any missing application fields.
  2. Call draft_application with the collected fields.
  3. Read the returned summary back to the user.
  4. Ask for confirmation.
  5. Call submit_application with confirmed: true.
  6. Share the IW-##### reference and the secure upload link.
  7. Call get_application_status on demand to report progress.

To expose a local instance for testing, tunnel it (e.g. ngrok http 3000) and use the public URL.

Data model

A single applications table:

column type notes
id TEXT (UUID) primary key, the draft_id
reference TEXT IW-100001+, set on submission
status TEXT draft → submitted → under_review → documents_requested
first_name, last_name, company_name TEXT
amount_requested, annual_turnover REAL GBP
use_of_funds, funds_duration TEXT
email, phone TEXT
created_at, updated_at TEXT ISO-8601

Validation rules

Enforced by Zod in src/validation.ts:

  • All fields required and non-empty.
  • amount_requested > 0 and ≤ £1,000,000.
  • annual_turnover numeric and ≥ 0.
  • email must be a valid address.
  • phone must match ^\+?[0-9 ()\-]{7,20}$.
  • submit_application requires confirmed: true (a literal true, not just truthy).

Validation failures are returned as isError: true tool results with a bullet list of issues so the model can ask the user for the missing/invalid fields.

What's deliberately out of scope

No underwriting, credit scoring, KYC/AML, Open Banking, document processing, OCR, email delivery, CRM integration, production iwoca APIs, authentication, dashboards, or notifications. The goal is purely to demonstrate the conversational application flow end-to-end inside ChatGPT.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选