Confluence POST Request
conf_postCreate Confluence pages, blog posts, labels, and comments via API. Specify the endpoint path, query parameters, and request body to add content to your Confluence spaces.
Instructions
Create Confluence resources. Returns TOON format by default (token-efficient).
IMPORTANT - Cost Optimization:
Use
jqparam to extract only needed fields from response (e.g.,jq: "{id: id, title: title}")Unfiltered responses include all metadata and are expensive!
Output format: TOON (default) or JSON (outputFormat: "json")
Common operations:
Create page:
/wiki/api/v2/pagesbody:{"spaceId": "123456", "status": "current", "title": "Page Title", "parentId": "789", "body": {"representation": "storage", "value": "<p>Content</p>"}}Create blog post:
/wiki/api/v2/blogpostsbody:{"spaceId": "123456", "status": "current", "title": "Blog Title", "body": {"representation": "storage", "value": "<p>Content</p>"}}Add label:
/wiki/api/v2/pages/{id}/labels- body:{"name": "label-name"}Add comment:
/wiki/api/v2/pages/{id}/footer-comments
API reference: https://developer.atlassian.com/cloud/confluence/rest/v2/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The Confluence API endpoint path (without base URL). Must start with "/". Examples: "/wiki/api/v2/spaces", "/wiki/api/v2/pages", "/wiki/api/v2/pages/{id}" | |
| queryParams | No | Optional query parameters as key-value pairs. Examples: {"limit": "25", "cursor": "...", "space-id": "123", "body-format": "storage"} | |
| jq | No | JMESPath expression to filter/transform the response. IMPORTANT: Always use this to extract only needed fields and reduce token costs. Examples: "results[*].{id: id, title: title}" (extract specific fields), "results[0]" (first result), "results[*].id" (IDs only). See https://jmespath.org | |
| outputFormat | No | Output format: "toon" (default, 30-60% fewer tokens) or "json". TOON is optimized for LLMs with tabular arrays and minimal syntax. | |
| body | Yes | Request body as a JSON object. Structure depends on the endpoint. Example for page: {"spaceId": "123", "title": "Page Title", "body": {"representation": "storage", "value": "<p>Content</p>"}} |
Implementation Reference
- The handlePost function is the actual handler that executes the conf_post tool logic. It calls the shared handleRequest function with 'POST' method, which calls the Atlassian API service and applies JQ filtering and output formatting.
export async function handlePost( options: RequestWithBodyArgsType, ): Promise<ControllerResponse> { return handleRequest('POST', options); } - src/tools/atlassian.api.tool.ts:247-256 (registration)The conf_post tool is registered with the MCP server using server.registerTool() with name 'conf_post', description CONF_POST_DESCRIPTION, inputSchema RequestWithBodyArgs, and the 'post' handler (which wraps handlePost).
// Register the POST tool using modern registerTool API server.registerTool( 'conf_post', { title: 'Confluence POST Request', description: CONF_POST_DESCRIPTION, inputSchema: RequestWithBodyArgs, }, post, ); - The input schema for conf_post is RequestWithBodyArgs, a Zod schema extending BaseApiToolArgs with a 'body' field (a JSON record) for POST request bodies.
export const RequestWithBodyArgs = z.object({ ...BaseApiToolArgs, body: bodyField, }); - The createWriteHandler function wraps the controller's handlePost into an MCP tool handler. It handles formatting the response and error formatting for the tool output.
function createWriteHandler( methodName: string, handler: ( options: RequestWithBodyArgsType, ) => Promise<{ content: string; rawResponsePath?: string | null }>, ) { return async (args: Record<string, unknown>) => { const methodLogger = Logger.forContext( 'tools/atlassian.api.tool.ts', methodName.toLowerCase(), ); methodLogger.debug(`Making ${methodName} request with args:`, { path: args.path, bodyKeys: args.body ? Object.keys(args.body as object) : [], }); try { const result = await handler(args as RequestWithBodyArgsType); methodLogger.debug( 'Successfully received response from controller', ); return { content: [ { type: 'text' as const, text: truncateForAI( result.content, result.rawResponsePath, ), }, ], }; } catch (error) { methodLogger.error(`Failed to make ${methodName} request`, error); return formatErrorForMcpTool(error); } }; } - The shared handleRequest function handles all HTTP methods (GET, POST, PUT, PATCH, DELETE). For POST, it calls atlassianApiService.request with method 'POST', then applies JQ filtering and converts output to TOON or JSON format.
async function handleRequest( method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', options: RequestWithBodyOptions, ): Promise<ControllerResponse> { const methodLogger = logger.forMethod(`handle${method}`); try { methodLogger.debug(`Making ${method} request`, { path: options.path, ...(options.body && { bodyKeys: Object.keys(options.body) }), }); // Call the service layer (returns TransportResponse with data and rawResponsePath) const response = await atlassianApiService.request<unknown>( options.path, { method, queryParams: options.queryParams, body: options.body, }, ); methodLogger.debug('Successfully received response from service'); // Apply JQ filter if provided, otherwise return raw data const result = applyJqFilter(response.data, options.jq); // Convert to output format (TOON by default, JSON if requested) const useToon = options.outputFormat !== 'json'; const content = await toOutputString(result, useToon); return { content, rawResponsePath: response.rawResponsePath, }; } catch (error) { throw handleControllerError(error, { entityType: 'API', operation: `${method} request`, source: `controllers/atlassian.api.controller.ts@handle${method}`, additionalInfo: { path: options.path }, }); } }