Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,38 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description

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.

## Using Pull Request Resources

The GitHub MCP Server supports fetching files in a pull request as resources using the following URI pattern:

- Pull request content (PR head commit):
- `repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}`

Other resource templates also available for repository content:

- Repository content:
- `repo://{owner}/{repo}/contents{/path*}`
- Branch content:
- `repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}`
- Commit content:
- `repo://{owner}/{repo}/sha/{sha}/contents{/path*}`
- Tag content:
- `repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}`

**Example**:

```json
{
"resources": [
{
"id": "prReadme",
"type": "repo",
"path": "repo://octocat/hello-world/refs/pull/42/head/contents/README.md"
}
]
}
```

## License

This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.
9 changes: 9 additions & 0 deletions pkg/github/repository_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,12 @@ func Test_GetRepositoryResourceTagContent(t *testing.T) {
tmpl, _ := GetRepositoryResourceTagContent(nil, stubGetRawClientFn(mockRawClient), translations.NullTranslationHelper)
require.Equal(t, "repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}", tmpl.URITemplate.Raw())
}

func Test_GetRepositoryResourcePrContent(t *testing.T) {
mockRawClient := raw.NewClient(github.NewClient(nil), &url.URL{})
tmpl, _ := GetRepositoryResourcePrContent(nil, stubGetRawClientFn(mockRawClient), translations.NullTranslationHelper)
require.Equal(t,
"repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}",
tmpl.URITemplate.Raw(),
)
}