MCPcopy
hub / github.com/github/github-mcp-server / DeleteFile

Function DeleteFile

pkg/github/repositories.go:998–1180  ·  view source on GitHub ↗

DeleteFile creates a tool to delete a file in a GitHub repository. This tool uses a more roundabout way of deleting a file than just using the client.Repositories.DeleteFile. This is because REST file deletion endpoint (and client.Repositories.DeleteFile) don't add commit signing to the deletion com

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

996// The approach implemented here gets automatic commit signing when used with either the github-actions user or as an app,
997// both of which suit an LLM well.
998func DeleteFile(t translations.TranslationHelperFunc) inventory.ServerTool {
999 return NewTool(
1000 ToolsetMetadataRepos,
1001 mcp.Tool{
1002 Name: "delete_file",
1003 Description: t("TOOL_DELETE_FILE_DESCRIPTION", "Delete a file from a GitHub repository"),
1004 Annotations: &mcp.ToolAnnotations{
1005 Title: t("TOOL_DELETE_FILE_USER_TITLE", "Delete file"),
1006 ReadOnlyHint: false,
1007 DestructiveHint: github.Ptr(true),
1008 },
1009 InputSchema: &jsonschema.Schema{
1010 Type: "object",
1011 Properties: map[string]*jsonschema.Schema{
1012 "owner": {
1013 Type: "string",
1014 Description: "Repository owner (username or organization)",
1015 },
1016 "repo": {
1017 Type: "string",
1018 Description: "Repository name",
1019 },
1020 "path": {
1021 Type: "string",
1022 Description: "Path to the file to delete",
1023 },
1024 "message": {
1025 Type: "string",
1026 Description: "Commit message",
1027 },
1028 "branch": {
1029 Type: "string",
1030 Description: "Branch to delete the file from",
1031 },
1032 },
1033 Required: []string{"owner", "repo", "path", "message", "branch"},
1034 },
1035 },
1036 []scopes.Scope{scopes.Repo},
1037 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
1038 owner, err := RequiredParam[string](args, "owner")
1039 if err != nil {
1040 return utils.NewToolResultError(err.Error()), nil, nil
1041 }
1042 repo, err := RequiredParam[string](args, "repo")
1043 if err != nil {
1044 return utils.NewToolResultError(err.Error()), nil, nil
1045 }
1046 path, err := RequiredParam[string](args, "path")
1047 if err != nil {
1048 return utils.NewToolResultError(err.Error()), nil, nil
1049 }
1050 message, err := RequiredParam[string](args, "message")
1051 if err != nil {
1052 return utils.NewToolResultError(err.Error()), nil, nil
1053 }
1054 branch, err := RequiredParam[string](args, "branch")
1055 if err != nil {

Callers 2

AllToolsFunction · 0.85
Test_DeleteFileFunction · 0.85

Calls 6

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
NewToolFunction · 0.85
CloseMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.45

Tested by 1

Test_DeleteFileFunction · 0.68