updateOrganization
Modify an organization's details in the Medplum MCP Server by providing its unique ID and updating fields such as name or aliases.
Instructions
Updates an existing organization. Requires the organization ID and the fields to update.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | No | An updated list of aliases. Optional. | |
| name | No | The new official name of the organization. Optional. | |
| organizationId | Yes | The unique ID of the organization to update. |
Implementation Reference
- src/tools/organizationUtils.ts:139-170 (handler)The core handler function that performs the organization update logic: authenticates, validates inputs, reads existing resource, merges updates safely, and updates via Medplum./** * Updates an existing Organization resource. * @param organizationId - The ID of the organization to update. * @param updates - The partial data to update the organization with. * @returns The updated Organization resource. */ export async function updateOrganization(organizationId: string, updates: UpdateOrganizationArgs): Promise<Organization> { await ensureAuthenticated(); if (!organizationId) { throw new Error('Organization ID is required to update an organization.'); } if (!updates || Object.keys(updates).length === 0) { throw new Error('Updates object cannot be empty for updating an organization.'); } const existingOrganization = await medplum.readResource("Organization", organizationId); if (!existingOrganization) { throw new Error(`Organization with ID ${organizationId} not found.`); } const { resourceType, id, ...safeUpdates } = updates as any; const organizationToUpdate: Organization = { ...existingOrganization, ...safeUpdates, resourceType: "Organization", id: organizationId, }; return medplum.updateResource(organizationToUpdate); }
- src/tools/toolSchemas.ts:144-158 (schema)JSON Schema definition for the updateOrganization tool input, specifying parameters like organizationId, name, alias.{ name: 'updateOrganization', description: "Updates an existing organization. Requires the organization ID and the fields to update.", input_schema: { type: 'object', properties: { organizationId: { type: 'string', description: "The unique ID of the organization to update." }, name: { type: 'string', description: "The new official name of the organization. Optional." }, alias: { type: 'array', items: { type: 'string' }, description: "An updated list of aliases. Optional." }, // Add other updatable fields from UpdateOrganizationArgs as simplified properties for LLM // Example: contact, address - keeping them simple for LLM }, required: ['organizationId'], // At least one update field implied }, },
- src/index.ts:328-350 (registration)Tool registration in MCP server: schema included in mcpTools array used by the server.{ name: "updateOrganization", description: "Updates an existing organization. Requires the organization ID and the fields to update.", inputSchema: { type: "object", properties: { organizationId: { type: "string", description: "The unique ID of the organization to update.", }, name: { type: "string", description: "The new official name of the organization. Optional.", }, alias: { type: "array", items: { type: "string" }, description: "An updated list of aliases. Optional.", }, }, required: ["organizationId"], }, },
- src/index.ts:21-25 (registration)Import of the updateOrganization handler function for use in the MCP tool mapping.createOrganization, getOrganizationById, updateOrganization, searchOrganizations, } from './tools/organizationUtils.js';
- src/index.ts:962-962 (registration)Mapping of 'updateOrganization' string key to the imported handler function in toolMapping object used for execution.updateOrganization,
- src/tools/organizationUtils.ts:30-32 (helper)TypeScript interface defining the shape of updates accepted by the updateOrganization handler.export interface UpdateOrganizationArgs extends Omit<Partial<Organization>, 'resourceType' | 'id'> { // if specific simplified fields are needed, they can be added here }