update_wiki_page
Create or modify Azure DevOps wiki pages with markdown content to maintain project documentation and share knowledge across teams.
Instructions
Create or update a wiki page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wikiIdentifier | Yes | Wiki identifier | |
| path | Yes | Page path | |
| content | Yes | Page content in markdown format | |
| comment | No | Comment for the update (optional) |
Implementation Reference
- src/tools/wiki/update.ts:12-61 (handler)Core handler function that implements the logic for updating a wiki page, including validation, wiki retrieval, and response formatting (noting current API limitations).export async function updateWikiPage(args: UpdateWikiPageArgs, config: AzureDevOpsConfig) { if (!args.wikiIdentifier || !args.path || !args.content) { throw new McpError( ErrorCode.InvalidParams, 'Wiki identifier, page path, and content are required' ); } AzureDevOpsConnection.initialize(config); const connection = AzureDevOpsConnection.getInstance(); const wikiApi = await connection.getWikiApi(); try { const wiki = await wikiApi.getWiki(config.project, args.wikiIdentifier); if (!wiki || !wiki.id) { throw new McpError( ErrorCode.InvalidParams, `Wiki ${args.wikiIdentifier} not found` ); } const updateParams = { content: args.content, comment: args.comment || `Updated page ${args.path}`, }; // Da die Wiki-API keine direkte Methode zum Aktualisieren von Seiten bietet, // geben wir vorerst nur die Wiki-Informationen zurück return { content: [ { type: 'text', text: JSON.stringify({ wiki, path: args.path, message: 'Wiki page update is not supported in the current API version', requestedUpdate: updateParams }, null, 2), }, ], }; } catch (error: unknown) { if (error instanceof McpError) throw error; const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new McpError( ErrorCode.InternalError, `Failed to update wiki page: ${errorMessage}` ); } }
- src/tools/wiki/index.ts:64-89 (schema)Tool input schema definition for update_wiki_page, specifying parameters and requirements.{ name: 'update_wiki_page', description: 'Create or update a wiki page', inputSchema: { type: 'object', properties: { wikiIdentifier: { type: 'string', description: 'Wiki identifier', }, path: { type: 'string', description: 'Page path', }, content: { type: 'string', description: 'Page content in markdown format', }, comment: { type: 'string', description: 'Comment for the update (optional)', }, }, required: ['wikiIdentifier', 'path', 'content'], }, },
- src/tools/wiki/index.ts:92-104 (registration)Registration of wiki tools including the updateWikiPage handler binding and definitions export.export const wikiTools = { initialize: (config: AzureDevOpsConfig) => ({ getWikis: (args: Record<string, never>) => getWikis(args, config), getWikiPage: (args: { wikiIdentifier: string; path: string; version?: string; includeContent?: boolean }) => getWikiPage(args, config), createWiki: (args: { name: string; projectId?: string; mappedPath?: string }) => createWiki(args, config), updateWikiPage: (args: { wikiIdentifier: string; path: string; content: string; comment?: string }) => updateWikiPage(args, config), definitions, }), definitions, };
- src/index.ts:148-150 (registration)Main server dispatch/registration for the update_wiki_page tool call.case 'update_wiki_page': result = await tools.wiki.updateWikiPage(request.params.arguments); break;
- src/tools/wiki/update.ts:5-10 (schema)TypeScript interface defining the arguments for the updateWikiPage function.interface UpdateWikiPageArgs { wikiIdentifier: string; path: string; content: string; comment?: string; }
- src/api/wiki.ts:129-170 (helper)WikiApi class method for updating wiki pages via direct API fetch (PUT request), used as helper in the tool ecosystem.async updateWikiPage( wikiIdentifier: string, path: string, content: string, comment?: string ): Promise<WikiPageUpdateResponse> { const authHeader = await this.getAuthHeader(); const encodedPath = encodeURIComponent(path); const response = await fetch( `${this.baseUrl}/${wikiIdentifier}/pages?path=${encodedPath}&api-version=7.0`, { method: 'PUT', headers: { 'Content-Type': 'application/json', Authorization: authHeader, }, body: JSON.stringify({ content, comment: comment || `Updated page ${path}`, }), } ); if (response.status === 404) { if (response.statusText.includes('Wiki not found')) { throw new WikiNotFoundError(wikiIdentifier); } throw new WikiPageNotFoundError(wikiIdentifier, path); } if (!response.ok) { throw new WikiError( `Failed to update wiki page: ${response.statusText}`, response.status, wikiIdentifier, path, await response.text() ); } return response.json(); }