confluence_add_labels
Add labels or tags to any Confluence page by specifying the page ID and an array of label names.
Instructions
Add labels (tags) to a Confluence page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageId | Yes | The ID of the page | |
| labels | Yes | Array of label names to add |
Implementation Reference
- index.js:178-196 (helper)Helper function that makes the API call to add labels to a Confluence page. It transforms label names into the required payload format (with prefix: 'global') and POSTs to the Confluence REST API endpoint.
/** * Add labels to a page */ async function addLabels(pageId, labels) { try { const payload = labels.map(name => ({ prefix: 'global', name })); const response = await client.post( `${CONFLUENCE_API_BASE}/content/${pageId}/label`, payload ); return response.data; } catch (error) { throw new Error(`Failed to add labels: ${error.message}`); } } - index.js:363-381 (registration)Registration of the 'confluence_add_labels' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema (pageId string and labels array, both required).
{ name: 'confluence_add_labels', description: 'Add labels (tags) to a Confluence page', inputSchema: { type: 'object', properties: { pageId: { type: 'string', description: 'The ID of the page', }, labels: { type: 'array', items: { type: 'string' }, description: 'Array of label names to add', }, }, required: ['pageId', 'labels'], }, }, - index.js:504-514 (handler)Handler case in CallToolRequestSchema that invokes the addLabels helper with pageId and labels arguments from the tool call.
case 'confluence_add_labels': { const result = await addLabels(args.pageId, args.labels); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }