Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add minimal response to CRUD tools,repositories andsearch toolsets#988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mattdholloway merged 22 commits intomainfromreduce-output-fields
Sep 1, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
22 commits
Select commitHold shift + click to select a range
ba785d2
add comprehensive minimal response where appropriate
mattdhollowayAug 27, 2025
bf3e789
remove unneeded comments
mattdhollowayAug 27, 2025
278b94e
remove incorrect diff param
mattdhollowayAug 27, 2025
0ebdf30
update docs
mattdhollowayAug 27, 2025
26ebb0d
rm comment
mattdhollowayAug 28, 2025
4a32e08
Update pkg/github/repositories.go
mattdhollowayAug 28, 2025
ca91a80
update toolsnaps and docs
mattdhollowayAug 28, 2025
9ea0ac9
change minimal_output to use new OptionalBoolParamWithDefault
mattdhollowayAug 28, 2025
4142f93
Update pkg/github/repositories.go
mattdhollowayAug 28, 2025
17c8564
refactor minimal conversion funcs to minimal_types.go
mattdhollowayAug 28, 2025
c82651f
consolidate response structs and remove unneeded message field
mattdhollowayAug 29, 2025
60213e6
consolidate response further
mattdhollowayAug 29, 2025
c36e4ce
remove CloneURL field
mattdhollowayAug 29, 2025
8e49c3f
Update pkg/github/repositories.go
mattdhollowayAug 29, 2025
7e4616e
Update pkg/github/server.go
mattdhollowayAug 29, 2025
093f86f
fix undefined
mattdhollowayAug 29, 2025
4fa0729
change incorrect comment
mattdhollowayAug 29, 2025
43cc7b4
Merge branch 'main' into reduce-output-fields
mattdhollowayAug 29, 2025
cfeed3d
remove old err var declaration
mattdhollowaySep 1, 2025
586a0d6
Update pkg/github/repositories.go
mattdhollowaySep 1, 2025
debef3e
fix syntax issue
mattdhollowaySep 1, 2025
e72c143
update toolsnaps
mattdhollowaySep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -830,6 +830,7 @@ The following sets of tools are available (all are on by default):
- `repo`: Repository name (string, required)

- **get_commit** - Get commit details
- `include_diff`: Whether to include file diffs and stats in the response. Default is true. (boolean, optional)
- `owner`: Repository owner (string, required)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
Expand DownExpand Up@@ -898,6 +899,7 @@ The following sets of tools are available (all are on by default):
- `sort`: Sort field ('indexed' only) (string, optional)

- **search_repositories** - Search repositories
- `minimal_output`: Return minimal repository information (default: true). When false, returns full GitHub API repository objects. (boolean, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `query`: Repository search query. Examples: 'machine learning in:name stars:>1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering. (string, required)
Expand Down
5 changes: 5 additions & 0 deletionspkg/github/__toolsnaps__/get_commit.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,11 @@
"description": "Get details for a commit from a GitHub repository",
"inputSchema": {
"properties": {
"include_diff": {
"default": true,
"description": "Whether to include file diffs and stats in the response. Default is true.",
"type": "boolean"
},
"owner": {
"description": "Repository owner",
"type": "string"
Expand Down
5 changes: 5 additions & 0 deletionspkg/github/__toolsnaps__/search_repositories.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,11 @@
"description": "Find GitHub repositories by name, description, readme, topics, or other metadata. Perfect for discovering projects, finding examples, or locating specific repositories across GitHub.",
"inputSchema": {
"properties": {
"minimal_output": {
"default": true,
"description": "Return minimal repository information (default: true). When false, returns full GitHub API repository objects.",
"type": "boolean"
},
"page": {
"description": "Page number for pagination (min 1)",
"minimum": 1,
Expand Down
12 changes: 10 additions & 2 deletionspkg/github/gists.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,11 @@ func CreateGist(getClient GetClientFn, t translations.TranslationHelperFunc) (to
return mcp.NewToolResultError(fmt.Sprintf("failed to create gist: %s", string(body))), nil
}

r, err := json.Marshal(createdGist)
minimalResponse := MinimalResponse{
URL: createdGist.GetHTMLURL(),
}

r, err := json.Marshal(minimalResponse)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
Expand DownExpand Up@@ -249,7 +253,11 @@ func UpdateGist(getClient GetClientFn, t translations.TranslationHelperFunc) (to
return mcp.NewToolResultError(fmt.Sprintf("failed to update gist: %s", string(body))), nil
}

r, err := json.Marshal(updatedGist)
minimalResponse := MinimalResponse{
URL: updatedGist.GetHTMLURL(),
}

r, err := json.Marshal(minimalResponse)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
Expand Down
35 changes: 7 additions & 28 deletionspkg/github/gists_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -321,23 +321,12 @@ func Test_CreateGist(t *testing.T) {
// Parse the result and get the text content
textContent := getTextResult(t, result)

// Unmarshal and verify the result
var gist*github.Gist
// Unmarshal and verify theminimalresult
var gistMinimalResponse
err = json.Unmarshal([]byte(textContent.Text), &gist)
require.NoError(t, err)

assert.Equal(t, *tc.expectedGist.ID, *gist.ID)
assert.Equal(t, *tc.expectedGist.Description, *gist.Description)
assert.Equal(t, *tc.expectedGist.HTMLURL, *gist.HTMLURL)
assert.Equal(t, *tc.expectedGist.Public, *gist.Public)

// Verify file content
for filename, expectedFile := range tc.expectedGist.Files {
actualFile, exists := gist.Files[filename]
assert.True(t, exists)
assert.Equal(t, *expectedFile.Filename, *actualFile.Filename)
assert.Equal(t, *expectedFile.Content, *actualFile.Content)
}
assert.Equal(t, tc.expectedGist.GetHTMLURL(), gist.URL)
})
}
}
Expand DownExpand Up@@ -486,22 +475,12 @@ func Test_UpdateGist(t *testing.T) {
// Parse the result and get the text content
textContent := getTextResult(t, result)

// Unmarshal and verify the result
vargist *github.Gist
err = json.Unmarshal([]byte(textContent.Text), &gist)
// Unmarshal and verify theminimalresult
varupdateResp MinimalResponse
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
require.NoError(t, err)

assert.Equal(t, *tc.expectedGist.ID, *gist.ID)
assert.Equal(t, *tc.expectedGist.Description, *gist.Description)
assert.Equal(t, *tc.expectedGist.HTMLURL, *gist.HTMLURL)

// Verify file content
for filename, expectedFile := range tc.expectedGist.Files {
actualFile, exists := gist.Files[filename]
assert.True(t, exists)
assert.Equal(t, *expectedFile.Filename, *actualFile.Filename)
assert.Equal(t, *expectedFile.Content, *actualFile.Content)
}
assert.Equal(t, tc.expectedGist.GetHTMLURL(), updateResp.URL)
})
}
}
14 changes: 12 additions & 2 deletionspkg/github/issues.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -872,7 +872,12 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
return mcp.NewToolResultError(fmt.Sprintf("failed to create issue: %s", string(body))), nil
}

r, err := json.Marshal(issue)
// Return minimal response with just essential information
minimalResponse := MinimalResponse{
URL: issue.GetHTMLURL(),
}

r, err := json.Marshal(minimalResponse)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
Expand DownExpand Up@@ -1242,7 +1247,12 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
return mcp.NewToolResultError(fmt.Sprintf("failed to update issue: %s", string(body))), nil
}

r, err := json.Marshal(updatedIssue)
// Return minimal response with just essential information
minimalResponse := MinimalResponse{
URL: updatedIssue.GetHTMLURL(),
}

r, err := json.Marshal(minimalResponse)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
Expand Down
74 changes: 7 additions & 67 deletionspkg/github/issues_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -712,39 +712,12 @@ func Test_CreateIssue(t *testing.T) {
require.NoError(t, err)
textContent := getTextResult(t, result)

// Unmarshal and verify the result
var returnedIssuegithub.Issue
// Unmarshal and verify theminimalresult
var returnedIssueMinimalResponse
err = json.Unmarshal([]byte(textContent.Text), &returnedIssue)
require.NoError(t, err)

assert.Equal(t, *tc.expectedIssue.Number, *returnedIssue.Number)
assert.Equal(t, *tc.expectedIssue.Title, *returnedIssue.Title)
assert.Equal(t, *tc.expectedIssue.State, *returnedIssue.State)
assert.Equal(t, *tc.expectedIssue.HTMLURL, *returnedIssue.HTMLURL)

if tc.expectedIssue.Body != nil {
assert.Equal(t, *tc.expectedIssue.Body, *returnedIssue.Body)
}

if tc.expectedIssue.Type != nil {
assert.Equal(t, *tc.expectedIssue.Type.Name, *returnedIssue.Type.Name)
}

// Check assignees if expected
if len(tc.expectedIssue.Assignees) > 0 {
assert.Equal(t, len(tc.expectedIssue.Assignees), len(returnedIssue.Assignees))
for i, assignee := range returnedIssue.Assignees {
assert.Equal(t, *tc.expectedIssue.Assignees[i].Login, *assignee.Login)
}
}

// Check labels if expected
if len(tc.expectedIssue.Labels) > 0 {
assert.Equal(t, len(tc.expectedIssue.Labels), len(returnedIssue.Labels))
for i, label := range returnedIssue.Labels {
assert.Equal(t, *tc.expectedIssue.Labels[i].Name, *label.Name)
}
}
assert.Equal(t, tc.expectedIssue.GetHTMLURL(), returnedIssue.URL)
})
}
}
Expand DownExpand Up@@ -1233,45 +1206,12 @@ func Test_UpdateIssue(t *testing.T) {
// Parse the result and get the text content if no error
textContent := getTextResult(t, result)

// Unmarshal and verify the result
varreturnedIssue github.Issue
err = json.Unmarshal([]byte(textContent.Text), &returnedIssue)
// Unmarshal and verify theminimalresult
varupdateResp MinimalResponse
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
require.NoError(t, err)

assert.Equal(t, *tc.expectedIssue.Number, *returnedIssue.Number)
assert.Equal(t, *tc.expectedIssue.Title, *returnedIssue.Title)
assert.Equal(t, *tc.expectedIssue.State, *returnedIssue.State)
assert.Equal(t, *tc.expectedIssue.HTMLURL, *returnedIssue.HTMLURL)

if tc.expectedIssue.Body != nil {
assert.Equal(t, *tc.expectedIssue.Body, *returnedIssue.Body)
}

if tc.expectedIssue.Type != nil {
assert.Equal(t, *tc.expectedIssue.Type.Name, *returnedIssue.Type.Name)
}

// Check assignees if expected
if len(tc.expectedIssue.Assignees) > 0 {
assert.Len(t, returnedIssue.Assignees, len(tc.expectedIssue.Assignees))
for i, assignee := range returnedIssue.Assignees {
assert.Equal(t, *tc.expectedIssue.Assignees[i].Login, *assignee.Login)
}
}

// Check labels if expected
if len(tc.expectedIssue.Labels) > 0 {
assert.Len(t, returnedIssue.Labels, len(tc.expectedIssue.Labels))
for i, label := range returnedIssue.Labels {
assert.Equal(t, *tc.expectedIssue.Labels[i].Name, *label.Name)
}
}

// Check milestone if expected
if tc.expectedIssue.Milestone != nil {
assert.NotNil(t, returnedIssue.Milestone)
assert.Equal(t, *tc.expectedIssue.Milestone.Number, *returnedIssue.Milestone.Number)
}
assert.Equal(t, tc.expectedIssue.GetHTMLURL(), updateResp.URL)
})
}
}
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp