start_session
Begin a development session by specifying project ID and goals to maintain context between coding sessions.
Instructions
Start a new development session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| goals | Yes | Session goals |
Implementation Reference
- src/server.ts:374-404 (handler)The handler function that implements the core logic of the 'start_session' tool. It creates a new session using ProjectStore.createSession and returns a structured response with the session ID or error.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:369-372 (schema)Input schema definition for the 'start_session' tool using Zod, specifying projectId and goals.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 with the McpServer instance in the setupTools method.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)Helper method in ProjectStore that persists the new session to a JSON file after validation and generates a unique sessionId.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; }