Skip to main content
Glama
aaronfeingold

MCP Project Context Server

get_project_context

Retrieve comprehensive project context including technology stack, tasks, decisions, and session history to maintain continuity between coding sessions without re-explaining project details.

Instructions

Get comprehensive project context and current state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID

Implementation Reference

  • The MCP tool handler function for 'get_project_context'. It retrieves the project context from ContextManager and returns it as MCP-formatted text content, with error handling.
    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"
              }`,
            },
          ],
        };
      }
    }
  • Tool metadata and input schema definition (Zod schema requiring projectId string).
    {
      title: "Get Project Context",
      description: "Get comprehensive project context and current state",
      inputSchema: {
        projectId: z.string().describe("Project ID"),
      },
    },
  • src/server.ts:91-126 (registration)
    Registration of the 'get_project_context' tool on the MCP server using registerTool, including schema and handler.
    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"
                }`,
              },
            ],
          };
        }
      }
    );
  • Helper method in ContextManager that implements the core logic: fetches project and sessions from store, formats a detailed markdown context summary including status, tech stack, tasks, next steps, last session, and recent 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();
      }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aaronfeingold/mcp-project-context'

If you have feedback or need assistance with the MCP directory API, please join our Discord server