Skip to main content
Glama
aaronfeingold

MCP Project Context Server

list_projects

Retrieve all projects from the MCP Project Context Server, sorted by most recent access, to maintain coding context across sessions.

Instructions

List all projects ordered by last accessed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'list_projects' tool. It calls ProjectStore.listProjects(), formats the projects into a markdown list sorted by last access, and returns MCP-formatted text content or error.
    async () => { try { const projects = await this.store.listProjects(); const projectList = projects .map( (p) => `- ${p.name} (${p.id}) - ${ p.status } - Last accessed: ${new Date( p.lastAccessedAt ).toLocaleDateString()}` ) .join("\n"); return { content: [ { type: "text", text: `Active Projects:\n${projectList || "No projects found"}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error listing projects: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } }
  • src/server.ts:129-170 (registration)
    Registers the 'list_projects' tool with the MCP server, specifying its name, metadata, empty input schema, and handler function.
    this.server.registerTool( "list_projects", { title: "List Projects", description: "List all projects ordered by last accessed", inputSchema: {}, }, async () => { try { const projects = await this.store.listProjects(); const projectList = projects .map( (p) => `- ${p.name} (${p.id}) - ${ p.status } - Last accessed: ${new Date( p.lastAccessedAt ).toLocaleDateString()}` ) .join("\n"); return { content: [ { type: "text", text: `Active Projects:\n${projectList || "No projects found"}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error listing projects: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } } );
  • Tool metadata and input schema definition (no input parameters required).
    { title: "List Projects", description: "List all projects ordered by last accessed", inputSchema: {}, },
  • Supporting method in ProjectStore that lists all projects by reading JSON files from the data directory, validates with ProjectContextSchema, and sorts by lastAccessedAt descending.
    async listProjects(): Promise<ProjectContext[]> { const files = await fs.readdir(this.projectsDir); const projects: ProjectContext[] = []; for (const file of files) { if (file.endsWith(".json")) { const data = await fs.readJson(path.join(this.projectsDir, file)); projects.push(ProjectContextSchema.parse(data)); } } return projects.sort( (a, b) => new Date(b.lastAccessedAt).getTime() - new Date(a.lastAccessedAt).getTime() ); }

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