Skip to main content
Glama
aflsolutions

ShadowGit MCP Server

by aflsolutions

end_session

Finalize your work session to resume automatic commits. Use after checkpoint to properly close the session.

Instructions

End your work session to resume ShadowGit auto-commits. MUST be called AFTER checkpoint to properly close your work session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID from start_session
commitHashNoCommit hash from checkpoint (optional)

Implementation Reference

  • The endSession method on SessionHandler - the main handler logic for the end_session tool. Validates that sessionId is provided, then delegates to SessionClient.endSession() to make the HTTP API call.
      async endSession(args: unknown): Promise<MCPToolResponse> {
        // Validate args
        if (!this.isEndSessionArgs(args)) {
          return createErrorResponse(
            'Error: "sessionId" is required for end_session.'
          );
        }
    
        // End session
        const success = await this.sessionClient.endSession(
          args.sessionId,
          args.commitHash
        );
    
        if (success) {
          log('info', `Session ended: ${args.sessionId}`);
          return {
            content: [{
              type: 'text',
              text: `Session ${args.sessionId} ended successfully.`
            }]
          };
        }
    
        return createErrorResponse(
          `āŒ **Failed to End Session**
    ${'='.repeat(50)}
    
    āš ļø The session may have already ended or expired.
    
    **Note:** Auto-commits may have already resumed.
    
    šŸ’” **NEXT STEP:** You can continue working or start a new session.`
        );
      }
  • EndSessionArgs interface - defines the input schema for end_session: sessionId (required string) and commitHash (optional string).
    interface EndSessionArgs {
      sessionId: string;
      commitHash?: string;
    }
  • SessionEndRequest and SessionEndResponse interfaces - the types used for the HTTP API request/response for ending a session.
    export interface SessionEndRequest {
      sessionId: string;
      commitHash?: string;
    }
    
    export interface SessionEndResponse {
      success: boolean;
      error?: string;
    }
  • Tool registration for end_session in the ListToolsRequestSchema handler - defines the tool name, description, and inputSchema (sessionId required, commitHash optional).
    {
      name: 'end_session',
      description: 'End your work session to resume ShadowGit auto-commits. MUST be called AFTER checkpoint to properly close your work session.',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'Session ID from start_session',
          },
          commitHash: {
            type: 'string',
            description: 'Commit hash from checkpoint (optional)',
          },
        },
        required: ['sessionId'],
      },
    }
  • Tool dispatch in the CallToolRequestSchema handler - routes the 'end_session' tool name to sessionHandler.endSession(args).
    case 'end_session':
      return await this.sessionHandler.endSession(args);
  • SessionClient.endSession() - the low-level HTTP client that sends a POST request to the Session API's /session/end endpoint with sessionId and optional commitHash.
    async endSession(sessionId: string, commitHash?: string): Promise<boolean> {
      try {
        const controller = new AbortController();
        const timeoutId = setTimeout(() => controller.abort(), this.timeout);
    
        const data: SessionEndRequest = { sessionId };
        if (commitHash) {
          data.commitHash = commitHash;
        }
    
        const response = await fetch(`${this.baseUrl}/session/end`, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data),
          signal: controller.signal,
        });
    
        clearTimeout(timeoutId);
    
        if (response.ok) {
          const result = await response.json() as SessionEndResponse;
          if (result.success) {
            log('info', `Session ended: ${sessionId}`);
            return true;
          }
        }
        
        log('warn', `Failed to end session: ${response.status} ${response.statusText}`);
      } catch (error) {
        if (error instanceof Error && error.name !== 'AbortError') {
          log('debug', `Failed to end session: ${error.message}`);
        }
      }
      return false;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.0

TDQS

A4.2/5.0
Behavior3/5

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

No annotations exist, so the description carries the burden. It discloses that ending the session resumes auto-commits and that proper closure requires prior checkpoint, but does not detail side effects or error conditions. This is minimal but not absent.

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

Conciseness5/5

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

Two sentences, both essential: one defines purpose and effect, the other provides mandatory ordering. No filler.

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

Completeness4/5

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

For a simple two-parameter tool without output schema, the description covers purpose, ordering, and consequence. It doesn't describe return values, but that's not expected given the schema and sibling context.

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 coverage is 100%, with both sessionId and commitHash already described in the schema. The description adds no new parameter-level information, so baseline 3 applies.

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

Purpose5/5

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

The description clearly states the tool ends the work session and resumes auto-commits, using a specific verb and resource. It distinguishes from siblings (start_session, checkpoint) by focusing on session termination.

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

Usage Guidelines5/5

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

Explicitly states it MUST be called after checkpoint, providing clear ordering guidance. This implies when to use it and establishes a workflow context with sibling tools.

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