diff --git a/package.json b/package.json index c891143e..2e23cdd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "githits", "description": "CLI companion for GitHits - code examples from global open source for developers and AI assistants", - "version": "0.1.1", + "version": "0.1.2", "type": "module", "files": [ "dist", diff --git a/src/commands/mcp.test.ts b/src/commands/mcp.test.ts index dd4244d3..5abb0047 100644 --- a/src/commands/mcp.test.ts +++ b/src/commands/mcp.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, spyOn } from "bun:test"; +import { describe, expect, it } from "bun:test"; import type { Dependencies } from "../container.js"; import { createMockAuthService, @@ -7,7 +7,6 @@ import { createMockFileSystemService, createMockGitHitsService, } from "../services/test-helpers.js"; -import { AuthRequiredError } from "../shared/require-auth.js"; import { createMcpServer, startMcpServer } from "./mcp.js"; function createTestDeps(overrides: Partial = {}): Dependencies { @@ -45,12 +44,11 @@ describe("createMcpServer", () => { }); describe("startMcpServer", () => { - it("throws AuthRequiredError on auth failure", async () => { - const consoleSpy = spyOn(console, "log").mockImplementation(() => {}); + it("starts successfully without a valid token", async () => { const deps = createTestDeps({ hasValidToken: false }); - await expect(startMcpServer(deps)).rejects.toThrow(AuthRequiredError); - - consoleSpy.mockRestore(); + // Server should start and connect transport without throwing. + // Auth errors are deferred to individual tool calls. + await expect(startMcpServer(deps)).resolves.toBeUndefined(); }); }); diff --git a/src/commands/mcp.ts b/src/commands/mcp.ts index 2158f403..387c879a 100644 --- a/src/commands/mcp.ts +++ b/src/commands/mcp.ts @@ -4,7 +4,6 @@ import type { Command } from "commander"; import { version } from "../../package.json"; import { createContainer, type Dependencies } from "../container.js"; import { dim, highlight, shouldUseColors } from "../shared/colors.js"; -import { AuthRequiredError, requireAuth } from "../shared/require-auth.js"; import { createFeedbackTool, createSearchLanguageTool, @@ -44,8 +43,6 @@ export function createMcpServer(deps: Dependencies): McpServer { * Start the MCP server. Exported for testability. */ export async function startMcpServer(deps: Dependencies): Promise { - requireAuth(deps, "to start MCP server"); - const server = createMcpServer(deps); const transport = new StdioServerTransport(); await server.connect(transport); @@ -101,13 +98,8 @@ Available tools: search, search_language, feedback`, showMcpSetupInstructions(); return; } - try { - const deps = await createContainer(); - await startMcpServer(deps); - } catch (error) { - if (error instanceof AuthRequiredError) process.exit(1); - throw error; - } + const deps = await createContainer(); + await startMcpServer(deps); }); mcpCommand @@ -120,12 +112,7 @@ This command explicitly starts the server and is intended for use in MCP configuration files. Use 'githits mcp' for interactive setup.`, ) .action(async () => { - try { - const deps = await createContainer(); - await startMcpServer(deps); - } catch (error) { - if (error instanceof AuthRequiredError) process.exit(1); - throw error; - } + const deps = await createContainer(); + await startMcpServer(deps); }); }