@@ -145,47 +145,80 @@ describe("buildSystemPrompt", () => {
145145 expect ( prompt ) . toContain ( "GitHub instructions" )
146146 } )
147147
148- test ( "should include connected MCP servers in system prompt" , async ( ) => {
148+ test ( "should include inferred MCP servers in system prompt" , async ( ) => {
149149 const config : AgentChatConfig = {
150150 mcpServers : { } ,
151151 }
152- const connectedServers = new Set ( [ "github" , "gitlab" ] )
152+ const inferredServers = new Set ( [ "github" , "gitlab" ] )
153153
154154 const prompt = await buildSystemPrompt ( {
155155 config,
156- connectedServers ,
156+ inferredServers ,
157157 } )
158158
159- expect ( prompt ) . toContain ( "Connected MCP Servers " )
159+ expect ( prompt ) . toContain ( "Server Selection Context " )
160160 expect ( prompt ) . toContain ( "github, gitlab" )
161161 } )
162162
163- test ( "should handle empty connected servers set " , async ( ) => {
163+ test ( "should include connected and failed MCP servers sections " , async ( ) => {
164164 const config : AgentChatConfig = {
165165 mcpServers : { } ,
166166 }
167- const connectedServers = new Set < string > ( )
167+ const mcpServers = [
168+ { name : "github" , status : "connected" } ,
169+ { name : "gitlab" , status : "failed" } ,
170+ ]
168171
169172 const prompt = await buildSystemPrompt ( {
170173 config,
171- connectedServers ,
174+ mcpServers ,
172175 } )
173176
174- expect ( prompt ) . toContain ( "Connected MCP Servers" )
175- expect ( prompt ) . toContain (
176- "The following MCP servers are currently connected and available:"
177- )
177+ expect ( prompt ) . toContain ( "Available MCP Servers" )
178+ expect ( prompt ) . toContain ( "- github" )
179+ expect ( prompt ) . toContain ( "ONLY servers with available tools" )
180+ expect ( prompt ) . toContain ( "Unavailable MCP Servers" )
181+ expect ( prompt ) . toContain ( "- gitlab" )
182+ expect ( prompt ) . toContain ( "These servers have NO tools available" )
178183 } )
179184
180- test ( "should work without connectedServers parameter" , async ( ) => {
185+ test ( "should not include connection status sections when no mcpServers provided" , async ( ) => {
186+ const config : AgentChatConfig = {
187+ mcpServers : { } ,
188+ }
189+
190+ const prompt = await buildSystemPrompt ( {
191+ config,
192+ } )
193+
194+ expect ( prompt ) . not . toContain ( "Available MCP Servers" )
195+ expect ( prompt ) . not . toContain ( "Unavailable MCP Servers" )
196+ } )
197+
198+ test ( "should handle empty inferred servers set" , async ( ) => {
199+ const config : AgentChatConfig = {
200+ mcpServers : { } ,
201+ }
202+ const inferredServers = new Set < string > ( )
203+
204+ const prompt = await buildSystemPrompt ( {
205+ config,
206+ inferredServers,
207+ } )
208+
209+ expect ( prompt ) . toContain ( "Current date:" )
210+ expect ( prompt ) . not . toContain ( "Server Selection Context" )
211+ } )
212+
213+ test ( "should work without inferredServers parameter" , async ( ) => {
181214 const config : AgentChatConfig = {
182215 mcpServers : { } ,
183216 }
184217
185218 const prompt = await buildSystemPrompt ( { config } )
186219
187- expect ( prompt ) . toContain ( "Connected MCP Servers" )
188220 expect ( prompt ) . toContain ( "Current date:" )
221+ expect ( prompt ) . not . toContain ( "Server Selection Context" )
189222 } )
190223
191224 test ( "should skip disabled MCP servers" , async ( ) => {
0 commit comments