create-page
Create a wiki page by specifying title, content, and optional details like comment and content model using the MCP server for MediaWiki.
Instructions
Creates a wiki page with the provided content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comment | No | Reason for creating the page | |
| contentModel | No | Type of content on the page. Defaults to "wikitext" | |
| source | Yes | Page content in the format specified by the contentModel parameter | |
| title | Yes | Wiki page title |
Implementation Reference
- src/tools/create-page.ts:9-28 (registration)Registers the 'create-page' tool with the MCP server, including input schema, annotations, and handler reference.export function createPageTool( server: McpServer ): RegisteredTool { return server.tool( 'create-page', 'Creates a wiki page with the provided content.', { source: z.string().describe( 'Page content in the format specified by the contentModel parameter' ), title: z.string().describe( 'Wiki page title' ), comment: z.string().optional().describe( 'Reason for creating the page' ), contentModel: z.string().optional().default( 'wikitext' ).describe( 'Type of content on the page' ) }, { title: 'Create page', readOnlyHint: false, destructiveHint: true } as ToolAnnotations, async ( { source, title, comment, contentModel } ) => handleCreatePageTool( source, title, comment, contentModel ) ); }
- src/tools/create-page.ts:30-58 (handler)Core execution logic: POSTs to /v1/page API endpoint to create the wiki page, handles errors, and delegates success formatting.async function handleCreatePageTool( source: string, title: string, comment?: string, contentModel?: string ): Promise<CallToolResult> { let data: MwRestApiPageObject; try { data = await makeRestPostRequest<MwRestApiPageObject>( '/v1/page', { source: source, title: title, comment: formatEditComment( 'create-page', comment ), // eslint-disable-next-line camelcase content_model: contentModel }, true ); } catch ( error ) { return { content: [ { type: 'text', text: `Failed to create page: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } return { content: createPageToolResult( data ) }; }
- src/tools/create-page.ts:14-18 (schema)Zod input schema defining parameters: source, title, optional comment and contentModel.source: z.string().describe( 'Page content in the format specified by the contentModel parameter' ), title: z.string().describe( 'Wiki page title' ), comment: z.string().optional().describe( 'Reason for creating the page' ), contentModel: z.string().optional().default( 'wikitext' ).describe( 'Type of content on the page' ) },
- src/tools/create-page.ts:60-80 (helper)Formats the API response into a detailed TextContent array for the tool output.function createPageToolResult( result: MwRestApiPageObject ): TextContent[] { return [ { type: 'text', text: `Page created successfully: ${ getPageUrl( result.title ) }` }, { type: 'text', text: [ 'Page object:', `Page ID: ${ result.id }`, `Title: ${ result.title }`, `Latest revision ID: ${ result.latest.id }`, `Latest revision timestamp: ${ result.latest.timestamp }`, `Content model: ${ result.content_model }`, `License: ${ result.license.url } ${ result.license.title }`, `HTML URL: ${ result.html_url }` ].join( '\n' ) } ]; }
- src/tools/index.ts:41-51 (registration)Overall tool registration function that calls createPageTool among others.export function registerAllTools( server: McpServer ): RegisteredTool[] { const registeredTools: RegisteredTool[] = []; for ( const registrar of toolRegistrars ) { try { registeredTools.push( registrar( server ) ); } catch ( error ) { console.error( `Error registering tool: ${ ( error as Error ).message }` ); } } return registeredTools; }