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
11 changes: 11 additions & 0 deletions docs/docs/features/mcp-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ Parameters:
| `ref` | no | Commit SHA, branch or tag name to search on. If not provided, defaults to the default branch. |
| `limit` | no | Maximum number of files to return (default: 100). |

### `get_diff`

Returns a structured diff between two refs in a repository using a two-dot comparison.

Parameters:
| Name | Required | Description |
|:----------|:---------|:--------------------------------------------------------------------------------------------------------------|
| `repo` | yes | The fully-qualified repository name. |
| `base` | yes | The base git ref (branch, tag, or commit SHA) to diff from. |
| `head` | yes | The head git ref (branch, tag, or commit SHA) to diff to. |

### `find_symbol_definitions`

Finds where a symbol (function, class, variable, etc.) is defined in a repository.
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/features/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getConfiguredLanguageModelsInfo } from "../chat/utils.server";
import {
findSymbolDefinitionsDefinition,
findSymbolReferencesDefinition,
getDiffDefinition,
listCommitsDefinition,
listReposDefinition,
listTreeDefinition,
Expand Down Expand Up @@ -40,6 +41,7 @@ export async function createMcpServer(): Promise<McpServer> {

registerMcpTool(server, grepDefinition, toolContext);
registerMcpTool(server, globDefinition, toolContext);
registerMcpTool(server, getDiffDefinition, toolContext);
registerMcpTool(server, listCommitsDefinition, toolContext);
registerMcpTool(server, listReposDefinition, toolContext);
registerMcpTool(server, readFileDefinition, toolContext);
Expand Down
40 changes: 40 additions & 0 deletions packages/web/src/features/tools/getDiff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { getDiff, GetDiffResult } from '@/features/git';
import { getDiffRequestSchema } from '@/features/git/schemas';
import { isServiceError } from '@/lib/utils';
import description from './getDiff.txt';
import { logger } from './logger';
import { ToolDefinition } from './types';

export type GetDiffMetadata = GetDiffResult & {
repo: string;
base: string;
head: string;
};

export const getDiffDefinition: ToolDefinition<'get_diff', typeof getDiffRequestSchema.shape, GetDiffMetadata> = {
name: 'get_diff',
title: 'Get diff',
isReadOnly: true,
isIdempotent: true,
description,
inputSchema: getDiffRequestSchema,
execute: async ({ repo, base, head }, _context) => {
logger.debug('get_diff', { repo, base, head });

const response = await getDiff({ repo, base, head });

if (isServiceError(response)) {
throw new Error(response.message);
}

return {
output: JSON.stringify(response),
metadata: {
...response,
repo,
base,
head,
},
};
},
};
4 changes: 4 additions & 0 deletions packages/web/src/features/tools/getDiff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Returns a structured git diff between two refs in a repository.

Use this tool when you need patch details (added, removed, and context lines) between a base and head revision.
The output includes changed files and hunks with line ranges and diff body content.
1 change: 1 addition & 0 deletions packages/web/src/features/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './listCommits';
export * from './listRepos';
export * from './grep';
export * from './glob';
export * from './getDiff';
export * from './findSymbolReferences';
export * from './findSymbolDefinitions';
export * from './listTree';
Expand Down
Loading