create_confluence_page
Create new pages in Confluence spaces to document information, organize content, and share knowledge within teams.
Instructions
Create a new page in a space
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spaceId | Yes | ID of the space to create the page in | |
| title | Yes | Title of the page | |
| content | Yes | Content of the page in Confluence storage format | |
| parentId | No | ID of the parent page (optional) |
Implementation Reference
- src/handlers/page-handlers.ts:188-233 (handler)The main handler function for the create_confluence_page tool. Validates input parameters, calls the ConfluenceClient to create the page, and returns a simplified response with page ID, version, and URL.export async function handleCreateConfluencePage( client: ConfluenceClient, args: { spaceId: string; title: string; content: string; parentId?: string } ): Promise<{ content: Array<{ type: "text"; text: string }>; }> { try { if (!args.spaceId || !args.title || !args.content) { throw new McpError( ErrorCode.InvalidParams, "spaceId, title, and content are required" ); } const page = await client.createConfluencePage( args.spaceId, args.title, args.content, args.parentId ); const simplified = { id: page.id, version: page.version.number, url: page._links.webui }; return { content: [ { type: "text", text: JSON.stringify(simplified), }, ], }; } catch (error) { console.error("Error creating page:", error instanceof Error ? error.message : String(error)); if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Failed to create page: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:224-235 (registration)Tool registration in the MCP server's CallToolRequestSchema handler switch statement. Extracts arguments, performs basic validation, and delegates to the handleCreateConfluencePage function.case "create_confluence_page": { const { spaceId, title, content, parentId } = (args || {}) as { spaceId: string; title: string; content: string; parentId?: string }; if (!spaceId || !title || !content) { throw new McpError(ErrorCode.InvalidParams, "spaceId, title, and content are required"); } return await handleCreateConfluencePage(this.confluenceClient, { spaceId, title, content, parentId }); }
- src/schemas/tool-schemas.ts:87-111 (schema)Zod-like input schema definition and description for the create_confluence_page tool, defining parameters, types, descriptions, and required fields.create_confluence_page: { description: "Create a new page in a space", inputSchema: { type: "object", properties: { spaceId: { type: "string", description: "ID of the space to create the page in", }, title: { type: "string", description: "Title of the page", }, content: { type: "string", description: "Content of the page in Confluence storage format", }, parentId: { type: "string", description: "ID of the parent page (optional)", }, }, required: ["spaceId", "title", "content"], }, },
- ConfluenceClient helper method that performs the actual HTTP POST request to the Confluence API endpoint /api/v2/pages to create the new page.async createConfluencePage(spaceId: string, title: string, content: string, parentId?: string): Promise<Page> { const body = { spaceId, status: 'current', title, body: { representation: 'storage', value: content }, ...(parentId && { parentId }) }; const response = await this.v2Client.post('/pages', body); return response.data; }