Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add line numbers to source output
  • Loading branch information
brendan-kellam committed Jan 27, 2026
commit d35ab77cae97ac52bf97d5bd269855f29956c233
3 changes: 2 additions & 1 deletion packages/mcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { env, numberSchema } from './env.js';
import { fileSourceRequestSchema, listCommitsQueryParamsSchema, listReposQueryParamsSchema } from './schemas.js';
import { FileSourceRequest, ListCommitsQueryParamsSchema, ListReposQueryParams, TextContent } from './types.js';
import _dedent from "dedent";
import { addLineNumbers } from './utils.js';

const dedent = _dedent.withOptions({ alignValues: true });

Expand Down Expand Up @@ -218,7 +219,7 @@ server.tool(
return {
content: [{
type: "text", text: JSON.stringify({
source: response.source,
source: addLineNumbers(response.source),
language: response.language,
path: response.path,
url: response.webUrl,
Expand Down
4 changes: 4 additions & 0 deletions packages/mcp/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ export class ServiceErrorException extends Error {
constructor(public readonly serviceError: ServiceError) {
super(JSON.stringify(serviceError));
}
}

export const addLineNumbers = (source: string, lineOffset = 1) => {
return source.split('\n').map((line, index) => `${index + lineOffset}:${line}`).join('\n');
}
Loading