update_wiki_page
Modify existing wiki pages in Azure DevOps by providing new content, project details, wiki identifier, and page path to maintain current documentation.
Instructions
Updates an existing wiki page with new content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content of the wiki page. | |
| path | Yes | The path of the wiki page. | |
| project | Yes | The name or ID of the project. | |
| wiki_identifier | Yes | The name or ID of the wiki. |
Implementation Reference
- Core handler implementation for updating a wiki page. Fetches current page to extract ETag for optimistic concurrency control, then updates content using Azure DevOps Wiki API.def update_wiki_page(self, project, wiki_identifier, path, content): page = self.wiki_client.get_page( project=project, wiki_identifier=wiki_identifier, path=path ) # Try to get ETag from various possible locations etag = None if hasattr(page, 'eTag'): etag = page.eTag elif hasattr(page, 'etag'): etag = page.etag elif hasattr(page, 'e_tag'): etag = page.e_tag elif hasattr(page, '_etag'): etag = page._etag elif hasattr(page, 'page') and hasattr(page.page, 'eTag'): etag = page.page.eTag elif hasattr(page, 'page') and hasattr(page.page, 'etag'): etag = page.page.etag elif hasattr(page, 'page') and hasattr(page.page, 'e_tag'): etag = page.page.e_tag parameters = { "content": content } return self.wiki_client.create_or_update_page( project=project, wiki_identifier=wiki_identifier, path=path, parameters=parameters, version=etag )
- mcp_azure_devops/server.py:967-973 (handler)MCP server-side handler in _execute_tool method that dispatches to the client's update_wiki_page method and formats the response.elif name == "update_wiki_page": page = self.client.update_wiki_page(**arguments) return { "path": page.page.path, "url": page.page.url, "content": page.page.content, }
- mcp_azure_devops/server.py:357-382 (schema)Tool schema definition including input validation schema for the update_wiki_page tool.types.Tool( name="update_wiki_page", description="Updates an existing wiki page with new content.", inputSchema={ "type": "object", "properties": { "project": { "type": "string", "description": "The name or ID of the project." }, "wiki_identifier": { "type": "string", "description": "The name or ID of the wiki." }, "path": { "type": "string", "description": "The path of the wiki page." }, "content": { "type": "string", "description": "The content of the wiki page." }, }, "required": ["project", "wiki_identifier", "path", "content"], "additionalProperties": False }
- mcp_azure_devops/server.py:857-862 (registration)Registration handler that returns the list of tools including update_wiki_page when list_tools is called.@self.server.list_tools() async def list_tools() -> List[types.Tool]: """Return the list of available tools.""" logger.info(f"Tools requested - returning {len(self.tools)} tools") self.tools_registered = True return self.tools
- Helper method that provides safe updating with automatic retries on version conflicts, building upon the core update_wiki_page logic.def update_wiki_page_safe(self, project, wiki_identifier, path, content, max_retries=3): """ Safely updates a wiki page with automatic retry on version conflicts. """ for attempt in range(max_retries): try: # Get the latest version of the page page = self.wiki_client.get_page( project=project, wiki_identifier=wiki_identifier, path=path ) # Try to get ETag from various possible locations etag = None if hasattr(page, 'eTag'): etag = page.eTag elif hasattr(page, 'etag'): etag = page.etag elif hasattr(page, 'e_tag'): etag = page.e_tag elif hasattr(page, '_etag'): etag = page._etag elif hasattr(page, 'page') and hasattr(page.page, 'eTag'): etag = page.page.eTag elif hasattr(page, 'page') and hasattr(page.page, 'etag'): etag = page.page.etag elif hasattr(page, 'page') and hasattr(page.page, 'e_tag'): etag = page.page.e_tag parameters = { "content": content } return self.wiki_client.create_or_update_page( project=project, wiki_identifier=wiki_identifier, path=path, parameters=parameters, version=etag ) except Exception as e: if "version" in str(e).lower() and attempt < max_retries - 1: # Version conflict, retry with fresh version continue else: raise e raise Exception(f"Failed to update wiki page after {max_retries} attempts due to version conflicts")