mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: improve MCP section logic consistency and null handling
- Enhanced null/undefined handling for mcpHub across all files - Made MCP server detection logic consistent between Task.ts and generateSystemPrompt.ts - Added defensive programming with optional chaining for getAllServers() calls - Ensures MCP sections are properly omitted when no servers are available
This commit is contained in:
parent
1b57b878dd
commit
cebbafa37b
4 changed files with 4 additions and 4 deletions
|
|
@ -33,7 +33,7 @@ CAPABILITIES
|
|||
? "\n- You can use the browser_action tool to interact with websites (including html files and locally running development servers) through a Puppeteer-controlled browser when you feel it is necessary in accomplishing the user's task. This tool is particularly useful for web development tasks as it allows you to launch a browser, navigate to pages, interact with elements through clicks and keyboard input, and capture the results through screenshots and console logs. This tool may be useful at key stages of web development tasks-such as after implementing new features, making substantial changes, when troubleshooting issues, or to verify the result of your work. You can analyze the provided screenshots to ensure correct rendering or identify errors, and review console logs for runtime issues.\n - For example, if asked to add a component to a react website, you might create the necessary files, use execute_command to run the site locally, then use browser_action to launch the browser, navigate to the local server, and verify the component renders & functions correctly before closing the browser."
|
||||
: ""
|
||||
}${
|
||||
mcpHub && mcpHub.getAllServers().length > 0
|
||||
mcpHub && (mcpHub.getAllServers()?.length ?? 0) > 0
|
||||
? `
|
||||
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
|
||||
`
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export async function getMcpServersSection(
|
|||
diffStrategy?: DiffStrategy,
|
||||
enableMcpServerCreation?: boolean,
|
||||
): Promise<string> {
|
||||
if (!mcpHub || mcpHub.getAllServers().length === 0) {
|
||||
if (!mcpHub || (mcpHub.getAllServers()?.length ?? 0) === 0) {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1608,7 +1608,7 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
})
|
||||
}
|
||||
|
||||
const hasMcpServers = (mcpHub?.getAllServers().length ?? 0) > 0
|
||||
const hasMcpServers = mcpHub && (mcpHub.getAllServers().length ?? 0) > 0
|
||||
|
||||
const rooIgnoreInstructions = this.rooIgnoreController?.getInstructions()
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export const generateSystemPrompt = async (provider: ClineProvider, message: Web
|
|||
const canUseBrowserTool = modelSupportsComputerUse && modeSupportsBrowser && (browserToolEnabled ?? true)
|
||||
|
||||
const mcpHub = provider.getMcpHub()
|
||||
const hasMcpServers = (mcpHub?.getAllServers().length ?? 0) > 0
|
||||
const hasMcpServers = mcpHub && (mcpHub.getAllServers().length ?? 0) > 0
|
||||
|
||||
const systemPrompt = await SYSTEM_PROMPT(
|
||||
provider.context,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue