start_session
Initiate a development session by specifying project ID and session goals, enabling consistent coding context using the MCP Project Context Server.
Instructions
Start a new development session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| goals | Yes | Session goals | |
| projectId | Yes | Project ID |
Implementation Reference
- src/server.ts:374-404 (handler)The handler function that implements the core logic of the start_session tool by creating a new session via ProjectStore and returning the session ID.async ({ projectId, goals }) => { try { const session = await this.store.createSession({ projectId, startTime: new Date().toISOString(), goals, achievements: [], blockers: [], nextSession: [], }); return { content: [ { type: "text", text: `Session started with ID: ${session.sessionId}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error starting session: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } }
- src/server.ts:366-372 (schema)Input schema definition for the start_session tool using Zod for validation of projectId and goals parameters.{ title: "Start Session", description: "Start a new development session", inputSchema: { projectId: z.string().describe("Project ID"), goals: z.array(z.string()).describe("Session goals"), },
- src/server.ts:364-405 (registration)Registration of the start_session tool on the MCP server, including schema and handler.this.server.registerTool( "start_session", { title: "Start Session", description: "Start a new development session", inputSchema: { projectId: z.string().describe("Project ID"), goals: z.array(z.string()).describe("Session goals"), }, }, async ({ projectId, goals }) => { try { const session = await this.store.createSession({ projectId, startTime: new Date().toISOString(), goals, achievements: [], blockers: [], nextSession: [], }); return { content: [ { type: "text", text: `Session started with ID: ${session.sessionId}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error starting session: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } } );
- src/storage/project-store.ts:93-106 (helper)Supporting method in ProjectStore that creates and persists a new session file to disk, used by the start_session handler.async createSession( sessionData: Omit<SessionContext, "sessionId"> ): Promise<SessionContext> { const session: SessionContext = { ...sessionData, sessionId: uuidv4(), }; const validated = SessionContextSchema.parse(session); const filePath = path.join(this.sessionsDir, `${session.sessionId}.json`); await fs.writeJson(filePath, validated, { spaces: 2 }); return validated; }
- src/types/project-types.ts:81-90 (schema)Zod schema for SessionContext type, used to validate session data in ProjectStore.createSession.export const SessionContextSchema = z.object({ sessionId: z.string(), projectId: z.string(), startTime: z.string(), endTime: z.string().optional(), goals: z.array(z.string()).default([]), achievements: z.array(z.string()).default([]), blockers: z.array(z.string()).default([]), nextSession: z.array(z.string()).default([]), });