Skip to main content
Glama
aflsolutions

ShadowGit MCP Server

by aflsolutions

start_session

Initialize a work session before making changes to prevent fragmented auto-commits. Always call this first to enable organized commit tracking.

Instructions

Start a work session. MUST be called BEFORE making any changes. Without this, ShadowGit will create fragmented auto-commits during your work!

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoYesRepository name
descriptionYesWhat you plan to do in this session

Implementation Reference

  • The main handler function for the 'start_session' tool. Validates args (repo and description), resolves the repo path, calls sessionClient.startSession(), and returns a success response with the session ID or an error.
      async startSession(args: unknown): Promise<MCPToolResponse> {
        // Validate args
        if (!this.isStartSessionArgs(args)) {
          return createErrorResponse(
            'Error: Both "repo" and "description" are required for start_session.'
          );
        }
    
        // Resolve repository
        const repoPath = this.repositoryManager.resolveRepoPath(args.repo);
        if (!repoPath) {
          return createErrorResponse(
            `Error: Repository '${args.repo}' not found. Use list_repos() to see available repositories.`
          );
        }
    
        // Start session
        const sessionId = await this.sessionClient.startSession({
          repoPath,
          aiTool: 'MCP Client',
          description: args.description
        });
    
        if (sessionId) {
          log('info', `Session started: ${sessionId}`);
          return {
            content: [{
              type: 'text',
              text: `Session started successfully.
    Session ID: ${sessionId}
    
    šŸ“‹ **Your Workflow Checklist:**
    1. Make your changes
    2. Call checkpoint() to commit
    3. Call end_session() with this session ID`
            }]
          };
        }
    
        // Fallback if Session API is offline
        return createErrorResponse(
          'Session API is offline. Proceeding without session tracking.'
        );
      }
  • The StartSessionArgs interface defining required input fields: repo (string) and description (string).
    interface StartSessionArgs {
      repo: string;
      description: string;
    }
  • The SessionStartRequest type sent to the Session API containing repoPath, aiTool, and description.
    export interface SessionStartRequest {
      repoPath: string;
      aiTool: string;
      description: string;
    }
    
    export interface SessionStartResponse {
      success: boolean;
      sessionId?: string;
      error?: string;
    }
  • Tool registration in the MCP server's ListToolsRequestSchema handler, defining the name 'start_session', description, and inputSchema (repo and description as required strings).
    {
      name: 'start_session',
      description: 'Start a work session. MUST be called BEFORE making any changes. Without this, ShadowGit will create fragmented auto-commits during your work!',
      inputSchema: {
        type: 'object',
        properties: {
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          description: {
            type: 'string',
            description: 'What you plan to do in this session',
          },
        },
        required: ['repo', 'description'],
      },
    },
  • Routing in the CallToolRequestSchema handler: the 'start_session' case delegates to sessionHandler.startSession(args).
    case 'start_session':
      return await this.sessionHandler.startSession(args);
  • The HTTP client method that POSTs to the Session API's /session/start endpoint with SessionStartRequest data and returns the sessionId string or null on failure.
    async startSession(data: SessionStartRequest): Promise<string | null> {
      try {
        const controller = new AbortController();
        const timeoutId = setTimeout(() => controller.abort(), this.timeout);
    
        const response = await fetch(`${this.baseUrl}/session/start`, {
          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 SessionStartResponse;
          if (result.success && result.sessionId) {
            log('info', `Session started: ${result.sessionId} for ${data.repoPath}`);
            return result.sessionId;
          }
        }
        
        log('warn', `Failed to start session: ${response.status} ${response.statusText}`);
      } catch (error) {
        // Silently fail - don't break MCP if Session API is down
        if (error instanceof Error && error.name !== 'AbortError') {
          log('debug', `Session API unavailable: ${error.message}`);
        }
      }
      return null;
    }
  • Type guard isStartSessionArgs that validates the incoming args object has 'repo' and 'description' string properties.
    private isStartSessionArgs(args: unknown): args is StartSessionArgs {
      return (
        typeof args === 'object' &&
        args !== null &&
        'repo' in args &&
        'description' in args &&
        typeof (args as StartSessionArgs).repo === 'string' &&
        typeof (args as StartSessionArgs).description === 'string'
      );
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.0

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals a critical behavioral trait: without starting a session, ShadowGit creates fragmented auto-commits. This is valuable context beyond the tool's name, though it does not cover other aspects like authentication or side effects.

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?

The description is two sentences long, front-loaded with the core purpose, and every sentence earns its place. The critical warning is emphasized in caps, making it highly scannable without unnecessary verbosity.

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 tool with two required parameters and no output schema, the description covers the essential context: when to call it and the consequence of not doing so. It does not explain internal session mechanics, but that is unnecessary given the schema and sibling tools. It is sufficiently complete for an agent to select and 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?

The input schema covers both parameters with clear descriptions ('Repository name' and 'What you plan to do in this session'), so schema coverage is 100%. The description adds no additional parameter-level information, which aligns with the baseline score of 3 for high schema coverage.

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's purpose with a specific verb and resource: 'Start a work session.' It also distinguishes from siblings by emphasizing the prerequisite role ('MUST be called BEFORE making any changes') and the consequence of skipping it, which sets it apart from end_session and git_command.

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?

The description provides an explicit when-to-use guideline: 'MUST be called BEFORE making any changes.' It also explains the negative outcome of not using it (fragmented auto-commits), giving clear context. However, it does not mention when not to use or point to alternatives, so it stops short of a 5.

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