create_wiki
Create a new wiki in Azure DevOps projects to document processes, code, and team knowledge. Specify wiki type (project or code) and configure repository settings for collaborative documentation.
Instructions
Create a new wiki in the project
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) | |
| name | Yes | The name of the new wiki | |
| type | No | Type of wiki to create (projectWiki or codeWiki) | projectWiki |
| repositoryId | No | The ID of the repository to associate with the wiki (required for codeWiki) | |
| mappedPath | No | Folder path inside repository which is shown as Wiki (only for codeWiki) | / |
Implementation Reference
- Core handler function that implements the create_wiki tool logic, using Azure DevOps Wiki client to create a new wiki.export async function createWiki( _connection: WebApi, options: CreateWikiOptions, ) { try { const { name, projectId, type = WikiType.ProjectWiki, repositoryId, mappedPath = '/', } = options; // Validate repository ID for code wiki if (type === WikiType.CodeWiki && !repositoryId) { throw new AzureDevOpsValidationError( 'Repository ID is required for code wikis', ); } // Get the Wiki client const wikiClient = await getWikiClient({ organizationId: options.organizationId, }); // Prepare the wiki creation parameters const wikiCreateParams = { name, projectId: projectId!, type, ...(type === WikiType.CodeWiki && { repositoryId, mappedPath, version: { version: 'main', versionType: 'branch' as const, }, }), }; // Create the wiki return await wikiClient.createWiki(projectId!, wikiCreateParams); } catch (error) { // Just rethrow if it's already one of our error types if (error instanceof AzureDevOpsError) { throw error; } // Otherwise wrap in AzureDevOpsError throw new AzureDevOpsError( `Failed to create wiki: ${error instanceof Error ? error.message : String(error)}`, ); } }
- Zod schema defining input parameters for the create_wiki tool, including validation for codeWiki requiring repositoryId.export const CreateWikiSchema = 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})`), name: z.string().describe('The name of the new wiki'), type: z .nativeEnum(WikiType) .optional() .default(WikiType.ProjectWiki) .describe('Type of wiki to create (projectWiki or codeWiki)'), repositoryId: z .string() .optional() .nullable() .describe( 'The ID of the repository to associate with the wiki (required for codeWiki)', ), mappedPath: z .string() .optional() .nullable() .default('/') .describe( 'Folder path inside repository which is shown as Wiki (only for codeWiki)', ), }) .refine( (data) => { // If type is codeWiki, then repositoryId is required return data.type !== WikiType.CodeWiki || !!data.repositoryId; }, { message: 'repositoryId is required when type is codeWiki', path: ['repositoryId'], }, );
- src/features/wikis/tool-definitions.ts:24-28 (registration)Tool registration in the wikis tools array, specifying name, description, and input schema.{ name: 'create_wiki', description: 'Create a new wiki in the project', inputSchema: zodToJsonSchema(CreateWikiSchema), },
- Enum defining WikiType used in CreateWikiSchema.export enum WikiType { /** * The wiki is published from a git repository */ CodeWiki = 'codeWiki', /** * The wiki is provisioned for the team project */ ProjectWiki = 'projectWiki', }
- src/features/wikis/index.ts:81-94 (helper)Dispatcher in handleWikisRequest that parses input with schema and calls the createWiki handler.case 'create_wiki': { const args = CreateWikiSchema.parse(request.params.arguments); const result = await createWiki(connection, { organizationId: args.organizationId ?? defaultOrg, projectId: args.projectId ?? defaultProject, name: args.name, type: args.type, repositoryId: args.repositoryId ?? undefined, mappedPath: args.mappedPath ?? undefined, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }