npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ga-finance-mcp

v0.1.0

Published

Read-only NetSuite finance MCP server with a built-in mock: AR, credit risk, AP, cash, bank and GL tools over stdio or Streamable HTTP, with OAuth 1.0 (TBA) and OAuth 2.0

Readme

ga-finance-mcp

A read-only NetSuite finance MCP server with a NetSuite mock built in. It gives an AI assistant 31 read-only tools for receivables, credit risk, payables, cash, bank deposits, general ledger and journal entries, plus 4 guided workflows.

  • Demo without a NetSuite account. The built-in mock holds a realistic company with 18 months of history. Run npx ga-finance-mcp and it works, with no database or setup. Every date shifts to today on start-up, so aging always looks current.
  • Connect a real account with the same tools. OAuth 1.0 (Token-Based Authentication) and OAuth 2.0 are both supported: authorization code + PKCE, client credentials, or a token you supply.
  • Runs over stdio or Streamable HTTP. HTTP mode can require a NetSuite OAuth 2.0 bearer token on every request, the same way NetSuite's own MCP endpoint works.
  • Works as a library. Import it to run the server inside a host app.

Requires Node.js 22.13 or later. The mock uses Node's built-in SQLite, so there are no native modules to compile.

Install

npx ga-finance-mcp
npm i -g ga-finance-mcp

Mock mode. The built-in mock is the default backend. The CLI reads NS_BACKEND (flag --backend). Unset, embedded, or the alias mock all start the in-process mock over stdio:

npx ga-finance-mcp
npx ga-finance-mcp --backend embedded
NS_BACKEND=embedded ga-finance-mcp

MCP client config (Claude Desktop / Cursor). Add a ga-finance-mcp entry inside the existing mcpServers object of claude_desktop_config.json (or Cursor MCP settings). Do not replace the file. Use ga-finance-mcp as the command. Environment keys are names only; replace placeholder values. Omit unused keys.

If mcpServers already has other servers, add only this entry:

    "ga-finance-mcp": {
      "command": "ga-finance-mcp",
      "env": {
        "NS_BACKEND": "embedded",
        "ARCAI_DATASET": "<path-to-dataset.json>",
        "ARCAI_TOOLSETS": "<ar,credit,ap,insights,bank,gl,journal,sql>",
        "NS_ACCOUNT_ID": "<account-id>",
        "NS_CONSUMER_KEY": "<consumer-key>",
        "NS_CONSUMER_SECRET": "<consumer-secret>",
        "NS_TOKEN_ID": "<token-id>",
        "NS_TOKEN_SECRET": "<token-secret>"
      }
    }

If the file is empty or {}, use the full block:

{
  "mcpServers": {
    "ga-finance-mcp": {
      "command": "ga-finance-mcp",
      "env": {
        "NS_BACKEND": "embedded",
        "ARCAI_DATASET": "<path-to-dataset.json>",
        "ARCAI_TOOLSETS": "<ar,credit,ap,insights,bank,gl,journal,sql>",
        "NS_ACCOUNT_ID": "<account-id>",
        "NS_CONSUMER_KEY": "<consumer-key>",
        "NS_CONSUMER_SECRET": "<consumer-secret>",
        "NS_TOKEN_ID": "<token-id>",
        "NS_TOKEN_SECRET": "<token-secret>"
      }
    }
  }
}

For the built-in mock, NS_BACKEND=embedded (or omit NS_BACKEND) is enough. The NS_* credential variables apply when NS_BACKEND=netsuite.

Quick start

npx ga-finance-mcp            # MCP over stdio, built-in mock
npx ga-finance-mcp --version  # prints to stdout (so `> v.txt` and `| less` work)
npx ga-finance-mcp --help     # same; errors stay on stderr

--help and --version exit 0 after writing to stdout. The MCP "ready" message and errors stay on stderr so they never mix with the stdio protocol channel.

Claude Code

claude mcp add ga-finance-mcp -- npx -y ga-finance-mcp

Claude Desktop / Cursor. Add this entry inside the existing mcpServers object. Do not replace the file.

    "ga-finance-mcp": { "command": "ga-finance-mcp" }

If the file is empty or {}, use the full block:

{
  "mcpServers": {
    "ga-finance-mcp": { "command": "ga-finance-mcp" }
  }
}

Then ask: "Give me a finance health check" or "Who should we put on credit hold?"

Docs

Running a customer demo

npx ga-finance-mcp demo           # mock + MCP over HTTP on :3333
npx ga-finance-mcp demo --oauth   # same, but clients must sign in with OAuth 2.0, like NetSuite's own MCP
claude mcp add --transport http ga-finance-mcp http://127.0.0.1:3333/mcp

demo runs the mock as a stand-in for NetSuite on port 3100. The MCP server then talks to it through the real NetSuite code path: SuiteQL REST with authentication. What you demo is what runs against a live account.

  • Without --oauth, the server signs requests with the mock's demo OAuth 1.0 keys.
  • With --oauth, Claude Code finds the sign-in endpoints itself. Run /mcp, then choose Authenticate, and a browser opens a "Mock NetSuite - Allow access?" consent page. That is the same OAuth 2.0 authorization code + PKCE flow a customer goes through with NetSuite. A GET (including ?decision=allow) only shows the page; the code is issued when you click Allow.

What the demo data shows

The bundled company has 120 customers and 40 vendors, with about 1,600 invoices, 1,400 payments and 700 bills, plus a general ledger with a Stripe clearing account, fee expense and bank activity (including a USD payout into a EUR bank), and planted journal entries for Stripe payout reconciliation. Every number is reproducible.

| Story | Where it shows up | |---|---| | About 38% of AR past due, DSO 63 and rising | get_finance_kpis, get_dso_trend | | 8 critical-risk customers, 4 over their credit limit | get_credit_risk_watchlist, evaluate_customer_risk | | Good customers who recently started paying late | get_payment_trend_alerts | | Who to call today, and what to say | get_collections_worklist, the collections_call_prep prompt | | 4 duplicate vendor bills, held out of the payment run | find_duplicate_bills, propose_payment_run | | Next 6 weeks of cash, based on real payment habits | get_cash_outlook | | Stripe payout matched to a bank deposit (USD into GBP, fees and refunds) | list_deposits, get_deposit | | Stripe clearing, processing fees and bank (USD and EUR) | get_account_balances, list_gl_detail | | Stripe fees, clearing and payout journals, including a USD payout into a GBP bank | list_journal_entries, get_journal_entry |

Prompts (guided workflows)

| Prompt | Toolsets | What it does | |---|---|---| | month_end_ar_review | ar, credit, insights | CFO-ready AR review: KPIs, DSO trend, aging by subsidiary and rep, risks, actions | | credit_review (customer) | ar, credit | Recommends raising, keeping or cutting the credit limit, or a credit hold, with evidence | | collections_call_prep (customer?) | ar | Situation summary, invoices to discuss, talking points and a follow-up email | | ap_payment_run (budget?) | ap, insights | What to pay this week, what to defer, duplicates to hold, approvals that block payment |

Tools

All tools are read-only. Customers and vendors can be referenced by internal id (33), entity id (CUST-1033) or name.

| Toolset | Tools | |---|---| | - | test_connection | | ar | search_customers, get_customer_details, get_customer_open_invoices, get_customer_payment_history, get_customer_statement (real calendar dates; from must be on or before to; only to defaults from to 90 days before that date), get_ar_aging_summary (by customer / subsidiary / category / sales rep), get_overdue_invoices, get_collections_worklist, get_top_customers | | credit | evaluate_customer_risk, get_credit_risk_watchlist, get_payment_trend_alerts | | ap | search_vendors, get_vendor_open_bills, get_ap_aging_summary, get_bills_pending_approval, find_duplicate_bills, get_vendor_spend_summary, propose_payment_run | | insights | get_finance_kpis, get_dso_trend, get_revenue_trend, get_cash_outlook | | bank | list_deposits (date range, account, amount or amount range at the ISO 4217 currency scale with required currency, memo/reference, subsidiary, period, limit/offset digits only, max 200), get_deposit (header, payment refs, fee/cash-back/refund lines; line amounts sum to the header net). Amount filters require currency and must match that scale exactly (USD 10.00, JPY 100, BHD 1.234); a missing currency or trailing zeros past the scale (JPY 100.00) is a 400. NetSuite SuiteQL for these tools is UNVERIFIED against a live account. | | gl | get_account_balances (trial balance as of a date or for a period, by subsidiary, optional account; debit, credit and net as decimal strings with transaction and base currency; totals is one entry per base currency, empty when there are no rows), list_gl_detail (posted, posting GL lines for an account and date range, with a per-subsidiary base-currency running balance and limit/offset paging). The NetSuite SuiteQL for these tools is UNVERIFIED against a live account. | | journal | list_journal_entries (date range, account, subsidiary, memo/reference contains, posting status; limit/offset paging, max 200), get_journal_entry (header plus lines with account, debit, credit, entity, memo, department/class/location; transaction and base amounts as decimal strings). NetSuite SuiteQL for these tools is UNVERIFIED against a live account. | | sql | run_suiteql: a single read-only SELECT, written in SuiteQL (REPLACE() is allowed; REPLACE INTO is not). limit (1–1000) is a user cap, distinct from NS_MAX_ROWS. |

Use --toolsets ar,credit (or ARCAI_TOOLSETS) to expose only some groups. Leave out sql to hide raw queries. A prompt is listed only when every toolset it depends on is enabled; --toolsets ar keeps collections_call_prep and hides the rest.

Risk score (0–100). The score adds up four factors: the share of the open balance that is past due (up to 30 points), the age of the oldest past-due invoice (25), credit utilization above 70% (25), and the average days paid late (20). A score of 25 or more is Moderate, 50 or more High, and 75 or more Critical. evaluate_customer_risk returns the factors behind the score, so a presenter can explain it.

Metrics. DSO = AR ÷ billing over the last 90 days × 90. DPO = open AP ÷ vendor bills over the last 90 days × 90. CEI = (opening AR + billing − closing AR) ÷ (opening AR + billing − closing current AR).

Connecting a real NetSuite account

NS_BACKEND=netsuite NS_ACCOUNT_ID=1234567_SB1 <credentials below> npx ga-finance-mcp

The NetSuite role needs these permissions: REST Web Services, SuiteAnalytics Workbook, and view access to customers, vendors, transactions, journal entries, deposits, accounts and accounting periods. The SuiteQL queries live in src/data.ts. Deposit SuiteQL (list_deposits, get_deposit) uses transaction, transactionline, account and accountingperiod and is UNVERIFIED against a live account.

The general-ledger SuiteQL (get_account_balances, list_gl_detail) is UNVERIFIED against a live account. It uses published SuiteQL records: TransactionAccountingLine.debit / credit (currency units, not cents), transactionline for memo and entity, and tal.posting = 'T'. TAL rows are restricted to the primary accounting book (accountingbook.isprimary = 'T') so Multi-Book Accounting does not double-count (UNVERIFIED). Currency ISO codes come from currency.symbol joined on account.currency / subsidiary.currency (UNVERIFIED: BUILTIN.DF on a currency id returns a display name such as US Dollar, not USD). Subsidiary is resolved by name to an id, then filtered as t.subsidiary = :id (400 if none or several match), rather than matching BUILTIN.DF(transaction.subsidiary) or account.subsidiary (a multi-id list). Trial-balance totals is one entry per base currency and is empty when there are no rows. list_gl_detail running balance is partitioned by subsidiary so mixed base currencies (USD and CAD on one account) are not added together; a transaction-currency running total is not returned because one account can post in more than one currency. Amounts are returned as TO_CHAR text (not JSON numbers) with a wide optional-decimal format (FM…0.999999). Trailing zeros (and a trailing .) are trimmed, then any non-zero digit past the currency's ISO 4217 scale is rejected (USD=2, JPY=0, BHD=3); unknown codes are rejected, empty amounts throw, and zero formats as 0.00 for two-decimal currencies.

Journal SuiteQL lives in NetSuite-only functions in src/data.ts and uses real transaction, transactionline, transactionaccountingline and accountingperiod fields; that path is UNVERIFIED against a live account. Transaction amounts come from tl.debitforeignamount / tl.creditforeignamount; base amounts come from tal.debit / tal.credit. The sqlite path uses bound parameters against mock tables. Both journal and GL format amounts through src/money.ts.

Authentication

| Method | When to use | Environment variables | |---|---|---| | OAuth 2.0 - authorization code + PKCE | A person signs in with their own NetSuite login and role. NetSuite's own MCP uses this flow. | NS_CLIENT_ID, optionally NS_CLIENT_SECRET (public clients use PKCE only), NS_REDIRECT_URI (default http://127.0.0.1:8976/callback). Then run npx ga-finance-mcp login once. | | OAuth 2.0 - client credentials (M2M) | Server-to-server with no user present, e.g. your backend | NS_CLIENT_ID, NS_CERTIFICATE_ID, NS_PRIVATE_KEY_PATH (or NS_PRIVATE_KEY), optionally NS_JWT_ALG (default PS256; ES256/384/512 and PS384/512 also work) | | OAuth 2.0 - existing token | A host app already holds the user's token | NS_ACCESS_TOKEN, optionally NS_REFRESH_TOKEN (needs NS_CLIENT_ID to refresh) | | OAuth 1.0 - Token-Based Authentication | Existing TBA integrations | NS_CONSUMER_KEY, NS_CONSUMER_SECRET, NS_TOKEN_ID, NS_TOKEN_SECRET |

The method is chosen from the variables that are set. Force it with NS_AUTH=tba|oauth2 and NS_OAUTH2_GRANT=authorization_code|client_credentials|access_token. Check the result with npx ga-finance-mcp info, which never prints secrets.

OAuth 2.0 details

  • Scope: NS_SCOPE defaults to rest_webservices, the scope REST and SuiteQL need.
  • Tokens: login saves tokens locally to ~/.ga-finance-mcp/tokens/<ACCOUNT>.json with mode 0600 (override the path with NS_TOKEN_STORE), and they refresh automatically. Access tokens last 60 minutes. Confidential-client refresh tokens last seven days and are reused. Public-client refresh tokens last two days by default, are one-time-use, and are rotated on each refresh. After a rotation, the stored token wins over NS_REFRESH_TOKEN when it is newer or was rotated from that env seed, so a restart does not replay a consumed token. If two processes share a store and one loses the refresh race, it re-reads the store and retries once with the winner's token. Shared-store refresh is serialized with a lockfile that records the holder's hostname and pid. A lock older than 20 seconds whose holder process is gone is stale and may be taken over; waiters give up after 25 seconds. A lock from another host is judged by age only (the 20 second stale window), never by pid. A lock older than 120 seconds is taken over even if a process with that pid is still alive, which caps pid reuse; a live holder heartbeats about every 6.7 seconds so it never reaches that age. Do not share the token directory across hosts or containers. Token-endpoint HTTP calls (refresh, code exchange, and client credentials) abort after 8 seconds. The stale window is above two fetch timeouts plus slack so a refresh followed by an invalid_grant retry cannot be stolen; the holder touches the lock through its open file handle. When a refresh token expires, run login again.
  • Loopback port 0: a redirect URI whose port is 0 (for example http://127.0.0.1:0/callback) is for tests and mocks only. NetSuite requires an exact redirect URI match, so a real integration must register a fixed loopback port. In tests, port 0 binds a free port and the authorize request uses the port that was assigned. If that bind fails, login rejects and does not leave the callback server running.
  • Login without a loopback redirect: if your integration's redirect URI isn't a loopback address, login prints the sign-in URL and asks you to paste back the URL NetSuite redirects to.
  • Client credentials: upload the certificate under Setup > Integration > OAuth 2.0 Client Credentials (M2M) Setup, and use the certificate ID it shows as NS_CERTIFICATE_ID.

HTTP mode, like NetSuite's own MCP

NS_ACCOUNT_ID=1234567_SB1 npx ga-finance-mcp --http --auth oauth --port 3333

Each request must carry a NetSuite OAuth 2.0 access token (Authorization: Bearer …), and the server calls NetSuite with that token. Each user therefore sees only what their own role allows, and the server holds no NetSuite credentials.

  • No token: the server answers 401 with a WWW-Authenticate header that points to /.well-known/oauth-protected-resource/mcp (RFC 9728). MCP clients use it to discover where to sign in.
  • Rejected token: if NetSuite rejects a token, the next request using it gets a 401, so the client signs in again.

Other modes: --auth token --token <secret> uses one shared secret, for example for your backend. --auth none is meant for localhost only; the server logs a warning if it's bound to any other address. --public-url sets the external URL when the server runs behind a proxy.

Relation to NetSuite's built-in MCP (AI Connector Service). NetSuite's endpoint is https://<account>.suitetalk.api.netsuite.com/services/mcp/v1/all with the OAuth scope mcp, and it exposes NetSuite's standard tools. This server uses the same sign-in flow, but calls the REST/SuiteQL API (scope rest_webservices) to offer purpose-built finance tools. The two can run side by side.

Status: the OAuth 1.0 signing matches the oauth-1.0a library, and every OAuth 2.0 flow passes end-to-end tests against the mock. Neither has been run against a live NetSuite account yet. Two things are unconfirmed:

  • whether NetSuite publishes the RFC 8414 metadata that --auth oauth points clients to (use --auth-server if it lives elsewhere);
  • SuiteQL field names such as foreignamountunpaid and closedate.

Expect to adjust src/data.ts after the first live connection.

Deploy on Vercel (public HTTP transport)

A second, hardened Streamable HTTP transport (src/vercel.ts) is meant to run the built-in mock behind a bearer token on a public host such as Vercel. It is deliberately separate from the --auth oauth mode above: that mode is for a trusted proxy where each client brings its own NetSuite token; this one exposes only the demo mock and fails closed. It will refuse to start unless the backend is the embedded mock (NS_BACKEND unset or embedded), and no NetSuite credentials belong anywhere near it.

The Vercel function lives at api/mcp.js and imports the compiled handler from dist/; vercel.json runs npm run build and bundles the demo dataset. Clients reach it at https://<your-deployment>/mcp (a rewrite maps /mcp to the function).

Set the token and the Origin allowlist

# Generate a strong token locally (never commit a real token or put one in the repo):
openssl rand -hex 32

| Variable | Purpose | Default | |---|---|---| | ARCAI_MCP_TOKEN | MCP bearer token. If unset or empty, it never matches. The endpoint fails closed when both this and ARCAI_PLATFORM_TOKEN are unset or empty. | - (fails closed with no tokens) | | ARCAI_PLATFORM_TOKEN | Platform bearer token (second credential). If unset or empty, it never matches. | - | | MCP_RATE_LIMIT_SALT | Secret for hashing rate-limit Redis bucket ids (not a bearer token). When unset, ARCAI_MCP_TOKEN is used as a legacy salt (ratelimit_salt=legacy once per instance). When both are unset, buckets are hashed unsalted (ratelimit_salt=missing once per instance). Log lines never include values. | - | | MCP_ALLOWED_ORIGINS | Comma-separated Origin allowlist, e.g. https://app.example.com. | empty (every present Origin is rejected) | | MCP_REQUIRE_ORIGIN | 1/true to also reject requests with no Origin header. | off (missing Origin is allowed with a valid token) | | MCP_RATE_LIMIT / MCP_RATE_WINDOW_MS | Per-IP rate limit for mcp and anon buckets (requests per window; Upstash Redis REST). | 60 / 60000 | | MCP_PLATFORM_RATE_LIMIT | Per-IP rate limit for the platform bucket (trimmed; digits 1–10000, no leading zeros or +). Invalid values fall back to 60 and log ratelimit_platform_limit=invalid once per instance. | 60 | | UPSTASH_REDIS_REST_URL / UPSTASH_REDIS_REST_TOKEN | Upstash Redis REST credentials for the shared rate limiter. | - | | KV_REST_API_URL / KV_REST_API_TOKEN | Vercel Marketplace alias for the same Upstash REST credentials. | - | | MCP_MAX_BODY_BYTES / MCP_MAX_BATCH | Request body byte cap and JSON-RPC batch length cap. | 1000000 / 50 |

In the Vercel dashboard set ARCAI_MCP_TOKEN and MCP_ALLOWED_ORIGINS under Settings → Environment Variables, then deploy.

Required: NODEJS_HELPERS=0. The handler reads and size-caps the raw request stream itself. Vercel's Node runtime otherwise pre-parses (and consumes) the JSON body, which would bypass the byte cap and Content-Encoding rejection - so if a pre-parsed body is ever seen, the handler fails closed with a 500. vercel.json already sets NODEJS_HELPERS=0 (build and runtime). If you deploy without that vercel.json (e.g. a custom pipeline), set NODEJS_HELPERS=0 as an environment variable yourself.

Security behavior, precisely:

  • Bearer auth. The Bearer scheme is matched case-insensitively; the credential must match exactly one of ARCAI_MCP_TOKEN or ARCAI_PLATFORM_TOKEN (no trimming, no prefix match), compared in constant time against both configured tokens. An empty configured token never matches anything (including an empty bearer value). The wrong scheme (e.g. Basic), duplicate Authorization headers, or no configured tokens fail closed with 401. Logs may record which token id was used (mcp or platform); the token value and Authorization header are never written to logs or responses, including on errors.
  • Origin. A request with no Origin is allowed only once the token is valid (unless MCP_REQUIRE_ORIGIN is set). Any Origin that is not on the allowlist - including the literal null and look-alike hosts such as evil-allowed.com or allowed.com.evil.com - gets 403. Origins are normalized before comparison: the scheme and host are lowercased, the default port is dropped, and a lone trailing slash is ignored (so https://App.Example.com/ matches https://app.example.com). A non-default port is significant. Any Origin carrying userinfo (user@…), a path (other than /), a query, or a fragment is rejected outright - a well-formed Origin header never has those.
  • Body limits. A body over the cap (including a chunked body with no Content-Length), a Content-Encoding body (we do not decompress - 415), deeply nested JSON, an over-long JSON-RPC batch, and malformed JSON/JSON-RPC all return a clean 4xx with a short message and no stack trace.
  • Rate limit - per IP and bearer bucket. Before Origin and bearer auth, POST /mcp is limited to 60 requests per 60 seconds per client IP (from x-real-ip) and per bearer bucket (mcp, platform, or anon for unauthenticated or wrong credentials). GET /health is exempt. Bucket ids are hashed in Redis using MCP_RATE_LIMIT_SALT when set (never a bearer token; unsalted when unset). The counter lives in Upstash Redis over its REST API (INCR + EXPIRE on first hit). Over the limit returns 429 with Retry-After and X-RateLimit-* (no WWW-Authenticate). If Redis is missing or errors, the handler fails open (allows the request and logs ratelimit_unavailable or ratelimit_config_missing with no secrets, tokens, or IPs).
  • No SuiteQL. run_suiteql is off on this transport: it is absent from tools/list and refused if called by name. Every exposed tool is read-only.
  • Stateless, no sessions. The transport issues no Mcp-Session-Id; any request carrying one is rejected (400), so a forged, reused, or foreign session id cannot be replayed.

Recommended Vercel Firewall rules

The Vercel Firewall rate rule is not always enforced in practice (see ARC-52); the Upstash limiter above is the application-level backstop. You can still add edge rules (Project → Firewall):

  • A rate-limiting rule on the /mcp path keyed by IP (for example 60 requests/minute).
  • Optionally restrict /mcp to known client IP ranges, and enable Attack Challenge Mode if abused.
  • Keep Vercel's default body-size limits; the function also caps bodies itself (MCP_MAX_BODY_BYTES).

Deployment hygiene

  • Set ARCAI_MCP_TOKEN for Production only, not Preview. Preview deployments get unique URLs that can leak, so do not hand them a working token.
  • Protect Preview deployments with Vercel Deployment Protection (Settings → Deployment Protection) so they are not publicly reachable.
  • Generate the token with openssl rand -hex 32. Never put a real token in the repo, in vercel.json, in client config committed to git, or in a URL - only in Vercel environment variables (or a local, untracked shell env).

Connecting a client

The token goes in an Authorization: Bearer <token> header. Never put the token in the URL.

Claude Code (passes the header directly):

claude mcp add --transport http ga-finance-mcp https://<your-deployment>/mcp \
  --header "Authorization: Bearer $ARCAI_MCP_TOKEN"

Claude Desktop / Cursor use mcp-remote to bridge a remote HTTP server to a local stdio client. Add this entry inside the existing mcpServers object of claude_desktop_config.json. Do not replace the file. Put the token in an environment variable and reference it - the value below is a placeholder, not a real token:

    "ga-finance-mcp": {
      "command": "npx",
      "args": [
        "-y", "mcp-remote", "https://<your-deployment>/mcp",
        "--header", "Authorization: Bearer ${ARCAI_MCP_TOKEN}"
      ],
      "env": { "ARCAI_MCP_TOKEN": "paste-your-token-here" }
    }

If the file is empty or {}, use the full block:

{
  "mcpServers": {
    "ga-finance-mcp": {
      "command": "npx",
      "args": [
        "-y", "mcp-remote", "https://<your-deployment>/mcp",
        "--header", "Authorization: Bearer ${ARCAI_MCP_TOKEN}"
      ],
      "env": { "ARCAI_MCP_TOKEN": "paste-your-token-here" }
    }
  }
}

If mcp-remote gets 403 or 429 on initialize, it exits and Claude Desktop will not retry until you restart the app (quit and reopen) after the rate limit or origin issue is resolved.

claude.ai / Claude mobile custom connectors are NOT supported. Those add remote MCP servers through a browser and expect the server to run OAuth (dynamic client registration + an authorization flow); they have no way to attach a static bearer token, and this transport does not implement OAuth. Adding OAuth would be a separate change. For now use Claude Code, Claude Desktop (via mcp-remote), or Cursor, all of which can send the Authorization header.

Embedding in a host app

import {
  createNetSuiteMcpServer, EmbeddedBackend, NetSuiteBackend,
  CallbackTokenAuthorizer, startMcpHttpServer, netsuiteUrls,
} from "ga-finance-mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

// 1. Demo mode, in-process
const server = createNetSuiteMcpServer({ backend: new EmbeddedBackend() });
await server.connect(new StdioServerTransport());   // or any MCP transport

// 2. A customer's account, with tokens a host app already manages
const backend = new NetSuiteBackend({
  restBaseUrl: netsuiteUrls("1234567_SB1").restBaseUrl,
  authorizer: new CallbackTokenAuthorizer(async ({ forceRefresh }) => host.getNetSuiteToken(tenantId, { forceRefresh })),
});
const tenantServer = createNetSuiteMcpServer({ backend, toolsets: ["ar", "credit", "insights"] });

// 3. As an HTTP service
await startMcpHttpServer({ backend, auth: { mode: "token", token: process.env.ARCAI_MCP_TOKEN! }, port: 3333 });

A host app can also run it as a child process (npx ga-finance-mcp), which is how desktop MCP clients start it. The package exports everything it uses internally: authorizers (TbaAuthorizer, RefreshingTokenAuthorizer, ClientCredentialsAuthorizer, …), startMockServer and createMockDatabase.

The mock

npx ga-finance-mcp mock --port 3100

| Endpoint | Purpose | |---|---| | POST /services/rest/query/v1/suiteql | Same request and response shape as NetSuite's SuiteQL REST API. Needs OAuth 1.0 TBA or an OAuth 2.0 bearer token. SuiteQL is translated to SQLite. | | GET/POST /app/login/oauth2/authorize.nl | Consent page (PKCE S256). GET always renders the form with a one-time nonce bound to that request (client_id, redirect_uri, state, PKCE, scope); only the Allow POST with the same values issues a code. ?decision= on GET is ignored. | | POST /services/rest/auth/oauth2/v1/token | authorization_code, refresh_token, and client_credentials (verifies the signed JWT against certificates registered with --cert) | | GET /.well-known/oauth-authorization-server, POST /register | OAuth metadata and dynamic client registration, so MCP clients can sign in by themselves | | POST /query/v1/suiteql, GET /record/v1/:type/:id | Compatible with @scottybee84/mock-netsuite (SQLite queries, no auth) |

Demo credentials. These are accepted only by the mock (also shown by ga-finance-mcp info):

  • Account: ARCAI_DEMO
  • OAuth 1.0 TBA: arcai-demo-consumer-key / arcai-demo-consumer-secret, token arcai-demo-token-id / arcai-demo-token-secret
  • OAuth 2.0 client: arcai-demo-client / arcai-demo-secret

Read-only (two layers). The mock is read-only in depth:

  1. Keyword guard - the primary layer. Every path into the database (run_suiteql, the internal query helpers, and the exposed handle's exec/prepare) first runs a guard that rejects anything other than a single SELECT (or WITH … SELECT): INSERT/UPDATE/DELETE, DDL, PRAGMA, VACUUM (so VACUUM INTO cannot write a file), ATTACH/DETACH and REINDEX. This is what stops VACUUM INTO and ATTACH, because a read-only connection does not - VACUUM INTO reads the open database and writes a separate file, so PRAGMA query_only = OFF followed by VACUUM INTO would otherwise copy the database to any host path. node:sqlite exposes no authorizer on the tested versions, so the guard is the enforcement point; the raw DatabaseSync is never handed out. REPLACE() as a string function is allowed; REPLACE INTO / INSERT OR REPLACE are not. Quoted strings and identifiers ('…', "…", […], `…`) are taken as a whole, then -- and /* */ comments are stripped, so neither a quote inside a comment nor -- / /* inside an identifier can hide a DELETE, extra statement or PRAGMA.
  2. Read-only connection - a second layer against writes. The underlying connection is also opened read-only, so a bug that bypassed the guard internally still could not INSERT/UPDATE/DELETE. Because node:sqlite only enforces a read-only connection for a file database (the flag is ignored for :memory:, and a shared-cache in-memory database still accepts writes through a read-only handle on Node 26.12.0), the mock is seeded into a private temp file and reopened with { readOnly: true }; the temp file is unlinked immediately, so nothing lingers on disk. Unlike PRAGMA query_only, this cannot be switched back to writable from SQL. This layer does not stop VACUUM INTO - layer 1 does.

ga-finance-mcp export-db <file> is the one writable path (it writes a SQLite file for @scottybee84/mock-netsuite); the served mock stays read-only. The mock binds to 127.0.0.1 by default.

Your own datasets. SEED=7 CUSTOMERS=200 npm run generate-dataset -- data/acme.json creates a new dataset, and --dataset data/acme.json (or ARCAI_DATASET) uses it. Datasets are plain JSON, so you can tailor one to a prospect's industry.

Using the original mock-netsuite. ga-finance-mcp export-db data.db writes the dataset as a SQLite file that @scottybee84/mock-netsuite can serve. Then use --backend mock-http --mock-url … to connect to it.

Configuration reference

| Variable | Flag | Default | |---|---|---| | NS_BACKEND | --backend | embedded (mock-http and netsuite are the other options) | | ARCAI_DATASET | --dataset | bundled demo dataset | | MOCK_URL | --mock-url | http://127.0.0.1:3100 | | ARCAI_TOOLSETS | --toolsets | all | | NS_ACCOUNT_ID | --account | - | | NS_REST_URL / NS_APP_URL | --rest-url / --app-url | NetSuite's URLs for the account | | NS_MAX_ROWS | | 5000 (hard cap on rows fetched per query). SuiteQL REST pages at 1000 rows; offset must be a multiple of limit; a non-integer limit/offset (e.g. limit=abc, offset=abc) and limit=0 are validation errors. Without SuiteAnalytics Connect, NetSuite itself caps a query at 100,000 rows. Going past NS_MAX_ROWS while more rows remain stops the query (error at any setting, including 1000 or less), rather than silently truncating. run_suiteql's limit argument is a separate user cap and still returns a short page. | | ARCAI_MCP_TOKEN | --token | - (also the bearer token for the Vercel transport, where it fails closed) | | ARCAI_PLATFORM_TOKEN, MCP_RATE_LIMIT_SALT, MCP_PLATFORM_RATE_LIMIT, MCP_ALLOWED_ORIGINS, MCP_REQUIRE_ORIGIN, MCP_RATE_LIMIT, MCP_RATE_WINDOW_MS, MCP_MAX_BODY_BYTES, MCP_MAX_BATCH, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN, KV_REST_API_URL, KV_REST_API_TOKEN | | Vercel HTTP transport only - see Deploy on Vercel | | auth variables | | see Authentication |

Development

npm install
npm run build        # TypeScript → dist/
npm test             # mock, auth, every tool, journal entries, bank deposits, general ledger, SuiteQL parity, OAuth flows, HTTP auth, the hardened Vercel transport, CLI, toolset prompts
npm run smoke        # drives the built CLI over stdio
npm run smoke:http   # drives the compiled hardened HTTP transport (dist/vercel.js) with a bearer token
npm run dev -- demo  # run from source

The tests run every tool twice, once against the built-in SQLite path and once through the full NetSuite path (SuiteQL REST with OAuth 1.0 signing, against the mock), and check that both return the same answers.

CI

Pull requests and pushes to main run typecheck, tests, build, and the stdio and HTTP smoke tests on Node 22 and 26 (.github/workflows/ci.yml). The workflow uses the built-in mock only; it does not use secrets or contact a live NetSuite account.