Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

searchOrganizations

Search for healthcare organizations by name or address using structured criteria. Designed for Medplum MCP Server to manage FHIR data efficiently through targeted queries.

Instructions

Searches for organizations based on criteria like name or address. Provide at least one criterion.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNoPart of the organization's address to search for. Optional.
nameNoThe name of the organization to search for. Optional.

Implementation Reference

  • The handler function that builds FHIR search query parameters from input arguments and executes the search using Medplum client.
    export async function searchOrganizations(searchArgs: OrganizationSearchArgs): Promise<Organization[]> {
      await ensureAuthenticated();
      
      const searchCriteria: string[] = [];
    
      if (searchArgs.name) {
        searchCriteria.push(`name=${encodeURIComponent(searchArgs.name)}`);
      }
      if (searchArgs.identifier) {
        searchCriteria.push(`identifier=${encodeURIComponent(searchArgs.identifier)}`);
      }
      if (searchArgs.type) {
        searchCriteria.push(`type=${encodeURIComponent(searchArgs.type)}`);
      }
      if (searchArgs.active !== undefined) {
        searchCriteria.push(`active=${searchArgs.active}`);
      }
      if (searchArgs.address) {
        searchCriteria.push(`address=${encodeURIComponent(searchArgs.address)}`);
      }
      if (searchArgs.city) {
        searchCriteria.push(`address-city=${encodeURIComponent(searchArgs.city)}`);
      }
      if (searchArgs.state) {
        searchCriteria.push(`address-state=${encodeURIComponent(searchArgs.state)}`);
      }
      if (searchArgs.postalCode) {
        searchCriteria.push(`address-postalcode=${encodeURIComponent(searchArgs.postalCode)}`);
      }
      if (searchArgs.country) {
        searchCriteria.push(`address-country=${encodeURIComponent(searchArgs.country)}`);
      }
    
      if (searchCriteria.length === 0) {
        return [];
      }
    
      const queryString = searchCriteria.join('&');
      return medplum.searchResources("Organization", queryString);
    }
  • MCP tool schema defining the input parameters for the searchOrganizations tool.
    {
      name: "searchOrganizations",
      description: "Searches for organizations based on criteria like name or address. Provide at least one criterion.",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description: "The name of the organization to search for. Optional.",
          },
          address: {
            type: "string",
            description: "Part of the organization's address to search for. Optional.",
          },
        },
        required: [],
      },
    },
  • src/index.ts:963-963 (registration)
    Registration of the searchOrganizations handler function in the toolMapping object used by the MCP server.
    searchOrganizations,
  • src/index.ts:21-25 (registration)
    Import of the searchOrganizations function into the main server file.
      createOrganization,
      getOrganizationById,
      updateOrganization,
      searchOrganizations,
    } from './tools/organizationUtils.js';
  • TypeScript schema definition for searchOrganizations tool (potentially legacy or supplementary).
    {
      name: 'searchOrganizations',
      description: "Searches for organizations based on criteria like name or address. Provide at least one criterion.",
      input_schema: {
        type: 'object',
        properties: {
          name: { type: 'string', description: "The name of the organization to search for. Optional." },
          address: { type: 'string', description: "Part of the organization\'s address to search for. Optional." },
        },
        required: [], // Function logic ensures at least one is present
      },
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the search action and a constraint ('Provide at least one criterion'), but lacks details on behavioral traits such as whether it's read-only (implied by 'Searches'), potential rate limits, authentication needs, or what the output looks like (no output schema). This leaves significant gaps for a tool with no annotation coverage.

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 two sentences, front-loaded with the core purpose and followed by a key constraint. Every sentence earns its place with no wasted words, making it appropriately sized and efficient for understanding.

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

Completeness2/5

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

Given the complexity (a search tool with 2 parameters), no annotations, and no output schema, the description is incomplete. It covers the basic purpose and a constraint but lacks details on output format, error handling, or behavioral context, which are crucial for effective use without structured data to compensate.

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%, so the schema already documents both parameters ('name' and 'address') as optional with clear descriptions. The description adds minimal value by listing examples ('like name or address') but doesn't provide additional semantics beyond what's in the schema, such as search behavior or format details, meeting the baseline for high coverage.

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

Purpose4/5

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

The description clearly states the verb ('Searches for') and resource ('organizations'), and specifies the type of criteria ('based on criteria like name or address'). However, it doesn't explicitly differentiate from sibling search tools like 'searchPatients' or 'searchPractitioners' beyond the resource type, which is implied but not stated.

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 provides some usage guidance with 'Provide at least one criterion,' which implies when to use it (when you have search criteria) and a constraint. However, it doesn't specify when to use this versus alternatives like 'getOrganizationById' for direct lookup or 'generalFhirSearch' for broader searches, leaving the context somewhat implied.

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

Related 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/rkirkendall/medplum-mcp'

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