Skip to main content
Glama

start_session

Begin a new AI coding session by specifying a development task, enabling persistent memory and project tracking for the assistant's work.

Instructions

Start a new AI coding session with a specific task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesDescription of the task to work on

Implementation Reference

  • MCP server handler for 'start_session' tool: extracts task argument and delegates to MemoryManager.startNewSession, returns confirmation with session ID.
    case 'start_session': {
      const task = args.task as string;
      const sessionId = await this.memoryManager.startNewSession(task);
      return { content: [{ type: 'text', text: `Started session: ${sessionId}` }] };
    }
  • Input schema definition for the 'start_session' tool: requires a 'task' string describing the coding task.
    {
      name: 'start_session',
      description: 'Start a new AI coding session with a specific task',
      inputSchema: {
        type: 'object',
        properties: {
          task: { type: 'string', description: 'Description of the task to work on' }
        },
        required: ['task']
      }
    },
  • src/index.ts:552-778 (registration)
    Registration of all tools including 'start_session' via ListToolsRequestSchema handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        // Memory Management Tools
        {
          name: 'start_session',
          description: 'Start a new AI coding session with a specific task',
          inputSchema: {
            type: 'object',
            properties: {
              task: { type: 'string', description: 'Description of the task to work on' }
            },
            required: ['task']
          }
        },
        {
          name: 'add_session_step',
          description: 'Record completion of a step in the current session',
          inputSchema: {
            type: 'object',
            properties: {
              step: { type: 'string', description: 'Description of the completed step' },
              filesModified: { type: 'array', items: { type: 'string' }, description: 'List of files that were modified' },
              description: { type: 'string', description: 'Optional detailed description' }
            },
            required: ['step', 'filesModified']
          }
        },
        {
          name: 'add_decision',
          description: 'Record an important technical decision',
          inputSchema: {
            type: 'object',
            properties: {
              key: { type: 'string', description: 'Decision key/name' },
              value: { type: 'string', description: 'Decision value' },
              reasoning: { type: 'string', description: 'Reasoning behind the decision' }
            },
            required: ['key', 'value', 'reasoning']
          }
        },
        {
          name: 'get_project_memory',
          description: 'Get current project memory and session state',
          inputSchema: {
            type: 'object',
            properties: {}
          }
        },
    
        // Approval Management Tools
        {
          name: 'set_file_approval',
          description: 'Set approval status for a file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' },
              approvalType: { type: 'string', enum: ['devApproved', 'codeReviewApproved', 'qaApproved'] },
              approvedBy: { type: 'string', description: 'Who approved it' }
            },
            required: ['filePath', 'approvalType', 'approvedBy']
          }
        },
        {
          name: 'get_file_approval_status',
          description: 'Get approval status for a file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' }
            },
            required: ['filePath']
          }
        },
    
        // Rule Engine Tools
        {
          name: 'check_before_modification',
          description: 'Check if a file can be modified according to AI metadata rules',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file to check' }
            },
            required: ['filePath']
          }
        },
        {
          name: 'get_modification_actions',
          description: 'Get actions that should be taken after modifying a file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' }
            },
            required: ['filePath']
          }
        },
    
        // Metadata Tools
        {
          name: 'parse_file_metadata',
          description: 'Parse AI metadata from a file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' }
            },
            required: ['filePath']
          }
        },
        {
          name: 'update_file_metadata',
          description: 'Update AI metadata in a file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' },
              updates: { type: 'object', description: 'Metadata updates to apply' }
            },
            required: ['filePath', 'updates']
          }
        },
        {
          name: 'find_files_with_metadata',
          description: 'Find all files that contain AI metadata',
          inputSchema: {
            type: 'object',
            properties: {
              pattern: { type: 'string', description: 'File pattern to search (optional)' }
            }
          }
        },
    
        // Changelog Tools
        {
          name: 'add_changelog_entry',
          description: 'Add an entry to the project changelog',
          inputSchema: {
            type: 'object',
            properties: {
              description: { type: 'string', description: 'Description of the change' },
              filesChanged: { type: 'array', items: { type: 'string' }, description: 'Files that were changed' },
              type: { type: 'string', enum: ['added', 'changed', 'deprecated', 'removed', 'fixed', 'security'] },
              breakingChange: { type: 'boolean', description: 'Whether this is a breaking change' },
              impact: { type: 'string', enum: ['major', 'minor', 'patch'] }
            },
            required: ['description', 'filesChanged', 'type']
          }
        },
        {
          name: 'get_file_changelog',
          description: 'Get changelog entries for a specific file',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' }
            },
            required: ['filePath']
          }
        },
        {
          name: 'get_recent_changes',
          description: 'Get recent changelog entries',
          inputSchema: {
            type: 'object',
            properties: {
              days: { type: 'number', description: 'Number of days to look back (default: 7)' }
            }
          }
        },
        
        // Folder Mapping Tools  
        {
          name: 'generate_folder_map',
          description: 'Generate or update a _map.md file for a specific folder',
          inputSchema: {
            type: 'object',
            properties: {
              folderPath: { type: 'string', description: 'Path to the folder to generate map for' }
            },
            required: ['folderPath']
          }
        },
        {
          name: 'generate_all_folder_maps', 
          description: 'Generate _map.md files for all folders in the project',
          inputSchema: {
            type: 'object',
            properties: {}
          }
        },
    
        // Git Tools
        {
          name: 'update_last_editor',
          description: 'Update @last-editor field in a file with Git author information',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file to update' }
            },
            required: ['filePath']
          }
        },
        {
          name: 'update_all_last_editors',
          description: 'Update @last-editor fields in all files with Git author information',
          inputSchema: {
            type: 'object',
            properties: {}
          }
        },
        {
          name: 'get_file_last_editor',
          description: 'Get the last editor of a file from Git history',
          inputSchema: {
            type: 'object',
            properties: {
              filePath: { type: 'string', description: 'Path to the file' }
            },
            required: ['filePath']
          }
        }
      ]
    }));
  • Core logic for starting a new session: generates ID, updates project memory's currentSession with task details, persists to file, and returns session ID.
    async startNewSession(task: string): Promise<string> {
      const memory = await this.getProjectMemory();
      const sessionId = this.generateSessionId();
      
      memory.currentSession = {
        sessionId,
        task,
        started: new Date().toISOString(),
        completedSteps: [],
        nextSteps: [],
        importantDecisions: {},
        blockers: []
      };
    
      await this.saveProjectMemory(memory);
      console.log(chalk.blue(`🚀 Started new session: ${sessionId}`));
      console.log(chalk.blue(`📋 Task: ${task}`));
      return sessionId;
    }

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/keleshteri/mcp-memory'

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