github/github-mcp-server · error

owner is required

Error message

owner is required

What it means

get_file_blame runs against the GitHub GraphQL API, so its handler calls deps.GetGQLClient(ctx) instead of GetClient. In per-request deployments (RequestDeps) this resolves token info from the request context and the GraphQL endpoint from apiHosts.GraphqlURL(ctx); failure wraps 'no token info in context' or 'failed to get GraphQL URL'. The REST client can be healthy while this fails if host config lacks a resolvable GraphQL endpoint. The tool is additionally gated by the file-blame feature flag.

Source

Thrown at pkg/github/repository_resource.go:126

}

// RepositoryResourceContentsHandler returns a handler function for repository content requests.
// It retrieves ToolDependencies from the context at call time via MustDepsFromContext.
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{}

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Read the wrapped cause: 'no token info in context' means auth, 'failed to get GraphQL URL' means host config
  2. Provide a valid token to the server process/request
  3. For GitHub Enterprise, ensure the configured base URL yields a valid GraphQL endpoint (e.g. https://github.example.com/api/graphql)
  4. Confirm the file-blame feature flag is enabled so the tool is registered and tested on your deployment

Example fix

// before: REST tools work, get_file_blame fails
//   "failed to get GitHub GraphQL client: failed to get GraphQL URL: ..."
export GITHUB_BASE_URL="https://github.example.com"

// after: host config resolves a GraphQL endpoint
export GITHUB_BASE_URL="https://github.example.com/api/v3"   # REST
export GITHUB_API_HOSTS="github.example.com"                  # derives /api/graphql
Defensive patterns

Strategy: try-catch

Validate before calling

// Before enabling blame workflows, confirm token + GraphQL endpoint resolvability.
func preflightGraphQLClient(baseURL string) error {
	if os.Getenv("GITHUB_PERSONAL_ACCESS_TOKEN") == "" {
		return fmt.Errorf("missing token: get_file_blame needs a GraphQL client")
	}
	u, err := url.Parse(baseURL)
	if err != nil || u.Scheme == "" || u.Host == "" {
		return fmt.Errorf("GITHUB_BASE_URL must be absolute: %q", baseURL)
	}
	return nil
}

Type guard

func isGraphQLClientError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "failed to get GitHub GraphQL client")
}

Try / catch

result, _, err := callGetFileBlame(ctx, args)
if err != nil {
	if isGraphQLClientError(err) {
		// deterministic config fault (token or GraphQL URL): fix env, restart; no retry
		return fmt.Errorf("server GraphQL auth/host misconfiguration: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling get_file_blame when the context carries no token info, or when an enterprise base URL cannot yield a GraphQL endpoint (e.g. GITHUB_BASE_URL set to a host without the /api/graphql path, or GITHUB_API_HOSTS missing the graphql URL).

Common situations: Enterprise GitHub Server deployments where REST works but the GraphQL URL derivation fails; missing token on remote servers; disabling or misconfiguring the file-blame feature flag so the tool's dependencies are never exercised.

Related errors


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