Skip to main content
Glama
nfw-audit-mcp

nfw-audit-mcp

Official
by nfw-run
README.md
# nfw-audit-mcp

The MCP server of [NFW Web Studio](https://www.nfw.run), a web studio in Verona, Italy. It is the free website audit the studio runs on its own clients' sites, and the monthly State of the Web data (every business website of a city, measured), as tools an AI assistant can call. There is no pro version: everything the scanner measures is in the free answer.

- **Public address:** `https://mcp.audits.nfw.run` (Streamable HTTP, stateless, JSON answers), served by nginx straight to this server. It also serves the OAuth discovery documents (the protected resource metadata, `/.well-known/oauth-protected-resource`) and its server card (`/.well-known/mcp/server-card.json`).
- **Version:** 1.13.1 (the `version` of `package.json`, the one place it is written).
- **Source of truth:** the website. The tools, their descriptions and their answers are the website's, ported here as they were; its texts, prices and methodology are read from it at runtime (see "Content documents"); which sites opted out is the backend's to say (see "Opt out").

The scanner measures the home page only, and the AI Crawlability Score is NFW Web Studio's own measure, not an industry standard. The server's `get_methodology` tool says what the figures do not measure.

## Connect

**Quick start:** add `https://mcp.audits.nfw.run` as a remote MCP server (Streamable HTTP) in your client and sign in. Every call needs a credential, free of charge: sign in with OAuth, or make an API key at <https://www.nfw.run/account#keys>.

- **Claude** (Settings, Connectors, add a custom connector): the URL `https://mcp.audits.nfw.run`, then sign in. For a key instead, choose no sign in and add the header `X-API-Key: <your key>`.
- **ChatGPT** (Settings, Connectors, developer mode, add a connector): the URL `https://mcp.audits.nfw.run`, with OAuth.
- **Claude Code:**

  ```sh
  claude mcp add --transport http nfw-audit https://mcp.audits.nfw.run --header "X-API-Key: <your key>"
  ```

- **Any other client:** send the key as `X-API-Key: <key>` or `Authorization: Bearer <key>`, or add `?key=<key>` to the address for a client that only takes an address. An OAuth access token goes in `Authorization: Bearer` only, never in the query string or in `X-API-Key`. The OAuth sign in is the backend's (`https://auth.nfw.run/account`); this server's protected resource metadata, which names it, is `https://mcp.audits.nfw.run/.well-known/oauth-protected-resource`. A token is bound to this server's resource, `https://mcp.audits.nfw.run`.

A call with no credential is a `401` with a `WWW-Authenticate: Bearer resource_metadata=...` challenge, which is how an OAuth client finds the sign in. A bad or revoked credential is a `401` with `error="invalid_token"`. A backend that cannot answer is a `503`, never a `401`. Keys made before 26 November 2026 keep working until they are revoked or go a year unused.

Help: <https://www.nfw.run/account/support> or support@nfw.run.

## Tools

| Tool | What it does |
| --- | --- |
| `start_audit` | Queues a free audit of a website's home page and returns a request id. |
| `get_audit` | Reads an audit: the Lighthouse scores, the AI Crawlability Score point by point, every check with its fix, what the site runs on, and the detail of each check. |
| `run_check` | Runs one single check of one page (spam lists, certificate, structured data, llms.txt, robots.txt and sitemap, redirects, meta tags, speed, technologies, broken links). |
| `get_check` | Reads a single check started with `run_check`. |
| `find_audit` | Finds the latest public audit of a site by its host. |
| `search_divisions` | Finds places (country, region, county, city) by name. |
| `find_scan` | Finds the State of the Web scans of a place. |
| `get_scan` | Reads a scan: businesses and websites covered, average and median scores, the archive (DOI) and a citation line. |
| `get_ai_crawlability_score_rules` | Every ruleset of the AI Crawlability Score with the weight of each point. |
| `get_scan_breakdown` | A scan cut by sector, technology, consent, content, security, channels, contacts or forms. |
| `rank_places` | Ranks places on one figure of their report. |
| `compare_places` | Compares two places on the same scanner version, in words. |
| `get_trend` | One figure of a place month after month, per scanner version. |
| `get_methodology` | How the State of the Web is measured, with its sources and limits. |
| `get_prices` | NFW Web Studio's starting prices. |
| `request_quote` | Passes a person's request to be contacted or quoted, only after their explicit consent. |

The authoritative list, with every description and input schema, is `src/mcp/definitions.ts`; a test keeps this table in step with it. The server also offers five prompts (`audit_my_site`, `explain_a_city_report`, `pitch_a_sector`, `compare_two_places`, `how_far_can_i_trust_this`) and the methodology as resources (`nfw://methodology`, `nfw://methodology/data-source`, `nfw://methodology/layers`, `nfw://methodology/ai-crawlability-score`, `nfw://methodology/limits`).

We do not sell data to third parties: not the audits you request, not quote requests, not accounts or API keys. Everything is stored on our servers in the European Union.

## Content documents

The server answers with the website's own words, so it reads them from the website instead of keeping a copy: six versioned JSON documents at `<MCP_CONTENT_BASE_URL>/api/mcp-content/v1/<name>.json`, listed by `index.json`.

| Document | What it holds | Read by |
| --- | --- | --- |
| `site` | Site constants, where a key is made, the public address of every page the answers link, address templates | every tool that links a page |
| `audit-checks` | The words of every check of an audit and the catalog of the single check tools | `get_audit`, `run_check` |
| `ai-crawlability-score` | The name, pass condition and reason of each point of the score | `get_audit` |
| `prices` | The starting prices, in both languages | `get_prices` |
| `methodology` | The methodology of the State of the Web, in both languages | `get_methodology`, the resources, citations |
| `contact` | The consent sentence of the contact form, the privacy policy address, the field limits | `request_quote` |

The client (`src/content/client.ts`) keeps each document in memory with its `ETag` and follows the website's `Cache-Control`: fresh for `max-age` less the `Age` it arrived with, then, inside `stale-while-revalidate`, the copy is returned at once and refreshed in the background (`no-cache` revalidates every time, `no-store` keeps no copy). It revalidates with `If-None-Match`, asks for one document once at a time, serves the last good copy (and reports it once, see "Analytics and warnings") if the website cannot be reached, answers "temporarily unavailable" when it holds none (it never invents content, and does not ask again for 10 seconds), and refuses a `schemaVersion` it does not know or a body that is not JSON. A methodology topic the server does not know is ignored, so a new one on the website never fails the document. The refusals of the audit service and the 401 need nothing from the website: the address of the keys page and the audits mailbox are written in `src/mcp/keysUrl.ts` (a drift from the `site` document is a startup warning).

## Opt out

The owner of a site can ask to stay out of the public audit. The list is the backend's: before a tool takes a site, it asks `POST {BACKEND_URL}/website/v1/opt-outs/check` (`Authorization: Bearer $MCP_SERVER_API_TOKEN`, body `{ "sites": [...] }`, up to 100 sites, answered in input order as `{ ok: true, results: [{ site, optedOut, invalid? }] }`). The site sent is the site key (the host in lower case, without `www.`). `start_audit`, `run_check`, `get_audit`, `get_check` and `find_audit` use it, and `find_audit` filters the public list with it in batches of 100. An opted out site is always the same answer (`The owner of this site asked not to appear in the public audit...`). Each site's answer is kept for 60 seconds (bounded). If the backend cannot answer, the check fails open and sends the warning `opt_out_check_failed`, because the dashboard enforces the opt out itself: it refuses a new audit with a 403 (`opted_out`, which this server turns into the same answer) and hides opted out audits on reads.

## Environment

Copy `.env.example` to `.env`. Node 20.20 or later, or 22.22 or later (the PostHog SDK needs it).

| Variable | Default | What it is |
| --- | --- | --- |
| `HOST` | `127.0.0.1` | Where the server listens. Keep it on localhost behind a reverse proxy. |
| `PORT` | `3100` | The port. |
| `BACKEND_URL` | `https://dashboard.nfw.run` | The dashboard the audits, scans and credential checks go to. |
| `MCP_SERVER_API_TOKEN` | none | The server's own backend token: a dedicated token accepted only on the introspection, public scans, tools, contact leads and opt out check routes. There is no fallback to any other token. Without it credentials cannot be checked. The client address the server relays is only ever `key:<id>` or `user:<id>`. |
| `PUBLIC_ORIGIN` | `https://mcp.audits.nfw.run` | This server's public origin, no trailing slash. The resource is `PUBLIC_ORIGIN` itself, the endpoint is the host root; the 401 challenge, the metadata and the server card use it. |
| `NFW_OAUTH_ISSUER` | `https://auth.nfw.run/account` | The authorization server the protected resource metadata names. |
| `MCP_CONTENT_BASE_URL` | `https://www.nfw.run` | Where the content documents are read from. |
| `MAX_CONNECTIONS` | `1024` | Most connections open at once; beyond it a connection is refused at the socket. |
| `POSTHOG_PROJECT_TOKEN`, `POSTHOG_HOST` | none | Optional: PostHog MCP analytics and the server's warnings (see "Analytics and warnings"). Anonymous: no session, no person profile, no IP, never a tool's arguments or answer. |
| `MCP_DEBUG` | none | Set to `1` for local work: prints the details of warnings to stderr. Leave it unset on a server: the process prints nothing. |
| `TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHANNEL_ID` | none | Optional: an anonymous ping, with no personal data, when a quote request is stored. |

## Analytics and warnings

This process prints nothing to stdout or stderr in normal operation: no access lines, no warnings. Only a fatal error that stops it at start is printed (with the pm2 configuration in `deploy/ecosystem.config.cjs`, that one line goes to `logs/error.log`, the only log file). `MCP_DEBUG=1` prints details for local work.

With `POSTHOG_PROJECT_TOKEN` and `POSTHOG_HOST` set, one PostHog client (`posthog-node` 6.2.0, used by nothing else) carries two things. Nothing is sent when they are unset, in tests, or with `NODE_ENV=development`.

**MCP analytics**, from PostHog's SDK (`@posthog/mcp` 1.8.2, `instrument` on the server of each request, `src/mcp/analytics.ts`). Anonymous events only, to measure performance and feature use. No session, no person, nothing a caller typed. `beforeSend` keeps only the events and property names in `ALLOWED_PROPERTIES` and drops everything else, so a field a future SDK version adds is never sent (a test pins every captured event to the list). The events land in the ordinary events table. All of them carry the properties of the first row.

| Event | When | Properties |
| --- | --- | --- |
| every event below | | `$mcp_server_name`, `$mcp_server_version` (our software), `$ip: null`, `$geoip_disable: true`, `$process_person_profile: false` |
| `$mcp_tool_call` | every tool call | `$mcp_tool_name`, `$mcp_duration_ms`, `$mcp_is_error`, `$mcp_error_type`, `$mcp_input_keys` (argument names only, never values; a name the tool does not declare is `[redacted]`), plus ours: `outcome` (`ok`, `stored`, `consent_required`, `rate_limited`, `refused`, `invalid_input`, `error`) and `status` (the answer's, when it has one) |
| `$mcp_initialize` | the handshake | `$mcp_client_name`, `$mcp_client_version` (each only when it looks like a name, `[\w .\-/()+]`, 60 characters at most, else `other`), `$mcp_protocol_version`, `$mcp_duration_ms` |
| `$mcp_tools_list` | `tools/list` | `$mcp_listed_tool_names`, `$mcp_duration_ms`, `$mcp_is_error` |
| `$mcp_resources_list` | `resources/list` | `$mcp_duration_ms`, `$mcp_is_error` |
| `$mcp_resource_read` | a methodology resource is read | `$mcp_resource_name` (the `nfw://` address, only one of ours), `$mcp_duration_ms`, `$mcp_is_error` |
| `$exception` | a tool that threw | `$exception_list` (per entry the error type and the stack frames only: function, file path inside the app (`src/...` or `node_modules/<package>/...`, never an absolute path), line and column; the message is always replaced by `[message removed]`, and no source line or variable value is sent), `$exception_level`, `$mcp_tool_name`; a refusal (`ok: false`) and a call whose arguments failed validation are answers, not exceptions, and send none |

Every event has the one `distinct_id` `mcp-server`: never per session, key, user or client. There is no `identify`, no `$set`, no person profile, no IP address and no GeoIP. Never sent: a session id (`$session_id`, `$mcp_session_source`, `$window_id`, any property whose name says session, window or conversation), the tool's arguments (`$mcp_parameters`) or answer (`$mcp_response`), the audited site, an intent, a conversation id, a model name, the client's user agent or any other raw header value. Not sent at all: events for an unknown tool name, prompts and feedback (they carry a name the caller chose). The SDK options that add an argument to every tool are off, so the tool list is exactly the website's.

**No session header.** The server is stateless and sends no `Mcp-Session-Id`. The SDK mints one at `initialize` and puts it on the answer, and it has no option to stop that, so `withoutSessionHeader` in `src/mcp/route.ts` removes it from every answer of the transport before it leaves; a request that sends the header is answered as before (the stateless transport ignores it). `test/mcp-analytics.test.ts` checks both, and fails if the stripping is removed.

**Warnings**, one `mcp_server_warning` event with a fixed `code` (`core/diagnostics.ts`), at most once every ten minutes per code and document, and no free text: `backend_token_missing`, `credential_check_failed`, `content_stale_copy` and `content_unavailable` (with `document`, `reason` and `status`), `content_not_loaded_at_start` (with `count`), `content_catalog_drift`, `content_address_drift`, `content_check_failed`, `quote_store_failed`, `telegram_failed`, `request_failed`, `opt_out_check_failed`, `unhandled_rejection` (the process carries on) and `uncaught_exception` (reported, then the process exits and pm2 restarts it).

## Run

```sh
npm install
cp .env.example .env     # then fill it in
npm run build
node --env-file=.env dist/main.js
```

`npm run dev` runs the source with `tsx watch`. The server answers only `/` (the endpoint), `GET /healthz` (`{"ok":true,"version":"1.13.1"}`), the OAuth discovery documents and the server card; the other discovery paths the authorization server owns (`/.well-known/oauth-authorization-server`, `/.well-known/openid-configuration`, `/mcp/.well-known/openid-configuration`, `/register`) and everything else, including the old `/mcp` (a JSON 404 naming the root endpoint, no redirect), are a JSON 404, and a request body over 1 MB is a 413. A call is checked for its credential before its body is read, a call that runs past 120 seconds (`DEADLINE_MS`; nginx waits 135) is stopped and answered as a JSON-RPC error, and every answer carries `Cache-Control: no-store`, except the public discovery documents, which carry their own. A `GET` asking for an event stream is a 405 with `Allow: POST`: no standalone stream is offered. The process prints nothing in normal operation (see "Analytics and warnings").

You do not need to run it yourself to use it: connect to `https://mcp.audits.nfw.run` (see "Connect"). The server needs NFW's backend to answer, so a copy of your own is mostly useful for reading or testing the code.

Running it on a server: `deploy/ecosystem.config.cjs` is a pm2 configuration for one process under a dedicated system user. Put a reverse proxy with TLS in front, keep the process on `127.0.0.1`, forward only the paths listed above with the `Authorization`, `X-API-Key` and `Mcp-` headers and the query string unchanged, give the proxy a read timeout longer than 120 seconds, limit request bodies to 1 MB, and keep the query string (it may hold an API key) out of the proxy's logs.

## Tests

```sh
npm test            # vitest
npm run typecheck   # tsc, for the tests and for the build
```

The suites are the website's, ported: the tools (`mcp-tools`), the credential check (`mcp-auth`, `mcp-api-keys`) and the analytics (`mcp-analytics`: what leaves the process, with `posthog-node` as the real client and no network), with the dashboard mocked. New here: the content client, the HTTP server on a real socket, a check that nothing under `src/` imports outside it, and a comparison of the definitions with the website's. The content documents are fixtures in `test/fixtures/content/`; refresh them from a published site with `npm run fixtures:content` (or `npm run fixtures:content -- --base http://localhost:3000`).

## Registry

`server.json` describes this server for the [MCP Registry](https://registry.modelcontextprotocol.io) under the name `run.nfw/seo-audit`, the same name the server gives itself. A test keeps its name and version in step with the code.

## Security

To report a vulnerability, see [SECURITY.md](SECURITY.md).

## Licence

[MIT](LICENSE), copyright 2026 NFW Web Studio.