get_project_context
Retrieve detailed project context and current state from the MCP server to maintain continuity, reduce repetitive explanations, and streamline coding sessions by accessing essential project information.
Instructions
Get comprehensive project context and current state
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID |
Implementation Reference
- src/server.ts:91-126 (registration)Registration of the 'get_project_context' tool including inline handler and schema. The handler fetches context from ContextManager and wraps it in MCP response format.this.server.registerTool( "get_project_context", { title: "Get Project Context", description: "Get comprehensive project context and current state", inputSchema: { projectId: z.string().describe("Project ID"), }, }, async ({ projectId }) => { try { const context = await this.contextManager.getCurrentContext( projectId ); return { content: [ { type: "text", text: context, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error getting project context: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } } );
- src/server.ts:100-125 (handler)The handler function for the tool, which calls ContextManager.getCurrentContext and returns the formatted text or error.async ({ projectId }) => { try { const context = await this.contextManager.getCurrentContext( projectId ); return { content: [ { type: "text", text: context, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error getting project context: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } }
- src/server.ts:93-98 (schema)Tool metadata including title, description, and input schema (projectId: string).{ title: "Get Project Context", description: "Get comprehensive project context and current state", inputSchema: { projectId: z.string().describe("Project ID"), },
- src/storage/context-manager.ts:12-78 (helper)Helper method that constructs the detailed markdown-formatted project context from project data, tasks, sessions, and decisions.async getCurrentContext(projectId: string): Promise<string> { const project = await this.store.getProject(projectId); if (!project) { return "Project not found"; } const recentSessions = await this.store.getProjectSessions(projectId); const lastSession = recentSessions[0]; return ` # Project: ${project.name} ## Current Status: ${project.status} ${project.description} ## Current Phase: ${project.currentPhase} ## Tech Stack: - Frontend: ${project.techStack.frontend.join(", ") || "Not specified"} - Backend: ${project.techStack.backend.join(", ") || "Not specified"} - Database: ${project.techStack.database.join(", ") || "Not specified"} - Infrastructure: ${ project.techStack.infrastructure.join(", ") || "Not specified" } ## Active Tasks (${ project.tasks.filter((t) => t.status !== "completed").length }): ${ project.tasks .filter((t) => t.status !== "completed") .map( (t) => `- [${t.status.toUpperCase()}] ${t.title} (Priority: ${t.priority})` ) .join("\n") || "No active tasks" } ## Next Steps: ${ project.nextSteps.map((step) => `- ${step}`).join("\n") || "No next steps defined" } ## Last Session Summary: ${ lastSession ? ` - Goals: ${lastSession.goals.join(", ")} - Achievements: ${lastSession.achievements.join(", ")} - Blockers: ${lastSession.blockers.join(", ")} - Next Session Plan: ${lastSession.nextSession.join(", ")} ` : "No previous sessions" } ## Recent Decisions: ${ project.decisions .slice(0, 3) .map( (d) => `- ${d.decision} (${new Date(d.timestamp).toLocaleDateString()})` ) .join("\n") || "No recent decisions" } `.trim(); }