Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

updatePatient

Update an existing patient's details such as name, birth date, and gender using their unique ID. Designed for Medplum MCP Server to manage FHIR healthcare data.

Instructions

Updates an existing patient's information. Requires the patient's ID and the fields to update.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
birthDateNoNew birth date in YYYY-MM-DD format.
firstNameNoNew first name for the patient.
genderNoNew gender (male, female, other, unknown).
lastNameNoNew last name for the patient.
patientIdYesThe unique ID of the patient to update.

Implementation Reference

  • The core handler function that authenticates, fetches the existing Patient, merges the provided updates (excluding resourceType and id), and updates the resource via Medplum.
    export async function updatePatient(patientId: string, updates: Omit<Partial<Patient>, 'resourceType' | 'id'>): Promise<Patient> {
      await ensureAuthenticated();
    
      if (!patientId) {
        throw new Error('Patient ID is required to update a patient.');
      }
      if (!updates || Object.keys(updates).length === 0) {
        throw new Error('Updates object cannot be empty for updating a patient.');
      }
    
      const existingPatient = await medplum.readResource('Patient', patientId);
      if (!existingPatient) {
        throw new Error(`Patient with ID ${patientId} not found.`);
      }
      
      const { resourceType, id, ...safeUpdates } = updates as any;
    
      const patientToUpdate: Patient = {
        ...(existingPatient as Patient),
        ...(safeUpdates as Partial<Patient>),
        resourceType: 'Patient',
        id: patientId,
      };
    
      return medplum.updateResource(patientToUpdate);
    }
  • MCP tool schema definition specifying the input structure for the updatePatient tool, including patientId as required and common updatable fields like name, birthDate, gender.
      name: "updatePatient",
      description: "Updates an existing patient's information. Requires the patient's ID and the fields to update.",
      inputSchema: {
        type: "object",
        properties: {
          patientId: {
            type: "string",
            description: "The unique ID of the patient to update.",
          },
          firstName: {
            type: "string",
            description: "New first name for the patient.",
          },
          lastName: {
            type: "string", 
            description: "New last name for the patient.",
          },
          birthDate: {
            type: "string",
            description: "New birth date in YYYY-MM-DD format.",
          },
          gender: {
            type: "string",
            description: "New gender (male, female, other, unknown).",
            enum: ["male", "female", "other", "unknown"],
          },
        },
        required: ["patientId"],
      },
    },
  • src/index.ts:953-953 (registration)
    Registration of the updatePatient handler function in the toolMapping object used by the MCP server to dispatch tool calls.
    updatePatient,
  • src/index.ts:29-29 (registration)
    Import of the updatePatient function from patientUtils.ts into the main index.ts for use in tool handling.
    updatePatient,
  • Auxiliary schema definition for updatePatient, likely used for LLM prompting or documentation, with more detailed description of the updates object.
    {
      name: 'updatePatient',
      description: 'Updates an existing patient resource. Requires the patient ID and an object containing the fields to update.',
      input_schema: {
        type: 'object',
        properties: {
          patientId: {
            type: 'string',
            description: 'The unique ID of the patient to update.',
          },
          updates: {
            type: 'object',
            description: "An object containing the patient fields to update. For example, { \"birthDate\": \"1990-01-01\", \"gender\": \"female\" }. Refer to the Patient FHIR resource for possible fields. For updating name, provide the full name structure, e.g., { name: [{ given: [\'NewFirstName\', \'NewMiddle\'], family: \'ExistingLastName\' }] }.",
            // We don't define exhaustive properties for 'updates' here as it's a partial Patient.
            // The description should guide the LLM.
          },
        },
        required: ['patientId', 'updates'],
      },
    },
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 of behavioral disclosure. It mentions that it 'Updates an existing patient's information,' which implies a mutation operation, but lacks details on permissions, side effects, error handling, or response format. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is concise with two sentences that front-load the purpose and key requirements. There is no wasted text, and it efficiently communicates the essential information without redundancy. However, it could be slightly more structured by explicitly listing key behavioral aspects.

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 of a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., what happens on partial updates, error conditions), and while the schema covers parameters well, the overall context for safe and effective use is insufficient.

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%, with detailed descriptions for all parameters (e.g., 'New birth date in YYYY-MM-DD format'). The description adds minimal value beyond the schema by mentioning 'Requires the patient's ID and the fields to update,' which aligns with the schema's required 'patientId' and optional fields. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Updates') and resource ('existing patient's information'), making the purpose evident. It distinguishes itself from sibling tools like 'createPatient' by specifying it updates existing records rather than creating new ones. However, it doesn't explicitly differentiate from other update tools (e.g., 'updateCondition') beyond the patient focus.

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 by stating it requires a patient ID and fields to update, suggesting it's for modifying existing patients. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'createPatient' for new patients or 'getPatientById' for viewing, nor does it mention any prerequisites or exclusions beyond the required ID.

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