NPI Dataset Statistics
npi_statsRetrieve statistics for the NPI dataset: total record count, states covered, last update timestamp, and data source. Free endpoint, no payment needed.
Instructions
Get statistics about the NPI dataset: total record count, number of states, last updated timestamp, and data source information. Free endpoint, no payment required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/npi.ts:152-173 (handler)The async handler function for the npi_stats tool. Calls the API endpoint /api/v1/npi/stats and returns the JSON response containing dataset statistics (record count, last updated, etc.).
async () => { const res = await apiGet<NpiStatsResponse>("/api/v1/npi/stats"); if (!res.ok) { return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } return { content: [ { type: "text" as const, text: JSON.stringify(res.data, null, 2) }, ], }; }, ); - src/tools/npi.ts:19-24 (schema)The NpiStatsResponse interface defines the shape of the API response: dataset, source, update_frequency, and a stats object.
interface NpiStatsResponse { dataset: string; source: string; update_frequency: string; stats: Record<string, unknown>; } - src/tools/npi.ts:143-151 (registration)Registration of the npi_stats tool on the MCP server via server.registerTool(), with the name 'npi_stats', a title, description, and an empty input schema.
server.registerTool( "npi_stats", { title: "NPI Dataset Statistics", description: "Get statistics about the NPI dataset: total record count, number of states, " + "last updated timestamp, and data source information. Free endpoint, no payment required.", inputSchema: {}, }, - src/index.ts:39-39 (registration)Call to registerNpiTools(server) in the main entry point, which wires up the npi_stats tool (along with query_npi_providers and lookup_npi) into the MCP server.
registerNpiTools(server); - src/client.ts:44-76 (helper)The apiGet helper function used by the npi_stats handler to make the HTTP GET request to the Verilex API.
export async function apiGet<T = unknown>( path: string, params?: Record<string, string | number | undefined>, ): Promise<ApiResponse<T>> { const url = buildUrl(path, params); const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "verilex-mcp-server/0.1.0", }; // Forward x402 payment token if present in env (for paid endpoints) const paymentToken = process.env.VERILEX_PAYMENT_TOKEN; if (paymentToken) { headers["X-Payment-Token"] = paymentToken; } const res = await fetch(url, { headers }); const data = (await res.json()) as T; const stale = res.headers.get("X-Data-Stale"); const lastUpdated = res.headers.get("X-Data-Last-Updated"); const ageSeconds = res.headers.get("X-Data-Age-Seconds"); return { ok: res.ok, status: res.status, data, stale: stale === "true", lastUpdated: lastUpdated ?? undefined, ageSeconds: ageSeconds ? Number(ageSeconds) : undefined, }; }