list_wiki_pages
Retrieve a list of wiki pages from an Azure DevOps wiki to view available documentation content and structure.
Instructions
List pages within an Azure DevOps wiki
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | No | The ID or name of the organization (Default: mycompany) | |
| projectId | No | The ID or name of the project (Default: MyProject) | |
| wikiId | Yes | The ID or name of the wiki |
Implementation Reference
- The core handler function implementing the list_wiki_pages tool logic. It retrieves wiki pages from Azure DevOps using the wiki client.export async function listWikiPages( options: ListWikiPagesOptions, ): Promise<WikiPageSummary[]> { const { organizationId, projectId, wikiId } = options; // Use defaults if not provided const orgId = organizationId || defaultOrg; const projId = projectId || defaultProject; try { // Create the client const client = await azureDevOpsClient.getWikiClient({ organizationId: orgId, }); // Get the wiki pages const pages = await client.listWikiPages(projId, wikiId); // Return the pages directly since the client interface now matches our requirements return pages.map((page) => ({ id: page.id, path: page.path, url: page.url, order: page.order, })); } catch (error) { // If it's already an AzureDevOpsError, rethrow it if (error instanceof AzureDevOpsError) { throw error; } // Otherwise wrap it in an AzureDevOpsError throw new AzureDevOpsError('Failed to list wiki pages', { cause: error }); } }
- Zod schema for input validation of the list_wiki_pages tool parameters.export const ListWikiPagesSchema = z.object({ organizationId: z .string() .optional() .nullable() .describe(`The ID or name of the organization (Default: ${defaultOrg})`), projectId: z .string() .optional() .nullable() .describe(`The ID or name of the project (Default: ${defaultProject})`), wikiId: z.string().describe('The ID or name of the wiki'), });
- src/features/wikis/tool-definitions.ts:34-38 (registration)Tool definition object registering the list_wiki_pages tool with name, description, and schema.{ name: 'list_wiki_pages', description: 'List pages within an Azure DevOps wiki', inputSchema: zodToJsonSchema(ListWikiPagesSchema), },
- src/features/wikis/index.ts:109-119 (registration)Switch case in the wikis request handler that dispatches to the listWikiPages function.case 'list_wiki_pages': { const args = ListWikiPagesSchema.parse(request.params.arguments); const result = await listWikiPages({ organizationId: args.organizationId ?? defaultOrg, projectId: args.projectId ?? defaultProject, wikiId: args.wikiId, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- Interface and function signature for the wiki pages handler.export interface WikiPageSummary { id: number; path: string; url?: string; order?: number; } /** * List wiki pages from a wiki * * @param options Options for listing wiki pages * @returns Array of wiki page summaries * @throws {AzureDevOpsResourceNotFoundError} When the wiki is not found * @throws {AzureDevOpsPermissionError} When the user does not have permission to access the wiki * @throws {AzureDevOpsError} When an error occurs while fetching the wiki pages */ export async function listWikiPages( options: ListWikiPagesOptions, ): Promise<WikiPageSummary[]> { const { organizationId, projectId, wikiId } = options; // Use defaults if not provided const orgId = organizationId || defaultOrg; const projId = projectId || defaultProject; try { // Create the client const client = await azureDevOpsClient.getWikiClient({ organizationId: orgId, }); // Get the wiki pages const pages = await client.listWikiPages(projId, wikiId); // Return the pages directly since the client interface now matches our requirements return pages.map((page) => ({ id: page.id, path: page.path, url: page.url, order: page.order, })); } catch (error) { // If it's already an AzureDevOpsError, rethrow it if (error instanceof AzureDevOpsError) { throw error; } // Otherwise wrap it in an AzureDevOpsError throw new AzureDevOpsError('Failed to list wiki pages', { cause: error }); } }