Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

getEpisodeOfCareById

Retrieve healthcare episode details using a unique ID to access and manage patient care data efficiently on Medplum MCP Server.

Instructions

Retrieves an episode of care by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
episodeOfCareIdYesThe unique ID of the episode of care to retrieve.

Implementation Reference

  • Core handler function that implements the tool logic: reads EpisodeOfCare resource by ID from Medplum, handles not-found as null, errors as OperationOutcome.
    export async function getEpisodeOfCareById(
      episodeOfCareId: string,
      client?: MedplumClient,
    ): Promise<EpisodeOfCare | null | OperationOutcome> {
      const medplumClient = client || medplum;
      await ensureAuthenticated();
      try {
        if (!episodeOfCareId) {
          throw new Error('EpisodeOfCare ID is required.');
        }
        const result = (await medplumClient.readResource(
          'EpisodeOfCare',
          episodeOfCareId,
        )) as EpisodeOfCare | null;
        console.log(result ? 'EpisodeOfCare retrieved:' : 'EpisodeOfCare not found:', episodeOfCareId);
        return result;
      } catch (error: any) {
        if (error.outcome && error.outcome.issue && error.outcome.issue[0]?.code === 'not-found') {
          console.log(`EpisodeOfCare with ID "${episodeOfCareId}" not found.`);
          return null;
        }
        const outcome: OperationOutcome = {
          resourceType: 'OperationOutcome',
          issue: [
            {
              severity: 'error',
              code: 'exception',
              diagnostics: `Error retrieving EpisodeOfCare: ${error.message || 'Unknown error'}`,
            },
          ],
        };
        if (error.outcome) {
          return error.outcome as OperationOutcome;
        }
        return outcome;
      }
    }
  • Input schema definition for the tool used in MCP server tool list.
      name: "getEpisodeOfCareById",
      description: "Retrieves an episode of care by its unique ID.",
      inputSchema: {
        type: "object",
        properties: {
          episodeOfCareId: {
            type: "string",
            description: "The unique ID of the episode of care to retrieve.",
          },
        },
        required: ["episodeOfCareId"],
      },
    },
  • src/index.ts:980-980 (registration)
    Maps the tool name to the handler function in the tool execution dispatcher.
    getEpisodeOfCareById,
  • src/index.ts:56-60 (registration)
    Imports the handler function for use in the MCP server.
      createEpisodeOfCare,
      getEpisodeOfCareById,
      updateEpisodeOfCare,
      searchEpisodesOfCare,
    } from './tools/episodeOfCareUtils.js';
  • Legacy or additional schema definition for the tool (possibly not actively used).
      name: 'getEpisodeOfCareById',
      description: 'Retrieves a specific EpisodeOfCare resource by its ID.',
      input_schema: {
        type: 'object',
        properties: {
          episodeOfCareId: { type: 'string', description: 'The unique ID of the EpisodeOfCare to retrieve.' }
        },
        required: ['episodeOfCareId']
      }
    },
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 states the action ('Retrieves') but does not disclose any behavioral traits such as read-only nature, error handling, authentication needs, or rate limits. For a retrieval 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.

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It is appropriately sized and front-loaded, making it easy to understand quickly, with zero waste.

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 output schema), the description is minimally adequate but lacks completeness. It does not explain return values or error cases, and with no annotations, it misses behavioral context. However, for a simple retrieval tool, it provides the basic purpose, though more detail would be beneficial.

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 input schema has 100% description coverage, with the parameter 'episodeOfCareId' clearly documented. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, so it meets the baseline score of 3 for high schema coverage without extra value.

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 ('an episode of care'), making the purpose unambiguous. However, it does not distinguish this tool from similar sibling tools like 'getConditionById' or 'getPatientById', which follow the same pattern but for different resources, so it lacks sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention when to use it over general search tools like 'searchEpisodesOfCare' or 'generalFhirSearch', nor does it specify prerequisites such as needing a known ID, leaving usage context implied but not explicit.

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