Skip to content

Commit e236c22

Browse files
committed
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.
1 parent 82dcf96 commit e236c22

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/mcp/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ server.tool(
106106
(acc, chunk) => acc + chunk.matchRanges.length,
107107
0,
108108
);
109-
let text = `file: ${file.webUrl}\nnum_matches: ${numMatches}\nrepository: ${file.repository}\nlanguage: ${file.language}`;
109+
const fileIdentifier = file.webUrl ?? file.fileName.text;
110+
let text = `file: ${fileIdentifier}\nnum_matches: ${numMatches}\nrepository: ${file.repository}\nlanguage: ${file.language}`;
110111

111112
if (includeCodeSnippets) {
112113
const snippets = file.chunks.map(chunk => {
@@ -200,9 +201,10 @@ server.tool(
200201

201202
// Format output
202203
const content: TextContent[] = paginated.map(repo => {
204+
const repoUrl = repo.webUrl ?? repo.repoCloneUrl;
203205
return {
204206
type: "text",
205-
text: `id: ${repo.repoName}\nurl: ${repo.webUrl}`,
207+
text: `id: ${repo.repoName}\nurl: ${repoUrl}`,
206208
}
207209
});
208210

0 commit comments

Comments
 (0)