wiki_get_page_content
Retrieve content from Azure DevOps wiki pages using unique identifiers and paths. Access specific project wikis and manage content efficiently with PAT authentication.
Instructions
Retrieve wiki page content by wikiIdentifier and path.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The path of the wiki page to retrieve content for. | |
| project | Yes | The project name or ID where the wiki is located. | |
| wikiIdentifier | Yes | The unique identifier of the wiki. |
Implementation Reference
- src/tools/wiki.ts:129-153 (handler)The core handler function that implements the wiki_get_page_content tool logic: connects to Azure DevOps, fetches the wiki page text as a stream using WikiApi.getPageText, converts it to string, and returns as JSON.async ({ wikiIdentifier, project, path }) => { try { const connection = await connectionProvider(); const wikiApi = await connection.getWikiApi(); const stream = await wikiApi.getPageText(project, wikiIdentifier, path, undefined, undefined, true); if (!stream) { return { content: [{ type: "text", text: "No wiki page content found" }], isError: true }; } const content = await streamToString(stream); return { content: [{ type: "text", text: JSON.stringify(content, null, 2) }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [{ type: "text", text: `Error fetching wiki page content: ${errorMessage}` }], isError: true, }; } }
- src/tools/wiki.ts:125-128 (schema)Input schema validation using Zod for the tool parameters: wikiIdentifier, project, and path.wikiIdentifier: z.string().describe("The unique identifier of the wiki."), project: z.string().describe("The project name or ID where the wiki is located."), path: z.string().describe("The path of the wiki page to retrieve content for."), },
- src/tools/wiki.ts:121-154 (registration)Direct registration of the wiki_get_page_content tool on the McpServer using server.tool, including description, schema, and handler.server.tool( WIKI_TOOLS.get_wiki_page_content, "Retrieve wiki page content by wikiIdentifier and path.", { wikiIdentifier: z.string().describe("The unique identifier of the wiki."), project: z.string().describe("The project name or ID where the wiki is located."), path: z.string().describe("The path of the wiki page to retrieve content for."), }, async ({ wikiIdentifier, project, path }) => { try { const connection = await connectionProvider(); const wikiApi = await connection.getWikiApi(); const stream = await wikiApi.getPageText(project, wikiIdentifier, path, undefined, undefined, true); if (!stream) { return { content: [{ type: "text", text: "No wiki page content found" }], isError: true }; } const content = await streamToString(stream); return { content: [{ type: "text", text: JSON.stringify(content, null, 2) }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [{ type: "text", text: `Error fetching wiki page content: ${errorMessage}` }], isError: true, }; } } );
- src/tools.ts:26-26 (registration)High-level registration call to configureWikiTools, which sets up all wiki tools including wiki_get_page_content.configureWikiTools(server, tokenProvider, connectionProvider);
- src/tools/wiki.ts:274-282 (helper)Helper function to convert the wiki page content stream to a string, used in the handler.function streamToString(stream: NodeJS.ReadableStream): Promise<string> { return new Promise((resolve, reject) => { let data = ""; stream.setEncoding("utf8"); stream.on("data", (chunk) => (data += chunk)); stream.on("end", () => resolve(data)); stream.on("error", reject); }); }