From e236c22db03b36389113334e704c043d36e2f03e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 8 Jan 2026 00:00:52 +0000 Subject: [PATCH] fix(mcp): Use fileName.text as fallback when webUrl is undefined for local repos For local repositories, the webUrl field is undefined since there's no web hosting URL. This fix makes both search_code and list_repos tools fallback to the fileName.text and repoCloneUrl respectively when webUrl is not available. --- packages/mcp/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts index c704540f4..43c08f248 100644 --- a/packages/mcp/src/index.ts +++ b/packages/mcp/src/index.ts @@ -106,7 +106,8 @@ server.tool( (acc, chunk) => acc + chunk.matchRanges.length, 0, ); - let text = `file: ${file.webUrl}\nnum_matches: ${numMatches}\nrepository: ${file.repository}\nlanguage: ${file.language}`; + const fileIdentifier = file.webUrl ?? file.fileName.text; + let text = `file: ${fileIdentifier}\nnum_matches: ${numMatches}\nrepository: ${file.repository}\nlanguage: ${file.language}`; if (includeCodeSnippets) { const snippets = file.chunks.map(chunk => { @@ -200,9 +201,10 @@ server.tool( // Format output const content: TextContent[] = paginated.map(repo => { + const repoUrl = repo.webUrl ?? repo.repoCloneUrl; return { type: "text", - text: `id: ${repo.repoName}\nurl: ${repo.webUrl}`, + text: `id: ${repo.repoName}\nurl: ${repoUrl}`, } });