Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

getMedicationRequestById

Retrieve specific medication request details using its unique ID on the Medplum MCP Server. Provides quick access to essential healthcare data for efficient management.

Instructions

Retrieves a medication request by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
medicationRequestIdYesThe unique ID of the medication request to retrieve.

Implementation Reference

  • The main handler function that authenticates, validates the medicationRequestId, and retrieves the MedicationRequest resource using medplum.readResource, returning null if not found.
    /**
     * Retrieves a MedicationRequest by its ID.
     * @param args - The arguments containing the medication request ID.
     * @returns The MedicationRequest resource, or null if not found.
     */
    export async function getMedicationRequestById(args: GetMedicationRequestByIdArgs): Promise<MedicationRequest | null> {
      await ensureAuthenticated();
      if (!args.medicationRequestId) {
        throw new Error('MedicationRequest ID is required to fetch a medication request.');
      }
      try {
        return await medplum.readResource('MedicationRequest', args.medicationRequestId);
      } catch (error: any) {
        if (error.outcome?.issue?.[0]?.code === 'not-found') {
          return null;
        }
        throw error;
      }
    }
  • TypeScript interface defining the input parameters for the getMedicationRequestById handler.
    // Interface for retrieving a MedicationRequest by ID
    export interface GetMedicationRequestByIdArgs {
      medicationRequestId: string;
    }
  • MCP tool schema definition including name, description, and input schema for validation in the MCP server.
      name: "getMedicationRequestById",
      description: "Retrieves a medication request by its unique ID.",
      inputSchema: {
        type: "object",
        properties: {
          medicationRequestId: {
            type: "string",
            description: "The unique ID of the medication request to retrieve.",
          },
        },
        required: ["medicationRequestId"],
      },
    },
  • src/index.ts:973-973 (registration)
    Registration of the getMedicationRequestById handler function in the toolMapping object used by the MCP server's CallToolRequest handler.
    getMedicationRequestById,
  • src/index.ts:45-48 (registration)
    Import statement that brings the getMedicationRequestById function into the index module for registration.
    createMedicationRequest,
    getMedicationRequestById,
    updateMedicationRequest,
    searchMedicationRequests,
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a retrieval operation, implying read-only behavior, but doesn't mention potential error cases (e.g., invalid ID, permissions), response format, or whether it returns full FHIR resources. This leaves significant gaps for a tool that likely interacts with sensitive healthcare data.

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 states the core purpose without unnecessary words. It's appropriately sized for a simple lookup tool and front-loads the essential information.

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 lack of annotations and output schema, the description is insufficiently complete. For a healthcare data retrieval tool with no structured output documentation, it should at minimum mention what kind of data is returned (e.g., FHIR MedicationRequest resource) and any important constraints or error conditions.

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 the single parameter 'medicationRequestId' clearly documented in the schema. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline for adequate coverage without adding 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 ('medication request by its unique ID'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'searchMedicationRequests' or other 'getXById' tools, which would require mentioning this is for single-record lookup by ID rather than search queries.

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 doesn't mention when to choose this over 'searchMedicationRequests' for broader queries or other 'getXById' tools for different resource types, nor does it specify prerequisites like needing a valid 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