Skip to main content
Glama
uright

Azure DevOps Wiki MCP Server

by uright

wiki_get_page

Retrieve content from Azure DevOps wiki pages to access documentation, project notes, or team knowledge directly within AI workflows.

Instructions

Get content of a specific wiki page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationNoAzure DevOps organization name
projectNoProject name
wikiIdYesWiki identifier
pathYesPage path or page ID

Implementation Reference

  • Handler function in the MCP server that processes 'wiki_get_page' tool calls: validates input using Zod schema, initializes Azure client if needed, delegates to client.getPage(), and formats response as MCP content.
    private async handleGetPage(args: any) {
      const request = WikiGetPageRequestSchema.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 page = await client.getPage(request);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(page, null, 2)
        }]
      };
    }
  • Core helper method that performs the actual API call to Azure DevOps Wiki API to retrieve page content, handles response parsing, and maps to WikiPageContent type.
    async getPage(request: WikiGetPageRequest): Promise<WikiPageContent> {
      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');
        }
    
        const orgUrl = this.config.azureDevOpsUrl || `https://dev.azure.com/${organization}`;
        const encodedPath = encodeURIComponent(request.path);
        const apiUrl = `${orgUrl}/${project}/_apis/wiki/wikis/${request.wikiId}/pages?path=${encodedPath}&includeContent=true&api-version=7.1`;
    
        const response = await this.connection.rest.client.get(apiUrl);
        
        if (!response.message || response.message.statusCode !== 200) {
          throw new Error(`Failed to get page: HTTP ${response.message?.statusCode || 'Unknown'}`);
        }
    
        const responseBody = await response.readBody();
        if (!responseBody) {
          throw new Error('Empty response body');
        }
    
        const data = JSON.parse(responseBody);
        
        // Handle the response structure
        let pageData;
        if (data.value) {
          // If value is an array, get the first element
          if (Array.isArray(data.value) && data.value.length > 0) {
            pageData = data.value[0];
          } else if (Array.isArray(data.value) && data.value.length === 0) {
            // Empty array means page not found
            throw new Error(`Page not found: ${request.path}`);
          } else {
            // value is not an array, use it directly
            pageData = data.value;
          }
        } else {
          // No value property, use data directly
          pageData = data;
        }
        
        if (!pageData || pageData === null) {
          throw new Error(`Page not found: ${request.path}`);
        }
    
        return {
          id: pageData.id?.toString() || '',
          path: pageData.path || request.path,
          title: pageData.path ? pageData.path.split('/').pop() || '' : '',
          content: pageData.content || '',
          gitItemPath: pageData.gitItemPath || '',
          order: pageData.order || 0,
          version: pageData.version || '',
          isParentPage: pageData.isParentPage || false
        };
      } catch (error) {
        throw new Error(`Failed to get page: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/server.ts:82-107 (registration)
    Tool registration in the MCP server's listTools response, defining name 'wiki_get_page', description, and JSON inputSchema.
    {
      name: 'wiki_get_page',
      description: 'Get content of a specific wiki page',
      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'
          }
        },
        required: ['wikiId', 'path']
      }
    },
  • Zod schema for input validation of wiki_get_page tool requests, used in handleGetPage for parsing arguments.
    export const WikiGetPageRequestSchema = z.object({
      organization: z.string().min(1).optional(),
      project: z.string().min(1).optional(),
      wikiId: z.string().min(1),
      path: z.string().min(1),
    });

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