Skip to content

Commit ba085a9

Browse files
msukkaricursoragentbrendan-kellam
authored
Mcp undefined filename bug (#718)
* 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. * fix fields and changelog * Move MCP changelog entry to MCP package changelog Moved the changelog entry for PR #718 from the main CHANGELOG.md to packages/mcp/CHANGELOG.md as requested. Co-authored-by: brendan <brendan@sourcebot.dev> * revert back to original changes * fix changelog entry --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: brendan <brendan@sourcebot.dev>
1 parent a14f0c2 commit ba085a9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/mcp/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed invalid file and url MCP results for local indexed repos [#718](https://github.com/sourcebot-dev/sourcebot/pull/718)
12+
1013
## [1.0.11] - 2025-12-03
1114

1215
### Changed

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)