add_project
Add new projects to the MCP Project Query Server by providing name, description, start date, investment amount, and progress details.
Instructions
新增项目
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes |
Implementation Reference
- src/main/index.ts:66-81 (registration)Registration of the 'add_project' MCP tool, including input schema (zod) and 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); } );
- src/main/index.ts:69-77 (schema)Input schema for add_project tool using zod{ project: z.object({ name: z.string().describe('项目名称'), description: z.string().describe('项目描述'), startDate: z.string().describe('开始日期'), investment: z.number().describe('投资金额'), progress: z.number().describe('当前进度'), }), },
- Handler in ProjectController that calls service to add project and returns formatted success/error responseasync 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 : '未知错误'}`, }, ], }; } }
- ProjectService.addProject: adds project via repository and saves changesasync addProject(project: Project): Promise<void> { this.projectRepository.addProject(project); await this.projectRepository.saveProjects(); }
- Repository method that appends the project to the in-memory arrayaddProject(project: any): void { this.projects.push(project); }