Skip to main content
Glama
rkirkendall

Medplum MCP Server

by rkirkendall

getOrganizationById

Retrieve detailed organization data by specifying its unique ID using Medplum MCP Server’s query tool for healthcare information management.

Instructions

Retrieves an organization by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesThe unique ID of the organization to retrieve.

Implementation Reference

  • Core implementation of the getOrganizationById tool handler. Fetches the Organization FHIR resource by ID using the Medplum client, supports both string ID and object args, gracefully handles not-found errors by returning null.
     * Retrieves an Organization resource by its ID.
     * @param args - The ID of the organization to retrieve.
     * @returns The Organization resource.
     */
    export async function getOrganizationById(args: { organizationId: string } | string): Promise<Organization | null> {
      await ensureAuthenticated();
      
      // Handle both string and object parameter formats
      const organizationId = typeof args === 'string' ? args : args.organizationId;
      
      if (!organizationId) {
        throw new Error('Organization ID is required to fetch an organization.');
      }
      try {
        // Remove generic type, let Medplum infer it
        return await medplum.readResource("Organization", organizationId);
      } catch (error: any) {
        if (error.outcome?.issue?.[0]?.code === 'not-found') {
          return null;
        }
        throw error;
      }
    }
  • JSON schema definition for validating input parameters of the getOrganizationById tool.
    {
      name: 'getOrganizationById',
      description: 'Retrieves an organization by its unique ID.',
      input_schema: {
        type: 'object',
        properties: {
          organizationId: { type: 'string', description: 'The unique ID of the organization to retrieve.' },
        },
        required: ['organizationId'],
      },
    },
  • src/index.ts:314-327 (registration)
    Registers the getOrganizationById tool in the MCP server's tool list (mcpTools), including name, description, and input schema for the ListTools request.
    {
      name: "getOrganizationById",
      description: "Retrieves an organization by its unique ID.",
      inputSchema: {
        type: "object",
        properties: {
          organizationId: {
            type: "string",
            description: "The unique ID of the organization to retrieve.",
          },
        },
        required: ["organizationId"],
      },
    },
  • src/index.ts:20-25 (registration)
    Imports the getOrganizationById handler function from organizationUtils for use in the MCP server.
    import {
      createOrganization,
      getOrganizationById,
      updateOrganization,
      searchOrganizations,
    } from './tools/organizationUtils.js';
  • src/index.ts:961-961 (registration)
    Maps the tool name to its handler function in the toolMapping object used for execution.
    getOrganizationById,
  • TypeScript interface defining the expected arguments for the getOrganizationById function.
    export interface GetOrganizationByIdArgs {
      organizationId: string;
    }
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 only states the basic action ('Retrieves') without addressing critical aspects: whether this is a read-only operation, authentication requirements, error handling (e.g., for invalid IDs), rate limits, or the format of returned data. 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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying essential information without redundancy or fluff.

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 FHIR resources and the lack of annotations and output schema, the description is incomplete. It doesn't explain what an 'organization' entails in this context (e.g., FHIR Organization resource), what data is returned, or how errors are handled. For a tool interacting with a structured healthcare data standard, more context is needed to ensure proper 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 description mentions retrieving by 'unique ID,' which aligns with the single parameter 'organizationId' in the schema. Since schema description coverage is 100% (the parameter is well-described in the schema), the description adds minimal value beyond restating the schema's purpose. This meets the baseline for high schema coverage but doesn't enhance understanding of the parameter's role or constraints.

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 ('Retrieves') and resource ('an organization'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'get' tools (like getPatientById, getConditionById) beyond the resource type, missing an opportunity to explain what makes retrieving an organization distinct from retrieving other FHIR resources.

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 use getOrganizationById instead of searchOrganizations (e.g., for known IDs vs. queries), nor does it reference other sibling tools like createOrganization or updateOrganization for related operations. This leaves the agent without context for tool selection.

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