add_project
Add a new project with details including name, description, start date, investment amount, and current progress to the project management system.
Instructions
新增项目
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes |
Implementation Reference
- src/main/index.ts:66-81 (registration)Registers the MCP tool 'add_project' with description, Zod input schema for project details, and a handler that delegates to ProjectController.addProjectserver.tool( 'add_project', '新增项目', { project: z.object({ name: z.string().describe('项目名称'), description: z.string().describe('项目描述'), startDate: z.string().describe('开始日期'), investment: z.number().describe('投资金额'), progress: z.number().describe('当前进度'), }), }, async ({ project }) => { return await projectController.addProject(project); } );
- Handler function that executes the core logic for adding a project: invokes the service, formats success/error response in MCP content format.async addProject(project: Project): Promise<{ content: Array<{ type: "text"; text: string }> }> { try { await this.projectService.addProject(project); return { content: [ { type: 'text', text: `新增项目成功: ${JSON.stringify(project)}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `新增项目失败: ${error instanceof Error ? error.message : '未知错误'}`, }, ], }; } }
- Service layer helper that adds the project to the repository and persists the changes.async addProject(project: Project): Promise<void> { this.projectRepository.addProject(project); await this.projectRepository.saveProjects(); }
- Repository method that appends the new project to the in-memory array of projects.addProject(project: any): void { this.projects.push(project); }
- src/main/models/Project.ts:1-7 (schema)TypeScript interface defining the Project structure, matching the tool input schema.export interface Project { name: string; description: string; startDate: string; investment: number; progress: number; }