Skip to main content
Glama

update_wiki_page_safe

Safely update Azure DevOps wiki pages with automatic retry on version conflicts to maintain content accuracy.

Instructions

Safely updates a wiki page with automatic retry on version conflicts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesThe name or ID of the project.
wiki_identifierYesThe name or ID of the wiki.
pathYesThe path of the wiki page.
contentYesThe content of the wiki page.
max_retriesNoMaximum number of retry attempts (default: 3).

Implementation Reference

  • Core handler implementation that safely updates wiki pages with retry logic on version conflicts using ETag for optimistic concurrency.
    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")
  • Tool schema definition including input parameters and validation for update_wiki_page_safe.
    types.Tool(
        name="update_wiki_page_safe",
        description="Safely updates a wiki page with automatic retry on version conflicts.",
        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."
                },
                "max_retries": {
                    "type": "integer", 
                    "description": "Maximum number of retry attempts (default: 3)."
                },
            },
            "required": ["project", "wiki_identifier", "path", "content"],
            "additionalProperties": False
        }
    ),
  • Server-side dispatch handler that calls the client method and formats the response for the MCP protocol.
    elif name == "update_wiki_page_safe":
        page = self.client.update_wiki_page_safe(**arguments)
        return {
            "path": page.page.path,
            "url": page.page.url,
            "content": page.page.content,
            "message": "Wiki page updated successfully with safe retry mechanism."
        }
  • Helper method that uses update_wiki_page_safe for upsert logic, falling back to create if not found.
    def create_or_update_wiki_page_smart(self, project, wiki_identifier, path, content):
        """
        Creates a new wiki page or updates existing one intelligently.
        """
        try:
            # Try to update first
            return self.update_wiki_page_safe(project, wiki_identifier, path, content)
        except Exception as e:
            if "not found" in str(e).lower() or "404" in str(e):
                # Page doesn't exist, create it
                return self.create_wiki_page(project, wiki_identifier, path, content)
            else:
                raise e

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xrmghost/mcp-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server