Skip to main content
Glama
uright

Azure DevOps Wiki MCP Server

by uright

wiki_update_page

Update content of an existing Azure DevOps wiki page or create a new page if it does not exist.

Instructions

Update content of an existing wiki page or create a new page if it does not exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationNoAzure DevOps organization name
projectNoProject name
wikiIdYesWiki identifier
pathYesPage path or page ID
contentYesNew page content (Markdown)

Implementation Reference

  • Handler function `handleUpdatePage` that parses request via `WikiUpdatePageRequestSchema`, validates org/project, calls `AzureDevOpsWikiClient.updatePage()`, and returns the result.
    private async handleUpdatePage(args: any) {
      const request = WikiUpdatePageRequestSchema.parse(args);
      const organization = request.organization || this.config.defaultOrganization;
      const project = request.project || this.config.defaultProject;
      
      if (!organization) {
        throw new Error('Organization is required either as parameter or in server configuration');
      }
      if (!project) {
        throw new Error('Project is required either as parameter or in server configuration');
      }
      
      const client = await this.getClient(organization, project);
      const result = await client.updatePage(request);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(result, null, 2)
        }]
      };
    }
  • Core implementation of `updatePage()` method on `AzureDevOpsWikiClient`. Checks if the page exists (to get version for If-Match header), then does a PUT request to the Azure DevOps Wiki REST API to update or create the page.
    async updatePage(request: WikiUpdatePageRequest): Promise<WikiPageUpdateResult> {
      if (!this.wikiApi || !this.connection) {
        throw new Error('Azure DevOps client not initialized');
      }
    
      try {
        const organization = request.organization || this.config.organization;
        const project = request.project || this.config.project;
        
        if (!organization || !project) {
          throw new Error('Organization and project must be provided');
        }
    
        // Set encoded pagePath
        const encodedPath = encodeURIComponent(request.path);
    
        // Get wiki object
        const wiki = await this.wikiApi.getWiki(request.wikiId, project);
        // Fix: Access the first element of versions array safely and get its version property
        const wikiVersion = Array.isArray(wiki.versions) && wiki.versions.length > 0
          ? wiki.versions[0].version
          : 'wikiMaster';
        
        // First, check if page exists to get version for updates
        let pageVersion: string | undefined;
        let pageExists = false;
        
        try {
          let wikiPageResponse = await this.wikiApi.http.get(`${wiki.url}/pages?path=${encodedPath}`);
    
          if (wikiPageResponse.message && wikiPageResponse.message.statusCode === 200) {
            pageExists = true;
            pageVersion = wikiPageResponse.message.headers.etag;
          }
        } catch (checkError) {
          // Page doesn't exist, we'll create it
          pageExists = false;
        }
    
        // Create headers object with proper typing
        const headers: { [key: string]: string } = {
          'Content-Type': 'application/json'
        };
    
        // Only add If-Match header if page exists and we have a version
        // For new pages, don't include If-Match header
        if (pageExists && pageVersion) {
          headers['If-Match'] = pageVersion;
        }
    
        const requestBody = {
          content: request.content
        };
    
        // TODO: Add versionDescriptor.versionType and versionDescriptor.version as optional environment variables
        const apiUrl = `${wiki.url}/pages?path=${encodedPath}&api-version=7.1&versionDescriptor.versionType=branch&versionDescriptor.version=${wikiVersion}`;
        
        const response = await this.wikiApi.http.put(apiUrl, JSON.stringify(requestBody), headers);
        
        if (!response.message || (response.message.statusCode !== 200 && response.message.statusCode !== 201)) {
          // Enhanced error information for debugging
          const errorDetails: {
            statusCode: number | undefined;
            statusMessage: string | undefined;
            headers: { [key: string]: string | string[] | undefined } | undefined;
            url: string;
            requestHeaders: { [key: string]: string };
            requestBody: { content: string };
            pageExists: boolean;
            pageVersion: string | undefined;
            responseBody?: string;
          } = {
            statusCode: response.message?.statusCode,
            statusMessage: response.message?.statusMessage,
            headers: response.message?.headers,
            url: apiUrl,
            requestHeaders: headers,
            requestBody: requestBody,
            pageExists,
            pageVersion
          };
          
          throw new Error(`Failed to ${pageExists ? 'update' : 'create'} page: HTTP ${response.message?.statusCode || 'Unknown'}. Details: ${JSON.stringify(errorDetails, null, 2)}`);
        }
    
        const responseBody = await response.readBody();
        if (!responseBody) {
          throw new Error('Empty response body');
        }
    
        const data = JSON.parse(responseBody);
        
        // Handle the response structure
        let pageData = data.value || data;
        
        if (!pageData || pageData === null || (data.value !== undefined && data.value === null)) {
          throw new Error(`Failed to ${pageExists ? 'update' : 'create'} page: ${request.path}`);
        }
    
        return {
          id: pageData.id?.toString() || '',
          path: pageData.path || request.path,
          title: pageData.path ? pageData.path.split('/').pop() || '' : '',
          version: pageData.version || response.message.headers.etag || '',
          isParentPage: pageData.isParentPage || false,
          order: pageData.order || 0,
          gitItemPath: pageData.gitItemPath || ''
        };
      } catch (error) {
        throw new Error(`Failed to update page: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Zod schema `WikiUpdatePageRequestSchema` defining the input fields: organization (optional), project (optional), wikiId (required), path (required), content (required).
    export const WikiUpdatePageRequestSchema = z.object({
      organization: z.string().min(1).optional(),
      project: z.string().min(1).optional(),
      wikiId: z.string().min(1),
      path: z.string().min(1),
      content: z.string(),
    });
  • Return type `WikiPageUpdateResult` interface with fields: id, path, title, version, isParentPage, order, gitItemPath.
    export interface WikiPageUpdateResult {
      id: string;
      path: string;
      title: string;
      version: string;
      isParentPage: boolean;
      order: number;
      gitItemPath: string;
    }
  • src/server.ts:108-137 (registration)
    Registration of `wiki_update_page` tool in the `ListToolsRequestSchema` handler with name, description, and input schema definition.
    {
      name: 'wiki_update_page',
      description: 'Update content of an existing wiki page or create a new page if it does not exist',
      inputSchema: {
        type: 'object',
        properties: {
          organization: {
            type: 'string',
            description: 'Azure DevOps organization name'
          },
          project: {
            type: 'string',
            description: 'Project name'
          },
          wikiId: {
            type: 'string',
            description: 'Wiki identifier'
          },
          path: {
            type: 'string',
            description: 'Page path or page ID'
          },
          content: {
            type: 'string',
            description: 'New page content (Markdown)'
          }
        },
        required: ['wikiId', 'path', 'content']
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description only says 'update or create,' lacking details on replacement behavior, permissions, or idempotency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with verb, no unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple upsert, but missing details on error handling, output, and permissions. No output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. Description adds no extra parameter meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool updates an existing page or creates a new one, distinguishing it from read-only siblings like list, search, and get.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied as the only write tool among siblings, but no explicit guidance on when to use vs alternatives or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/uright/azure-devops-wiki-mcp'

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