You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before updating an existing file, always call 'get_file_contents' to retrieve the SHA of the file blob. Use this SHA as the "sha" parameter in create_or_update_file tool call to avoid conflicts.
Copy file name to clipboardExpand all lines: pkg/github/repositories.go
+36-8Lines changed: 36 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -310,8 +310,15 @@ func ListBranches(getClient GetClientFn, t translations.TranslationHelperFunc) (
310
310
// CreateOrUpdateFile creates a tool to create or update a file in a GitHub repository.
311
311
funcCreateOrUpdateFile(getClientGetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
312
312
tool:= mcp.Tool{
313
-
Name: "create_or_update_file",
314
-
Description: t("TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION", "Create or update a single file in a GitHub repository. If updating, you must provide the SHA of the file you want to update. Use this tool to create or update a file in a GitHub repository remotely; do not use it for local file operations."),
313
+
Name: "create_or_update_file",
314
+
Description: t("TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION", `Create or update a single file in a GitHub repository.
315
+
If updating, you should provide the SHA of the file you want to update. Use this tool to create or update a file in a GitHub repository remotely; do not use it for local file operations.
316
+
317
+
In order to obtain the SHA of original file version before updating, use the following git command:
318
+
git ls-tree HEAD <path to file>
319
+
320
+
If the SHA is not provided, the tool will attempt to acquire it by fetching the current file contents from the repository, which may lead to rewriting latest committed changes if the file has changed since last retrieval.
321
+
`),
315
322
Annotations: &mcp.ToolAnnotations{
316
323
Title: t("TOOL_CREATE_OR_UPDATE_FILE_USER_TITLE", "Create or update file"),
317
324
ReadOnlyHint: false,
@@ -345,7 +352,7 @@ func CreateOrUpdateFile(getClient GetClientFn, t translations.TranslationHelperF
345
352
},
346
353
"sha": {
347
354
Type: "string",
348
-
Description: "Required if updating an existing file. The blob SHA of the file being replaced.",
355
+
Description: "The blob SHA of the file being replaced.",
0 commit comments