mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 15:53:23 +02:00
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
This commit is contained in:
committed by
GitHub
parent
ae40ec239d
commit
c7e0c7e730
@@ -10,6 +10,7 @@ from mcp.types import (
|
|||||||
Tool,
|
Tool,
|
||||||
ListRootsResult,
|
ListRootsResult,
|
||||||
RootsCapability,
|
RootsCapability,
|
||||||
|
ToolAnnotations,
|
||||||
)
|
)
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import git
|
import git
|
||||||
@@ -309,63 +310,133 @@ async def serve(repository: Path | None) -> None:
|
|||||||
name=GitTools.STATUS,
|
name=GitTools.STATUS,
|
||||||
description="Shows the working tree status",
|
description="Shows the working tree status",
|
||||||
inputSchema=GitStatus.model_json_schema(),
|
inputSchema=GitStatus.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.DIFF_UNSTAGED,
|
name=GitTools.DIFF_UNSTAGED,
|
||||||
description="Shows changes in the working directory that are not yet staged",
|
description="Shows changes in the working directory that are not yet staged",
|
||||||
inputSchema=GitDiffUnstaged.model_json_schema(),
|
inputSchema=GitDiffUnstaged.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.DIFF_STAGED,
|
name=GitTools.DIFF_STAGED,
|
||||||
description="Shows changes that are staged for commit",
|
description="Shows changes that are staged for commit",
|
||||||
inputSchema=GitDiffStaged.model_json_schema(),
|
inputSchema=GitDiffStaged.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.DIFF,
|
name=GitTools.DIFF,
|
||||||
description="Shows differences between branches or commits",
|
description="Shows differences between branches or commits",
|
||||||
inputSchema=GitDiff.model_json_schema(),
|
inputSchema=GitDiff.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.COMMIT,
|
name=GitTools.COMMIT,
|
||||||
description="Records changes to the repository",
|
description="Records changes to the repository",
|
||||||
inputSchema=GitCommit.model_json_schema(),
|
inputSchema=GitCommit.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=False,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=False,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.ADD,
|
name=GitTools.ADD,
|
||||||
description="Adds file contents to the staging area",
|
description="Adds file contents to the staging area",
|
||||||
inputSchema=GitAdd.model_json_schema(),
|
inputSchema=GitAdd.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=False,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.RESET,
|
name=GitTools.RESET,
|
||||||
description="Unstages all staged changes",
|
description="Unstages all staged changes",
|
||||||
inputSchema=GitReset.model_json_schema(),
|
inputSchema=GitReset.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=False,
|
||||||
|
destructiveHint=True,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.LOG,
|
name=GitTools.LOG,
|
||||||
description="Shows the commit logs",
|
description="Shows the commit logs",
|
||||||
inputSchema=GitLog.model_json_schema(),
|
inputSchema=GitLog.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.CREATE_BRANCH,
|
name=GitTools.CREATE_BRANCH,
|
||||||
description="Creates a new branch from an optional base branch",
|
description="Creates a new branch from an optional base branch",
|
||||||
inputSchema=GitCreateBranch.model_json_schema(),
|
inputSchema=GitCreateBranch.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=False,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=False,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.CHECKOUT,
|
name=GitTools.CHECKOUT,
|
||||||
description="Switches branches",
|
description="Switches branches",
|
||||||
inputSchema=GitCheckout.model_json_schema(),
|
inputSchema=GitCheckout.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=False,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=False,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.SHOW,
|
name=GitTools.SHOW,
|
||||||
description="Shows the contents of a commit",
|
description="Shows the contents of a commit",
|
||||||
inputSchema=GitShow.model_json_schema(),
|
inputSchema=GitShow.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Tool(
|
Tool(
|
||||||
name=GitTools.BRANCH,
|
name=GitTools.BRANCH,
|
||||||
description="List Git branches",
|
description="List Git branches",
|
||||||
inputSchema=GitBranch.model_json_schema(),
|
inputSchema=GitBranch.model_json_schema(),
|
||||||
|
annotations=ToolAnnotations(
|
||||||
|
readOnlyHint=True,
|
||||||
|
destructiveHint=False,
|
||||||
|
idempotentHint=True,
|
||||||
|
openWorldHint=False,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user