@@ -245,6 +245,51 @@ func Test_GetFileContents(t *testing.T) {
245245expectError :false ,
246246expectedResult :mockDirContent ,
247247},
248+ {
249+ name :"successful text content fetch with leading slash in path" ,
250+ mockedClient :mock .NewMockedHTTPClient (
251+ mock .WithRequestMatchHandler (
252+ mock .GetReposGitRefByOwnerByRepoByRef ,
253+ http .HandlerFunc (func (w http.ResponseWriter ,_ * http.Request ) {
254+ w .WriteHeader (http .StatusOK )
255+ _ ,_ = w .Write ([]byte (`{"ref": "refs/heads/main", "object": {"sha": ""}}` ))
256+ }),
257+ ),
258+ mock .WithRequestMatchHandler (
259+ mock .GetReposContentsByOwnerByRepoByPath ,
260+ http .HandlerFunc (func (w http.ResponseWriter ,_ * http.Request ) {
261+ w .WriteHeader (http .StatusOK )
262+ fileContent := & github.RepositoryContent {
263+ Name :github .Ptr ("README.md" ),
264+ Path :github .Ptr ("README.md" ),
265+ SHA :github .Ptr ("abc123" ),
266+ Type :github .Ptr ("file" ),
267+ }
268+ contentBytes ,_ := json .Marshal (fileContent )
269+ _ ,_ = w .Write (contentBytes )
270+ }),
271+ ),
272+ mock .WithRequestMatchHandler (
273+ raw .GetRawReposContentsByOwnerByRepoByBranchByPath ,
274+ http .HandlerFunc (func (w http.ResponseWriter ,_ * http.Request ) {
275+ w .Header ().Set ("Content-Type" ,"text/markdown" )
276+ _ ,_ = w .Write (mockRawContent )
277+ }),
278+ ),
279+ ),
280+ requestArgs :map [string ]interface {}{
281+ "owner" :"owner" ,
282+ "repo" :"repo" ,
283+ "path" :"/README.md" ,
284+ "ref" :"refs/heads/main" ,
285+ },
286+ expectError :false ,
287+ expectedResult : mcp.ResourceContents {
288+ URI :"repo://owner/repo/refs/heads/main/contents/README.md" ,
289+ Text :"# Test Repository\n \n This is a test repository." ,
290+ MIMEType :"text/markdown" ,
291+ },
292+ },
248293{
249294name :"content fetch fails" ,
250295mockedClient :mock .NewMockedHTTPClient (