get_project_info
Retrieve project details including start date, description, investment amount, and current status by providing the project name.
Instructions
根据项目名称查询项目基本信息,包括开始日期、简介、投资金额和当前进度
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectName | Yes | 要查询的项目名称 |
Implementation Reference
- Core handler logic for the get_project_info tool: retrieves project data via service, formats it into MCP-compatible content blocks (JSON stringified), handles missing projects and errors gracefully.async getProjectInfo(projectName: string): Promise<{ content: Array<{ type: "text"; text: string }> }> { try { const project = await this.projectService.getProjectInfo(projectName); if (!project) { return { content: [ { type: "text" as const, text: `未找到名为"${projectName}"的项目。`, }, ], }; } return { content: [ { type: "text" as const, text: JSON.stringify(project), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `查询项目时出错: ${error instanceof Error ? error.message : '未知错误'}`, }, ], }; } }
- src/main/index.ts:33-42 (registration)Registers the 'get_project_info' MCP tool with name, description, input schema (projectName: string), and delegates to ProjectController.getProjectInfo().server.tool( 'get_project_info', '根据项目名称查询项目基本信息,包括开始日期、简介、投资金额和当前进度', { projectName: z.string().describe('要查询的项目名称'), }, async ({ projectName }) => { return await projectController.getProjectInfo(projectName); } );
- src/main/index.ts:36-38 (schema)Input schema for the tool using Zod: requires 'projectName' as string.{ projectName: z.string().describe('要查询的项目名称'), },
- Helper service method that fetches the project by name from the repository, returning null if not found.async getProjectInfo(projectName: string): Promise<Project | null> { return this.projectRepository.findProjectByName(projectName) || null; }