Skip to main content
Glama
mmruesch12
by mmruesch12

create_wiki_page

Automate wiki page creation in Azure DevOps with a structured input system, specifying project, wiki name, path, and content for streamlined documentation.

Instructions

Create a new wiki page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent of the wiki page
pathYesPath of the wiki page
projectYesName of the Azure DevOps project
wikiYesName of the wiki

Implementation Reference

  • The core handler function that executes the logic for creating a wiki page in Azure DevOps, including wiki creation if needed, parameter validation, and API calls.
    export async function createWikiPage(rawParams: any) {
      // Parse arguments with defaults from environment variables
      const params = createWikiPageSchema.parse({
        project: rawParams.project || DEFAULT_PROJECT,
        wiki: rawParams.wiki,
        path: rawParams.path,
        content: rawParams.content,
      });
    
      console.error("[API] Creating wiki page:", params.path);
    
      try {
        // First try to get all wikis in the project
        const wikiListUrl = `${ORG_URL}/${params.project}/_wiki/wikis/${params.wiki}?api-version=7.1-preview.1`;
        console.error("[API] Getting wikis from:", wikiListUrl);
        const wikis = await makeAzureDevOpsRequest(wikiListUrl);
        console.error("[API] Found wikis:", wikis);
    
        // Try to find existing wiki
        let wiki = wikis.value.find((w: any) => w.name === params.wiki);
    
        if (!wiki) {
          // Create new project wiki
          console.error("[API] Creating new project wiki");
          const createWikiUrl = `${ORG_URL}/${params.project}/_wiki/wikis?api-version=7.1-preview.1`;
          wiki = await makeAzureDevOpsRequest(createWikiUrl, "POST", {
            name: `${params.wiki}.wiki`,
            projectId: params.project,
            type: "projectWiki",
          });
          console.error("[API] Created wiki:", wiki);
        }
    
        // Create the page using REST API
        const pageUrl = `${ORG_URL}/${params.project}/_wiki/wikis/${
          wiki.id
        }/pages?path=${encodeURIComponent(params.path)}&api-version=7.1-preview.1`;
        const page = await makeAzureDevOpsRequest(pageUrl, "PUT", {
          content: params.content,
        });
        console.error("[API] Created page:", page);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(page, null, 2),
            },
          ],
        };
      } catch (error) {
        logError("Error creating wiki page", error);
        throw error;
      }
    }
  • Zod schema definition for input parameters of create_wiki_page tool, used for runtime validation in the handler.
    export const createWikiPageSchema = z.object({
      project: z.string(),
      wiki: z.string(),
      path: z.string(),
      content: z.string(),
    });
    
    export type CreateWikiPageParams = z.infer<typeof createWikiPageSchema>;
  • Tool registration object defining the name, description, and input schema for create_wiki_page, part of wikiTools array used by the MCP server.
    {
      name: "create_wiki_page",
      description: "Create a new wiki page",
      inputSchema: {
        type: "object",
        properties: {
          project: {
            type: "string",
            description: "Name of the Azure DevOps project",
          },
          wiki: {
            type: "string",
            description: "Name of the wiki",
          },
          path: {
            type: "string",
            description: "Path of the wiki page",
          },
          content: {
            type: "string",
            description: "Content of the wiki page",
          },
        },
        required: ["project", "wiki", "path", "content"],
      },
    },
  • src/index.ts:50-63 (registration)
    MCP server handler for listing tools, which includes the wikiTools containing create_wiki_page.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          // Work Items
          ...workItemTools,
          // Pull Requests
          ...pullRequestTools,
          // Wiki
          ...wikiTools,
          // Projects
          ...projectTools,
        ],
      };
    });
  • src/index.ts:91-92 (registration)
    Dispatch case in the main CallToolRequest handler that routes calls to create_wiki_page to the handler function.
    case "create_wiki_page":
      return await createWikiPage(request.params.arguments || {});

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/mmruesch12/azdo-mcp'

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