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
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | The unique ID of the organization to retrieve. |
Implementation Reference
- src/tools/organizationUtils.ts:115-137 (handler)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; } } - src/tools/toolSchemas.ts:133-143 (schema)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, - src/tools/organizationUtils.ts:26-28 (helper)TypeScript interface defining the expected arguments for the getOrganizationById function.
export interface GetOrganizationByIdArgs { organizationId: string; }