Skip to content

Add MCP_DISABLE_EMBEDDED_RESOURCES feature flag for client compatibility#1956

Open
Copilot wants to merge 6 commits intomainfrom
copilot/add-flag-for-embedded-resources
Open

Add MCP_DISABLE_EMBEDDED_RESOURCES feature flag for client compatibility#1956
Copilot wants to merge 6 commits intomainfrom
copilot/add-flag-for-embedded-resources

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Summary

Adds MCP_DISABLE_EMBEDDED_RESOURCES feature flag to return file contents as standard MCP content types (TextContent/ImageContent) instead of EmbeddedResource, improving compatibility with clients like Antigravity.

Why

Some MCP clients have limited embedded resource support, causing get_file_contents to fail or display incorrectly.

What changed

  • Added FeatureFlagDisableEmbeddedResources constant to pkg/github/feature_flags.go
  • Updated NewToolResultResource() in pkg/utils/result.go to accept flag parameter:
    • Text files → TextContent with MIME type in metadata
    • Binary files → ImageContent with raw binary data
    • Default → EmbeddedResource (backward compatible)
  • Updated get_file_contents to check flag once and pass to utility function (simplified from duplicate checks)
  • Added Feature Flags section to docs/server-configuration.md with simplified configuration guidance
  • Added troubleshooting note to Antigravity installation guide

MCP impact

  • Tool schema or behavior changed

get_file_contents behavior changes when feature flag is enabled. Schema unchanged. Default behavior (flag disabled) preserves existing EmbeddedResource format.

Prompts tested (tool changes only)

  • "Get the contents of README.md in github/github-mcp-server" (text file)
  • "Show me the logo.png file from the repo" (binary file)
  • Verified both with flag enabled and disabled

Security / limits

  • No security or limits impact

Feature flag only changes content serialization format. No auth, data exposure, or rate limit implications.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Updated (README / docs / examples)

Added Feature Flags section to server configuration guide and troubleshooting note to Antigravity installation guide. Documentation simplified to remove remote server references and focus on local server configuration.

Original prompt

Using the feature flag checker in the passed in deps to tool calls, instead of returning an embedded resource always in the get_file_contents tool, let's add a flag MCP_DISABLE_EMBEDDED_RESOURCES, and when that flag is on, we do our best to return the text or base64 encoded binary content with mime type etc. the same as we would, but as general MCP content and not as embedded resource?

We should then update the docs for any clients mentioned in issues in this repository as failing to get file content (just missing), and same with spaces tool, but that's only in remote server repository, so you can't fix that (but it'll use the same feature flag).

It should be simple if conditions for the flag, at the leaf nodes where we set the return content. Make it simple, clear etc.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 4, 2026 12:32
- Added FeatureFlagDisableEmbeddedResources constant to feature_flags.go
- Implemented NewToolResultResourceWithFlag in utils/result.go
  - When flag is enabled, returns TextContent for text files
  - Returns ImageContent with base64 data for binary files
  - Maintains backward compatibility when flag is disabled
- Updated get_file_contents tool to check feature flag and use new function
- Added comprehensive tests for both utils function and integration with get_file_contents

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
- Added Feature Flags section to server-configuration.md
- Added troubleshooting note to Antigravity installation guide
- Fixed linter issue in result_test.go
- Generated updated documentation

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
The MCP SDK handles base64 encoding during JSON marshaling, so the Data
field should contain raw binary data, not pre-encoded base64 strings.
This prevents double-encoding where base64 strings were being encoded again.

- Updated NewToolResultResourceWithFlag to pass raw binary data
- Updated test to verify raw binary data instead of base64 string
- Removed unused encoding/base64 imports

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
- Updated test to verify raw binary data matches expected value
- Fixed comment to accurately describe what is being verified
- Ensures test properly validates SDK's base64 encoding behavior

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
Copilot AI changed the title [WIP] Add flag to disable embedded resources in get_file_contents tool Add MCP_DISABLE_EMBEDDED_RESOURCES feature flag for client compatibility Feb 4, 2026
Copilot AI requested a review from SamMorrowDrums February 4, 2026 12:41
@SamMorrowDrums SamMorrowDrums marked this pull request as ready for review February 4, 2026 13:01
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner February 4, 2026 13:01
Copilot AI review requested due to automatic review settings February 4, 2026 13:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the MCP_DISABLE_EMBEDDED_RESOURCES feature flag to improve compatibility with MCP clients that have limited embedded resource support. When enabled, the get_file_contents tool returns file contents as standard MCP content types (TextContent for text files, ImageContent for binary files) instead of EmbeddedResource.

Changes:

  • Added runtime feature flag MCP_DISABLE_EMBEDDED_RESOURCES to control content serialization format
  • Created NewToolResultResourceWithFlag() utility function with conditional logic based on flag state
  • Updated get_file_contents tool to check flag and use new utility function at all return sites
  • Added comprehensive test coverage for flag-enabled and flag-disabled scenarios
  • Documented feature flag usage and added troubleshooting guidance for Antigravity client

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/github/feature_flags.go Defines the new MCP_DISABLE_EMBEDDED_RESOURCES feature flag constant with documentation
pkg/utils/result.go Implements NewToolResultResourceWithFlag() to return TextContent/ImageContent when flag is enabled, with fallback to EmbeddedResource
pkg/utils/result_test.go Comprehensive unit tests covering all branches: flag disabled, text content with flag, binary content with flag, and empty content fallback
pkg/github/repositories.go Updates get_file_contents to check feature flag at 4 return sites (text/binary with/without SHA)
pkg/github/repositories_test.go Integration tests verifying flag behavior with mocked HTTP client for text and binary files
docs/server-configuration.md Adds Feature Flags section documenting flag purpose, usage, and configuration for local/remote servers
docs/installation-guides/install-antigravity.md Adds troubleshooting guidance for file content display issues with note about upcoming remote server support

},
}
case len(contents.Blob) > 0:
// Binary content - use ImageContent with base64 data
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment mentions "base64 data" which could be misleading. ImageContent stores raw binary data in the Data field, not base64-encoded data. The SDK handles the base64 encoding only during JSON marshaling (as noted in the comment below), so this comment should say "Binary content - use ImageContent with raw binary data" to be more accurate.

Suggested change
// Binary content - use ImageContent with base64 data
// Binary content - use ImageContent with raw binary data

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 916c71b - updated comment to say "Binary content - use ImageContent with raw binary data".

var content mcp.Content
switch {
case contents.Text != "":
// Text content - use TextContent with mime type in annotations
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment incorrectly states "mime type in annotations" but the MIME type is actually stored in Meta, not Annotations. The comment should be corrected to say "mime type in metadata" or "mime type in Meta" for accuracy.

Suggested change
// Text content - use TextContent with mime type in annotations
// Text content - use TextContent with mime type in metadata (Meta)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 916c71b - updated comment to say "Text content - use TextContent with MIME type in metadata".

Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I left a bunch of cleanup suggestions amounting to:

  • no trailers in documentation
  • ignore remote server, just document the ENV and arg methods for STDIO server feature flag configuration
  • no pointless function rename


If you experience issues with the `get_file_contents` tool not displaying file contents correctly, this may be due to limited embedded resource support in some versions of Antigravity.

**Solution:** The remote GitHub MCP Server will soon support the `MCP_DISABLE_EMBEDDED_RESOURCES` feature flag to improve compatibility. This flag makes file contents return as standard MCP content types that work better across different clients.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the spoiler soon support is not good. Neither is for updates on this feature you should just document. We can ignore the remote server entirely for now, and update that once it's shipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 916c71b - removed "soon support" and "for updates" references, simplified to just document the known limitation.

Comment on lines 369 to 390
**Coming soon:** Remote server support for this flag will be available in the next release.

</td>
<td>

Feature flags are checked at runtime via the feature flag checker. Configuration method depends on your deployment:

**For custom integrations:**
```go
featureChecker := func(ctx context.Context, flagName string) (bool, error) {
if flagName == "MCP_DISABLE_EMBEDDED_RESOURCES" {
return true, nil // Enable the flag
}
return false, nil
}
```

</td>
</tr>
</table>

> **Note:** This feature flag does not affect other tools, only `get_file_contents`. The default behavior (embedded resources) is maintained when the flag is not enabled, ensuring backward compatibility.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the selection is redundant. We don't need to add trailers or describe what tools it does or doesn't do or mention the remote server yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 916c71b - simplified to just explain what the flag does and that it's configured via feature flag checker, removed remote server references and extra notes.

// Include SHA in the result metadata
if fileSHA != "" {
return utils.NewToolResultResource(fmt.Sprintf("successfully downloaded text file (SHA: %s)", fileSHA)+successNote, result), nil, nil
return utils.NewToolResultResourceWithFlag(fmt.Sprintf("successfully downloaded text file (SHA: %s)", fileSHA)+successNote, result, disableEmbedded), nil, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we need to rename this function at all? I don't think so, the flag is not material to the naming of the function, it's just a new argument. @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 916c71b - reverted to using NewToolResultResource with the flag as a new parameter instead of creating a separate function.

MIMEType: contentType,
}
// Check if embedded resources should be disabled
disableEmbedded := deps.IsFeatureEnabled(ctx, FeatureFlagDisableEmbeddedResources)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we checking this twice in same function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 916c71b - moved flag check before the if/else block so it's only checked once and reused for both text and binary content paths.

- Reverted function rename: NewToolResultResource now takes flag parameter directly
- Fixed duplicate flag checks: check once and reuse variable
- Fixed comments: "base64 data" → "raw binary data", "annotations" → "metadata"
- Simplified Antigravity docs: removed "soon support" and update references
- Simplified server-configuration.md: removed remote server mentions and redundant notes

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 4, 2026

@copilot I left a bunch of cleanup suggestions amounting to:

  • no trailers in documentation...

All addressed in 916c71b:

  • Removed trailers and "soon support" from documentation
  • Removed remote server references, documented feature flag configuration only
  • Reverted function rename - NewToolResultResource now takes flag as parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants