Skip to content

Commit 7e44a51

Browse files
Merge branch 'main' into copilot/add-copilot-instructions-file
2 parents e1c8f43 + 7359888 commit 7e44a51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1341
-599
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
name: go-sdk-tool-migrator
3+
description: Agent specializing in migrating MCP tools from mark3labs/mcp-go to modelcontextprotocol/go-sdk
4+
---
5+
6+
# Go SDK Tool Migrator Agent
7+
8+
You are a specialized agent designed to assist developers in migrating MCP tools from the mark3labs/mcp-go library to the modelcontextprotocol/go-sdk. Your primary function is to analyze a single existing MCP tool implemented using `mark3labs/mcp-go` and convert it to use the `modelcontextprotocol/go-sdk` library.
9+
10+
## Migration Process
11+
12+
You should focus on ONLY the toolset you are asked to migrate and its corresponding test file. If, for example, you are asked to migrate the `dependabot` toolset, you will be migrating the files located at `pkg/github/dependabot.go` and `pkg/github/dependabot_test.go`. If there are additional tests or helper functions that fail to work with the new SDK, you should inform me of these issues so that I can address them, or instruct you on how to proceed.
13+
14+
When generating the migration guide, consider the following aspects:
15+
16+
* The initial tool file and its corresponding test file will have the `//go:build ignore` build tag, as the tests will fail if the code is not ignored. The `ignore` build tag should be removed before work begins.
17+
* The import for `github.com/mark3labs/mcp-go/mcp` should be changed to `github.com/modelcontextprotocol/go-sdk/mcp`
18+
* The return type for the tool constructor function should be updated from `mcp.Tool, server.ToolHandlerFunc` to `(mcp.Tool, mcp.ToolHandlerFor[map[string]any, any])`.
19+
* The tool handler function signature should be updated to use generics, changing from `func(ctx context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error)` to `func(context.Context, *mcp.CallToolRequest, map[string]any) (*mcp.CallToolResult, any, error)`.
20+
* The `RequiredParam`, `RequiredInt`, `RequiredBigInt`, `OptionalParamOK`, `OptionalParam`, `OptionalIntParam`, `OptionalIntParamWithDefault`, `OptionalBoolParamWithDefault`, `OptionalStringArrayParam`, `OptionalBigIntArrayParam` and `OptionalCursorPaginationParams` functions should be changed to use the tool arguments that are now passed as a map in the tool handler function, rather than extracting them from the `mcp.CallToolRequest`.
21+
* `mcp.NewToolResultText`, `mcp.NewToolResultError`, `mcp.NewToolResultErrorFromErr` and `mcp.NewToolResultResource` no longer available in `modelcontextprotocol/go-sdk`. There are a few helper functions available in `pkg/utils/result.go` that can be used to replace these, in the `utils` package.
22+
23+
### Schema Changes
24+
25+
The biggest change when migrating MCP tools from mark3labs/mcp-go to modelcontextprotocol/go-sdk is the way input and output schemas are defined and handled. In `mark3labs/mcp-go`, input and output schemas were often defined using a DSL provided by the library. In `modelcontextprotocol/go-sdk`, schemas are defined using `jsonschema.Schema` structures using `github.com/google/jsonschema-go`, which are more verbose.
26+
27+
When migrating a tool, you will need to convert the existing schema definitions to JSON Schema format. This involves defining the properties, types, and any validation rules using the JSON Schema specification.
28+
29+
#### Example Schema Guide
30+
31+
If we take an example of a tool that has the following input schema in mark3labs/mcp-go:
32+
33+
```go
34+
...
35+
return mcp.NewTool(
36+
"list_dependabot_alerts",
37+
mcp.WithDescription(t("TOOL_LIST_DEPENDABOT_ALERTS_DESCRIPTION", "List dependabot alerts in a GitHub repository.")),
38+
mcp.WithToolAnnotation(mcp.ToolAnnotation{
39+
Title: t("TOOL_LIST_DEPENDABOT_ALERTS_USER_TITLE", "List dependabot alerts"),
40+
ReadOnlyHint: ToBoolPtr(true),
41+
}),
42+
mcp.WithString("owner",
43+
mcp.Required(),
44+
mcp.Description("The owner of the repository."),
45+
),
46+
mcp.WithString("repo",
47+
mcp.Required(),
48+
mcp.Description("The name of the repository."),
49+
),
50+
mcp.WithString("state",
51+
mcp.Description("Filter dependabot alerts by state. Defaults to open"),
52+
mcp.DefaultString("open"),
53+
mcp.Enum("open", "fixed", "dismissed", "auto_dismissed"),
54+
),
55+
mcp.WithString("severity",
56+
mcp.Description("Filter dependabot alerts by severity"),
57+
mcp.Enum("low", "medium", "high", "critical"),
58+
),
59+
),
60+
...
61+
```
62+
63+
The corresponding input schema in modelcontextprotocol/go-sdk would look like this:
64+
65+
```go
66+
...
67+
return mcp.Tool{
68+
Name: "list_dependabot_alerts",
69+
Description: t("TOOL_LIST_DEPENDABOT_ALERTS_DESCRIPTION", "List dependabot alerts in a GitHub repository."),
70+
Annotations: &mcp.ToolAnnotations{
71+
Title: t("TOOL_LIST_DEPENDABOT_ALERTS_USER_TITLE", "List dependabot alerts"),
72+
ReadOnlyHint: true,
73+
},
74+
InputSchema: &jsonschema.Schema{
75+
Type: "object",
76+
Properties: map[string]*jsonschema.Schema{
77+
"owner": {
78+
Type: "string",
79+
Description: "The owner of the repository.",
80+
},
81+
"repo": {
82+
Type: "string",
83+
Description: "The name of the repository.",
84+
},
85+
"state": {
86+
Type: "string",
87+
Description: "Filter dependabot alerts by state. Defaults to open",
88+
Enum: []any{"open", "fixed", "dismissed", "auto_dismissed"},
89+
Default: "open",
90+
},
91+
"severity": {
92+
Type: "string",
93+
Description: "Filter dependabot alerts by severity",
94+
Enum: []any{"low", "medium", "high", "critical"},
95+
},
96+
},
97+
Required: []string{"owner", "repo"},
98+
},
99+
}
100+
```
101+
102+
### Tests
103+
104+
After migrating the tool code and test file, ensure that all tests pass successfully. If any tests fail, review the error messages and adjust the migrated code as necessary to resolve any issues. If you encounter any challenges or need further assistance during the migration process, please let me know.
105+
106+
At the end of your changes, you will continue to have an issue with the `toolsnaps` tests, these validate that the schema has not changed unexpectedly. You can update the snapshots by setting `UPDATE_TOOLSNAPS=true` before running the tests, e.g.:
107+
108+
```bash
109+
UPDATE_TOOLSNAPS=true go test ./...
110+
```
111+
112+
You should however, only update the toolsnaps after confirming that the schema changes are intentional and correct. Some schema changes are unavoidable, such as argument ordering, however the schemas themselves should remain logically equivalent.

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
# https://github.com/docker/metadata-action
7171
- name: Extract Docker metadata
7272
id: meta
73-
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
73+
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
7474
with:
7575
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7676
tags: |

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
with:
1919
go-version: stable
2020
- name: golangci-lint
21-
uses: golangci/golangci-lint-action@v8
21+
uses: golangci/golangci-lint-action@v9
2222
with:
2323
version: v2.5

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25.3-alpine AS build
1+
FROM golang:1.25.4-alpine AS build
22
ARG VERSION="dev"
33

44
# Set the working directory

README.md

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ The following sets of tools are available:
400400
| `discussions` | GitHub Discussions related tools |
401401
| `experiments` | Experimental features that are not considered stable yet |
402402
| `gists` | GitHub Gist related tools |
403+
| `git` | GitHub Git API related tools for low-level Git operations |
403404
| `issues` | GitHub Issues related tools |
404405
| `labels` | GitHub Labels related tools |
405406
| `notifications` | GitHub Notifications related tools |
@@ -413,7 +414,7 @@ The following sets of tools are available:
413414
| `users` | GitHub User related tools |
414415
<!-- END AUTOMATED TOOLSETS -->
415416

416-
### Additional Toolsets in Remote Github MCP Server
417+
### Additional Toolsets in Remote GitHub MCP Server
417418

418419
| Toolset | Description |
419420
| ----------------------- | ------------------------------------------------------------- |
@@ -630,6 +631,19 @@ The following sets of tools are available:
630631

631632
<details>
632633

634+
<summary>Git</summary>
635+
636+
- **get_repository_tree** - Get repository tree
637+
- `owner`: Repository owner (username or organization) (string, required)
638+
- `path_filter`: Optional path prefix to filter the tree results (e.g., 'src/' to only show files in the src directory) (string, optional)
639+
- `recursive`: Setting this parameter to true returns the objects or subtrees referenced by the tree. Default is false (boolean, optional)
640+
- `repo`: Repository name (string, required)
641+
- `tree_sha`: The SHA1 value or ref (branch or tag) name of the tree. Defaults to the repository's default branch (string, optional)
642+
643+
</details>
644+
645+
<details>
646+
633647
<summary>Issues</summary>
634648

635649
- **add_issue_comment** - Add comment to issue
@@ -830,24 +844,30 @@ Options are:
830844
- `project_number`: The project's number. (number, required)
831845

832846
- **list_project_fields** - List project fields
847+
- `after`: Forward pagination cursor from previous pageInfo.nextCursor. (string, optional)
848+
- `before`: Backward pagination cursor from previous pageInfo.prevCursor (rare). (string, optional)
833849
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
834850
- `owner_type`: Owner type (string, required)
835-
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
851+
- `per_page`: Results per page (max 50) (number, optional)
836852
- `project_number`: The project's number. (number, required)
837853

838854
- **list_project_items** - List project items
839-
- `fields`: Specific list of field IDs to include in the response (e.g. ["102589", "985201", "169875"]). If not provided, only the title field is included. (string[], optional)
855+
- `after`: Forward pagination cursor from previous pageInfo.nextCursor. (string, optional)
856+
- `before`: Backward pagination cursor from previous pageInfo.prevCursor (rare). (string, optional)
857+
- `fields`: Field IDs to include (e.g. ["102589", "985201"]). CRITICAL: Always provide to get field values. Without this, only titles returned. (string[], optional)
840858
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
841859
- `owner_type`: Owner type (string, required)
842-
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
860+
- `per_page`: Results per page (max 50) (number, optional)
843861
- `project_number`: The project's number. (number, required)
844-
- `query`: Search query to filter items (string, optional)
862+
- `query`: Query string for advanced filtering of project items using GitHub's project filtering syntax. (string, optional)
845863

846864
- **list_projects** - List projects
865+
- `after`: Forward pagination cursor from previous pageInfo.nextCursor. (string, optional)
866+
- `before`: Backward pagination cursor from previous pageInfo.prevCursor (rare). (string, optional)
847867
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
848868
- `owner_type`: Owner type (string, required)
849-
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
850-
- `query`: Filter projects by a search query (matches title and description) (string, optional)
869+
- `per_page`: Results per page (max 50) (number, optional)
870+
- `query`: Filter projects by title text and open/closed state; permitted qualifiers: is:open, is:closed; examples: "roadmap is:open", "is:open feature planning". (string, optional)
851871

852872
- **update_project_item** - Update project item
853873
- `item_id`: The unique identifier of the project item. This is not the issue or pull request ID. (number, required)
@@ -1168,7 +1188,7 @@ Possible options:
11681188
</details>
11691189
<!-- END AUTOMATED TOOLS -->
11701190

1171-
### Additional Tools in Remote Github MCP Server
1191+
### Additional Tools in Remote GitHub MCP Server
11721192

11731193
<details>
11741194

@@ -1204,7 +1224,7 @@ Possible options:
12041224

12051225
## Dynamic Tool Discovery
12061226

1207-
**Note**: This feature is currently in beta and may not be available in all environments. Please test it out and let us know if you encounter any issues.
1227+
**Note**: This feature is currently in beta and is not available in the Remote GitHub MCP Server. Please test it out and let us know if you encounter any issues.
12081228

12091229
Instead of starting with all tools enabled, you can turn on dynamic toolset discovery. Dynamic toolsets allow the MCP host to list and enable toolsets in response to a user prompt. This should help to avoid situations where the model gets confused by the sheer number of tools available.
12101230

@@ -1242,6 +1262,25 @@ docker run -i --rm \
12421262
ghcr.io/github/github-mcp-server
12431263
```
12441264

1265+
## Lockdown Mode
1266+
1267+
Lockdown mode limits the content that the server will surface from public repositories. When enabled, requests that fetch issue details will return an error if the issue was created by someone who does not have push access to the repository. Private repositories are unaffected, and collaborators can still access their own issues.
1268+
1269+
```bash
1270+
./github-mcp-server --lockdown-mode
1271+
```
1272+
1273+
When running with Docker, set the corresponding environment variable:
1274+
1275+
```bash
1276+
docker run -i --rm \
1277+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
1278+
-e GITHUB_LOCKDOWN_MODE=1 \
1279+
ghcr.io/github/github-mcp-server
1280+
```
1281+
1282+
At the moment lockdown mode applies to the issue read toolset, but it is designed to extend to additional data surfaces over time.
1283+
12451284
## i18n / Overriding Descriptions
12461285

12471286
The descriptions of the tools can be overridden by creating a

cmd/github-mcp-server/generate_docs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/github/github-mcp-server/pkg/raw"
1414
"github.com/github/github-mcp-server/pkg/toolsets"
1515
"github.com/github/github-mcp-server/pkg/translations"
16-
gogithub "github.com/google/go-github/v77/github"
16+
gogithub "github.com/google/go-github/v79/github"
1717
"github.com/mark3labs/mcp-go/mcp"
1818
"github.com/shurcooL/githubv4"
1919
"github.com/spf13/cobra"
@@ -64,7 +64,7 @@ func generateReadmeDocs(readmePath string) error {
6464
t, _ := translations.TranslationHelper()
6565

6666
// Create toolset group with mock clients
67-
tsg := github.DefaultToolsetGroup(false, mockGetClient, mockGetGQLClient, mockGetRawClient, t, 5000)
67+
tsg := github.DefaultToolsetGroup(false, mockGetClient, mockGetGQLClient, mockGetRawClient, t, 5000, github.FeatureFlags{})
6868

6969
// Generate toolsets documentation
7070
toolsetsDoc := generateToolsetsDoc(tsg)
@@ -302,7 +302,7 @@ func generateRemoteToolsetsDoc() string {
302302
t, _ := translations.TranslationHelper()
303303

304304
// Create toolset group with mock clients
305-
tsg := github.DefaultToolsetGroup(false, mockGetClient, mockGetGQLClient, mockGetRawClient, t, 5000)
305+
tsg := github.DefaultToolsetGroup(false, mockGetClient, mockGetGQLClient, mockGetRawClient, t, 5000, github.FeatureFlags{})
306306

307307
// Generate table header
308308
buf.WriteString("| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |\n")

cmd/github-mcp-server/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var (
6161
EnableCommandLogging: viper.GetBool("enable-command-logging"),
6262
LogFilePath: viper.GetString("log-file"),
6363
ContentWindowSize: viper.GetInt("content-window-size"),
64+
LockdownMode: viper.GetBool("lockdown-mode"),
6465
}
6566
return ghmcp.RunStdioServer(stdioServerConfig)
6667
},
@@ -82,6 +83,7 @@ func init() {
8283
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
8384
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
8485
rootCmd.PersistentFlags().Int("content-window-size", 5000, "Specify the content window size")
86+
rootCmd.PersistentFlags().Bool("lockdown-mode", false, "Enable lockdown mode")
8587

8688
// Bind flag to viper
8789
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
@@ -92,6 +94,7 @@ func init() {
9294
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
9395
_ = viper.BindPFlag("host", rootCmd.PersistentFlags().Lookup("gh-host"))
9496
_ = viper.BindPFlag("content-window-size", rootCmd.PersistentFlags().Lookup("content-window-size"))
97+
_ = viper.BindPFlag("lockdown-mode", rootCmd.PersistentFlags().Lookup("lockdown-mode"))
9598

9699
// Add subcommands
97100
rootCmd.AddCommand(stdioCmd)

cmd/mcpcurl/mcpcurl

6.41 MB
Binary file not shown.

docs/installation-guides/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,5 @@ After installation, you may want to explore:
9494
- **Toolsets**: Enable/disable specific GitHub API capabilities
9595
- **Read-Only Mode**: Restrict to read-only operations
9696
- **Dynamic Tool Discovery**: Enable tools on-demand
97+
- **Lockdown Mode**: Hide public issue details created by users without push access
9798

0 commit comments

Comments
 (0)