Delete Managed Object
deleteManagedObjectDelete a managed object by its type and ID from PingOne Advanced Identity Cloud. Provide the object type (like alpha_user) and unique identifier to permanently remove it.
Instructions
Delete a managed object by ID from PingOne AIC
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectType | Yes | Managed object type (e.g., alpha_user, bravo_user, alpha_role, bravo_role, alpha_group, bravo_group, alpha_organization, bravo_organization). Use listManagedObjects to discover all available types. | |
| objectId | Yes | The object's unique identifier (_id) |
Implementation Reference
- The handler for the deleteManagedObject tool. It sends a DELETE request to /openidm/managed/{objectType}/{objectId} and returns a success message or error.
export const deleteManagedObjectTool = { name: 'deleteManagedObject', title: 'Delete Managed Object', description: 'Delete a managed object by ID from PingOne AIC', scopes: SCOPES, annotations: { destructiveHint: true, openWorldHint: true }, inputSchema: { objectType: z .string() .min(1) .describe( `Managed object type (e.g., ${EXAMPLE_TYPES_STRING}). Use listManagedObjects to discover all available types.` ), objectId: safePathSegmentSchema.describe("The object's unique identifier (_id)") }, async toolFunction({ objectType, objectId }: { objectType: string; objectId: string }) { const url = `https://${aicBaseUrl}/openidm/managed/${objectType}/${objectId}`; try { const { response } = await makeAuthenticatedRequest(url, SCOPES, { method: 'DELETE' }); const successMessage = `Deleted managed object ${objectId} from ${objectType}`; return createToolResponse(formatSuccess(successMessage, response)); } catch (error: any) { return createToolResponse(`Failed to delete managed object: ${error.message}`); } } }; - Input schema for the tool: objectType (string, min 1) and objectId (validated via safePathSegmentSchema to prevent path traversal).
inputSchema: { objectType: z .string() .min(1) .describe( `Managed object type (e.g., ${EXAMPLE_TYPES_STRING}). Use listManagedObjects to discover all available types.` ), objectId: safePathSegmentSchema.describe("The object's unique identifier (_id)") }, - src/index.ts:27-44 (registration)All tools (including deleteManagedObject) are registered with the MCP server via server.registerTool() in a generic loop that iterates allTool objects.
allTools.forEach((tool) => { const toolConfig: ToolConfig = { title: tool.title, description: tool.description }; // Only add inputSchema if it exists (some tools like getLogSources don't have one) if ('inputSchema' in tool && tool.inputSchema) { toolConfig.inputSchema = tool.inputSchema; } // Add annotations if present if ('annotations' in tool && tool.annotations) { toolConfig.annotations = tool.annotations; } server.registerTool(tool.name, toolConfig, tool.toolFunction as any); }); - src/tools/managedObjects/index.ts:8-8 (registration)Re-exports deleteManagedObjectTool from the managedObjects index, which is then imported by toolHelpers.ts.
export { deleteManagedObjectTool } from './deleteManagedObject.js'; - src/utils/apiHelpers.ts:14-42 (helper)The makeAuthenticatedRequest helper used by the handler to make authenticated HTTP DELETE requests to the PingOne AIC API.
export async function makeAuthenticatedRequest( url: string, scopes: string[], options: RequestInit = {} ): Promise<{ data: unknown; response: Response }> { const token = await getAuthService().getToken(scopes); const response = await fetch(url, { ...options, headers: { Authorization: `Bearer ${token}`, 'User-Agent': USER_AGENT, // Only add Content-Type header if the request has a body ...(options.body && { 'Content-Type': 'application/json' }), ...options.headers } }); if (!response.ok) { const errorBody = await response.text(); throw new Error(formatError(response, errorBody)); } // Handle empty responses (e.g., 204 No Content or DELETE operations) const contentLength = response.headers.get('content-length'); const data = response.status === 204 || contentLength === '0' ? null : await response.json(); return { data, response }; }