From c021c4df6c3efa9df15785721d7805d3fa0d649f Mon Sep 17 00:00:00 2001 From: LuluBeatson Date: Fri, 11 Jul 2025 14:15:45 +0100 Subject: [PATCH 1/3] update path description to use "/" for root --- pkg/github/repositories.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/github/repositories.go b/pkg/github/repositories.go index 8a7a8af4a..b0375779e 100644 --- a/pkg/github/repositories.go +++ b/pkg/github/repositories.go @@ -464,7 +464,7 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t ), mcp.WithString("path", mcp.Required(), - mcp.Description("Path to file/directory (directories must end with a slash '/')"), + mcp.Description("Path to file/directory. Directories, including root, must end with '/'"), ), mcp.WithString("ref", mcp.Description("Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head`"), From e99f9b81670553719afee53841f1d0cd2db1d394 Mon Sep 17 00:00:00 2001 From: LuluBeatson Date: Fri, 11 Jul 2025 14:16:32 +0100 Subject: [PATCH 2/3] update docs and toolsnaps --- README.md | 2 +- pkg/github/__toolsnaps__/get_file_contents.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8cff2e138..5f2b8fd9f 100644 --- a/README.md +++ b/README.md @@ -899,7 +899,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - **get_file_contents** - Get file or directory contents - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path to file/directory (directories must end with a slash '/') (string, required) + - `path`: Path to file/directory. Directories, including root, must end with '/' (string, required) - `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional) - `repo`: Repository name (string, required) - `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional) diff --git a/pkg/github/__toolsnaps__/get_file_contents.snap b/pkg/github/__toolsnaps__/get_file_contents.snap index e550e8db8..295f6c3b2 100644 --- a/pkg/github/__toolsnaps__/get_file_contents.snap +++ b/pkg/github/__toolsnaps__/get_file_contents.snap @@ -11,7 +11,7 @@ "type": "string" }, "path": { - "description": "Path to file/directory (directories must end with a slash '/')", + "description": "Path to file/directory. Directories, including root, must end with '/'", "type": "string" }, "ref": { From 3bf01124924d59a85297a6afb8d6ffd27e13ddac Mon Sep 17 00:00:00 2001 From: LuluBeatson Date: Fri, 11 Jul 2025 17:13:35 +0100 Subject: [PATCH 3/3] use mcp.DefaultString, revert description, update unit test --- README.md | 2 +- pkg/github/__toolsnaps__/get_file_contents.snap | 6 +++--- pkg/github/repositories.go | 4 ++-- pkg/github/repositories_test.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f2b8fd9f..c5274ff83 100644 --- a/README.md +++ b/README.md @@ -899,7 +899,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - **get_file_contents** - Get file or directory contents - `owner`: Repository owner (username or organization) (string, required) - - `path`: Path to file/directory. Directories, including root, must end with '/' (string, required) + - `path`: Path to file/directory (directories must end with a slash '/') (string, optional) - `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional) - `repo`: Repository name (string, required) - `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional) diff --git a/pkg/github/__toolsnaps__/get_file_contents.snap b/pkg/github/__toolsnaps__/get_file_contents.snap index 295f6c3b2..53f5a29e5 100644 --- a/pkg/github/__toolsnaps__/get_file_contents.snap +++ b/pkg/github/__toolsnaps__/get_file_contents.snap @@ -11,7 +11,8 @@ "type": "string" }, "path": { - "description": "Path to file/directory. Directories, including root, must end with '/'", + "default": "/", + "description": "Path to file/directory (directories must end with a slash '/')", "type": "string" }, "ref": { @@ -29,8 +30,7 @@ }, "required": [ "owner", - "repo", - "path" + "repo" ], "type": "object" }, diff --git a/pkg/github/repositories.go b/pkg/github/repositories.go index b0375779e..0804a6b86 100644 --- a/pkg/github/repositories.go +++ b/pkg/github/repositories.go @@ -463,8 +463,8 @@ func GetFileContents(getClient GetClientFn, getRawClient raw.GetRawClientFn, t t mcp.Description("Repository name"), ), mcp.WithString("path", - mcp.Required(), - mcp.Description("Path to file/directory. Directories, including root, must end with '/'"), + mcp.Description("Path to file/directory (directories must end with a slash '/')"), + mcp.DefaultString("/"), ), mcp.WithString("ref", mcp.Description("Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head`"), diff --git a/pkg/github/repositories_test.go b/pkg/github/repositories_test.go index b621cec43..2be63d839 100644 --- a/pkg/github/repositories_test.go +++ b/pkg/github/repositories_test.go @@ -33,7 +33,7 @@ func Test_GetFileContents(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "path") assert.Contains(t, tool.InputSchema.Properties, "ref") assert.Contains(t, tool.InputSchema.Properties, "sha") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "path"}) + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"}) // Mock response for raw content mockRawContent := []byte("# Test Repository\n\nThis is a test repository.")