get_project_info
Retrieve detailed project structure and file information by specifying the root directory path using this MCP server tool.
Instructions
Get information about the project structure and files
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the project root directory |
Implementation Reference
- src/index.ts:1192-1265 (handler)Handler implementation for get_project_info tool. Extracts projectPath from arguments, fetches git repository information (remote URL, branch, last commit), reads and parses package.json if present, recursively builds a directory structure (up to depth 3, skipping dotfiles and node_modules), compiles docsStatus from global state, and returns a JSON-formatted text response containing all this information.case "get_project_info": { const { projectPath } = request.params.arguments as { projectPath: string }; try { // Get git info if available let gitInfo = {}; try { gitInfo = { remoteUrl: execSync("git config --get remote.origin.url", { cwd: projectPath }).toString().trim(), branch: execSync("git branch --show-current", { cwd: projectPath }).toString().trim(), lastCommit: execSync("git log -1 --format=%H", { cwd: projectPath }).toString().trim() }; } catch { // Not a git repository or git not available } // Get package.json if it exists let packageInfo = {}; try { const packageJson = await fs.readFile(`${projectPath}/package.json`, "utf8"); packageInfo = JSON.parse(packageJson); } catch { // No package.json or invalid JSON } // Get directory structure const getDirectoryStructure = async (dir: string, depth = 3): Promise<any> => { if (depth === 0) return "..."; const items = await fs.readdir(dir, { withFileTypes: true }); const structure: Record<string, any> = {}; for (const item of items) { if (item.name.startsWith(".") || item.name === "node_modules") continue; if (item.isDirectory()) { structure[item.name] = await getDirectoryStructure(`${dir}/${item.name}`, depth - 1); } else { structure[item.name] = null; } } return structure; }; const projectStructure = await getDirectoryStructure(projectPath); return { content: [ { type: "text", text: JSON.stringify({ gitInfo, packageInfo, projectStructure, docsStatus: { completed: state.completedFiles, current: state.currentFile, inProgress: state.inProgress, lastRead: state.lastReadFile, remaining: DEFAULT_DOCS.filter(doc => !state.completedFiles.includes(doc)) } }, null, 2) } ] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Error getting project info: ${errorMessage}` ); } }
- src/index.ts:498-510 (registration)Registration of the get_project_info tool in the tools array passed to server.setTools(). Includes the tool name, description, and input schema defining the required projectPath parameter.{ name: "get_project_info", description: "Get information about the project structure and files", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the project root directory" } }, required: ["projectPath"] }
- src/index.ts:502-510 (schema)Input schema for the get_project_info tool, specifying an object with a required string projectPath.type: "object", properties: { projectPath: { type: "string", description: "Path to the project root directory" } }, required: ["projectPath"] }