MCP4Acumatica — Azure App Service Hosting Guide
How to run MCP4Acumatica on Azure App Service (Linux, Node.js) with Azure Table Storage and Azure Blob Storage, instead of Cloudflare Workers.
This is a full alternative host, not a shim. Every capability of the Cloudflare deployment is present: all 50 tools, per-user Acumatica OAuth, the canary-GI access gate, the consent interstitial, sensitive-field redaction, rate limiting, durable audit logs, and transparent re-auth when a refresh token dies.
Why this is a port and not a recompile
The Cloudflare deployment is built on primitives that exist nowhere else, so four of them had to be replaced rather than retargeted:
| Cloudflare | Azure replacement | Where |
|---|---|---|
| Workers KV | Azure Table Storage | src/platform/azure/azure-table-kv-store.ts |
| R2 buckets | Azure Blob Storage (audit logs + schema index) | src/platform/azure/azure-blob-store.ts |
TokenManager Durable Object |
in-process coalescing + a Table Storage lease | src/platform/azure/locking-token-provider.ts |
@cloudflare/workers-oauth-provider |
a self-hosted OAuth 2.1 server | src/oauth/ |
McpAgent Durable Object (one per session) |
in-process session map + StreamableHTTPServerTransport |
src/mcp/session-manager.ts |
Everything above the storage line is shared source, not a copy — the tool registry, the redaction and audit pipeline, the access gate, the login pages, and the docs site are single implementations used by both hosts. That is deliberate: the tool descriptions and the redaction rules are the two places where a silent divergence between hosts would do real damage.
The pieces that remain Cloudflare-only are the admin console
(src/admin/admin-handler.ts) and Logpush integration. See
Not yet ported.
Prerequisites
- An Azure subscription with permission to create a resource group, an App Service plan, a web app, and a storage account.
- The Azure CLI (
az), logged in:az login. - Node.js 20 or newer locally, to build the bundle. (App Service itself now offers
NODE:24-lts; Node 20 has been retired from the platform, soaz webapp createrejects it. Check current options withaz webapp list-runtimes --os-type linux.) - Acumatica-side setup, identical to the Cloudflare deployment — it is not
optional, and the server cannot create any of it for you:
- A Connected Application (SM303010) with the Authorization Code flow
enabled. Its redirect URI must be
https://<your-app>/callback. - The
MCPAccesscanary Generic Inquiry (SM208000), exposed via OData, readable only by the users who should have AI access. Without it, every login fails the access gate. See architecture. - Optionally but strongly recommended, the GI gate feeds (
MCPGIs,MCPGIFields) fromacumatica/. See generic inquiries.
- A Connected Application (SM303010) with the Authorization Code flow
enabled. Its redirect URI must be
Note on the Acumatica VM. Your Acumatica instance can run anywhere the App Service can reach it over HTTPS, including an Azure VM. What matters is that the instance's public HTTPS URL is what you configure as
ACUMATICA_URL, and that its certificate is valid — the server makes ordinary outbound HTTPS calls and does not skip certificate validation. If Acumatica is reachable only inside a VNet, see Private networking.
1. Create the Azure resources
Adjust the names, then run:
az group create --name mcp4acumatica-rg --location eastus
az storage account create --name mcp4acustore --resource-group mcp4acumatica-rg --location eastus --sku Standard_LRS --min-tls-version TLS1_2 --allow-blob-public-access false
az appservice plan create --name mcp4acumatica-plan --resource-group mcp4acumatica-rg --is-linux --sku B1
az webapp create --name mcp4acumatica --resource-group mcp4acumatica-rg --plan mcp4acumatica-plan --runtime "NODE:24-lts"
Storage account names must be globally unique, 3–24 lowercase alphanumeric
characters. The web app name becomes https://<name>.azurewebsites.net.
On the B1 tier: anything smaller (F1/D1) has no Always On and gets
recycled aggressively, which drops MCP sessions mid-conversation. B1 is the
realistic floor.
2. Configure the app
Generate the encryption key — it must be exactly 64 hex characters, and the server refuses to start otherwise rather than failing later with unreadable "please reconnect" loops:
openssl rand -hex 32
Then set the application settings:
az webapp config appsettings set --name mcp4acumatica --resource-group mcp4acumatica-rg --settings ACUMATICA_URL="https://your-instance.example.com" ACUMATICA_TENANT="YourTenant" ACUMATICA_ENDPOINT_VERSION="25.200.001" ACUMATICA_CLIENT_ID="<from SM303010>" ACUMATICA_CLIENT_SECRET="<from SM303010>" COOKIE_ENCRYPTION_KEY="<the 64 hex chars>" ADMIN_SECRET="<a long random string>" PUBLIC_URL="https://mcp4acumatica.azurewebsites.net" AZURE_STORAGE_ACCOUNT="mcp4acustore" WEBSITE_RUN_FROM_PACKAGE="0"
Turn on Always On and pin the startup command:
az webapp config set --name mcp4acumatica --resource-group mcp4acumatica-rg --always-on true --startup-file "node dist/server.mjs"
Grant the app access to storage (managed identity — recommended)
This is the preferred path: no storage key ever lives in configuration.
az webapp identity assign --name mcp4acumatica --resource-group mcp4acumatica-rg
PRINCIPAL=$(az webapp identity show --name mcp4acumatica --resource-group mcp4acumatica-rg --query principalId -o tsv) && SCOPE=$(az storage account show --name mcp4acustore --resource-group mcp4acumatica-rg --query id -o tsv) && az role assignment create --assignee "$PRINCIPAL" --role "Storage Table Data Contributor" --scope "$SCOPE" && az role assignment create --assignee "$PRINCIPAL" --role "Storage Blob Data Contributor" --scope "$SCOPE"
Role assignments can take a couple of minutes to propagate. If the app logs
AuthorizationPermissionMismatch on first boot, wait and restart it.
Alternative — connection string. Simpler, but puts a key in app settings.
Set AZURE_STORAGE_CONNECTION_STRING instead of AZURE_STORAGE_ACCOUNT:
az webapp config appsettings set --name mcp4acumatica --resource-group mcp4acumatica-rg --settings AZURE_STORAGE_CONNECTION_STRING="$(az storage account show-connection-string --name mcp4acustore --resource-group mcp4acumatica-rg --query connectionString -o tsv)"
If neither is set the server starts with an in-memory store and says so loudly. Every restart then invalidates all issued MCP tokens and stored Acumatica refresh tokens. That mode is for local development only.
3. Build and deploy
npm ci && npm run build
Deploy the app root — dist/, node_modules/, package.json, and the markdown
that the docs site reads:
npm run deploy:azure
That script is a thin wrapper around az webapp deploy; see
azure/deploy.sh for what it packages and how to override the app name. For
CI, .github/workflows/azure-deploy.yml does the same on push.
4. Point Acumatica at the deployment
In SM303010, set the Connected Application's redirect URI to exactly:
https://mcp4acumatica.azurewebsites.net/callback
Every hostname users connect through needs its own entry — if you later add a custom domain, add that callback URL too.
Scopes are not configured on the Connected Application (SM303010 has no
scope field). The server requests api openid profile email offline_access in
the authorize URL. offline_access is required: without it Acumatica issues no
refresh token and every session dies when its ~1-hour access token expires.
5. Verify
Health check. Since 0.42.0 it returns only {"status":"ok"}; the storage
backend, instance URL and tenant are in the startup log (az webapp log tail)
and in /preflight:
curl -s https://mcp4acumatica.azurewebsites.net/health
Full configuration diagnostics — this probes instance reachability, OIDC
discovery, the Connected Application credentials, the tenant OData path, and the
contract endpoint version. It requires ADMIN_SECRET because the results name
which settings are missing:
curl -s -H "Authorization: Bearer $ADMIN_SECRET" https://mcp4acumatica.azurewebsites.net/preflight
Confirm the OAuth server is discoverable:
curl -s https://mcp4acumatica.azurewebsites.net/.well-known/oauth-authorization-server
Then add https://mcp4acumatica.azurewebsites.net/mcp as a custom connector in
Claude and complete the Acumatica login. Live logs:
az webapp log tail --name mcp4acumatica --resource-group mcp4acumatica-rg
Configuration reference
Required
| Setting | Notes |
|---|---|
ACUMATICA_URL |
Instance base URL, no trailing slash |
ACUMATICA_TENANT |
Tenant/login company, used for the OData GI path |
ACUMATICA_CLIENT_ID |
From the Connected Application (SM303010) |
ACUMATICA_CLIENT_SECRET |
From the Connected Application |
COOKIE_ENCRYPTION_KEY |
Exactly 64 hex chars. Encrypts refresh tokens at rest — rotating it invalidates every stored token |
Storage (one of)
| Setting | Notes |
|---|---|
AZURE_STORAGE_ACCOUNT |
Account name; uses managed identity. Recommended |
AZURE_STORAGE_CONNECTION_STRING |
Takes precedence if both are set |
AZURE_TABLE_NAME |
Default mcp4acumatica |
AZURE_LOGS_CONTAINER |
Default mcp4acumatica-logs, created if absent |
AZURE_INDEX_CONTAINER |
Default mcp4acumatica-index, never auto-created |
Optional
| Setting | Default | Notes |
|---|---|---|
PUBLIC_URL |
derived per request | Pins the OAuth issuer and callback origin. Recommended in production |
PORT |
8080 |
App Service sets this |
ACUMATICA_ENDPOINT_VERSION |
25.200.001 |
Contract API version |
ACUMATICA_ENDPOINT_NAME |
Default |
Only for a custom endpoint (SM207060) |
ACUMATICA_MAX_RECORDS |
1000 |
Row cap per query |
ACUMATICA_CANARY_GI |
MCPAccess |
Access-gate GI name |
ACUMATICA_WRITES_ENABLED |
unset (off) | true enables the write tools |
REDACT_PATTERNS |
— | Extra field-name patterns to redact |
REDACT_SKIP |
— | Field-name patterns to exempt from redaction |
ADMIN_SECRET |
— | Bearer token for /preflight. Without it /preflight returns 503 |
MCP_ACCESS_TOKEN_TTL_SECONDS |
3600 |
MCP access-token lifetime; refresh tokens rotate |
MCP_ALLOWED_CLIENT_IDS |
unset (not enforced) | Comma- or space-separated CIMD client_id URLs allowed to connect. Setting this or the next variable turns the client allowlist on. See Client allowlist |
MCP_ALLOWED_REDIRECT_HOSTS |
unset (not enforced) | Comma- or space-separated hostnames an authorization code may be sent to (exact match, e.g. claude.ai localhost) |
MCP_MAX_SESSIONS_PER_USER |
10 |
Concurrent MCP sessions per user. At the cap, that user's least-recently-used session is closed to make room |
MCP_GRANT_MAX_LIFETIME_DAYS |
90 |
Absolute lifetime of a connection (an MCP grant), however often it is refreshed. After it, the user signs in again and passes the access gate and consent page again |
Operational notes
Run a single instance, or add sticky routing
MCP over streamable HTTP is a session protocol: after initialize, the
client's follow-up requests carry an mcp-session-id that must reach the same
process. Cloudflare gets this for free because a Durable Object has a stable
address; here sessions live in the instance's memory.
On a single instance — the default — this is automatic. If you scale out, enable ARR affinity so a client sticks to one instance:
az webapp update --name mcp4acumatica --resource-group mcp4acumatica-rg --client-affinity-enabled true
Without it, a request routed elsewhere gets a 404 Session not found and the
client silently re-initializes — recoverable, but it drops in-flight context.
Note that token refresh is safe to scale out regardless: it is serialized by a Table Storage lease, not by process memory. That matters because Acumatica rotates the refresh token on every use, so two concurrent refreshes would otherwise race and one would be wrongly treated as permanently dead.
Client allowlist
Anyone can register an OAuth client with this server (Dynamic Client
Registration) or publish a CIMD document, and then send a user a link to
/authorize. If the user signs in and clicks Continue, the authorization
code goes wherever that client said. Two defences, added in 0.42.0:
The consent page always shows who is asking: the client's self-declared name, the host that publishes its
client_id(or "dynamic registration"), and the host the access will be sent to. It warns for self-registered clients, and warns more strongly for clients it does not recognise (not Claude's CIMD URLs, and not sending to a known host).An optional allowlist. Set
MCP_ALLOWED_CLIENT_IDSand/orMCP_ALLOWED_REDIRECT_HOSTSto enforce it. A client is then allowed when itsclient_idis listed or the redirect URI it is using has a listed host; anything else is refused at/authorize(403) and DCR refuses unlisted redirect hosts at/register. If only one of the two variables is set, the other uses the built-in defaults:- client IDs:
https://claude.ai/oauth/mcp-oauth-client-metadata,https://claude.ai/oauth/claude-code-client-metadata - redirect hosts:
claude.ai,claude.com,localhost,127.0.0.1,[::1]
So
MCP_ALLOWED_REDIRECT_HOSTS="claude.ai claude.com localhost 127.0.0.1"limits the server to Claude's clients. Test with each client your users have (Claude.ai, Claude Desktop, Claude Code) before relying on it. The startup log showsclients: allowlist ENFORCEDwhen it is on.- client IDs:
The same variables work on Cloudflare (set them as vars); there the check runs
in the /authorize handler, since registration is handled by the Cloudflare
OAuth library.
Other security behaviour (0.42.0)
- Access is re-checked on every Acumatica token refresh (roughly hourly per user), not only at login. A 403 on the canary GI deletes the user's stored token and revokes their MCP grants. A 404, 5xx or timeout leaves the session alone, so an Acumatica outage does not log everyone out.
- A login with no resolvable Acumatica username is refused (a "Could not identify your account" page) rather than being filed under a shared or random key.
- The GI gate fails closed once it has ever been active. The first
successful registry build writes a
gi_gate:activerow (no expiry). After that, if no registry can be loaded or rebuilt, every GI is denied instead of the gate reverting to "inactive". To retire the gate on purpose, delete that row from the table. Users can no longer cleargi_registrywithacumatica_clear_cache. - Request limits.
/register,/token,/revokeand/consentaccept at most 16 KB, and/mcpat most 1 MB (413 beyond that). DCR accepts at most 5redirect_urisof up to 2,048 characters each and aclient_nameof up to 100 characters. A registration nobody completes a login for expires after 24 hours. - Tokens at rest are encrypted. Both the Acumatica access and refresh
tokens (and the short-lived pending-consent copy) are AES-256-GCM encrypted
under
COOKIE_ENCRYPTION_KEY, bound to the row they are stored in. RotatingCOOKIE_ENCRYPTION_KEYtherefore signs every user out of Acumatica (they reconnect once). Rows from 0.41.x are read and rewritten on first use. - One-time OAuth values are atomic, and refresh-token reuse revokes. Authorization codes and refresh tokens are consumed with an etag-conditional delete. Presenting a refresh token that was already used revokes the grant, so a client that retries a refresh after a network error may be asked to reconnect. That is the OAuth 2.1 trade-off for detecting a stolen token.
- Timeouts. Acumatica token refresh 10 s, refresh-time access re-check 5 s, API calls 55 s. The refresh lease is 30 s and is only released by its holder.
- Response headers. Every response carries
X-Content-Type-Options: nosniffand, over https,Strict-Transport-Security: max-age=31536000. HTML responses also carryX-Frame-Options: DENY,Referrer-Policy: no-referrerand a CSP withframe-ancestors 'none', unless the page sets its own (the docs site does).
Expired rows are swept, not auto-expired
Table Storage has no native TTL. Rows carry an expiresAt column; reads treat an
expired row as absent, and a sweeper runs every 15 minutes to reclaim the rest.
Without the sweeper the per-minute rate-limit buckets would accumulate forever.
Audit logs
Tool invocations, redaction events, auth events (login, denial, consent,
access_revoked; since 0.42.0, before which they went to stdout only), and write
mutations are written as NDJSON to the logs container under do-logs/{date}/, batched (25 entries or
15 seconds) to keep the blob count manageable. The batch is also flushed on
SIGTERM, so a deploy does not lose the tail of the trail.
Everything is additionally written to stdout, which App Service captures — use
az webapp log tail for live debugging and the blobs for the durable record.
Cost
At rest this is the App Service plan plus a few cents of storage. B1 is around
$13/month at the time of writing; Table and Blob usage for a small team is
negligible. Compare with Cloudflare, where Logpush requires the $5/month Workers
Paid plan.
Private networking
If Acumatica is reachable only inside a VNet, enable VNet integration on the web app and ensure DNS resolves the instance hostname from within it:
az webapp vnet-integration add --name mcp4acumatica --resource-group mcp4acumatica-rg --vnet <vnet-name> --subnet <subnet-name>
The server needs outbound access to the Acumatica instance, to Azure Storage,
and — for CIMD clients such as Claude.ai — to the public internet to fetch the
client's metadata document. That last fetch is deliberately restricted to public
HTTPS addresses; the guard in src/oauth/clients.ts refuses anything resolving
to a private or link-local address, which notably blocks the instance metadata
service at 169.254.169.254.
Not yet ported
- Admin console (
/docs/adminon Cloudflare) — the settings editor, log viewer, and preflight page./preflightis available here as JSON; runtime config can still be changed by writingconfig:*rows directly to the table, and audit logs can be read from the blob container. The console itself is 1,100 lines of Cloudflare-specific code and was left out of this port. - Logpush — Cloudflare-specific. Azure equivalents are App Service diagnostic settings or Application Insights; the durable NDJSON trail in Blob Storage is independent of either.
/install.sh— the one-line installer bootstraps a Cloudflare deploy, so it is not served here.
Troubleshooting
| Symptom | Cause |
|---|---|
Startup fails: COOKIE_ENCRYPTION_KEY must be 64 hex characters |
The key is not 32 bytes of hex. Regenerate with openssl rand -hex 32 |
Startup logs using an IN-MEMORY store |
Neither storage setting is configured |
AuthorizationPermissionMismatch |
Managed-identity role assignments have not propagated yet, or were never made |
| Login ends on "Access Denied" | The user cannot read the canary GI. This is the gate working — grant access in Acumatica |
| Login ends on "Configuration Error" | The canary GI is missing, not OData-exposed, or ACUMATICA_TENANT is wrong. Run /preflight |
| Token exchange error page | Connected Application misconfigured — wrong secret, or the redirect URI does not match exactly |
| Claude reconnects repeatedly | Check for token_resolve_outcome entries in the logs; reason: decrypt_failed means COOKIE_ENCRYPTION_KEY changed |
404 Session not found |
The instance restarted, the session was idle >30 min, or you scaled out without ARR affinity |
| Schema tools missing from the tool list | Expected when no schema index is uploaded. Build it with npm run build-schema-index and upload schema-index.json to the index container |
| Every entity tool 404s | ACUMATICA_ENDPOINT_VERSION names a Default endpoint version your instance does not have. See the warning below — do not infer it from the release |
invalid_client at the token exchange, with credentials that look right |
The Connected Application's shared secret was never saved. See below |
| Preflight's OData tenant check times out, but login works | The check allows 5s; a cold Acumatica OData endpoint can take 10s+. Re-run it, or confirm with a real login |
az reports ResourceNotFound for a resource whose ID is obviously correct |
Git Bash rewrote the /subscriptions/... argument into a Windows path. Prefix the command with MSYS_NO_PATHCONV=1 |
CI deploy fails: Publish profile is invalid for app-name and slot-name provided |
Not a bad profile. Azure disables basic publishing credentials by default on new App Services, so those credentials are rejected outright. See below |
Field notes from a first production deployment
Every item here cost real time on a live 2025 R1 instance. None is obvious from the Acumatica UI, and most fail silently rather than with an error.
The endpoint version is not the release version
A 2025 R1 instance (build 25.101.0153) exposed no Default endpoint above
24.200.001. Neither 25.200.001 (this repo's default) nor 25.100.001 (the
intuitive guess for R1) existed. Read the real value from SM207060 — and note
that probing /entity/Default/{version}/ proves nothing, because instances
routinely return 401 for every path under /entity/ whether or not the version
exists.
A Connected Application secret does not exist until you click Save
Acumatica → SM303010 → SECRETS → ADD SHARED SECRET shows the generated value
immediately. If you copy it and navigate away without saving the record, Acumatica
discards it. You are then holding a perfectly real-looking secret that the server
has never heard of, and every token exchange returns invalid_client.
Copy the value with the field focused (Ctrl+A, Ctrl+C — not a drag-select,
which can truncate), then Save, then confirm a masked row appears in the grid.
Publishing a GI to the UI clears "Expose via OData"
Acumatica refuses to expose a Generic Inquiry over OData until the inquiry is published to the UI ("You should make the screen visible in the UI first"). But PUBLISH TO THE UI resets the Expose via OData checkbox. The working order is:
- Build the inquiry (title, data source, results grid)
- PUBLISH TO THE UI
- Re-tick Expose via OData
- Save
Skipping step 3 produces a canary GI that exists, looks correct, and still makes the access gate return 404. Verify by reopening the Inquiry Title lookup and confirming the OData column is ticked — the lookup is the only place the truth is visible at a glance.
Note the consequence: the canary GI necessarily gets a site-map entry. Restrict it
with the MCP Access role rather than leaving it broadly visible.
The client_id carries an @tenant suffix
Acumatica's OAuth client_id is {guid}@{tenant login name}, and the SM303010
field truncates it visually at the @. The bare GUID is rejected. If the tenant
login name contains spaces (e.g. Prod Copy 13Feb2025 - Standard Testing), the
whole string including spaces is the client_id — quote it when setting app settings,
and never pass it through a PowerShell command line unquoted.
Claude Desktop requires HTTPS
Its custom-connector UI rejects http://localhost:... outright ("URL must start
with 'https'") with no loopback exception. For local testing, use the
mcp-remote stdio proxy in
claude_desktop_config.json. Once deployed behind a real certificate, add the
server through the native Connectors UI and remove the proxy entry.
Publish-profile deploys need basic auth, which Azure disables by default
Since 0.42.0 the workflow runs in two jobs:
build(all npm code, no secrets) anddeploy(holds the publish profile, runs no npm or repository code, only downloads the packaged artifact). Keep it that way if you edit the workflow: a secret visible to a job that runsnpm ciis visible to every dependency. OIDC federated credentials remain the better model; see the comments at the top of.github/workflows/azure-deploy.yml.
.github/workflows/azure-deploy.yml can deploy on push, but the publish-profile
credential model depends on basic publishing credentials, and new App Services
ship with them off:
az resource show -g <rg> --name scm --namespace Microsoft.Web \
--resource-type basicPublishingCredentialsPolicies \
--parent sites/<app> --query properties.allow
If that returns false, azure/webapps-deploy fails with "Publish profile is
invalid for app-name and slot-name provided" — wording that points at the profile
rather than the policy, which sends you re-generating a profile that was never the
problem.
Enabling basic auth creates a long-lived credential with full deploy rights to a
server holding live ERP access, stored in a GitHub secret rather than behind your
MFA. For infrequent deploys, npm run deploy:azure from a workstation
authenticates as you and is the better trade; for real CI/CD, use OIDC federated
credentials instead of a publish profile. The workflow header documents all three
options.
A Private DNS zone shadows the entire domain
If you route traffic to Acumatica privately via an Azure Private DNS zone, that
zone becomes authoritative for the whole domain inside the VNet — it does not
fall back to public DNS. Any *.yourdomain record that is not mirrored into the
zone returns NXDOMAIN for every VM in that VNet.
Enumerate the real public records first and mirror all of them. In one case this
silently broke an unrelated internal service (api.<domain>) for every server in
the VNet. VNet integration alone changes routing, not resolution, so this is only
worth doing if you actually intend to restrict Acumatica's public endpoint.
Relationship to the Cloudflare deployment
Both hosts can run against the same Acumatica instance simultaneously — they share nothing but Acumatica itself. Each needs its own callback URL registered on the Connected Application, and each maintains its own token store, so a user connecting to both authorizes twice.
For the platform-agnostic design this port is built on — IKeyValueStore,
IBlobStore, ITokenProvider, and AppEnv — see the
self-hosting guide and
architecture.