Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

updateCondition

Modify existing medical condition details in Medplum MCP Server by updating fields like clinical status, verification status, or onset description using the condition ID.

Instructions

Updates an existing condition. Requires the condition ID and at least one field to update.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clinicalStatusNoThe new clinical status of the condition.
conditionIdYesThe unique ID of the condition to update.
onsetStringNoUpdate the onset description. To remove this field, provide a `null` value.
verificationStatusNoThe new verification status of the condition.

Implementation Reference

  • The core handler function that executes the updateCondition tool logic: reads existing Condition by ID, merges updates, handles null removals, and updates via Medplum client.
    export async function updateCondition(
      args: UpdateConditionArgs,
      client?: MedplumClient,
    ): Promise<Condition | OperationOutcome> {
      const medplumClient = client || medplum;
      await ensureAuthenticated();
      try {
        const { id, ...updates } = args;
        if (!id) {
          throw new Error('Condition ID is required for update.');
        }
        if (Object.keys(updates).length === 0) {
          throw new Error('No updates provided for Condition.');
        }
    
        const existingCondition = (await medplumClient.readResource(
          'Condition',
          id,
        )) as Condition;
    
        const updatedResource: Condition = { ...existingCondition, ...(updates as any) };
        // Handle null values for removal
        if (updates.onsetDateTime === null) delete updatedResource.onsetDateTime;
        if (updates.onsetString === null) delete updatedResource.onsetString;
        if (updates.recordedDate === null) delete updatedResource.recordedDate;
    
        const result = (await medplumClient.updateResource(updatedResource)) as Condition;
        console.log('Condition updated successfully:', result.id);
        return result;
      } catch (error: any) {
        console.error('Error updating Condition:', error);
        const outcome: OperationOutcome = {
          resourceType: 'OperationOutcome',
          issue: [
            {
              severity: 'error',
              code: 'exception',
              diagnostics: `Error updating Condition: ${error.message || 'Unknown error'}`,
            },
          ],
        };
        if (error.outcome) {
          console.error('Server OperationOutcome:', JSON.stringify(error.outcome, null, 2));
          return error.outcome as OperationOutcome;
        }
        return outcome;
      }
  • MCP tool schema definition including input schema with properties for conditionId, clinicalStatus, verificationStatus, onsetString.
    name: "updateCondition",
    description: "Updates an existing condition. Requires the condition ID and at least one field to update.",
    inputSchema: {
      type: "object",
      properties: {
        conditionId: {
          type: "string",
          description: "The unique ID of the condition to update.",
        },
        clinicalStatus: {
          type: "string",
          description: "The new clinical status of the condition.",
          enum: ["active", "recurrence", "relapse", "inactive", "remission", "resolved"],
        },
        verificationStatus: {
          type: "string",
          description: "The new verification status of the condition.",
          enum: ["unconfirmed", "provisional", "differential", "confirmed", "refuted", "entered-in-error"],
        },
        onsetString: {
          type: "string",
          description: "Update the onset description. To remove this field, provide a `null` value.",
        },
      },
      required: ["conditionId"],
    },
  • src/index.ts:985-985 (registration)
    Registration of the updateCondition handler function in the toolMapping object used by the MCP server to dispatch tool calls.
    updateCondition,
  • src/index.ts:1027-1043 (registration)
    Special dispatch logic in MCP server handler for updateCondition, converting schema inputs to UpdateConditionArgs format.
            // Special handling for updateCondition
    if (toolName === 'updateCondition') {
      const updateArgs: any = { id };
      if ((updates as any).clinicalStatus) {
        const key = ((updates as any).clinicalStatus as string).toUpperCase() as keyof typeof ConditionClinicalStatusCodes;
        updateArgs.clinicalStatus = { coding: [ConditionClinicalStatusCodes[key]] };
      }
      if ((updates as any).verificationStatus) {
        const verStatusMap: { [key: string]: string } = { 'entered-in-error': 'ENTERED-IN-ERROR' };
        const key = (verStatusMap[(updates as any).verificationStatus] || ((updates as any).verificationStatus as string).toUpperCase()) as keyof typeof ConditionVerificationStatusCodes;
        updateArgs.verificationStatus = { coding: [ConditionVerificationStatusCodes[key]] };
      }
      if ((updates as any).onsetString !== undefined) {
        updateArgs.onsetString = (updates as any).onsetString;
      }
      result = await toolFunction(updateArgs);
    } else {
  • TypeScript interface defining the arguments expected by the updateCondition handler function.
    export interface UpdateConditionArgs {
      id: string;
      clinicalStatus?: CodeableConcept;
      verificationStatus?: CodeableConcept;
      code?: CodeableConcept;
      onsetDateTime?: string | null; // null to remove
      onsetString?: string | null;
      recordedDate?: string | null;
    }
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 requirement for condition ID and at least one field, which is useful, but fails to disclose critical behavioral traits such as authentication needs, error handling, whether updates are idempotent, or what happens to unspecified fields. For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 a single, efficient sentence that front-loads the core action ('Updates an existing condition') and adds necessary constraints. There's no wasted text, making it appropriately concise for the tool's complexity.

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 tool's complexity as a mutation operation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects like permissions, side effects, response format, or error cases, which are crucial for an AI agent to use it correctly in a healthcare context.

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 all parameters thoroughly. The description adds minimal value by implying that at least one field beyond 'conditionId' is needed, but doesn't provide additional semantics beyond what's in the schema. This meets the baseline for high schema 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 ('Updates') and resource ('an existing condition'), making the purpose immediately understandable. It distinguishes from sibling 'createCondition' by specifying it's for existing conditions, though it doesn't explicitly differentiate from other update tools like 'updateEncounter' or 'updatePatient' beyond the resource type.

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 context by stating 'Requires the condition ID and at least one field to update,' which implies prerequisites. However, it doesn't explicitly guide when to use this tool versus alternatives like 'getConditionById' for reading or 'createCondition' for new entries, nor does it mention when not to use it.

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