create-page
Create new wiki pages by providing content and titles for MediaWiki sites through the MCP server.
Instructions
Creates a wiki page with the provided content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Page content in the format specified by the contentModel parameter | |
| title | Yes | Wiki page title | |
| comment | No | Reason for creating the page | |
| contentModel | No | Type of content on the page | wikitext |
Implementation Reference
- src/tools/create-page.ts:9-28 (registration)Registers the 'create-page' tool with MCP server, defining input schema using Zod and linking to the handler function.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)Executes the tool: sends POST request to /v1/page endpoint with page data, handles errors, and returns success response.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:60-80 (helper)Helper function to format the tool result content from the API response.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)Registers all tools, including createPageTool, by calling each registrar function on the MCP server.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; }
- src/tools/create-page.ts:14-18 (schema)Zod schema defining input parameters for the create-page tool.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' ) },