list_repos
List all accessible ShadowGit repositories to discover which ones you can analyze.
Instructions
List all available ShadowGit repositories. Use this first to discover which repositories you can work with.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/list-repos-handler.ts:1-73 (handler)The ListReposHandler class with the handle() method that executes the list_repos tool logic. It fetches repositories from RepositoryManager and formats them with workflow instructions.
/** * Handler for list_repos tool */ import { RepositoryManager } from '../core/repository-manager'; import { createTextResponse, formatRepositoryList } from '../utils/response-utils'; import type { MCPToolResponse } from '../types'; export class ListReposHandler { constructor(private repositoryManager: RepositoryManager) {} /** * Handle list_repos tool execution */ async handle(): Promise<MCPToolResponse> { const repos = this.repositoryManager.getRepositories(); if (repos.length === 0) { return createTextResponse( `No repositories found in ShadowGit. To add repositories: 1. Open the ShadowGit application 2. Click "Add Repository" 3. Select the repository you want to track ShadowGit will automatically create shadow repositories (.shadowgit.git) to track changes.` ); } const repoList = formatRepositoryList(repos); const firstRepo = repos[0].name; return createTextResponse( `🚀 **ShadowGit MCP Server Connected** ${'='.repeat(50)} 📁 **Available Repositories (${repos.length})** ${repoList} ${'='.repeat(50)} ⚠️ **CRITICAL: Required Workflow for ALL Changes** ${'='.repeat(50)} **You MUST follow this 4-step workflow:** 1️⃣ **START SESSION** (before ANY edits) \`start_session({repo: "${firstRepo}", description: "your task"})\` 2️⃣ **MAKE YOUR CHANGES** Edit code, fix bugs, add features 3️⃣ **CREATE CHECKPOINT** (after changes complete) \`checkpoint({repo: "${firstRepo}", title: "Clear commit message"})\` 4️⃣ **END SESSION** (to resume auto-commits) \`end_session({sessionId: "...", commitHash: "..."})\` ${'='.repeat(50)} 💡 **Quick Start Examples:** \`\`\`javascript // Check recent history git_command({repo: "${firstRepo}", command: "log -5"}) // Start your work session start_session({repo: "${firstRepo}", description: "Fixing authentication bug"}) \`\`\` 📖 **NEXT STEP:** Call \`start_session()\` before making any changes!` ); } } - src/shadowgit-mcp-server.ts:67-78 (registration)Tool registration: name 'list_repos' is declared in the ListToolsRequestSchema handler with its description and empty inputSchema.
private setupHandlers(): void { // List available tools this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'list_repos', description: 'List all available ShadowGit repositories. Use this first to discover which repositories you can work with.', inputSchema: { type: 'object', properties: {}, }, }, - src/shadowgit-mcp-server.ts:169-171 (registration)Tool dispatch: the CallToolRequestSchema switch-case routes 'list_repos' to listReposHandler.handle().
switch (name) { case 'list_repos': return await this.listReposHandler.handle(); - src/utils/response-utils.ts:40-45 (helper)The formatRepositoryList() helper used by the handler to format repository names and paths for display.
export function formatRepositoryList(repos: Array<{ name: string; path: string }>): string { if (repos.length === 0) { return 'No repositories available.'; } return repos.map(r => ` ${r.name}:\n Path: ${r.path}`).join('\n\n'); } - src/core/repository-manager.ts:40-42 (helper)The getRepositories() method on RepositoryManager that provides the list of repositories displayed by list_repos.
getRepositories(): Repository[] { return this.repositories; }