Skip to content

Commit 3553c37

Browse files
docs: add resource URI templates for PR resources
Co-authored-by: IrynaKulakova <[email protected]>
1 parent cdd45e3 commit 3553c37

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,29 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
10011001

10021002
The exported Go API of this module should currently be considered unstable, and subject to breaking changes. In the future, we may offer stability; please file an issue if there is a use case where this would be valuable.
10031003

1004+
## Resource URI Templates
1005+
1006+
The GitHub MCP Server supports accessing repository file contents via resource URI templates. These templates use the `repo://` scheme to reference repository contents for different Git references:
1007+
1008+
```text
1009+
repo://{owner}/{repo}/contents{/path*}
1010+
repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}
1011+
repo://{owner}/{repo}/sha/{sha}/contents{/path*}
1012+
repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}
1013+
repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}
1014+
```
1015+
1016+
- **owner**: Repository owner (e.g., `octocat`).
1017+
- **repo**: Repository name (e.g., `Hello-World`).
1018+
- **branch**, **tag**, **sha**, **prNumber**: Git reference (branch name, tag name, commit SHA, or pull request number).
1019+
- **path**: File path relative to the repository root (one or more segments). Must specify a file, not a directory.
1020+
1021+
Example: To fetch `README.md` from the head commit of pull request #42 in the `octocat/Hello-World` repository:
1022+
1023+
```text
1024+
repo://octocat/Hello-World/refs/pull/42/head/contents/README.md
1025+
```
1026+
10041027
## License
10051028

10061029
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.

pkg/github/repository_resource_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,9 @@ func Test_GetRepositoryResourceTagContent(t *testing.T) {
278278
tmpl, _ := GetRepositoryResourceTagContent(nil, stubGetRawClientFn(mockRawClient), translations.NullTranslationHelper)
279279
require.Equal(t, "repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}", tmpl.URITemplate.Raw())
280280
}
281+
282+
func Test_GetRepositoryResourcePrContent(t *testing.T) {
283+
mockRawClient := raw.NewClient(github.NewClient(nil), &url.URL{})
284+
tmpl, _ := GetRepositoryResourcePrContent(nil, stubGetRawClientFn(mockRawClient), translations.NullTranslationHelper)
285+
require.Equal(t, "repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}", tmpl.URITemplate.Raw())
286+
}

0 commit comments

Comments
 (0)