Skip to content

Commit 916c71b

Browse files
Address PR feedback - simplify implementation and documentation
- 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>
1 parent e5014cd commit 916c71b

File tree

5 files changed

+44
-73
lines changed

5 files changed

+44
-73
lines changed

docs/installation-guides/install-antigravity.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ If you prefer running the server locally with Docker:
104104

105105
### File contents not displaying properly
106106

107-
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.
108-
109-
**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.
110-
111-
For updates on this feature, see the [Server Configuration Guide](../server-configuration.md#feature-flags).
107+
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. This is a known limitation that affects how file contents are displayed.
112108

113109
### "Error: serverUrl or command must be specified"
114110

docs/server-configuration.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -351,43 +351,13 @@ The GitHub MCP Server supports runtime feature flags that can modify tool behavi
351351

352352
### MCP_DISABLE_EMBEDDED_RESOURCES
353353

354-
**Purpose:** Improves compatibility with MCP clients that don't fully support embedded resources.
355-
356354
When enabled, the `get_file_contents` tool returns file content as standard MCP content types instead of embedded resources:
357355
- **Text files**: Returned as `TextContent` with MIME type in metadata
358-
- **Binary files**: Returned as `ImageContent` with base64-encoded data
359-
360-
**When to use:** Enable this flag if your MCP client has issues displaying or accessing file contents retrieved via `get_file_contents`.
356+
- **Binary files**: Returned as `ImageContent` with raw binary data
361357

362358
**Configuration:**
363359

364-
<table>
365-
<tr><th>Remote Server</th><th>Local Server</th></tr>
366-
<tr valign="top">
367-
<td>
368-
369-
**Coming soon:** Remote server support for this flag will be available in the next release.
370-
371-
</td>
372-
<td>
373-
374-
Feature flags are checked at runtime via the feature flag checker. Configuration method depends on your deployment:
375-
376-
**For custom integrations:**
377-
```go
378-
featureChecker := func(ctx context.Context, flagName string) (bool, error) {
379-
if flagName == "MCP_DISABLE_EMBEDDED_RESOURCES" {
380-
return true, nil // Enable the flag
381-
}
382-
return false, nil
383-
}
384-
```
385-
386-
</td>
387-
</tr>
388-
</table>
389-
390-
> **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.
360+
Feature flags are checked at runtime via the feature flag checker passed to `BaseDeps`. You can configure this through environment variables or command-line arguments depending on your deployment setup.
391361

392362
---
393363

pkg/github/repositories.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,33 +768,32 @@ func GetFileContents(t translations.TranslationHelperFunc) inventory.ServerTool
768768
strings.HasSuffix(contentType, "+json") ||
769769
strings.HasSuffix(contentType, "+xml")
770770

771+
// Check if embedded resources should be disabled
772+
disableEmbedded := deps.IsFeatureEnabled(ctx, FeatureFlagDisableEmbeddedResources)
773+
771774
if isTextContent {
772775
result := &mcp.ResourceContents{
773776
URI: resourceURI,
774777
Text: string(body),
775778
MIMEType: contentType,
776779
}
777-
// Check if embedded resources should be disabled
778-
disableEmbedded := deps.IsFeatureEnabled(ctx, FeatureFlagDisableEmbeddedResources)
779780
// Include SHA in the result metadata
780781
if fileSHA != "" {
781-
return utils.NewToolResultResourceWithFlag(fmt.Sprintf("successfully downloaded text file (SHA: %s)", fileSHA)+successNote, result, disableEmbedded), nil, nil
782+
return utils.NewToolResultResource(fmt.Sprintf("successfully downloaded text file (SHA: %s)", fileSHA)+successNote, result, disableEmbedded), nil, nil
782783
}
783-
return utils.NewToolResultResourceWithFlag("successfully downloaded text file"+successNote, result, disableEmbedded), nil, nil
784+
return utils.NewToolResultResource("successfully downloaded text file"+successNote, result, disableEmbedded), nil, nil
784785
}
785786

786787
result := &mcp.ResourceContents{
787788
URI: resourceURI,
788789
Blob: body,
789790
MIMEType: contentType,
790791
}
791-
// Check if embedded resources should be disabled
792-
disableEmbedded := deps.IsFeatureEnabled(ctx, FeatureFlagDisableEmbeddedResources)
793792
// Include SHA in the result metadata
794793
if fileSHA != "" {
795-
return utils.NewToolResultResourceWithFlag(fmt.Sprintf("successfully downloaded binary file (SHA: %s)", fileSHA)+successNote, result, disableEmbedded), nil, nil
794+
return utils.NewToolResultResource(fmt.Sprintf("successfully downloaded binary file (SHA: %s)", fileSHA)+successNote, result, disableEmbedded), nil, nil
796795
}
797-
return utils.NewToolResultResourceWithFlag("successfully downloaded binary file"+successNote, result, disableEmbedded), nil, nil
796+
return utils.NewToolResultResource("successfully downloaded binary file"+successNote, result, disableEmbedded), nil, nil
798797
}
799798

800799
// Raw API call failed

pkg/utils/result.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,31 @@ func NewToolResultErrorFromErr(message string, err error) *mcp.CallToolResult {
3636
}
3737
}
3838

39-
func NewToolResultResource(message string, contents *mcp.ResourceContents) *mcp.CallToolResult {
40-
return &mcp.CallToolResult{
41-
Content: []mcp.Content{
42-
&mcp.TextContent{
43-
Text: message,
44-
},
45-
&mcp.EmbeddedResource{
46-
Resource: contents,
47-
},
48-
},
49-
IsError: false,
50-
}
51-
}
52-
53-
// NewToolResultResourceWithFlag returns a CallToolResult with either an embedded resource
39+
// NewToolResultResource returns a CallToolResult with either an embedded resource
5440
// or regular content based on the disableEmbeddedResources flag.
5541
// When disableEmbeddedResources is true, text content is returned as TextContent and
5642
// binary content is returned as ImageContent, providing better client compatibility.
57-
func NewToolResultResourceWithFlag(message string, contents *mcp.ResourceContents, disableEmbeddedResources bool) *mcp.CallToolResult {
43+
func NewToolResultResource(message string, contents *mcp.ResourceContents, disableEmbeddedResources bool) *mcp.CallToolResult {
5844
if !disableEmbeddedResources {
5945
// Default behavior - return as embedded resource
60-
return NewToolResultResource(message, contents)
46+
return &mcp.CallToolResult{
47+
Content: []mcp.Content{
48+
&mcp.TextContent{
49+
Text: message,
50+
},
51+
&mcp.EmbeddedResource{
52+
Resource: contents,
53+
},
54+
},
55+
IsError: false,
56+
}
6157
}
6258

6359
// When flag is enabled, return as regular content
6460
var content mcp.Content
6561
switch {
6662
case contents.Text != "":
67-
// Text content - use TextContent with mime type in annotations
63+
// Text content - use TextContent with MIME type in metadata
6864
content = &mcp.TextContent{
6965
Text: contents.Text,
7066
Annotations: &mcp.Annotations{
@@ -76,7 +72,7 @@ func NewToolResultResourceWithFlag(message string, contents *mcp.ResourceContent
7672
},
7773
}
7874
case len(contents.Blob) > 0:
79-
// Binary content - use ImageContent with base64 data
75+
// Binary content - use ImageContent with raw binary data
8076
// Note: MCP SDK will handle base64 encoding during JSON marshaling
8177
content = &mcp.ImageContent{
8278
Data: contents.Blob,
@@ -90,7 +86,17 @@ func NewToolResultResourceWithFlag(message string, contents *mcp.ResourceContent
9086
}
9187
default:
9288
// Fallback to embedded resource if neither text nor blob
93-
return NewToolResultResource(message, contents)
89+
return &mcp.CallToolResult{
90+
Content: []mcp.Content{
91+
&mcp.TextContent{
92+
Text: message,
93+
},
94+
&mcp.EmbeddedResource{
95+
Resource: contents,
96+
},
97+
},
98+
IsError: false,
99+
}
94100
}
95101

96102
return &mcp.CallToolResult{

pkg/utils/result_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"github.com/stretchr/testify/require"
99
)
1010

11-
func TestNewToolResultResourceWithFlag_DisabledFlag(t *testing.T) {
11+
func TestNewToolResultResource_DisabledFlag(t *testing.T) {
1212
// When flag is disabled, should return embedded resource (default behavior)
1313
contents := &mcp.ResourceContents{
1414
URI: "test://file.txt",
1515
Text: "Hello, World!",
1616
MIMEType: "text/plain",
1717
}
1818

19-
result := NewToolResultResourceWithFlag("Test message", contents, false)
19+
result := NewToolResultResource("Test message", contents, false)
2020

2121
require.NotNil(t, result)
2222
require.Len(t, result.Content, 2)
@@ -35,15 +35,15 @@ func TestNewToolResultResourceWithFlag_DisabledFlag(t *testing.T) {
3535
assert.Equal(t, contents.MIMEType, embeddedResource.Resource.MIMEType)
3636
}
3737

38-
func TestNewToolResultResourceWithFlag_EnabledFlag_TextContent(t *testing.T) {
38+
func TestNewToolResultResource_EnabledFlag_TextContent(t *testing.T) {
3939
// When flag is enabled with text content, should return TextContent
4040
contents := &mcp.ResourceContents{
4141
URI: "test://file.txt",
4242
Text: "Hello, World!",
4343
MIMEType: "text/plain",
4444
}
4545

46-
result := NewToolResultResourceWithFlag("Test message", contents, true)
46+
result := NewToolResultResource("Test message", contents, true)
4747

4848
require.NotNil(t, result)
4949
require.Len(t, result.Content, 2)
@@ -65,7 +65,7 @@ func TestNewToolResultResourceWithFlag_EnabledFlag_TextContent(t *testing.T) {
6565
assert.Contains(t, textContent.Annotations.Audience, mcp.Role("user"))
6666
}
6767

68-
func TestNewToolResultResourceWithFlag_EnabledFlag_BinaryContent(t *testing.T) {
68+
func TestNewToolResultResource_EnabledFlag_BinaryContent(t *testing.T) {
6969
// When flag is enabled with binary content, should return ImageContent
7070
binaryData := []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A} // PNG header
7171
contents := &mcp.ResourceContents{
@@ -74,7 +74,7 @@ func TestNewToolResultResourceWithFlag_EnabledFlag_BinaryContent(t *testing.T) {
7474
MIMEType: "image/png",
7575
}
7676

77-
result := NewToolResultResourceWithFlag("Binary message", contents, true)
77+
result := NewToolResultResource("Binary message", contents, true)
7878

7979
require.NotNil(t, result)
8080
require.Len(t, result.Content, 2)
@@ -98,14 +98,14 @@ func TestNewToolResultResourceWithFlag_EnabledFlag_BinaryContent(t *testing.T) {
9898
assert.Contains(t, imageContent.Annotations.Audience, mcp.Role("user"))
9999
}
100100

101-
func TestNewToolResultResourceWithFlag_EnabledFlag_EmptyContent(t *testing.T) {
101+
func TestNewToolResultResource_EnabledFlag_EmptyContent(t *testing.T) {
102102
// When flag is enabled but neither text nor blob exists, should fallback to embedded resource
103103
contents := &mcp.ResourceContents{
104104
URI: "test://empty",
105105
MIMEType: "application/octet-stream",
106106
}
107107

108-
result := NewToolResultResourceWithFlag("Empty message", contents, true)
108+
result := NewToolResultResource("Empty message", contents, true)
109109

110110
require.NotNil(t, result)
111111
require.Len(t, result.Content, 2)

0 commit comments

Comments
 (0)