edit_wiki_page
Update and manage Azure DevOps wiki pages directly by modifying content, specifying project and wiki details, and ensuring concurrency control with ETag.
Instructions
Edit an existing wiki page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | New content of the wiki page | |
| etag | No | ETag for concurrency control | |
| path | Yes | Path of the wiki page | |
| project | Yes | Name of the Azure DevOps project | |
| wiki | Yes | Name of the wiki |
Input Schema (JSON Schema)
{
"properties": {
"content": {
"description": "New content of the wiki page",
"type": "string"
},
"etag": {
"description": "ETag for concurrency control",
"type": "string"
},
"path": {
"description": "Path of the wiki page",
"type": "string"
},
"project": {
"description": "Name of the Azure DevOps project",
"type": "string"
},
"wiki": {
"description": "Name of the wiki",
"type": "string"
}
},
"required": [
"project",
"wiki",
"path",
"content"
],
"type": "object"
}
Implementation Reference
- src/tools/wiki.ts:74-127 (handler)Core handler function for the 'edit_wiki_page' tool. Parses input parameters using Zod schema, retrieves current page ETag if not provided, and updates the wiki page content via Azure DevOps REST API calls.export async function editWikiPage(rawParams: any) { // Parse arguments with defaults from environment variables const params = editWikiPageSchema.parse({ project: rawParams.project || DEFAULT_PROJECT, wiki: rawParams.wiki, path: rawParams.path, content: rawParams.content, etag: rawParams.etag, }); console.error("[API] Editing wiki page:", params.path); try { // Get current page to get ETag if not provided const wikiId = params.wiki; // Assuming wiki parameter is the wiki ID const getPageUrl = `${ORG_URL}/${ params.project }/_wiki/wikis/${wikiId}/pages?path=${encodeURIComponent( params.path )}&api-version=7.1-preview.1`; const currentPage = await makeAzureDevOpsRequest(getPageUrl); console.error("[API] Current page:", currentPage); // Use provided etag or get from current page const etag = params.etag || currentPage.eTag; console.error("[API] Using ETag:", etag); // Then update the page const updatePageUrl = `${ORG_URL}/${ params.project }/_wiki/wikis/${wikiId}/pages?path=${encodeURIComponent( params.path )}&api-version=7.1-preview.1`; const page = await makeAzureDevOpsRequest( updatePageUrl, "PUT", { content: params.content }, { "If-Match": etag } ); return { content: [ { type: "text", text: JSON.stringify(page, null, 2), }, ], }; } catch (error) { logError("Error editing wiki page", error); throw error; }
- src/schemas/wiki.ts:18-26 (schema)Zod schema and TypeScript type for validating and typing the input parameters of the editWikiPage handler.export const editWikiPageSchema = z.object({ project: z.string(), wiki: z.string(), path: z.string(), content: z.string(), etag: z.string(), }); export type EditWikiPageParams = z.infer<typeof editWikiPageSchema>;
- src/tools/wiki.ts:160-189 (registration)Tool registration specification for 'edit_wiki_page' within the wikiTools array, defining name, description, and JSON inputSchema advertised to MCP clients via listTools.{ name: "edit_wiki_page", description: "Edit an existing wiki page", inputSchema: { type: "object", properties: { project: { type: "string", description: "Name of the Azure DevOps project", }, wiki: { type: "string", description: "Name of the wiki", }, path: { type: "string", description: "Path of the wiki page", }, content: { type: "string", description: "New content of the wiki page", }, etag: { type: "string", description: "ETag for concurrency control", }, }, required: ["project", "wiki", "path", "content"], }, },
- src/index.ts:93-94 (registration)Dispatch handler in the MCP server's CallToolRequest handler that routes calls to 'edit_wiki_page' to the editWikiPage function.case "edit_wiki_page": return await editWikiPage(request.params.arguments || {});
- src/index.ts:50-62 (registration)MCP server request handler for ListToolsRequest that includes wikiTools (containing edit_wiki_page spec) in the advertised tool list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // Work Items ...workItemTools, // Pull Requests ...pullRequestTools, // Wiki ...wikiTools, // Projects ...projectTools, ], };