startsession
Initiate development sessions by retrieving active projects, high-priority tasks, and milestones. Tracks progress, dependencies, and recent work for effective context setting in software development.
Instructions
A powerful session initialization tool for software development contextual work. This tool starts a new development session and provides a comprehensive overview of the current development landscape. It retrieves recent sessions, active projects, high-priority tasks, and upcoming milestones to help focus the work effectively.
When to use this tool:
Beginning a new development work session
Establishing context before diving into specific development work
Key features:
Generates a unique session identifier for tracking activity
Retrieves and displays recent development sessions
Shows active software development projects (based on has_status relations)
Highlights high-priority tasks (based on has_priority relations)
Lists upcoming project milestones with progress tracking
Displays task dependencies and sequencing information
Parameters explained:
No parameters required - the tool automatically retrieves all relevant context
Return information:
Session ID: A unique identifier for this development session (format: dev_timestamp_randomstring)
Recent Development Sessions: Up to 3 most recent sessions with:
Date
Project focus
Session summary (truncated to 100 characters)
Active Projects: List of active software projects with their status
High-Priority Tasks: Tasks with high priority status (via has_priority relation) including:
Task name
Current status (via has_status relation)
Task sequencing information (preceding and following tasks)
Upcoming Milestones: Milestones with active status including:
Milestone name
Progress percentage based on completed tasks
You should:
Use the generated session ID with the loadcontext tool to load specific entities
End the session with endsession when work is complete
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "startsession"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:1207-1345 (handler)The complete handler function for the 'startsession' tool. It generates a unique session ID, persists the initial session state, retrieves recent sessions, active projects, high-priority active tasks, and active milestones from the knowledge graph, then returns a formatted markdown response presenting options for the user to choose context to load next.
server.tool( "startsession", toolDescriptions["startsession"], {}, async () => { try { // Generate a unique session ID const sessionId = generateSessionId(); // Get recent sessions from persistent storage const sessionStates = await loadSessionStates(); // Initialize the session state sessionStates.set(sessionId, []); await saveSessionStates(sessionStates); // Convert sessions map to array, sort by date, and take most recent ones const recentSessions = Array.from(sessionStates.entries()) .map(([id, stages]) => { // Extract summary data from the first stage (if it exists) const summaryStage = stages.find(s => s.stage === "summary"); return { id, project: summaryStage?.stageData?.project || "Unknown project", focus: summaryStage?.stageData?.focus || "Unknown focus", summary: summaryStage?.stageData?.summary || "No summary available" }; }) .slice(0, 3); // Default to showing 3 recent sessions // Get active development projects const graph = await knowledgeGraphManager.readGraph(); const activeProjects = []; // Find projects with active status for (const entity of graph.entities) { if (entity.entityType === 'project') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); if (status === 'active') { activeProjects.push(entity); } } } // Get high-priority development tasks const highPriorityTasks = []; // Find tasks with high priority and active status for (const entity of graph.entities) { if (entity.entityType === 'task') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); const priority = await knowledgeGraphManager.getEntityPriority(entity.name); if (status === 'active' && priority === 'high') { highPriorityTasks.push(entity); } } } // Get upcoming milestones const upcomingMilestones = []; // Find milestones with active status for (const entity of graph.entities) { if (entity.entityType === 'milestone') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); if (status === 'active') { upcomingMilestones.push(entity); } } } let sessionsText = "No recent sessions found."; if (recentSessions.length > 0) { sessionsText = recentSessions.map(session => `- ${session.project} - ${session.focus} - ${session.summary.substring(0, 100)}${session.summary.length > 100 ? '...' : ''}` ).join('\n'); } let projectsText = "No active projects found."; if (activeProjects.length > 0) { projectsText = activeProjects.map(project => { const obsPreview = project.observations.length > 0 ? `: ${project.observations[0].substring(0, 60)}${project.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${project.name}${obsPreview}`; }).join('\n'); } let tasksText = "No high-priority tasks found."; if (highPriorityTasks.length > 0) { tasksText = highPriorityTasks.map(task => { const obsPreview = task.observations.length > 0 ? `: ${task.observations[0].substring(0, 60)}${task.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${task.name}${obsPreview}`; }).join('\n'); } let milestonesText = "No upcoming milestones found."; if (upcomingMilestones.length > 0) { milestonesText = upcomingMilestones.map(milestone => { const obsPreview = milestone.observations.length > 0 ? `: ${milestone.observations[0].substring(0, 60)}${milestone.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${milestone.name}${obsPreview}`; }).join('\n'); } return { content: [{ type: "text", text: `# Ask user to choose what to focus on in this session. Present the following options: ## Recent Development Sessions ${sessionsText} ## Active Projects ${projectsText} ## High-Priority Tasks ${tasksText} ## Upcoming Milestones ${milestonesText} To load specific context based on the user's choice, use the \`loadcontext\` tool with the entity name and developer session ID - ${sessionId}.` }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) }, null, 2) }] }; } } - index.ts:1207-1345 (registration)The MCP server.tool call that registers the 'startsession' tool with empty input schema and inline handler.
server.tool( "startsession", toolDescriptions["startsession"], {}, async () => { try { // Generate a unique session ID const sessionId = generateSessionId(); // Get recent sessions from persistent storage const sessionStates = await loadSessionStates(); // Initialize the session state sessionStates.set(sessionId, []); await saveSessionStates(sessionStates); // Convert sessions map to array, sort by date, and take most recent ones const recentSessions = Array.from(sessionStates.entries()) .map(([id, stages]) => { // Extract summary data from the first stage (if it exists) const summaryStage = stages.find(s => s.stage === "summary"); return { id, project: summaryStage?.stageData?.project || "Unknown project", focus: summaryStage?.stageData?.focus || "Unknown focus", summary: summaryStage?.stageData?.summary || "No summary available" }; }) .slice(0, 3); // Default to showing 3 recent sessions // Get active development projects const graph = await knowledgeGraphManager.readGraph(); const activeProjects = []; // Find projects with active status for (const entity of graph.entities) { if (entity.entityType === 'project') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); if (status === 'active') { activeProjects.push(entity); } } } // Get high-priority development tasks const highPriorityTasks = []; // Find tasks with high priority and active status for (const entity of graph.entities) { if (entity.entityType === 'task') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); const priority = await knowledgeGraphManager.getEntityPriority(entity.name); if (status === 'active' && priority === 'high') { highPriorityTasks.push(entity); } } } // Get upcoming milestones const upcomingMilestones = []; // Find milestones with active status for (const entity of graph.entities) { if (entity.entityType === 'milestone') { const status = await knowledgeGraphManager.getEntityStatus(entity.name); if (status === 'active') { upcomingMilestones.push(entity); } } } let sessionsText = "No recent sessions found."; if (recentSessions.length > 0) { sessionsText = recentSessions.map(session => `- ${session.project} - ${session.focus} - ${session.summary.substring(0, 100)}${session.summary.length > 100 ? '...' : ''}` ).join('\n'); } let projectsText = "No active projects found."; if (activeProjects.length > 0) { projectsText = activeProjects.map(project => { const obsPreview = project.observations.length > 0 ? `: ${project.observations[0].substring(0, 60)}${project.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${project.name}${obsPreview}`; }).join('\n'); } let tasksText = "No high-priority tasks found."; if (highPriorityTasks.length > 0) { tasksText = highPriorityTasks.map(task => { const obsPreview = task.observations.length > 0 ? `: ${task.observations[0].substring(0, 60)}${task.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${task.name}${obsPreview}`; }).join('\n'); } let milestonesText = "No upcoming milestones found."; if (upcomingMilestones.length > 0) { milestonesText = upcomingMilestones.map(milestone => { const obsPreview = milestone.observations.length > 0 ? `: ${milestone.observations[0].substring(0, 60)}${milestone.observations[0].length > 60 ? '...' : ''}` : ''; return `- ${milestone.name}${obsPreview}`; }).join('\n'); } return { content: [{ type: "text", text: `# Ask user to choose what to focus on in this session. Present the following options: ## Recent Development Sessions ${sessionsText} ## Active Projects ${projectsText} ## High-Priority Tasks ${tasksText} ## Upcoming Milestones ${milestonesText} To load specific context based on the user's choice, use the \`loadcontext\` tool with the entity name and developer session ID - ${sessionId}.` }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) }, null, 2) }] }; } } - index.ts:123-125 (helper)Helper function used by startsession handler to generate unique session IDs.
function generateSessionId(): string { return `dev_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`; } - index.ts:1210-1210 (schema)Empty input schema for startsession tool (no parameters required).
{}, - index.ts:95-111 (helper)Session state persistence helper used by startsession to load recent sessions.
async function loadSessionStates(): Promise<Map<string, any[]>> { try { const fileContent = await fs.readFile(SESSIONS_FILE_PATH, 'utf-8'); const sessions = JSON.parse(fileContent); // Convert from object to Map const sessionsMap = new Map<string, any[]>(); for (const [key, value] of Object.entries(sessions)) { sessionsMap.set(key, value as any[]); } return sessionsMap; } catch (error) { if (error instanceof Error && 'code' in error && (error as any).code === "ENOENT") { return new Map<string, any[]>(); } throw error; } }