Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

getConditionById

Retrieve a specific condition resource using its unique ID within the Medplum MCP Server. Simplifies access to healthcare data for precise queries and management.

Instructions

Retrieves a condition resource by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conditionIdYesThe unique ID of the condition to retrieve.

Implementation Reference

  • The main handler function that retrieves a Condition FHIR resource by its ID using the Medplum client. Handles authentication, reads the resource, logs success, returns null if not found, and OperationOutcome on errors.
    export async function getConditionById(
      conditionId: string,
      client?: MedplumClient,
    ): Promise<Condition | null | OperationOutcome> {
      const medplumClient = client || medplum;
      await ensureAuthenticated();
      try {
        if (!conditionId) {
          throw new Error('Condition ID is required.');
        }
        const condition = (await medplumClient.readResource(
          'Condition',
          conditionId,
        )) as Condition | null;
        if (condition) {
          console.log('Condition retrieved:', condition.id);
        }
        return condition;
      } catch (error: any) {
        if (error.outcome && error.outcome.issue && error.outcome.issue[0]?.code === 'not-found') {
          console.log(`Condition with ID "${conditionId}" not found.`);
          return null;
        }
        console.error(`Error retrieving Condition with ID "${conditionId}":`, error);
        const outcome: OperationOutcome = {
          resourceType: 'OperationOutcome',
          issue: [
            {
              severity: 'error',
              code: 'exception',
              diagnostics: `Error retrieving 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 for getConditionById defining the input as an object with required 'conditionId' string.
      name: "getConditionById",
      description: "Retrieves a condition resource by its unique ID.",
      inputSchema: {
        type: "object",
        properties: {
          conditionId: {
            type: "string",
            description: "The unique ID of the condition to retrieve.",
          },
        },
        required: ["conditionId"],
      },
    },
  • src/index.ts:950-988 (registration)
    Registration of the getConditionById function in the toolMapping object used by the MCP server's CallToolRequest handler to dispatch tool calls.
    const toolMapping: Record<string, (...args: any[]) => Promise<any>> = {
      createPatient,
      getPatientById, 
      updatePatient,
      searchPatients,
      searchPractitionersByName,
      createPractitioner,
      getPractitionerById,
      updatePractitioner,
      searchPractitioners,
      createOrganization,
      getOrganizationById,
      updateOrganization,
      searchOrganizations,
      createEncounter,
      getEncounterById,
      updateEncounter,
      searchEncounters,
      createObservation,
      getObservationById,
      updateObservation,
      searchObservations,
      createMedicationRequest,
      getMedicationRequestById,
      updateMedicationRequest,
      searchMedicationRequests,
      createMedication,
      getMedicationById,
      searchMedications,
      createEpisodeOfCare,
      getEpisodeOfCareById,
      updateEpisodeOfCare,
      searchEpisodesOfCare,
      createCondition,
      getConditionById,
      updateCondition,
      searchConditions,
      generalFhirSearch,
    };
  • src/index.ts:62-68 (registration)
    Import statement bringing the getConditionById handler into the main index.ts for use in tool mapping.
      createCondition,
      getConditionById,
      updateCondition,
      searchConditions,
      ConditionClinicalStatusCodes,
      ConditionVerificationStatusCodes,
    } from './tools/conditionUtils.js';
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states this is a retrieval operation, implying read-only behavior, but doesn't disclose any behavioral traits such as error handling (e.g., what happens if the ID doesn't exist), authentication needs, rate limits, or response format. For a tool with no 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.

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It's appropriately sized for a simple retrieval tool, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool's low complexity (single parameter, no nested objects) and high schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it fails to provide complete context—missing details on return values, error cases, or behavioral expectations. It meets basic needs but leaves gaps for effective agent use.

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?

The schema description coverage is 100%, with the single parameter 'conditionId' fully documented in the schema. The description adds no additional parameter semantics beyond what's in the schema (e.g., format examples or constraints). Baseline 3 is appropriate when the schema does the heavy lifting, but no extra value is provided.

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 ('retrieves') and resource ('condition resource') with specificity about the identifier ('by its unique ID'). It distinguishes from sibling tools like 'searchConditions' by focusing on individual retrieval rather than search operations. However, it doesn't explicitly differentiate from other 'getById' tools (e.g., 'getPatientById'), though the resource type is implied.

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 you have a specific condition ID to retrieve, but doesn't explicitly state when to use this versus alternatives like 'searchConditions' or other 'getById' tools. There's no guidance on prerequisites or error conditions. The context is clear but lacks explicit comparison or exclusions.

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