Skip to content

Commit c7e0c7e

Browse files
add tools | 3573 (#3589)
feat(git): add tool annotations Adds MCP ToolAnnotations to all 12 git server tools, marking read-only operations (status, diff, log, show, branch) and distinguishing destructive (reset) from non-destructive write operations (add, commit, create_branch, checkout). Fixes #3573
1 parent ae40ec2 commit c7e0c7e

1 file changed

Lines changed: 73 additions & 2 deletions

File tree

src/git/src/mcp_server_git/server.py

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Tool,
1111
ListRootsResult,
1212
RootsCapability,
13+
ToolAnnotations,
1314
)
1415
from enum import Enum
1516
import git
@@ -309,63 +310,133 @@ async def list_tools() -> list[Tool]:
309310
name=GitTools.STATUS,
310311
description="Shows the working tree status",
311312
inputSchema=GitStatus.model_json_schema(),
313+
annotations=ToolAnnotations(
314+
readOnlyHint=True,
315+
destructiveHint=False,
316+
idempotentHint=True,
317+
openWorldHint=False,
318+
),
312319
),
313320
Tool(
314321
name=GitTools.DIFF_UNSTAGED,
315322
description="Shows changes in the working directory that are not yet staged",
316323
inputSchema=GitDiffUnstaged.model_json_schema(),
324+
annotations=ToolAnnotations(
325+
readOnlyHint=True,
326+
destructiveHint=False,
327+
idempotentHint=True,
328+
openWorldHint=False,
329+
),
317330
),
318331
Tool(
319332
name=GitTools.DIFF_STAGED,
320333
description="Shows changes that are staged for commit",
321334
inputSchema=GitDiffStaged.model_json_schema(),
335+
annotations=ToolAnnotations(
336+
readOnlyHint=True,
337+
destructiveHint=False,
338+
idempotentHint=True,
339+
openWorldHint=False,
340+
),
322341
),
323342
Tool(
324343
name=GitTools.DIFF,
325344
description="Shows differences between branches or commits",
326345
inputSchema=GitDiff.model_json_schema(),
346+
annotations=ToolAnnotations(
347+
readOnlyHint=True,
348+
destructiveHint=False,
349+
idempotentHint=True,
350+
openWorldHint=False,
351+
),
327352
),
328353
Tool(
329354
name=GitTools.COMMIT,
330355
description="Records changes to the repository",
331356
inputSchema=GitCommit.model_json_schema(),
357+
annotations=ToolAnnotations(
358+
readOnlyHint=False,
359+
destructiveHint=False,
360+
idempotentHint=False,
361+
openWorldHint=False,
362+
),
332363
),
333364
Tool(
334365
name=GitTools.ADD,
335366
description="Adds file contents to the staging area",
336367
inputSchema=GitAdd.model_json_schema(),
368+
annotations=ToolAnnotations(
369+
readOnlyHint=False,
370+
destructiveHint=False,
371+
idempotentHint=True,
372+
openWorldHint=False,
373+
),
337374
),
338375
Tool(
339376
name=GitTools.RESET,
340377
description="Unstages all staged changes",
341378
inputSchema=GitReset.model_json_schema(),
379+
annotations=ToolAnnotations(
380+
readOnlyHint=False,
381+
destructiveHint=True,
382+
idempotentHint=True,
383+
openWorldHint=False,
384+
),
342385
),
343386
Tool(
344387
name=GitTools.LOG,
345388
description="Shows the commit logs",
346389
inputSchema=GitLog.model_json_schema(),
390+
annotations=ToolAnnotations(
391+
readOnlyHint=True,
392+
destructiveHint=False,
393+
idempotentHint=True,
394+
openWorldHint=False,
395+
),
347396
),
348397
Tool(
349398
name=GitTools.CREATE_BRANCH,
350399
description="Creates a new branch from an optional base branch",
351400
inputSchema=GitCreateBranch.model_json_schema(),
401+
annotations=ToolAnnotations(
402+
readOnlyHint=False,
403+
destructiveHint=False,
404+
idempotentHint=False,
405+
openWorldHint=False,
406+
),
352407
),
353408
Tool(
354409
name=GitTools.CHECKOUT,
355410
description="Switches branches",
356411
inputSchema=GitCheckout.model_json_schema(),
412+
annotations=ToolAnnotations(
413+
readOnlyHint=False,
414+
destructiveHint=False,
415+
idempotentHint=False,
416+
openWorldHint=False,
417+
),
357418
),
358419
Tool(
359420
name=GitTools.SHOW,
360421
description="Shows the contents of a commit",
361422
inputSchema=GitShow.model_json_schema(),
423+
annotations=ToolAnnotations(
424+
readOnlyHint=True,
425+
destructiveHint=False,
426+
idempotentHint=True,
427+
openWorldHint=False,
428+
),
362429
),
363-
364430
Tool(
365431
name=GitTools.BRANCH,
366432
description="List Git branches",
367433
inputSchema=GitBranch.model_json_schema(),
368-
434+
annotations=ToolAnnotations(
435+
readOnlyHint=True,
436+
destructiveHint=False,
437+
idempotentHint=True,
438+
openWorldHint=False,
439+
),
369440
)
370441
]
371442

0 commit comments

Comments
 (0)