Saifuban MCP Server
Hard daily caps on AI agents' API spend, plus phone approval before any other payment.
Saifuban scores 67 (Good), licensed MIT and written in PLpgSQL. It can be reached as a remote MCP endpoint. It declares 4 tools. Filed under Finance. GitHub shows 1 stars. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
67 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: mit.
License, quality and maintenance
Where the 67 comes from
22 + 20 + 1 + 10 + 4 + 10 = 67. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 1 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Remote auth: API key required. Get a key or token from the provider first, then add it as a header in your client config. How remote auth works
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "ut181749ut-saifuban": { "url": "https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp" } }}
Environment variables
This server does not declare environment variables.
Tools4Tool docs quality grade C
All capabilitiesCheck whether a pending request was approved.
get_budgettoolRemaining budget today, this week and this month, per-transaction limit, auto-approve threshold, allowed merchants.
list_paymentstoolThe agent's own past requests (filter by merchant / days), so it can check e.g. whether a Spotify charge was already approved this month and avoid paying twice.
request_paymenttoolAsk whether a payment (merchant, amount, currency JPY/USD, reason, recurring none/week/month/year) is allowed. Waits up to 45 s for phone approval. Returns a single-use paymenttoken when approved. Subscriptions always need your approval, wh
About
AIの財布番 (Saifuban) — a spending guard for AI agents
AIがお金を使う前に、あなたのスマホに承認を聞きにくる。AIエージェントのAPI代も1日の予算で止める。Claude・ChatGPT・Museで使えて、Museならチャットに1通送るだけ。日本語・円対応。 Hard daily caps on your AI agents' API spend, plus phone approval before any other payment.
👉 https://ut181749ut.github.io/saifuban/
日本語
AIエージェントは支払いの前に財布番に「払っていいか」を聞きます。財布番はあなたが決めたルールで答えます。
- 少額(例: 300円以下)は自動で許可
- それを超えるとスマホに通知 → 承認 / 却下をワンタップ
- 1日・1週間・1か月の予算、1回の上限、支払先の制限
- 「聞かずに払う」のを、前に払ったことがある支払先だけにする設定(初めての支払先はスマホで確認)
- 緊急停止ボタン
- AIごとに別々のルール
- サブスク(定期購入)は金額に関係なく必ずスマホで確認。通知に年額を表示。AIが申告し忘れても、理由や支払先の文言から定期購入らしいものを見つけて確認に回す
- AIが自分の過去の申請を調べられる(同じ支払いを二重にしないため)
- APIキーを預ければ、AIエージェントのAPI代も1日・週・月の予算で強制停止(AIには代理のキーだけを渡す)
- LangChain・CrewAI・OpenAI Agents SDK・Vercel AI SDK・Claude Codeでは、接続先と鍵を差し替えるだけ(コード例は英語版の「Use it from your agent framework」)
- 日本語・円で使える。GitHub・Googleでワンタップ(パスワード不要)・無料
財布番はお金を動かしません。カード情報や口座は預かりません。
APIキーを他人のサーバーに預けたくない場合は、全部を自分のSupabaseとCloudflare(どちらも無料枠で足ります)で動かせます。手順は SELF_HOST.md。
ほかの方法との違い
- 公式の上限(Anthropic Console・OpenAI):無料なので設定はしておくのがおすすめです。ただしConsoleの上限は月単位・ワークスペース単位なので、一晩で1か月分を使えてしまい、同じワークスペースのAI全部で1つの枠を分け合います。財布番はAIごと・1日ごとです。
- LangSmithのLLM Gateway(ベータ):キーごとの1日上限があります。LangSmithを使っているならそれでも十分です。財布番はMITライセンスで自分で動かせること、Claude Codeの中で2行で設定できること、呼び出しの前に最大額を予約するので同時実行ややり直しでも抜けないこと、上限に達したらスマホに「今日だけ+500円」のボタンが届くことが違います。
- フレームワーク側の制限(
max_iterなど):ループ止めとして残しておくのがおすすめです。ただ、数えるのが呼び出しの後で、1つのプロセスの中だけ、しかもAIが本物のキーを持ったままです。代理のキーなら、コードが何をしても予算以上は使えません。
勉強会・授業・ボットで、みんなで使う
- 勉強会・授業・ハッカソンで参加者にAPIを使わせたいとき:AIの設定の「みんなで使う」で名前を1行に1人ずつ貼り、「参加者のキーを作る」を押すと、1人ずつ別のキー(
sbk_m_...)ができます(CSVで保存)。1人あたりの1日の上限と終わる日時を決めておけば、時間が来たら全員止まります。1人だけ止める、全員止める、誰が今日いくら使ったかを見る、もできます。本物のAPIキーは配りません - DiscordなどのボットでAIを使うとき:呼び出しに
x-saifuban-user: discord:1234のように利用者のIDを付けると、その人ごとに1日の上限がかかります。1人が連打しても、ほかの人は使い続けられます
使い方
Claude Codeを使っているなら、Claude Codeの中で2行打つだけです(登録・AI作成・APIキー預け・設定まで全部やります。APIキーをチャットに貼る必要はありません):
/plugin install saifuban --marketplace ut181749ut/saifuban
/saifuban:setup
(予算は /saifuban:setup 1500円 のように付けられます。付けなければ1日1,000円で、あとから管理画面で変えられます)
設定が終わると、Claude Codeの画面の下に「財布番 残り ¥620 / ¥1,000」のように今日の残りが出ます。「今日いくら使った?」と聞けば答えます(/saifuban:status)。予算を変えるのは管理画面からだけです(AIが自分で上限を上げられないように)。
このプラグインには買い物の承認も入っています。初めて使うときに /mcp で saifuban を選んで「許可する」を押すだけです(はじめての人は、その画面でアカウントも自動で作られます)。
ClaudeやChatGPTの画面で使う場合も、コネクタに下のURLを登録して「許可する」を押すだけです。
ターミナルからなら1行です: npx saifuban(WindowsのPowerShellでは npx.cmd)。手元に入っているAPIキーを見つけて使うか聞いてくれます。お金をかけずに試すなら、Geminiの無料APIキー(aistudio.google.com/apikey)で「Google Gemini」を選んでください。
- サイトで「はじめる」→ 予算を選ぶ → AI用のURLが出る
- そのURLをAIに登録(Claude: コネクタ / ChatGPT: 開発者モードのアプリ / Muse: チャットでURLを送る / Cursor・VS Code: MCP設定)
URLをコピーせずにつなぐこともできます(OAuth)。ClaudeやChatGPTのコネクタに次のURLを登録すると財布番の許可画面が開くので、つなぐAIを選んで「許可する」を押すだけです。
https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp
- AIに「財布番で今日の残り予算を見て」と聞いて確認
English
Stop your AI agents from overspending. Saifuban puts a hard daily cap on your agents' API bills and makes them ask your phone before any other payment.
- Keep your real Anthropic / OpenAI / Google key. No reseller in between, no markup, new API features work on day one. The agent gets a proxy key; your key stays encrypted on the server.
- Parallel calls can't go over. Every call reserves its worst-case cost before it's sent, so ten calls started at once still stop at the cap.
- Per agent, per day, in your time zone. Each agent gets its own daily (and optional weekly/monthly) budget that resets at your midnight. Budgets can be shown in USD (Settings → currency).
- Open source and self-hostable. Don't want to hand your key to someone else's server? Run the whole thing on your own Supabase and Cloudflare free tiers: SELF_HOST.md.
How is this different from…
- Provider spend limits (Anthropic Console, OpenAI projects). Set them anyway, they're free. But on the Console they're monthly and per workspace, so one bad night can use the whole month and every agent in the workspace shares the pool. Saifuban is per agent and per day.
- LangSmith LLM Gateway (beta). Also does per-key daily caps. If you already live in LangSmith, it's a good fit. Saifuban is MIT and self-hostable, sets itself up inside Claude Code in two lines, reserves the worst case before each call (so parallel calls and SDK retries can't slip past), and pings your phone with a "+$3 today" button when an agent hits the cap.
- Framework limits (
max_iter,recursion_limit, token-counting callbacks). Keep them, they stop loops. But they count after the call, live inside one process, and the agent still holds your real key. A proxy key can't spend more than its budget no matter what the code does. - Rolling your own. Totally doable. The tricky cases are in the reserve → settle → release test if you want to compare notes.
Hard cap on API bills
Store your OpenAI, Anthropic, Google or OpenRouter key in Saifuban. Your agent only gets a proxy key (sbk_...), every call is metered, and requests are refused once the agent's daily (or optional weekly/monthly) budget is reached. Your real key never reaches the agent.
Before each call, the proxy reserves the most it could cost (input size + max_tokens × the model's price) and settles to the actual usage when the call ends. Reservations count against the caps together with spend, so parallel calls can't all slip under the line. If a stream is cut before the usage arrives, the reserved amount is recorded instead of zero. Each reservation is settled exactly once: a retried or late settle can't charge twice, and a reservation whose settle never arrives is charged at its reserved amount after 10 minutes (and corrected if the real usage shows up later). See the reserve → settle → release test. Days reset at midnight in the owner's own time zone (taken from their device, changeable in Settings), and a call is charged to the day it started, so a call from 23:59 to 00:01 stays on the earlier day (day boundary test). If a request doesn't set an output limit, the proxy sets one (the model's maximum, up to 32k tokens) and reserves for it, so a call can't write past its reservation; asking for several answers at once (n) reserves for each. Web searches and other per-call tool fees are counted too, prices and the exchange rate update daily, and a model missing from the price list is charged at that provider's highest price. If a call doesn't fit only because other calls still hold reservations, the proxy answers 429 (retry shortly), so a retry goes through once they finish. If the rest of the day's budget can't cover the requested max_tokens but can cover at least 4,096 tokens, the proxy lowers max_tokens to what's left instead of refusing (the response carries x-saifuban-output-capped). When the budget is really used up, it answers 429 with billing_error, x-should-retry: false and Retry-After set to the reset time, the same shape Claude Code expects from a spend-limit gateway, so clients stop instead of retrying. Token-counting calls (count_tokens, input_tokens) pass through free. Requests that pull in content from outside the body (OpenAI previous_response_id/conversation, uploaded file ids, Anthropic file/URL documents, MCP connectors, Gemini files) get their input counted first with the provider's free token-count endpoint, and server-side web search/fetch results are reserved as input too. If a call still comes in over its reservation, it's charged at the actual cost and marked as an overrun on that line. Endpoints whose cost can't be metered per call (batches, images, audio, video, fine-tuning, realtime) are refused, so they can't go around the cap. The proxy runs on Cloudflare, so responses that take several minutes stream to the end (the older https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-proxy/... address still works, but cuts responses at 150 seconds).
Each agent can also have at most a few API requests in flight at once (8 by default, adjustable). Extra requests get a 429 and the official SDKs retry them automatically, so a runaway loop can't fire hundreds of calls before the budget check catches up.
Use it from your agent framework
Fastest: from inside Claude Code. Add the plugin and tell it your daily budget:
/plugin install saifuban --marketplace ut181749ut/saifuban
/saifuban:setup
(Add a budget like /saifuban:setup 10 for $10/day; the default is $7. On Claude Code older than v2.1.275, add the marketplace first with /plugin marketplace add ut181749ut/saifuban, then /plugin install saifuban@saifuban.)
It creates your account and an agent with a daily cap, stores the Anthropic key that's already in your environment (you never paste it into the chat), checks the key works through the proxy, writes ~/.claude/settings.json, and opens your dashboard already signed in. Restart Claude Code and every call goes through the cap, with the money left today shown at the bottom of the screen. Ask "how much did I spend today?" (or run /saifuban:status) any time. The plugin also connects Saifuban's payment approvals, so Claude asks before buying anything: the first time, run /mcp, pick saifuban and press Allow (new users get an account with a daily budget on that same page).
Or from the terminal, one command:
npx saifuban
On Windows PowerShell use npx.cmd instead of npx. Git doesn't need to be installed. It finds the API key already in your environment and offers to use it, remembers your account on this computer, and checks GitHub for a newer version on start. For a new account it asks two things at most (budget, and whether to use the key it found); add --yes to skip both. Already have an account? Add --login.
Want to try it for free? Get a free Gemini API key at aistudio.google.com/apikey and choose "Google Gemini" (or --provider google).
Point the client at the Saifuban proxy and give it the agent's proxy key. Nothing else changes.
Claude Code
export ANTHROPIC_BASE_URL="https://saifuban.saifuban-app.workers.dev/proxy/anthropic"
export ANTHROPIC_AUTH_TOKEN="sbk_..."
Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY: with ANTHROPIC_API_KEY, Claude Code asks once whether to use the key, the default answer is No, and a declined key is ignored silently after that. To keep it for every new terminal, put both in the "env" block of ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows). The setup command offers to do this for you.
OpenAI SDK / OpenAI Agents SDK (Python)
from openai import AsyncOpenAI
from agents import set_default_openai_client
set_default_openai_client(AsyncOpenAI(
base_url="https://saifuban.saifuban-app.workers.dev/proxy/openai/v1",
api_key="sbk_...",
))
LangChain
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
gpt = ChatOpenAI(model="gpt-4o-mini", base_url="https://saifuban.saifuban-app.workers.dev/proxy/openai/v1", api_key="sbk_...")
claude = ChatAnthropic(model="claude-sonnet-4-5", base_url="https://saifuban.saifuban-app.workers.dev/proxy/anthropic", api_key="sbk_...")
CrewAI
from crewai import LLM
llm = LLM(model="openai/gpt-4o-mini", base_url="https://saifuban.saifuban-app.workers.dev/proxy/openai/v1", api_key="sbk_...")
Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai";
const openai = createOpenAI({ baseURL: "https://saifuban.saifuban-app.workers.dev/proxy/openai/v1", apiKey: "sbk_..." });
OpenRouter (hundreds of models, actual cost reported per call): base URL https://saifuban.saifuban-app.workers.dev/proxy/openrouter/v1. Gemini: https://saifuban.saifuban-app.workers.dev/proxy/google/v1beta/openai (OpenAI-compatible).
Sharing one key: workshops, classes, bots
Handing out API access to a group (a workshop, a class, a hackathon): open an agent's settings → "Shared use", paste one name per line and press "Create participant keys". Everyone gets their own sbk_m_... key (downloaded as a CSV). Set a daily cap per person and an end time; when it passes, every key stops. You can stop one person's key or all of them, and see who spent what today. Your real provider key is never handed out.
Public bots (Discord, Slack, a web chat): send the end user's ID with each call and each user gets their own daily cap, so one person spamming the bot can't burn the whole budget.
client = OpenAI(base_url="https://saifuban.saifuban-app.workers.dev/proxy/openai/v1", api_key="sbk_...")
reply = client.chat.completions.create(model="gpt-4o-mini", messages=msgs,
extra_headers={"x-saifuban-user": f"discord:{user_id}"})
Over the cap, that user gets a 429 (x-should-retry: false); everyone else keeps working. The response carries x-saifuban-user-remaining-jpy. Test: tests/members-and-user-caps.sql.
Phone approval for everything else
Your AI agent asks Saifuban before every payment. Saifuban answers using your rules.
- Auto-approve small amounts (e.g. under ¥300)
- Anything above goes to your phone as a push notification — approve or reject in one tap
- Daily, weekly and monthly budgets, per-transaction limit, allowed merchants
- Optional: auto-approve only merchants you've paid before; new merchants always go to your phone
- Kill switch
- Separate rules per agent
Saifuban never moves money and never stores card or bank details. It only decides whether a payment is allowed.
Setup
- Open the site, press "はじめる" (Start), pick a budget — you get a personal MCP URL
- Add the URL to your AI as a remote MCP server (Streamable HTTP, no auth — the key is in the URL). With Muse, just send the URL in a chat message and ask it to connect
Or skip the copy-paste and connect with OAuth: add https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp as a connector in Claude or ChatGPT. A Saifuban consent page opens; pick (or create) the agent and press Allow. Dynamic Client Registration and PKCE (S256) are supported.
3. Ask your AI: "Check my remaining budget with Saifuban"
MCP tools
| Tool | What it does |
|---|---|
request_payment | Ask whether a payment (merchant, amount, currency JPY/USD, reason, recurring none/week/month/year) is allowed. Waits up to 45 s for phone approval. Returns a single-use payment_token when approved. Subscriptions always need your approval, whatever the amount, and the notification shows the yearly cost. Retrying a request that is still pending returns the same request instead of creating a new one (or pass idempotency_key). |
check_payment_status | Check whether a pending request was approved. |
list_payments | The agent's own past requests (filter by merchant / days), so it can check e.g. whether a Spotify charge was already approved this month and avoid paying twice. |
get_budget | Remaining budget today, this week and this month, per-transaction limit, auto-approve threshold, allowed merchants. |
Endpoint: https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp/<your-key> (get your key on the site)
Hard enforcement: single-use payment tokens
Calling request_payment is voluntary, so a prompt-injected agent could simply skip it. To make the guard enforceable, every approved request comes with a payment_token (sbt_...):
- single-use, valid for 24 hours
- bound to the approved merchant and amount
- invalid if the AI is stopped or the kill switch is on
Whatever actually moves the money (your payment tool, wrapper, or merchant backend) should require this token and redeem it before paying:
curl -X POST https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban/redeem \
-H "content-type: application/json" \
-d '{"token":"sbt_...","merchant":"OpenAI","amount":12.5,"currency":"USD"}'
# => {"valid":true,"consumed":true,...} or {"valid":false,"error":"already_used" | "merchant_mismatch" | "amount_exceeds_approval" | ...}
/verify takes the same body and checks without consuming. No agent key is needed to redeem, so the payment side doesn't have to share secrets with the agent.
API spend is already hard-enforced: when you store your provider API key in Saifuban, the agent only ever gets a proxy key.
Challenge
Think you can make Saifuban approve more than the budget? A live agent with a ¥100/day budget is open to everyone: https://ut181749ut.github.io/saifuban/challenge.html
Thanks
- u/organic-humanoid pointed out that metered API calls were checked before the call but counted after, so calls already in flight could slip past the cap. That led to reserve-then-settle in the proxy. Thank you!
Links
- 利用規約 / Terms
- プライバシーポリシー / Privacy
- Issues / requests: https://github.com/ut181749ut/saifuban/issues
Frequently asked questions
What is Saifuban MCP Server?
Hard daily caps on AI agents' API spend, plus phone approval before any other payment.
How do I install Saifuban MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. Saifuban MCP Server connects to the remote endpoint https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp, so there is nothing to install locally.
Is Saifuban MCP Server free and open source?
Yes. Saifuban MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does Saifuban MCP Server support remote (HTTP) connections?
Yes. Saifuban MCP Server offers a hosted endpoint over Streamable HTTP, so HTTP-capable clients can connect to it without running anything locally.
What tools does Saifuban MCP Server provide?
Saifuban MCP Server provides 4 tools: check_payment_status, get_budget, list_payments, and request_payment. See the full tool list for descriptions and parameters.
How is Saifuban MCP Server's trust score calculated?
Saifuban MCP Server scores 67 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.