mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Refactor: Make MCP server discovery non-blocking (#716)
This commit is contained in:
@@ -254,7 +254,7 @@ export function createServerConfig(params: ConfigParameters): Config {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createToolRegistry(config: Config): Promise<ToolRegistry> {
|
function createToolRegistry(config: Config): Promise<ToolRegistry> {
|
||||||
const registry = new ToolRegistry(config);
|
const registry = new ToolRegistry(config);
|
||||||
const targetDir = config.getTargetDir();
|
const targetDir = config.getTargetDir();
|
||||||
const tools = config.getCoreTools()
|
const tools = config.getCoreTools()
|
||||||
@@ -281,8 +281,12 @@ export function createToolRegistry(config: Config): Promise<ToolRegistry> {
|
|||||||
registerCoreTool(ShellTool, config);
|
registerCoreTool(ShellTool, config);
|
||||||
registerCoreTool(MemoryTool);
|
registerCoreTool(MemoryTool);
|
||||||
registerCoreTool(WebSearchTool, config);
|
registerCoreTool(WebSearchTool, config);
|
||||||
return (async () => {
|
|
||||||
await registry.discoverTools();
|
// This is async, but we can't wait for it to finish because when we register
|
||||||
return registry;
|
// discovered tools, we need to see if existing tools already exist in order to
|
||||||
})();
|
// avoid duplicates.
|
||||||
|
registry.discoverTools();
|
||||||
|
|
||||||
|
// Maintain an async registry return so it's easy in the future to add async behavior to this instantiation.
|
||||||
|
return Promise.resolve(registry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ You are running outside of a sandbox container, directly on the user's system. F
|
|||||||
${(function () {
|
${(function () {
|
||||||
// note git repo can change so we need to check every time system prompt is generated
|
// note git repo can change so we need to check every time system prompt is generated
|
||||||
const gitRootCmd = 'git rev-parse --show-toplevel 2>/dev/null || true';
|
const gitRootCmd = 'git rev-parse --show-toplevel 2>/dev/null || true';
|
||||||
const gitRoot = execSync(gitRootCmd).toString().trim();
|
const gitRoot = execSync(gitRootCmd)?.toString()?.trim();
|
||||||
if (gitRoot) {
|
if (gitRoot) {
|
||||||
return `
|
return `
|
||||||
# Git Repository
|
# Git Repository
|
||||||
|
|||||||
Reference in New Issue
Block a user