github/github-mcp-server · warning

repo is required

Error message

repo is required

What it means

Raised when json.Marshal fails on the get_file_blame result struct (Ranges, Commits, PageInfo, TotalRanges, Truncated - with Ranges already nil-guarded to []BlameRange{}). All fields are JSON-safe slices/structs of strings and ints, so Go's encoder would need a NaN/Inf, chan, func, or cyclic value to fail. This is a defensive invariant that is effectively unreachable with stock types.

Source

Thrown at pkg/github/repository_resource.go:130

func RepositoryResourceContentsHandler(resourceURITemplate *uritemplate.Template) mcp.ResourceHandler {
	return func(ctx context.Context, request *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) {
		deps := MustDepsFromContext(ctx)
		// Match the URI to extract parameters
		uriValues := resourceURITemplate.Match(request.Params.URI)
		if uriValues == nil {
			return nil, fmt.Errorf("failed to match URI: %s", request.Params.URI)
		}

		// Extract required vars
		owner := uriValues.Get("owner").String()
		repo := uriValues.Get("repo").String()

		if owner == "" {
			return nil, errors.New("owner is required")
		}

		if repo == "" {
			return nil, errors.New("repo is required")
		}

		pathValue := uriValues.Get("path")
		pathComponents := pathValue.List()
		var path string

		if len(pathComponents) == 0 {
			path = pathValue.String()
		} else {
			path = strings.Join(pathComponents, "/")
		}

		opts := &github.RepositoryContentGetOptions{}
		rawOpts := &raw.ContentOpts{}

		sha := uriValues.Get("sha").String()
		if sha != "" {
			opts.Ref = sha

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Treat as a bug: capture the tool input (owner/repo/path/ref) and report upstream
  2. Upgrade to a released github-mcp-server build
  3. If maintaining a fork, keep blame payload fields JSON-safe (strings, ints, bools, slices)

Example fix

// before: fork adds an unsupported field
type BlameCommit struct {
	// ...
	Fetch chan struct{} `json:"fetch"` // marshal fails
}

// after
type BlameCommit struct {
	// ...
	Fetched bool `json:"fetched"`
}
Defensive patterns

Strategy: try-catch

Type guard

func isMarshalError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "failed to marshal")
}

Try / catch

result, _, err := callGetFileBlame(ctx, args)
if err != nil && isMarshalError(err) {
	// internal serialization bug: capture inputs and report upstream; not retryable
	log.Printf("blame marshal bug: args=%v err=%v", args, err)
	return err
}

Prevention

When it happens

Trigger: Only possible if a fork adds an unmarshalable field to BlameRange/BlameCommit/pageInfo types, or a race corrupts the result struct between assembly and marshal. Values built from decoded GraphQL responses never trigger it.

Common situations: Forked DTOs with unsupported field types; version skew between github-mcp-server forks; local patches to the blame payload.

Related errors


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/b05cc31c2c677fa6. Report an issue: GitHub.