Skip to main content
Glama

end_session

Close Cursor work sessions by syncing context files, updating Agent OS, and committing changes to git with session summaries.

Instructions

Close the current Cursor session, sync all context files, update Agent OS files, and commit to git. This is the main tool for ending a work session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversationSummaryYesSummary of what was accomplished in this session. If not provided, will attempt to extract from context.
accomplishmentsNoList of specific accomplishments (optional, will be extracted if not provided)
decisionsNoList of decisions made during this session (optional)
blockersNoList of blockers or issues encountered (optional)
nextStepsNoList of next steps or TODO items (optional)

Implementation Reference

  • Core handler implementation for the end_session tool. This method orchestrates the entire session closing process: gathering summary, updating session summary, Agent OS files, syncing context files, and committing to git.
    async closeSession(conversationSummary: string): Promise<{
      success: boolean;
      summary: SessionSummary;
      filesUpdated: string[];
      gitCommit?: string;
    }> {
      const timestamp = new Date().toISOString();
      const summary = await this.gatherSessionSummary(conversationSummary, timestamp);
      
      const filesUpdated: string[] = [];
    
      // 1. Update session summary file
      await this.updateSessionSummary(summary);
      filesUpdated.push('.agent-os/session-summary.md');
    
      // 2. Update Agent OS files if they exist
      const agentOSUpdates = await this.updateAgentOSFiles(summary);
      filesUpdated.push(...agentOSUpdates);
    
      // 3. Sync context files
      const contextFiles = await this.syncContextFiles(summary);
      filesUpdated.push(...contextFiles);
    
      // 4. Git commit
      let gitCommit: string | undefined;
      if (await this.isGitRepo()) {
        gitCommit = await this.commitChanges(summary, filesUpdated);
      }
    
      return {
        success: true,
        summary,
        filesUpdated,
        gitCommit
      };
    }
  • MCP CallToolRequestSchema handler switch case for 'end_session'. Extracts input parameters and delegates to SessionCloser.closeSession, formats the response.
    case 'end_session': {
      const conversationSummary = args.conversationSummary as string || 
        'Session work completed. Review conversation history for details.';
      
      const result = await this.sessionCloser.closeSession(conversationSummary);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: result.success,
              summary: result.summary,
              filesUpdated: result.filesUpdated,
              gitCommit: result.gitCommit,
              message: 'Session closed successfully! All context files synced and changes committed.',
            }, null, 2),
          },
        ],
      };
    }
  • JSON Schema definition for end_session tool input parameters, defining conversationSummary as required and others as optional arrays.
    inputSchema: {
      type: 'object',
      properties: {
        conversationSummary: {
          type: 'string',
          description: 'Summary of what was accomplished in this session. If not provided, will attempt to extract from context.',
        },
        accomplishments: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of specific accomplishments (optional, will be extracted if not provided)',
        },
        decisions: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of decisions made during this session (optional)',
        },
        blockers: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of blockers or issues encountered (optional)',
        },
        nextSteps: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of next steps or TODO items (optional)',
        },
      },
      required: ['conversationSummary'],
    },
  • src/index.ts:43-77 (registration)
    Registration of the end_session tool in the ListToolsRequestSchema handler response, including name, description, and full input schema.
    {
      name: 'end_session',
      description: 'Close the current Cursor session, sync all context files, update Agent OS files, and commit to git. This is the main tool for ending a work session.',
      inputSchema: {
        type: 'object',
        properties: {
          conversationSummary: {
            type: 'string',
            description: 'Summary of what was accomplished in this session. If not provided, will attempt to extract from context.',
          },
          accomplishments: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of specific accomplishments (optional, will be extracted if not provided)',
          },
          decisions: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of decisions made during this session (optional)',
          },
          blockers: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of blockers or issues encountered (optional)',
          },
          nextSteps: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of next steps or TODO items (optional)',
          },
        },
        required: ['conversationSummary'],
      },
    },
    {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions actions like syncing files and committing to git, which imply mutations and potential side effects, but doesn't detail permissions needed, error handling, or what happens if operations fail. For a tool with multiple operations and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, with two sentences that efficiently convey the tool's purpose and main use case. Every sentence adds value without redundancy, though it could be slightly more structured by explicitly listing key actions or outcomes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multiple operations like syncing and committing) and lack of annotations or output schema, the description is somewhat incomplete. It covers the high-level purpose but misses details on behavioral traits, error scenarios, and return values. This leaves gaps for an AI agent to fully understand how to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, such as formatting details or examples. Baseline 3 is appropriate when the schema handles parameter documentation effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Close', 'sync', 'update', 'commit') and resources ('Cursor session', 'context files', 'Agent OS files', 'git'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'sync_context_files' or 'update_session_summary', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating 'This is the main tool for ending a work session,' which suggests it should be used to conclude sessions. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'sync_context_files' or 'update_session_summary,' nor does it specify prerequisites or exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Tylarcam/mcp-session-closer'

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