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;
    }
Behavior3/5

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

No annotations are provided, so the description carries full responsibility. It hints at consequences via “MUST be called AFTER checkpoint” but does not detail side effects or error states if misused.

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: first states purpose, second gives a critical usage note. No extraneous words, front-loaded with the key action.

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 end tool with no output schema, the description covers the essential action and prerequisite. Could mention what happens if sessionId is invalid, but overall adequate.

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

Parameters4/5

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

Schema coverage is 100%, and the description adds context: sessionId comes from start_session, commitHash is optional from checkpoint. This aids understanding beyond the schema.

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 it ends the work session and resumes auto-commits. It distinguishes itself from siblings like ‘start_session’ (opposite) and ‘checkpoint’ (preceding step) 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 Guidelines4/5

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

Explicitly states to call after checkpoint, providing clear ordering. Does not mention when not to use or list alternatives, but the directive is strong and sufficient.

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/aflsolutions/shadowgit-mcp'

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