Skip to content

Commit 7f38753

Browse files
readonly hint
1 parent bbbb982 commit 7f38753

File tree

9 files changed

+15
-1
lines changed

9 files changed

+15
-1
lines changed

packages/web/src/features/tools/adapters.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export function registerMcpTool<TName extends string, TShape extends z.ZodRawSha
2626
// type. def.inputSchema.parse() recovers the correctly typed value inside.
2727
server.registerTool(
2828
def.name,
29-
{ description: def.description, inputSchema: def.inputSchema.shape as z.ZodRawShape },
29+
{
30+
description: def.description,
31+
inputSchema: def.inputSchema.shape as z.ZodRawShape,
32+
annotations: {
33+
readOnlyHint: def.isReadOnly,
34+
},
35+
},
3036
async (input) => {
3137
try {
3238
const parsed = def.inputSchema.parse(input);

packages/web/src/features/tools/findSymbolDefinitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const findSymbolDefinitionsDefinition: ToolDefinition<
2323
FindSymbolDefinitionsMetadata
2424
> = {
2525
name: 'find_symbol_definitions',
26+
isReadOnly: true,
2627
description,
2728
inputSchema: z.object(findSymbolDefinitionsShape),
2829
execute: async ({ symbol, language, repo }, _context) => {

packages/web/src/features/tools/findSymbolReferences.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const findSymbolReferencesDefinition: ToolDefinition<
3030
FindSymbolReferencesMetadata
3131
> = {
3232
name: 'find_symbol_references',
33+
isReadOnly: true,
3334
description,
3435
inputSchema: z.object(findSymbolReferencesShape),
3536
execute: async ({ symbol, language, repo }, _context) => {

packages/web/src/features/tools/listCommits.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type ListCommitsMetadata = SearchCommitsResult;
2020

2121
export const listCommitsDefinition: ToolDefinition<"list_commits", typeof listCommitsShape, ListCommitsMetadata> = {
2222
name: "list_commits",
23+
isReadOnly: true,
2324
description,
2425
inputSchema: z.object(listCommitsShape),
2526
execute: async (params, _context) => {

packages/web/src/features/tools/listRepos.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const listReposDefinition: ToolDefinition<
3333
ListReposMetadata
3434
> = {
3535
name: 'list_repos',
36+
isReadOnly: true,
3637
description,
3738
inputSchema: z.object(listReposShape),
3839
execute: async ({ page, perPage, sort, direction, query }, context) => {

packages/web/src/features/tools/listTree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type ListTreeMetadata = {
4040

4141
export const listTreeDefinition: ToolDefinition<'list_tree', typeof listTreeShape, ListTreeMetadata> = {
4242
name: 'list_tree',
43+
isReadOnly: true,
4344
description,
4445
inputSchema: z.object(listTreeShape),
4546
execute: async ({ repo, path = '', ref = 'HEAD', depth = DEFAULT_TREE_DEPTH, includeFiles = true, includeDirectories = true, maxEntries = DEFAULT_MAX_TREE_ENTRIES }, context) => {

packages/web/src/features/tools/readFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type ReadFileMetadata = {
3535

3636
export const readFileDefinition: ToolDefinition<"read_file", typeof readFileShape, ReadFileMetadata> = {
3737
name: "read_file",
38+
isReadOnly: true,
3839
description,
3940
inputSchema: z.object(readFileShape),
4041
execute: async ({ path, repo, offset, limit }, context) => {

packages/web/src/features/tools/searchCode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type SearchCodeMetadata = {
6464

6565
export const searchCodeDefinition: ToolDefinition<'search_code', typeof searchCodeShape, SearchCodeMetadata> = {
6666
name: 'search_code',
67+
isReadOnly: true,
6768
description,
6869
inputSchema: z.object(searchCodeShape),
6970
execute: async ({

packages/web/src/features/tools/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface ToolDefinition<
1212
name: TName;
1313
description: string;
1414
inputSchema: z.ZodObject<TShape>;
15+
isReadOnly: boolean;
1516
execute: (input: z.infer<z.ZodObject<TShape>>, context: ToolContext) => Promise<ToolResult<TMetadata>>;
1617
}
1718

0 commit comments

Comments
 (0)