Skip to content

Commit 831b908

Browse files
Merge branch 'main' into raw-client-error-annotation
2 parents dd7f537 + a48e306 commit 831b908

18 files changed

+537
-141
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,12 @@ The following sets of tools are available:
726726
- **issue_read** - Get issue details
727727
- `issue_number`: The number of the issue (number, required)
728728
- `method`: The read operation to perform on a single issue.
729-
Options are:
730-
1. get - Get details of a specific issue.
731-
2. get_comments - Get issue comments.
732-
3. get_sub_issues - Get sub-issues of the issue.
733-
4. get_labels - Get labels assigned to the issue.
734-
(string, required)
729+
Options are:
730+
1. get - Get details of a specific issue.
731+
2. get_comments - Get issue comments.
732+
3. get_sub_issues - Get sub-issues of the issue.
733+
4. get_labels - Get labels assigned to the issue.
734+
(string, required)
735735
- `owner`: The owner of the repository (string, required)
736736
- `page`: Page number for pagination (min 1) (number, optional)
737737
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
@@ -744,10 +744,10 @@ Options are:
744744
- `issue_number`: Issue number to update (number, optional)
745745
- `labels`: Labels to apply to this issue (string[], optional)
746746
- `method`: Write operation to perform on a single issue.
747-
Options are:
748-
- 'create' - creates a new issue.
749-
- 'update' - updates an existing issue.
750-
(string, required)
747+
Options are:
748+
- 'create' - creates a new issue.
749+
- 'update' - updates an existing issue.
750+
(string, required)
751751
- `milestone`: Milestone number (number, optional)
752752
- `owner`: Repository owner (string, required)
753753
- `repo`: Repository name (string, required)
@@ -784,11 +784,11 @@ Options are:
784784
- `before_id`: The ID of the sub-issue to be prioritized before (either after_id OR before_id should be specified) (number, optional)
785785
- `issue_number`: The number of the parent issue (number, required)
786786
- `method`: The action to perform on a single sub-issue
787-
Options are:
788-
- 'add' - add a sub-issue to a parent issue in a GitHub repository.
789-
- 'remove' - remove a sub-issue from a parent issue in a GitHub repository.
790-
- 'reprioritize' - change the order of sub-issues within a parent issue in a GitHub repository. Use either 'after_id' or 'before_id' to specify the new position.
791-
(string, required)
787+
Options are:
788+
- 'add' - add a sub-issue to a parent issue in a GitHub repository.
789+
- 'remove' - remove a sub-issue from a parent issue in a GitHub repository.
790+
- 'reprioritize' - change the order of sub-issues within a parent issue in a GitHub repository. Use either 'after_id' or 'before_id' to specify the new position.
791+
(string, required)
792792
- `owner`: Repository owner (string, required)
793793
- `replace_parent`: When true, replaces the sub-issue's current parent issue. Use with 'add' method only. (boolean, optional)
794794
- `repo`: Repository name (string, required)
@@ -986,15 +986,15 @@ Options are:
986986

987987
- **pull_request_read** - Get details for a single pull request
988988
- `method`: Action to specify what pull request data needs to be retrieved from GitHub.
989-
Possible options:
990-
1. get - Get details of a specific pull request.
991-
2. get_diff - Get the diff of a pull request.
992-
3. get_status - Get status of a head commit in a pull request. This reflects status of builds and checks.
993-
4. get_files - Get the list of files changed in a pull request. Use with pagination parameters to control the number of results returned.
994-
5. get_review_comments - Get the review comments on a pull request. They are comments made on a portion of the unified diff during a pull request review. Use with pagination parameters to control the number of results returned.
995-
6. get_reviews - Get the reviews on a pull request. When asked for review comments, use get_review_comments method.
996-
7. get_comments - Get comments on a pull request. Use this if user doesn't specifically want review comments. Use with pagination parameters to control the number of results returned.
997-
(string, required)
989+
Possible options:
990+
1. get - Get details of a specific pull request.
991+
2. get_diff - Get the diff of a pull request.
992+
3. get_status - Get status of a head commit in a pull request. This reflects status of builds and checks.
993+
4. get_files - Get the list of files changed in a pull request. Use with pagination parameters to control the number of results returned.
994+
5. get_review_comments - Get the review comments on a pull request. They are comments made on a portion of the unified diff during a pull request review. Use with pagination parameters to control the number of results returned.
995+
6. get_reviews - Get the reviews on a pull request. When asked for review comments, use get_review_comments method.
996+
7. get_comments - Get comments on a pull request. Use this if user doesn't specifically want review comments. Use with pagination parameters to control the number of results returned.
997+
(string, required)
998998
- `owner`: Repository owner (string, required)
999999
- `page`: Page number for pagination (min 1) (number, optional)
10001000
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
@@ -1092,7 +1092,7 @@ Possible options:
10921092

10931093
- **get_file_contents** - Get file or directory contents
10941094
- `owner`: Repository owner (username or organization) (string, required)
1095-
- `path`: Path to file/directory (directories must end with a slash '/') (string, optional)
1095+
- `path`: Path to file/directory (string, optional)
10961096
- `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional)
10971097
- `repo`: Repository name (string, required)
10981098
- `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional)

cmd/github-mcp-server/generate_docs.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ func generateToolDoc(tool mcp.Tool) string {
269269

270270
description = prop.Description
271271

272+
// Indent any continuation lines in the description to maintain markdown formatting
273+
description = indentMultilineDescription(description, " ")
274+
272275
paramLine := fmt.Sprintf(" - `%s`: %s (%s, %s)", propName, description, typeStr, requiredStr)
273276
lines = append(lines, paramLine)
274277
}
@@ -288,6 +291,19 @@ func contains(slice []string, item string) bool {
288291
return false
289292
}
290293

294+
// indentMultilineDescription adds the specified indent to all lines after the first line.
295+
// This ensures that multi-line descriptions maintain proper markdown list formatting.
296+
func indentMultilineDescription(description, indent string) string {
297+
lines := strings.Split(description, "\n")
298+
if len(lines) <= 1 {
299+
return description
300+
}
301+
for i := 1; i < len(lines); i++ {
302+
lines[i] = indent + lines[i]
303+
}
304+
return strings.Join(lines, "\n")
305+
}
306+
291307
func replaceSection(content, startMarker, endMarker, newContent string) string {
292308
startPattern := fmt.Sprintf(`<!-- %s -->`, regexp.QuoteMeta(startMarker))
293309
endPattern := fmt.Sprintf(`<!-- %s -->`, regexp.QuoteMeta(endMarker))

docs/remote-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Below is a table of available toolsets for the remote GitHub MCP Server. Each to
1919
<!-- START AUTOMATED TOOLSETS -->
2020
| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
2121
|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
22-
| Default | ["Default" toolset](../README.md#default-toolset) | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
22+
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
2323
| Actions | GitHub Actions workflows and CI/CD operations | https://api.githubcopilot.com/mcp/x/actions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/actions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%2Freadonly%22%7D) |
2424
| Code Security | Code security related tools, such as GitHub Code Scanning | https://api.githubcopilot.com/mcp/x/code_security | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/code_security/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%2Freadonly%22%7D) |
2525
| Dependabot | Dependabot tools | https://api.githubcopilot.com/mcp/x/dependabot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/dependabot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%2Freadonly%22%7D) |

internal/ghmcp/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ func NewMCPServer(cfg MCPServerConfig) (*mcp.Server, error) {
100100

101101
enabledToolsets := cfg.EnabledToolsets
102102

103-
// If dynamic toolsets are enabled, remove "all" from the enabled toolsets
103+
// If dynamic toolsets are enabled, remove "all" and "default" from the enabled toolsets
104104
if cfg.DynamicToolsets {
105105
enabledToolsets = github.RemoveToolset(enabledToolsets, github.ToolsetMetadataAll.ID)
106+
enabledToolsets = github.RemoveToolset(enabledToolsets, github.ToolsetMetadataDefault.ID)
106107
}
107108

108109
// Clean up the passed toolsets
@@ -176,8 +177,8 @@ func NewMCPServer(cfg MCPServerConfig) (*mcp.Server, error) {
176177

177178
// Register specific tools if configured
178179
if len(cfg.EnabledTools) > 0 {
179-
// Clean and validate tool names
180180
enabledTools := github.CleanTools(cfg.EnabledTools)
181+
enabledTools, _ = tsg.ResolveToolAliases(enabledTools)
181182

182183
// Register the specified tools (additive to any toolsets already enabled)
183184
err = tsg.RegisterSpecificTools(ghServer, enabledTools, cfg.ReadOnly)

pkg/github/__toolsnaps__/get_file_contents.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"path": {
1919
"type": "string",
20-
"description": "Path to file/directory (directories must end with a slash '/')",
20+
"description": "Path to file/directory",
2121
"default": "/"
2222
},
2323
"ref": {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// deprecated_tool_aliases.go
2+
package github
3+
4+
// DeprecatedToolAliases maps old tool names to their new canonical names.
5+
// When tools are renamed, add an entry here to maintain backward compatibility.
6+
// Users referencing the old name will receive the new tool with a deprecation warning.
7+
//
8+
// Example:
9+
//
10+
// "get_issue": "issue_read",
11+
// "create_pr": "pull_request_create",
12+
var DeprecatedToolAliases = map[string]string{
13+
// Add entries as tools are renamed
14+
}

pkg/github/issues.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,11 +1381,14 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
13811381
return utils.NewToolResultError(err.Error()), nil, nil
13821382
}
13831383

1384-
// If the state has a value, cast into an array of strings
1384+
// Normalize and filter by state
1385+
state = strings.ToUpper(state)
13851386
var states []githubv4.IssueState
1386-
if state != "" {
1387-
states = append(states, githubv4.IssueState(state))
1388-
} else {
1387+
1388+
switch state {
1389+
case "OPEN", "CLOSED":
1390+
states = []githubv4.IssueState{githubv4.IssueState(state)}
1391+
default:
13891392
states = []githubv4.IssueState{githubv4.IssueStateOpen, githubv4.IssueStateClosed}
13901393
}
13911394

@@ -1405,13 +1408,21 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
14051408
return utils.NewToolResultError(err.Error()), nil, nil
14061409
}
14071410

1408-
// These variables are required for the GraphQL query to be set by default
1409-
// If orderBy is empty, default to CREATED_AT
1410-
if orderBy == "" {
1411+
// Normalize and validate orderBy
1412+
orderBy = strings.ToUpper(orderBy)
1413+
switch orderBy {
1414+
case "CREATED_AT", "UPDATED_AT", "COMMENTS":
1415+
// Valid, keep as is
1416+
default:
14111417
orderBy = "CREATED_AT"
14121418
}
1413-
// If direction is empty, default to DESC
1414-
if direction == "" {
1419+
1420+
// Normalize and validate direction
1421+
direction = strings.ToUpper(direction)
1422+
switch direction {
1423+
case "ASC", "DESC":
1424+
// Valid, keep as is
1425+
default:
14151426
direction = "DESC"
14161427
}
14171428

pkg/github/issues_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,16 @@ func Test_ListIssues(t *testing.T) {
11831183
expectError: false,
11841184
expectedCount: 2,
11851185
},
1186+
{
1187+
name: "filter by open state - lc",
1188+
reqParams: map[string]interface{}{
1189+
"owner": "owner",
1190+
"repo": "repo",
1191+
"state": "open",
1192+
},
1193+
expectError: false,
1194+
expectedCount: 2,
1195+
},
11861196
{
11871197
name: "filter by closed state",
11881198
reqParams: map[string]interface{}{
@@ -1229,6 +1239,9 @@ func Test_ListIssues(t *testing.T) {
12291239
case "filter by open state":
12301240
matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsOpenOnly, mockResponseOpenOnly)
12311241
httpClient = githubv4mock.NewMockedHTTPClient(matcher)
1242+
case "filter by open state - lc":
1243+
matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsOpenOnly, mockResponseOpenOnly)
1244+
httpClient = githubv4mock.NewMockedHTTPClient(matcher)
12321245
case "filter by closed state":
12331246
matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsClosedOnly, mockResponseClosedOnly)
12341247
httpClient = githubv4mock.NewMockedHTTPClient(matcher)

0 commit comments

Comments
 (0)