Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

wiki_create_or_update_page

Create or update wiki pages in Azure DevOps with markdown content. Specify wiki identifier, path, and content for precise documentation management using PAT authentication.

Instructions

Create or update a wiki page with content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content of the wiki page in markdown format.
etagNoETag for editing existing pages (optional, will be fetched if not provided).
pathYesThe path of the wiki page (e.g., '/Home' or '/Documentation/Setup').
projectNoThe project name or ID where the wiki is located. If not provided, the default project will be used.
wikiIdentifierYesThe unique identifier or name of the wiki.

Implementation Reference

  • The core handler implementation for the wiki_create_or_update_page tool. It handles creating new wiki pages or updating existing ones via direct REST API calls to Azure DevOps, managing ETags for updates.
    server.tool(
      WIKI_TOOLS.create_or_update_page,
      "Create or update a wiki page with content.",
      {
        wikiIdentifier: z.string().describe("The unique identifier or name of the wiki."),
        path: z.string().describe("The path of the wiki page (e.g., '/Home' or '/Documentation/Setup')."),
        content: z.string().describe("The content of the wiki page in markdown format."),
        project: z.string().optional().describe("The project name or ID where the wiki is located. If not provided, the default project will be used."),
        etag: z.string().optional().describe("ETag for editing existing pages (optional, will be fetched if not provided)."),
      },
      async ({ wikiIdentifier, path, content, project, etag }) => {
        try {
          const connection = await connectionProvider();
          const accessToken = await tokenProvider();
    
          // Normalize the path
          const normalizedPath = path.startsWith("/") ? path : `/${path}`;
          const encodedPath = encodeURIComponent(normalizedPath);
    
          // Build the URL for the wiki page API
          const baseUrl = connection.serverUrl;
          const projectParam = project || "";
          const url = `${baseUrl}/${projectParam}/_apis/wiki/wikis/${wikiIdentifier}/pages?path=${encodedPath}&api-version=7.1`;
    
          // First, try to create a new page (PUT without ETag)
          try {
            const createResponse = await fetch(url, {
              method: "PUT",
              headers: {
                "Authorization": `Bearer ${accessToken.token}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({ content: content }),
            });
    
            if (createResponse.ok) {
              const result = await createResponse.json();
              return {
                content: [
                  {
                    type: "text",
                    text: `Successfully created wiki page at path: ${normalizedPath}. Response: ${JSON.stringify(result, null, 2)}`,
                  },
                ],
              };
            }
    
            // If creation failed with 409 (Conflict) or 500 (Page exists), try to update it
            if (createResponse.status === 409 || createResponse.status === 500) {
              // Page exists, we need to get the ETag and update it
              let currentEtag = etag;
    
              if (!currentEtag) {
                // Fetch current page to get ETag
                const getResponse = await fetch(url, {
                  method: "GET",
                  headers: {
                    Authorization: `Bearer ${accessToken.token}`,
                  },
                });
    
                if (getResponse.ok) {
                  currentEtag = getResponse.headers.get("etag") || getResponse.headers.get("ETag") || undefined;
                  if (!currentEtag) {
                    const pageData = await getResponse.json();
                    currentEtag = pageData.eTag;
                  }
                }
    
                if (!currentEtag) {
                  throw new Error("Could not retrieve ETag for existing page");
                }
              }
    
              // Now update the existing page with ETag
              const updateResponse = await fetch(url, {
                method: "PUT",
                headers: {
                  "Authorization": `Bearer ${accessToken.token}`,
                  "Content-Type": "application/json",
                  "If-Match": currentEtag,
                },
                body: JSON.stringify({ content: content }),
              });
    
              if (updateResponse.ok) {
                const result = await updateResponse.json();
                return {
                  content: [
                    {
                      type: "text",
                      text: `Successfully updated wiki page at path: ${normalizedPath}. Response: ${JSON.stringify(result, null, 2)}`,
                    },
                  ],
                };
              } else {
                const errorText = await updateResponse.text();
                throw new Error(`Failed to update page (${updateResponse.status}): ${errorText}`);
              }
            } else {
              const errorText = await createResponse.text();
              throw new Error(`Failed to create page (${createResponse.status}): ${errorText}`);
            }
          } catch (fetchError) {
            throw fetchError;
          }
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
    
          return {
            content: [{ type: "text", text: `Error creating/updating wiki page: ${errorMessage}` }],
            isError: true,
          };
        }
      }
    );
  • Input schema using Zod for validating tool parameters: wikiIdentifier, path, content, project (optional), etag (optional).
    {
      wikiIdentifier: z.string().describe("The unique identifier or name of the wiki."),
      path: z.string().describe("The path of the wiki page (e.g., '/Home' or '/Documentation/Setup')."),
      content: z.string().describe("The content of the wiki page in markdown format."),
      project: z.string().optional().describe("The project name or ID where the wiki is located. If not provided, the default project will be used."),
      etag: z.string().optional().describe("ETag for editing existing pages (optional, will be fetched if not provided)."),
    },
  • src/tools.ts:15-26 (registration)
    The wiki tools, including wiki_create_or_update_page, are registered by calling configureWikiTools(server, tokenProvider, connectionProvider). This function uses server.tool() internally to register the tool.
    import { configureWikiTools } from "./tools/wiki.js";
    import { configureWorkTools } from "./tools/work.js";
    import { configureWorkItemTools } from "./tools/workitems.js";
    
    function configureAllTools(server: McpServer, tokenProvider: () => Promise<AccessToken>, connectionProvider: () => Promise<WebApi>, userAgentProvider: () => string) {
      configureCoreTools(server, tokenProvider, connectionProvider, userAgentProvider);
      configureWorkTools(server, tokenProvider, connectionProvider);
      configureBuildTools(server, tokenProvider, connectionProvider, userAgentProvider);
      configureRepoTools(server, tokenProvider, connectionProvider, userAgentProvider);
      configureWorkItemTools(server, tokenProvider, connectionProvider, userAgentProvider);
      configureReleaseTools(server, tokenProvider, connectionProvider);
      configureWikiTools(server, tokenProvider, connectionProvider);
  • Constant object mapping internal names to tool names, defining 'create_or_update_page' as 'wiki_create_or_update_page'.
    const WIKI_TOOLS = {
      list_wikis: "wiki_list_wikis",
      get_wiki: "wiki_get_wiki",
      list_wiki_pages: "wiki_list_pages",
      get_wiki_page_content: "wiki_get_page_content",
      create_or_update_page: "wiki_create_or_update_page",
    };
  • Duplicate handler implementation in microsoft-exact-tools.ts, likely for an alternative tool registration mechanism.
    {
      name: "wiki_create_or_update_page",
      description: "Create or update a wiki page with content.",
      inputSchema: {
        type: "object",
        properties: {
          wikiIdentifier: { type: "string", description: "The unique identifier or name of the wiki." },
          path: { type: "string", description: "The path of the wiki page (e.g., '/Home' or '/Documentation/Setup')." },
          content: { type: "string", description: "The content of the wiki page in markdown format." },
          project: { type: "string", description: "The project name or ID where the wiki is located. If not provided, the default project will be used." },
          etag: { type: "string", description: "ETag for editing existing pages (optional, will be fetched if not provided)." }
        },
        required: ["wikiIdentifier", "path", "content"]
      },
      handler: async (args, connection, tokenProvider) => {
        try {
          if (!tokenProvider) {
            throw new Error("Token provider is required for wiki page creation/update");
          }
          
          const accessToken = await tokenProvider();
    
          // Normalize the path
          const normalizedPath = args.path.startsWith("/") ? args.path : `/${args.path}`;
          const encodedPath = encodeURIComponent(normalizedPath);
    
          // Build the URL for the wiki page API
          const baseUrl = connection.serverUrl;
          const projectParam = args.project || "";
          const url = `${baseUrl}/${projectParam}/_apis/wiki/wikis/${args.wikiIdentifier}/pages?path=${encodedPath}&api-version=7.1`;
    
          // First, try to create a new page (PUT without ETag)
          try {
            const createResponse = await fetch(url, {
              method: "PUT",
              headers: {
                "Authorization": `Bearer ${accessToken.token}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({ content: args.content }),
            });
    
            if (createResponse.ok) {
              const result = await createResponse.json();
              return {
                content: [
                  {
                    type: "text",
                    text: `Successfully created wiki page at path: ${normalizedPath}. Response: ${JSON.stringify(result, null, 2)}`,
                  },
                ],
              };
            }
    
            // If creation failed with 409 (Conflict) or 500 (Page exists), try to update it
            if (createResponse.status === 409 || createResponse.status === 500) {
              // Page exists, we need to get the ETag and update it
              let currentEtag = args.etag;
    
              if (!currentEtag) {
                // Fetch current page to get ETag
                const getResponse = await fetch(url, {
                  method: "GET",
                  headers: {
                    Authorization: `Bearer ${accessToken.token}`,
                  },
                });
    
                if (getResponse.ok) {
                  currentEtag = getResponse.headers.get("etag") || getResponse.headers.get("ETag") || undefined;
                  if (!currentEtag) {
                    const pageData = await getResponse.json();
                    currentEtag = pageData.eTag;
                  }
                }
    
                if (!currentEtag) {
                  throw new Error("Could not retrieve ETag for existing page");
                }
              }
    
              // Now update the existing page with ETag
              const updateResponse = await fetch(url, {
                method: "PUT",
                headers: {
                  "Authorization": `Bearer ${accessToken.token}`,
                  "Content-Type": "application/json",
                  "If-Match": currentEtag,
                },
                body: JSON.stringify({ content: args.content }),
              });
    
              if (updateResponse.ok) {
                const result = await updateResponse.json();
                return {
                  content: [
                    {
                      type: "text",
                      text: `Successfully updated wiki page at path: ${normalizedPath}. Response: ${JSON.stringify(result, null, 2)}`,
                    },
                  ],
                };
              } else {
                const errorText = await updateResponse.text();
                throw new Error(`Failed to update page (${updateResponse.status}): ${errorText}`);
              }
            } else {
              const errorText = await createResponse.text();
              throw new Error(`Failed to create page (${createResponse.status}): ${errorText}`);
            }
          } catch (fetchError) {
            throw fetchError;
          }
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
    
          return {
            content: [{ type: "text", text: `Error creating/updating wiki page: ${errorMessage}` }],
            isError: true,
          };
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'create or update' which implies mutation, but doesn't specify permissions needed, whether operations are atomic, how conflicts are handled, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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?

The description is a single, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized and front-loaded with the essential action, earning full marks for conciseness.

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

Completeness2/5

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

For a mutation tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the 'create or update' logic, return values, error handling, or how it differs from sibling tools, leaving significant gaps for the agent.

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 description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline expectation but not providing extra value.

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

Purpose4/5

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

The description clearly states the verb ('create or update') and resource ('wiki page with content'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'wiki_get_page_content' or explain the 'create or update' logic, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'wiki_get_page_content' or 'wiki_list_pages'. There's no mention of prerequisites, error conditions, or typical use cases, leaving the agent with minimal contextual direction.

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

Related 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/ennuiii/DevOpsMcpPAT'

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