@@ -3,6 +3,7 @@ import { IgniteCommand } from './ignite.js'
33import type { PromptTemplateManager } from '../lib/PromptTemplateManager.js'
44import type { GitWorktreeManager } from '../lib/GitWorktreeManager.js'
55import * as claudeUtils from '../utils/claude.js'
6+ import * as githubUtils from '../utils/github.js'
67
78describe ( 'IgniteCommand' , ( ) => {
89 let command : IgniteCommand
@@ -599,4 +600,138 @@ describe('IgniteCommand', () => {
599600 }
600601 } )
601602 } )
603+
604+ describe ( 'MCP Configuration' , ( ) => {
605+ it ( 'should generate MCP config for issue workflows' , async ( ) => {
606+ const launchClaudeSpy = vi . spyOn ( claudeUtils , 'launchClaude' ) . mockResolvedValue ( undefined )
607+ const getRepoInfoSpy = vi . spyOn ( githubUtils , 'getRepoInfo' ) . mockResolvedValue ( {
608+ owner : 'testowner' ,
609+ name : 'testrepo' ,
610+ } )
611+
612+ const originalCwd = process . cwd
613+ process . cwd = vi . fn ( ) . mockReturnValue ( '/path/to/feat/issue-77-mcp-test' )
614+
615+ try {
616+ await command . execute ( )
617+
618+ // Verify launchClaude was called with mcpConfig
619+ const launchClaudeCall = launchClaudeSpy . mock . calls [ 0 ]
620+ expect ( launchClaudeCall [ 1 ] ) . toHaveProperty ( 'mcpConfig' )
621+ expect ( launchClaudeCall [ 1 ] . mcpConfig ) . toBeInstanceOf ( Array )
622+ expect ( launchClaudeCall [ 1 ] . mcpConfig . length ) . toBeGreaterThan ( 0 )
623+
624+ // Verify MCP config structure
625+ const mcpConfig = launchClaudeCall [ 1 ] . mcpConfig [ 0 ]
626+ expect ( mcpConfig ) . toHaveProperty ( 'mcpServers' )
627+ expect ( mcpConfig . mcpServers ) . toHaveProperty ( 'github_comment' )
628+ expect ( mcpConfig . mcpServers . github_comment ) . toHaveProperty ( 'command' )
629+ expect ( mcpConfig . mcpServers . github_comment ) . toHaveProperty ( 'args' )
630+ expect ( mcpConfig . mcpServers . github_comment ) . toHaveProperty ( 'env' )
631+ } finally {
632+ process . cwd = originalCwd
633+ launchClaudeSpy . mockRestore ( )
634+ getRepoInfoSpy . mockRestore ( )
635+ }
636+ } )
637+
638+ it ( 'should generate MCP config for PR workflows' , async ( ) => {
639+ const launchClaudeSpy = vi . spyOn ( claudeUtils , 'launchClaude' ) . mockResolvedValue ( undefined )
640+ const getRepoInfoSpy = vi . spyOn ( githubUtils , 'getRepoInfo' ) . mockResolvedValue ( {
641+ owner : 'testowner' ,
642+ name : 'testrepo' ,
643+ } )
644+
645+ const originalCwd = process . cwd
646+ process . cwd = vi . fn ( ) . mockReturnValue ( '/path/to/feature_pr_456' )
647+
648+ try {
649+ await command . execute ( )
650+
651+ // Verify launchClaude was called with mcpConfig
652+ const launchClaudeCall = launchClaudeSpy . mock . calls [ 0 ]
653+ expect ( launchClaudeCall [ 1 ] ) . toHaveProperty ( 'mcpConfig' )
654+ expect ( launchClaudeCall [ 1 ] . mcpConfig ) . toBeInstanceOf ( Array )
655+ } finally {
656+ process . cwd = originalCwd
657+ launchClaudeSpy . mockRestore ( )
658+ getRepoInfoSpy . mockRestore ( )
659+ }
660+ } )
661+
662+ it ( 'should NOT generate MCP config for regular workflows' , async ( ) => {
663+ const launchClaudeSpy = vi . spyOn ( claudeUtils , 'launchClaude' ) . mockResolvedValue ( undefined )
664+
665+ const originalCwd = process . cwd
666+ process . cwd = vi . fn ( ) . mockReturnValue ( '/path/to/main' )
667+
668+ mockGitWorktreeManager . getRepoInfo = vi . fn ( ) . mockResolvedValue ( {
669+ currentBranch : 'main' ,
670+ } )
671+
672+ try {
673+ await command . execute ( )
674+
675+ // Verify launchClaude was NOT called with mcpConfig
676+ const launchClaudeCall = launchClaudeSpy . mock . calls [ 0 ]
677+ expect ( launchClaudeCall [ 1 ] . mcpConfig ) . toBeUndefined ( )
678+ } finally {
679+ process . cwd = originalCwd
680+ launchClaudeSpy . mockRestore ( )
681+ }
682+ } )
683+
684+ it ( 'should include correct environment variables in MCP config for issue workflows' , async ( ) => {
685+ const launchClaudeSpy = vi . spyOn ( claudeUtils , 'launchClaude' ) . mockResolvedValue ( undefined )
686+ const getRepoInfoSpy = vi . spyOn ( githubUtils , 'getRepoInfo' ) . mockResolvedValue ( {
687+ owner : 'testowner' ,
688+ name : 'testrepo' ,
689+ } )
690+
691+ const originalCwd = process . cwd
692+ process . cwd = vi . fn ( ) . mockReturnValue ( '/path/to/feat/issue-88-env-test' )
693+
694+ try {
695+ await command . execute ( )
696+
697+ const launchClaudeCall = launchClaudeSpy . mock . calls [ 0 ]
698+ const mcpConfig = launchClaudeCall [ 1 ] . mcpConfig [ 0 ]
699+ const env = mcpConfig . mcpServers . github_comment . env
700+
701+ expect ( env ) . toHaveProperty ( 'REPO_OWNER' )
702+ expect ( env ) . toHaveProperty ( 'REPO_NAME' )
703+ expect ( env ) . toHaveProperty ( 'GITHUB_EVENT_NAME' , 'issues' )
704+ expect ( env ) . toHaveProperty ( 'GITHUB_API_URL' )
705+ } finally {
706+ process . cwd = originalCwd
707+ launchClaudeSpy . mockRestore ( )
708+ getRepoInfoSpy . mockRestore ( )
709+ }
710+ } )
711+
712+ it ( 'should include correct environment variables in MCP config for PR workflows' , async ( ) => {
713+ const launchClaudeSpy = vi . spyOn ( claudeUtils , 'launchClaude' ) . mockResolvedValue ( undefined )
714+ const getRepoInfoSpy = vi . spyOn ( githubUtils , 'getRepoInfo' ) . mockResolvedValue ( {
715+ owner : 'testowner' ,
716+ name : 'testrepo' ,
717+ } )
718+
719+ const originalCwd = process . cwd
720+ process . cwd = vi . fn ( ) . mockReturnValue ( '/path/to/feature_pr_789' )
721+
722+ try {
723+ await command . execute ( )
724+
725+ const launchClaudeCall = launchClaudeSpy . mock . calls [ 0 ]
726+ const mcpConfig = launchClaudeCall [ 1 ] . mcpConfig [ 0 ]
727+ const env = mcpConfig . mcpServers . github_comment . env
728+
729+ expect ( env ) . toHaveProperty ( 'GITHUB_EVENT_NAME' , 'pull_request' )
730+ } finally {
731+ process . cwd = originalCwd
732+ launchClaudeSpy . mockRestore ( )
733+ getRepoInfoSpy . mockRestore ( )
734+ }
735+ } )
736+ } )
602737} )
0 commit comments