Skip to main content
Glama

Lookup NPI Provider

lookup_npi

Find healthcare provider details by their 10-digit NPI: name, address, specialty, and enumeration date.

Instructions

Look up a single healthcare provider by their 10-digit NPI number. Returns full provider details including name, address, specialty, and enumeration date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
npiYesThe 10-digit NPI number

Implementation Reference

  • The main handler function for the 'lookup_npi' tool. It takes an 'npi' parameter (10-digit string validated via regex), calls the API at /api/v1/npi/{npi}, and returns the provider data or an error.
    server.registerTool(
      "lookup_npi",
      {
        title: "Lookup NPI Provider",
        description:
          "Look up a single healthcare provider by their 10-digit NPI number. " +
          "Returns full provider details including name, address, specialty, and enumeration date.",
        inputSchema: {
          npi: z
            .string()
            .regex(/^\d{10}$/, "NPI must be exactly 10 digits")
            .describe("The 10-digit NPI number"),
        },
      },
      async ({ npi }) => {
        const res = await apiGet<{ dataset: string; data: Record<string, unknown> }>(
          `/api/v1/npi/${npi}`,
        );
    
        if (!res.ok) {
          const msg =
            res.status === 404
              ? `NPI ${npi} not found in the registry.`
              : `API error (${res.status}): ${JSON.stringify(res.data)}`;
          return {
            content: [{ type: "text" as const, text: msg }],
            isError: res.status !== 404,
          };
        }
    
        return {
          content: [
            { type: "text" as const, text: JSON.stringify(res.data.data, null, 2) },
          ],
        };
      },
    );
  • Input schema for 'lookup_npi': the 'npi' parameter with a 10-digit regex validation pattern.
    {
      title: "Lookup NPI Provider",
      description:
        "Look up a single healthcare provider by their 10-digit NPI number. " +
        "Returns full provider details including name, address, specialty, and enumeration date.",
      inputSchema: {
        npi: z
          .string()
          .regex(/^\d{10}$/, "NPI must be exactly 10 digits")
          .describe("The 10-digit NPI number"),
      },
  • Registration function registerNpiTools that registers all NPI tools (including 'lookup_npi') via server.registerTool() on an McpServer instance.
    export function registerNpiTools(server: McpServer): void {
      // ── Query providers ──────────────────────────────────────────────────────
    
      server.registerTool(
        "query_npi_providers",
        {
          title: "Query NPI Providers",
          description:
            "Search the NPI (National Provider Identifier) registry for healthcare providers. " +
            "Filter by state, specialty, name, city, or ZIP code. Returns up to 100 results per query. " +
            "Source: CMS NPPES, updated weekly. ~7.2 million providers.",
          inputSchema: {
            state: z
              .string()
              .length(2)
              .optional()
              .describe("Two-letter US state code (e.g. CA, NY, TX)"),
            specialty: z
              .string()
              .optional()
              .describe(
                "Provider specialty or taxonomy description (e.g. Cardiology, Family Medicine)",
              ),
            name: z
              .string()
              .optional()
              .describe(
                "Provider name (partial match on first or last name, or organization name)",
              ),
            city: z.string().optional().describe("City name"),
            zip: z
              .string()
              .optional()
              .describe("5-digit ZIP code"),
            limit: z
              .number()
              .int()
              .min(1)
              .max(100)
              .optional()
              .describe("Maximum number of results to return (default 25, max 100)"),
          },
        },
        async ({ state, specialty, name, city, zip, limit }) => {
          const res = await apiGet<NpiQueryResponse>("/api/v1/npi", {
            state,
            specialty,
            name,
            city,
            zip,
            limit: limit ?? 25,
          });
    
          if (!res.ok) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `API error (${res.status}): ${JSON.stringify(res.data)}`,
                },
              ],
              isError: true,
            };
          }
    
          const { count, data } = res.data;
          const summary = `Found ${count} NPI provider(s).`;
          const json = JSON.stringify(data, null, 2);
    
          return {
            content: [{ type: "text" as const, text: `${summary}\n\n${json}` }],
          };
        },
      );
    
      // ── Single provider lookup ───────────────────────────────────────────────
    
      server.registerTool(
        "lookup_npi",
        {
          title: "Lookup NPI Provider",
          description:
            "Look up a single healthcare provider by their 10-digit NPI number. " +
            "Returns full provider details including name, address, specialty, and enumeration date.",
          inputSchema: {
            npi: z
              .string()
              .regex(/^\d{10}$/, "NPI must be exactly 10 digits")
              .describe("The 10-digit NPI number"),
          },
        },
        async ({ npi }) => {
          const res = await apiGet<{ dataset: string; data: Record<string, unknown> }>(
            `/api/v1/npi/${npi}`,
          );
    
          if (!res.ok) {
            const msg =
              res.status === 404
                ? `NPI ${npi} not found in the registry.`
                : `API error (${res.status}): ${JSON.stringify(res.data)}`;
            return {
              content: [{ type: "text" as const, text: msg }],
              isError: res.status !== 404,
            };
          }
    
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(res.data.data, null, 2) },
            ],
          };
        },
      );
    
      // ── Dataset stats ────────────────────────────────────────────────────────
    
      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: {},
        },
        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/index.ts:12-12 (registration)
    Import of registerNpiTools from the npi.ts module in the main server entry point.
    import { registerNpiTools } from "./tools/npi.js";
  • src/index.ts:39-39 (registration)
    Call to registerNpiTools(server) in the main server setup to register the lookup_npi tool.
    registerNpiTools(server);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that this is a read operation returning provider details but does not mention any limitations, required permissions, or side effects. The behavior is straightforward, so a middle score is appropriate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that clearly states the purpose and return value. Every word provides value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple single-parameter tool with no output schema, the description sufficiently covers what the tool returns (name, address, specialty, enumeration date). No additional context is needed for an agent to use this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for the single parameter npi, which already includes a regex pattern and description. The tool description adds no additional semantic meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it looks up a single healthcare provider by their 10-digit NPI number and specifies the returned details (name, address, specialty, enumeration date). It uniquely distinguishes this tool from siblings like lookup_contract or query_npi_providers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when an NPI number is available but does not explicitly state when to use this tool versus alternatives such as query_npi_providers for bulk lookups. No when-not-to-use or exclusions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/carrierone/verilexdata-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server