add_project
Creates a new project in Backlog with a name and key, supporting optional settings for chart, subtasking, and text formatting.
Instructions
Creates a new project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Project name | |
| key | Yes | Project key | |
| chartEnabled | No | Whether to enable chart (default: false) | |
| subtaskingEnabled | No | Whether to enable subtasking (default: false) | |
| projectLeaderCanEditProjectLeader | No | Whether project leaders can edit other project leaders (default: false) | |
| textFormattingRule | No | Text formatting rule (default: 'backlog') | |
| organization | No | Optional organization name. Use list_organizations to inspect available organizations. |
Implementation Reference
- src/tools/addProject.ts:1-78 (handler)The main implementation of the 'add_project' tool. Defines the schema (input validation via Zod) and the handler function that calls backlog.postProject() to create a new project. The handler accepts name, key, chartEnabled, subtaskingEnabled, projectLeaderCanEditProjectLeader, and textFormattingRule with defaults.
import { z } from 'zod'; import { Backlog } from 'backlog-js'; import { buildToolSchema, ToolDefinition } from '../types/tool.js'; import { TranslationHelper } from '../createTranslationHelper.js'; import { ProjectSchema } from '../types/zod/backlogOutputDefinition.js'; const addProjectSchema = buildToolSchema((t) => ({ name: z.string().describe(t('TOOL_ADD_PROJECT_NAME', 'Project name')), key: z.string().describe(t('TOOL_ADD_PROJECT_KEY', 'Project key')), chartEnabled: z .boolean() .optional() .describe( t( 'TOOL_ADD_PROJECT_CHART_ENABLED', 'Whether to enable chart (default: false)' ) ), subtaskingEnabled: z .boolean() .optional() .describe( t( 'TOOL_ADD_PROJECT_SUBTASKING_ENABLED', 'Whether to enable subtasking (default: false)' ) ), projectLeaderCanEditProjectLeader: z .boolean() .optional() .describe( t( 'TOOL_ADD_PROJECT_LEADER_CAN_EDIT', 'Whether project leaders can edit other project leaders (default: false)' ) ), textFormattingRule: z .enum(['backlog', 'markdown']) .optional() .describe( t( 'TOOL_ADD_PROJECT_TEXT_FORMATTING', "Text formatting rule (default: 'backlog')" ) ), })); export const addProjectTool = ( backlog: Backlog, { t }: TranslationHelper ): ToolDefinition< ReturnType<typeof addProjectSchema>, (typeof ProjectSchema)['shape'] > => { return { name: 'add_project', description: t('TOOL_ADD_PROJECT_DESCRIPTION', 'Creates a new project'), schema: z.object(addProjectSchema(t)), outputSchema: ProjectSchema, handler: async ({ name, key, chartEnabled, subtaskingEnabled, projectLeaderCanEditProjectLeader, textFormattingRule, }) => backlog.postProject({ name, key, chartEnabled: chartEnabled ?? false, subtaskingEnabled: subtaskingEnabled ?? false, projectLeaderCanEditProjectLeader: projectLeaderCanEditProjectLeader ?? false, textFormattingRule: textFormattingRule ?? 'backlog', }), }; }; - src/types/tool.ts:5-22 (schema)ToolDefinition type and buildToolSchema helper, used to define the structure of the add_project tool (name, description, schema, outputSchema, handler).
export type ToolDefinition< Shape extends z.ZodRawShape, OutputShape extends z.ZodRawShape, > = { name: string; description: string; schema: z.ZodObject<Shape>; outputSchema: z.ZodObject<OutputShape>; handler: ( input: z.infer<z.ZodObject<Shape>> & { fields?: string; organization?: string; } ) => Promise< z.infer<z.ZodObject<OutputShape>> | z.infer<z.ZodObject<OutputShape>>[] >; importantFields?: (keyof z.infer<z.ZodObject<OutputShape>>)[]; }; - The ProjectSchema Zod schema, which serves as the outputSchema for the add_project tool, defining the shape of a Backlog project object returned by the handler.
export const ProjectSchema = z.object({ id: z.number(), projectKey: z.string(), name: z.string(), chartEnabled: z.boolean(), useResolvedForChart: z.boolean(), subtaskingEnabled: z.boolean(), projectLeaderCanEditProjectLeader: z.boolean(), useWiki: z.boolean(), useFileSharing: z.boolean(), useWikiTreeView: z.boolean(), useOriginalImageSizeAtWiki: z.boolean(), useSubversion: z.boolean(), useGit: z.boolean(), textFormattingRule: TextFormattingRuleSchema, archived: z.boolean(), displayOrder: z.number(), useDevAttributes: z.boolean(), }); - src/tools/tools.ts:6-6 (registration)Import of addProjectTool from './addProject.js'.
import { addProjectTool } from './addProject.js'; - src/tools/tools.ts:89-89 (registration)Registration of the add_project tool within the 'project' toolset group. addProjectTool(backlog, helper) is added to the tools array.
addProjectTool(backlog, helper),