Skip to main content
Glama

remove_confluence_label

Remove a label from a Confluence page by specifying the page ID and label name. This tool helps clean up page organization and metadata in Confluence Cloud.

Instructions

Remove a label from a page.

Error Handling:

  • Returns 403 for insufficient permissions

  • Returns 404 if page or label not found

Response includes:

  • Success status

  • Operation details (pageId, label, operation type)

  • Success message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdYesID of the page
labelYesLabel to remove

Implementation Reference

  • MCP tool handler: validates parameters, verifies page access, removes the label via client, handles errors, and returns formatted JSON response.
    export async function handleRemoveConfluenceLabel( client: ConfluenceClient, args: { pageId: string; label: string } ): Promise<{ content: Array<{ type: "text"; text: string }>; }> { try { if (!args.pageId || !args.label) { throw new McpError( ErrorCode.InvalidParams, "pageId and label are required" ); } // First check if the page exists and is accessible try { await client.getConfluencePage(args.pageId); } catch (error: unknown) { if (error instanceof ConfluenceError) { switch (error.code) { case 'PAGE_NOT_FOUND': throw new McpError(ErrorCode.InvalidParams, "Page not found"); case 'INSUFFICIENT_PERMISSIONS': throw new McpError(ErrorCode.InvalidRequest, "Insufficient permissions to access page"); default: throw new McpError(ErrorCode.InternalError, error.message); } } throw error; } await client.removeConfluenceLabel(args.pageId, args.label); const simplified = { success: true, message: `Successfully removed label '${args.label}' from page ${args.pageId}`, details: { pageId: args.pageId, label: args.label, operation: 'remove' } }; return { content: [ { type: "text", text: JSON.stringify(simplified), }, ], }; } catch (error: unknown) { console.error("Error removing label:", error instanceof Error ? error.message : String(error)); if (error instanceof McpError) { throw error; } // Handle specific HTTP errors from the Confluence API if (error instanceof ConfluenceError) { switch (error.code) { case 'PAGE_NOT_FOUND': throw new McpError(ErrorCode.InvalidParams, "Page not found"); case 'PERMISSION_DENIED': throw new McpError(ErrorCode.InvalidRequest, "You don't have permission to remove labels from this page"); default: throw new McpError(ErrorCode.InternalError, `Failed to remove label: ${error.message}`); } } throw new McpError( ErrorCode.InternalError, `Failed to remove label: ${error instanceof Error ? error.message : String(error)}` ); } }
  • Tool schema defining input parameters (pageId, label) and description for the remove_confluence_label tool.
    remove_confluence_label: { description: "Remove a label from a page.\n\nError Handling:\n- Returns 403 for insufficient permissions\n- Returns 404 if page or label not found\n\nResponse includes:\n- Success status\n- Operation details (pageId, label, operation type)\n- Success message", inputSchema: { type: "object", properties: { pageId: { type: "string", description: "ID of the page", }, label: { type: "string", description: "Label to remove", }, }, required: ["pageId", "label"], }, }, } as const;
  • src/index.ts:271-275 (registration)
    Tool registration in the main switch dispatcher: extracts arguments, validates, and calls the handler function.
    case "remove_confluence_label": { const { pageId, label } = (args || {}) as { pageId: string; label: string }; if (!pageId || !label) throw new McpError(ErrorCode.InvalidParams, "pageId and label are required"); return await handleRemoveConfluenceLabel(this.confluenceClient, { pageId, label }); }
  • Low-level client method that makes the DELETE API call to remove a label from a Confluence page and handles API errors.
    async removeConfluenceLabel(pageId: string, label: string): Promise<void> { try { await this.v2Client.delete(`/pages/${pageId}/labels/${label}`); } catch (error) { if (axios.isAxiosError(error)) { switch (error.response?.status) { case 403: throw new ConfluenceError( 'Insufficient permissions to remove labels', 'PERMISSION_DENIED' ); case 404: throw new ConfluenceError( 'Page or label not found', 'PAGE_NOT_FOUND' ); default: console.error('Error removing label:', error.response?.data); throw new ConfluenceError( `Failed to remove label: ${error.message}`, 'UNKNOWN' ); } } throw error; } }

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/aaronsb/confluence-cloud-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server