From 9e2b1f03a58806278203e14feb03dbc6d961409e Mon Sep 17 00:00:00 2001 From: Ariel Deitcher <1149246+mntlty@users.noreply.github.com> Date: Thu, 3 Apr 2025 15:19:00 -0700 Subject: [PATCH 01/10] speed up docker builds (#92) --- .github/workflows/docker-publish.yml | 13 ++++++++++++- Dockerfile | 13 +++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b4583b018..4c370ebe3 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,7 +23,7 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-xl permissions: contents: read packages: write @@ -67,6 +67,17 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Go Build Cache for Docker + uses: actions/cache@v4 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: Inject go-build-cache + uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4 + with: + cache-source: go-build-cache + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image diff --git a/Dockerfile b/Dockerfile index 6b96ffeca..05fe1ddd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,18 @@ FROM golang:1.23.7 AS build ARG VERSION # Set the working directory WORKDIR /build -# Copy the current directory contents into the working directory -COPY . . + +RUN go env -w GOMODCACHE=/root/.cache/go-build + # Install dependencies -RUN go mod download +COPY go.mod go.sum ./ +RUN --mount=type=cache,target=/root/.cache/go-build go mod download + +COPY . ./ # Build the server -RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ -o github-mcp-server cmd/github-mcp-server/main.go + # Make a stage to run the app FROM gcr.io/distroless/base-debian12 # Set the working directory From e267a3c4a1f42e3b25f52772385c1f5cb35905d2 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 4 Apr 2025 11:35:12 +0200 Subject: [PATCH 02/10] assert request params (#94) --- pkg/github/code_scanning_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/github/code_scanning_test.go b/pkg/github/code_scanning_test.go index 6263a7f0f..9dd301374 100644 --- a/pkg/github/code_scanning_test.go +++ b/pkg/github/code_scanning_test.go @@ -156,9 +156,15 @@ func Test_ListCodeScanningAlerts(t *testing.T) { { name: "successful alerts listing", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposCodeScanningAlertsByOwnerByRepo, - mockAlerts, + expectQueryParams(t, map[string]string{ + "ref": "main", + "state": "open", + "severity": "high", + }).andThen( + mockResponse(t, http.StatusOK, mockAlerts), + ), ), ), requestArgs: map[string]interface{}{ From ca1a8f96d475f06fcc0df73ac6ef675895926bf4 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 4 Apr 2025 13:57:35 +0200 Subject: [PATCH 03/10] assert request params and body (#95) --- pkg/github/pullrequests_test.go | 84 +++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index 30efe4f69..761de5010 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -171,9 +171,17 @@ func Test_ListPullRequests(t *testing.T) { { name: "successful PRs listing", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposPullsByOwnerByRepo, - mockPRs, + expectQueryParams(t, map[string]string{ + "state": "all", + "sort": "created", + "direction": "desc", + "per_page": "30", + "page": "1", + }).andThen( + mockResponse(t, http.StatusOK, mockPRs), + ), ), ), requestArgs: map[string]interface{}{ @@ -281,9 +289,15 @@ func Test_MergePullRequest(t *testing.T) { { name: "successful merge", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PutReposPullsMergeByOwnerByRepoByPullNumber, - mockMergeResult, + expectRequestBody(t, map[string]interface{}{ + "commit_title": "Merge PR #42", + "commit_message": "Merging awesome feature", + "merge_method": "squash", + }).andThen( + mockResponse(t, http.StatusOK, mockMergeResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -662,7 +676,11 @@ func Test_UpdatePullRequestBranch(t *testing.T) { mockedClient: mock.NewMockedHTTPClient( mock.WithRequestMatchHandler( mock.PutReposPullsUpdateBranchByOwnerByRepoByPullNumber, - mockResponse(t, http.StatusAccepted, mockUpdateResult), + expectRequestBody(t, map[string]interface{}{ + "expected_head_sha": "abcd1234", + }).andThen( + mockResponse(t, http.StatusAccepted, mockUpdateResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -679,7 +697,9 @@ func Test_UpdatePullRequestBranch(t *testing.T) { mockedClient: mock.NewMockedHTTPClient( mock.WithRequestMatchHandler( mock.PutReposPullsUpdateBranchByOwnerByRepoByPullNumber, - mockResponse(t, http.StatusAccepted, mockUpdateResult), + expectRequestBody(t, map[string]interface{}{}).andThen( + mockResponse(t, http.StatusAccepted, mockUpdateResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -1030,9 +1050,14 @@ func Test_CreatePullRequestReview(t *testing.T) { { name: "successful review creation with body only", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposPullsReviewsByOwnerByRepoByPullNumber, - mockReview, + expectRequestBody(t, map[string]interface{}{ + "body": "Looks good!", + "event": "APPROVE", + }).andThen( + mockResponse(t, http.StatusOK, mockReview), + ), ), ), requestArgs: map[string]interface{}{ @@ -1048,9 +1073,15 @@ func Test_CreatePullRequestReview(t *testing.T) { { name: "successful review creation with commit_id", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposPullsReviewsByOwnerByRepoByPullNumber, - mockReview, + expectRequestBody(t, map[string]interface{}{ + "body": "Looks good!", + "event": "APPROVE", + "commit_id": "abcdef123456", + }).andThen( + mockResponse(t, http.StatusOK, mockReview), + ), ), ), requestArgs: map[string]interface{}{ @@ -1067,9 +1098,26 @@ func Test_CreatePullRequestReview(t *testing.T) { { name: "successful review creation with comments", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposPullsReviewsByOwnerByRepoByPullNumber, - mockReview, + expectRequestBody(t, map[string]interface{}{ + "body": "Some issues to fix", + "event": "REQUEST_CHANGES", + "comments": []interface{}{ + map[string]interface{}{ + "path": "file1.go", + "position": float64(10), + "body": "This needs to be fixed", + }, + map[string]interface{}{ + "path": "file2.go", + "position": float64(20), + "body": "Consider a different approach here", + }, + }, + }).andThen( + mockResponse(t, http.StatusOK, mockReview), + ), ), ), requestArgs: map[string]interface{}{ @@ -1240,10 +1288,18 @@ func Test_CreatePullRequest(t *testing.T) { mockedClient: mock.NewMockedHTTPClient( mock.WithRequestMatchHandler( mock.PostReposPullsByOwnerByRepo, - mockResponse(t, http.StatusCreated, mockPR), + expectRequestBody(t, map[string]interface{}{ + "title": "Test PR", + "body": "This is a test PR", + "head": "feature-branch", + "base": "main", + "draft": false, + "maintainer_can_modify": true, + }).andThen( + mockResponse(t, http.StatusCreated, mockPR), + ), ), ), - requestArgs: map[string]interface{}{ "owner": "owner", "repo": "repo", From ccaedb6f46ba6f123e314f54356298a059f6a23e Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 4 Apr 2025 14:32:00 +0200 Subject: [PATCH 04/10] assert params and body (#96) --- pkg/github/repositories_test.go | 122 ++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 22 deletions(-) diff --git a/pkg/github/repositories_test.go b/pkg/github/repositories_test.go index 1b416d8c9..4ae450831 100644 --- a/pkg/github/repositories_test.go +++ b/pkg/github/repositories_test.go @@ -70,9 +70,13 @@ func Test_GetFileContents(t *testing.T) { { name: "successful file content fetch", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposContentsByOwnerByRepoByPath, - mockFileContent, + expectQueryParams(t, map[string]string{ + "ref": "main", + }).andThen( + mockResponse(t, http.StatusOK, mockFileContent), + ), ), ), requestArgs: map[string]interface{}{ @@ -87,9 +91,11 @@ func Test_GetFileContents(t *testing.T) { { name: "successful directory content fetch", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposContentsByOwnerByRepoByPath, - mockDirContent, + expectQueryParams(t, map[string]string{}).andThen( + mockResponse(t, http.StatusOK, mockDirContent), + ), ), ), requestArgs: map[string]interface{}{ @@ -352,9 +358,14 @@ func Test_CreateBranch(t *testing.T) { mock.GetReposGitRefByOwnerByRepoByRef, mockSourceRef, ), - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposGitRefsByOwnerByRepo, - mockCreatedRef, + expectRequestBody(t, map[string]interface{}{ + "ref": "refs/heads/new-feature", + "sha": "abc123def456", + }).andThen( + mockResponse(t, http.StatusCreated, mockCreatedRef), + ), ), ), requestArgs: map[string]interface{}{ @@ -538,9 +549,15 @@ func Test_ListCommits(t *testing.T) { { name: "successful commits fetch with branch", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposCommitsByOwnerByRepo, - mockCommits, + expectQueryParams(t, map[string]string{ + "sha": "main", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockCommits), + ), ), ), requestArgs: map[string]interface{}{ @@ -554,9 +571,14 @@ func Test_ListCommits(t *testing.T) { { name: "successful commits fetch with pagination", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetReposCommitsByOwnerByRepo, - mockCommits, + expectQueryParams(t, map[string]string{ + "page": "2", + "per_page": "10", + }).andThen( + mockResponse(t, http.StatusOK, mockCommits), + ), ), ), requestArgs: map[string]interface{}{ @@ -676,9 +698,15 @@ func Test_CreateOrUpdateFile(t *testing.T) { { name: "successful file creation", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PutReposContentsByOwnerByRepoByPath, - mockFileResponse, + expectRequestBody(t, map[string]interface{}{ + "message": "Add example file", + "content": "IyBFeGFtcGxlCgpUaGlzIGlzIGFuIGV4YW1wbGUgZmlsZS4=", // Base64 encoded content + "branch": "main", + }).andThen( + mockResponse(t, http.StatusOK, mockFileResponse), + ), ), ), requestArgs: map[string]interface{}{ @@ -695,9 +723,16 @@ func Test_CreateOrUpdateFile(t *testing.T) { { name: "successful file update with SHA", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PutReposContentsByOwnerByRepoByPath, - mockFileResponse, + expectRequestBody(t, map[string]interface{}{ + "message": "Update example file", + "content": "IyBVcGRhdGVkIEV4YW1wbGUKClRoaXMgZmlsZSBoYXMgYmVlbiB1cGRhdGVkLg==", // Base64 encoded content + "branch": "main", + "sha": "abc123def456", + }).andThen( + mockResponse(t, http.StatusOK, mockFileResponse), + ), ), ), requestArgs: map[string]interface{}{ @@ -819,7 +854,14 @@ func Test_CreateRepository(t *testing.T) { Pattern: "/user/repos", Method: "POST", }, - mockResponse(t, http.StatusCreated, mockRepo), + expectRequestBody(t, map[string]interface{}{ + "name": "test-repo", + "description": "Test repository", + "private": true, + "auto_init": true, + }).andThen( + mockResponse(t, http.StatusCreated, mockRepo), + ), ), ), requestArgs: map[string]interface{}{ @@ -839,7 +881,14 @@ func Test_CreateRepository(t *testing.T) { Pattern: "/user/repos", Method: "POST", }, - mockResponse(t, http.StatusCreated, mockRepo), + expectRequestBody(t, map[string]interface{}{ + "name": "test-repo", + "auto_init": false, + "description": "", + "private": false, + }).andThen( + mockResponse(t, http.StatusCreated, mockRepo), + ), ), ), requestArgs: map[string]interface{}{ @@ -980,19 +1029,48 @@ func Test_PushFiles(t *testing.T) { mockCommit, ), // Create tree - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposGitTreesByOwnerByRepo, - mockTree, + expectRequestBody(t, map[string]interface{}{ + "base_tree": "def456", + "tree": []interface{}{ + map[string]interface{}{ + "path": "README.md", + "mode": "100644", + "type": "blob", + "content": "# Updated README\n\nThis is an updated README file.", + }, + map[string]interface{}{ + "path": "docs/example.md", + "mode": "100644", + "type": "blob", + "content": "# Example\n\nThis is an example file.", + }, + }, + }).andThen( + mockResponse(t, http.StatusCreated, mockTree), + ), ), // Create commit - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PostReposGitCommitsByOwnerByRepo, - mockNewCommit, + expectRequestBody(t, map[string]interface{}{ + "message": "Update multiple files", + "tree": "ghi789", + "parents": []interface{}{"abc123"}, + }).andThen( + mockResponse(t, http.StatusCreated, mockNewCommit), + ), ), // Update reference - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.PatchReposGitRefsByOwnerByRepoByRef, - mockUpdatedRef, + expectRequestBody(t, map[string]interface{}{ + "sha": "jkl012", + "force": false, + }).andThen( + mockResponse(t, http.StatusOK, mockUpdatedRef), + ), ), ), requestArgs: map[string]interface{}{ From 95c7b0add672d57bc780451d6a3f0850fee54d1a Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Apr 2025 14:47:20 +0200 Subject: [PATCH 05/10] Add missing milestone to create_issue (#88) --- pkg/github/issues.go | 15 +++++++++++++++ pkg/github/issues_test.go | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index e27215ce1..0e3376373 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -261,6 +261,9 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t }, ), ), + mcp.WithNumber("milestone", + mcp.Description("Milestone number"), + ), ), func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { owner, err := requiredParam[string](request, "owner") @@ -294,12 +297,24 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t return mcp.NewToolResultError(err.Error()), nil } + // Get optional milestone + milestone, err := optionalIntParam(request, "milestone") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + var milestoneNum *int + if milestone != 0 { + milestoneNum = &milestone + } + // Create the issue request issueRequest := &github.IssueRequest{ Title: github.Ptr(title), Body: github.Ptr(body), Assignees: &assignees, Labels: &labels, + Milestone: milestoneNum, } issue, resp, err := client.Issues.Create(ctx, owner, repo, issueRequest) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index d9fdeb548..f29e2b04d 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -392,6 +392,7 @@ func Test_CreateIssue(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "body") assert.Contains(t, tool.InputSchema.Properties, "assignees") assert.Contains(t, tool.InputSchema.Properties, "labels") + assert.Contains(t, tool.InputSchema.Properties, "milestone") assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "title"}) // Setup mock issue for success case @@ -403,6 +404,7 @@ func Test_CreateIssue(t *testing.T) { HTMLURL: github.Ptr("https://github.com/owner/repo/issues/123"), Assignees: []*github.User{{Login: github.Ptr("user1")}, {Login: github.Ptr("user2")}}, Labels: []*github.Label{{Name: github.Ptr("bug")}, {Name: github.Ptr("help wanted")}}, + Milestone: &github.Milestone{Number: github.Ptr(5)}, } tests := []struct { @@ -423,6 +425,7 @@ func Test_CreateIssue(t *testing.T) { "body": "This is a test issue", "labels": []any{"bug", "help wanted"}, "assignees": []any{"user1", "user2"}, + "milestone": float64(5), }).andThen( mockResponse(t, http.StatusCreated, mockIssue), ), @@ -435,6 +438,7 @@ func Test_CreateIssue(t *testing.T) { "body": "This is a test issue", "assignees": []string{"user1", "user2"}, "labels": []string{"bug", "help wanted"}, + "milestone": float64(5), }, expectError: false, expectedIssue: mockIssue, From bdfb30ce4bcb782c509a5e5e1a97a42deff8f5c8 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 4 Apr 2025 14:51:53 +0200 Subject: [PATCH 06/10] assert query params (#97) --- pkg/github/search_test.go | 68 +++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/pkg/github/search_test.go b/pkg/github/search_test.go index 69fa7ca4e..44513b1f5 100644 --- a/pkg/github/search_test.go +++ b/pkg/github/search_test.go @@ -60,15 +60,21 @@ func Test_SearchRepositories(t *testing.T) { { name: "successful repository search", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchRepositories, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "golang test", + "page": "2", + "per_page": "10", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ "query": "golang test", - "page": float64(1), - "per_page": float64(30), + "page": float64(2), + "per_page": float64(10), }, expectError: false, expectedResult: mockSearchResult, @@ -76,9 +82,15 @@ func Test_SearchRepositories(t *testing.T) { { name: "repository search with default pagination", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchRepositories, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "golang test", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -195,9 +207,17 @@ func Test_SearchCode(t *testing.T) { { name: "successful code search with all parameters", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchCode, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "fmt.Println language:go", + "sort": "indexed", + "order": "desc", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -213,9 +233,15 @@ func Test_SearchCode(t *testing.T) { { name: "code search with minimal parameters", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchCode, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "fmt.Println language:go", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -336,9 +362,17 @@ func Test_SearchUsers(t *testing.T) { { name: "successful users search with all parameters", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchUsers, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "location:finland language:go", + "sort": "followers", + "order": "desc", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ @@ -354,9 +388,15 @@ func Test_SearchUsers(t *testing.T) { { name: "users search with minimal parameters", mockedClient: mock.NewMockedHTTPClient( - mock.WithRequestMatch( + mock.WithRequestMatchHandler( mock.GetSearchUsers, - mockSearchResult, + expectQueryParams(t, map[string]string{ + "q": "location:finland language:go", + "page": "1", + "per_page": "30", + }).andThen( + mockResponse(t, http.StatusOK, mockSearchResult), + ), ), ), requestArgs: map[string]interface{}{ From 07f6d11cff9d46a772ede93be0c678802792655d Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Apr 2025 15:01:17 +0200 Subject: [PATCH 07/10] Remove non-existent README property (#99) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 127c2b839..5b9084c4b 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,6 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `description`: Repository description (string, optional) - `private`: Whether the repository is private (boolean, optional) - `auto_init`: Auto-initialize with README (boolean, optional) - - `gitignore_template`: Gitignore template name (string, optional) - **get_file_contents** - Get contents of a file or directory From 26f96680a913f3a24fbd473216d717891bb38344 Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Fri, 4 Apr 2025 15:33:36 +0200 Subject: [PATCH 08/10] chore: support x-platform licence generation (#98) --- script/licenses | 20 +- script/licenses-check | 25 ++- ...enses.md => third-party-licenses.darwin.md | 0 third-party-licenses.linux.md | 33 +++ third-party-licenses.windows.md | 34 +++ .../inconshreveable/mousetrap/LICENSE | 201 ++++++++++++++++++ third-party/golang.org/x/sys/windows/LICENSE | 27 +++ 7 files changed, 330 insertions(+), 10 deletions(-) rename third-party-licenses.md => third-party-licenses.darwin.md (100%) create mode 100644 third-party-licenses.linux.md create mode 100644 third-party-licenses.windows.md create mode 100644 third-party/github.com/inconshreveable/mousetrap/LICENSE create mode 100644 third-party/golang.org/x/sys/windows/LICENSE diff --git a/script/licenses b/script/licenses index 3becfbe23..f231a4588 100755 --- a/script/licenses +++ b/script/licenses @@ -1,5 +1,21 @@ #!/bin/bash go install github.com/google/go-licenses@latest -go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.md || echo "Ignore warnings" -go-licenses save ./... --save_path=third-party --force || echo "Ignore warnings" + +rm -rf third-party +mkdir -p third-party +export TEMPDIR="$(mktemp -d)" + +trap "rm -fr ${TEMPDIR}" EXIT + +for goos in linux darwin windows ; do + # Note: we ignore warnings because we want the command to succeed, however the output should be checked + # for any new warnings, and potentially we may need to add licence information. + # + # Normally these warnings are packages containing non go code, which may or may not require explicit attribution, + # depending on the license. + GOOS="${goos}" go-licenses save ./... --save_path="${TEMPDIR}/${goos}" --force || echo "Ignore warnings" + GOOS="${goos}" go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.${goos}.md || echo "Ignore warnings" + cp -fR "${TEMPDIR}/${goos}"/* third-party/ +done + diff --git a/script/licenses-check b/script/licenses-check index f2906fd35..369277ca2 100755 --- a/script/licenses-check +++ b/script/licenses-check @@ -1,12 +1,21 @@ #!/bin/bash -trap 'rm -f third-party-licenses.copy.md' EXIT - go install github.com/google/go-licenses@latest -go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.copy.md || echo "Ignore warnings" -# if not diff -s then exit 1 -if ! diff -s third-party-licenses.copy.md third-party-licenses.md; then - echo "License check failed. Please update the license file." - exit 1 -fi +for goos in linux darwin windows ; do + # Note: we ignore warnings because we want the command to succeed, however the output should be checked + # for any new warnings, and potentially we may need to add licence information. + # + # Normally these warnings are packages containing non go code, which may or may not require explicit attribution, + # depending on the license. + GOOS="${goos}" go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.${goos}.copy.md || echo "Ignore warnings" + if ! diff -s third-party-licenses.${goos}.copy.md third-party-licenses.${goos}.md; then + echo "License check failed.\n\nPlease update the license file by running \`.script/licenses\` and committing the output." + rm -f third-party-licenses.${goos}.copy.md + exit 1 + fi + rm -f third-party-licenses.${goos}.copy.md +done + + + diff --git a/third-party-licenses.md b/third-party-licenses.darwin.md similarity index 100% rename from third-party-licenses.md rename to third-party-licenses.darwin.md diff --git a/third-party-licenses.linux.md b/third-party-licenses.linux.md new file mode 100644 index 000000000..354101ed2 --- /dev/null +++ b/third-party-licenses.linux.md @@ -0,0 +1,33 @@ +# GitHub MCP Server dependencies + +The following open source dependencies are used to build the [github/github-mcp-server][] GitHub Model Context Protocol Server. + +## Go Packages + +Some packages may only be included on certain architectures or operating systems. + + + - [github.com/aws/smithy-go/ptr](https://pkg.go.dev/github.com/aws/smithy-go/ptr) ([Apache-2.0](https://github.com/aws/smithy-go/blob/v1.22.3/LICENSE)) + - [github.com/fsnotify/fsnotify](https://pkg.go.dev/github.com/fsnotify/fsnotify) ([BSD-3-Clause](https://github.com/fsnotify/fsnotify/blob/v1.8.0/LICENSE)) + - [github.com/github/github-mcp-server](https://pkg.go.dev/github.com/github/github-mcp-server) ([MIT](https://github.com/github/github-mcp-server/blob/HEAD/LICENSE)) + - [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.2.1/LICENSE)) + - [github.com/google/go-github/v69/github](https://pkg.go.dev/github.com/google/go-github/v69/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v69.2.0/LICENSE)) + - [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.1.0/LICENSE)) + - [github.com/google/uuid](https://pkg.go.dev/github.com/google/uuid) ([BSD-3-Clause](https://github.com/google/uuid/blob/v1.6.0/LICENSE)) + - [github.com/mark3labs/mcp-go](https://pkg.go.dev/github.com/mark3labs/mcp-go) ([MIT](https://github.com/mark3labs/mcp-go/blob/v0.18.0/LICENSE)) + - [github.com/pelletier/go-toml/v2](https://pkg.go.dev/github.com/pelletier/go-toml/v2) ([MIT](https://github.com/pelletier/go-toml/blob/v2.2.3/LICENSE)) + - [github.com/sagikazarmark/locafero](https://pkg.go.dev/github.com/sagikazarmark/locafero) ([MIT](https://github.com/sagikazarmark/locafero/blob/v0.9.0/LICENSE)) + - [github.com/sirupsen/logrus](https://pkg.go.dev/github.com/sirupsen/logrus) ([MIT](https://github.com/sirupsen/logrus/blob/v1.9.3/LICENSE)) + - [github.com/sourcegraph/conc](https://pkg.go.dev/github.com/sourcegraph/conc) ([MIT](https://github.com/sourcegraph/conc/blob/v0.3.0/LICENSE)) + - [github.com/spf13/afero](https://pkg.go.dev/github.com/spf13/afero) ([Apache-2.0](https://github.com/spf13/afero/blob/v1.14.0/LICENSE.txt)) + - [github.com/spf13/cast](https://pkg.go.dev/github.com/spf13/cast) ([MIT](https://github.com/spf13/cast/blob/v1.7.1/LICENSE)) + - [github.com/spf13/cobra](https://pkg.go.dev/github.com/spf13/cobra) ([Apache-2.0](https://github.com/spf13/cobra/blob/v1.9.1/LICENSE.txt)) + - [github.com/spf13/pflag](https://pkg.go.dev/github.com/spf13/pflag) ([BSD-3-Clause](https://github.com/spf13/pflag/blob/v1.0.6/LICENSE)) + - [github.com/spf13/viper](https://pkg.go.dev/github.com/spf13/viper) ([MIT](https://github.com/spf13/viper/blob/v1.20.1/LICENSE)) + - [github.com/subosito/gotenv](https://pkg.go.dev/github.com/subosito/gotenv) ([MIT](https://github.com/subosito/gotenv/blob/v1.6.0/LICENSE)) + - [github.com/yosida95/uritemplate/v3](https://pkg.go.dev/github.com/yosida95/uritemplate/v3) ([BSD-3-Clause](https://github.com/yosida95/uritemplate/blob/v3.0.2/LICENSE)) + - [golang.org/x/sys/unix](https://pkg.go.dev/golang.org/x/sys/unix) ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.31.0:LICENSE)) + - [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) ([BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.23.0:LICENSE)) + - [gopkg.in/yaml.v3](https://pkg.go.dev/gopkg.in/yaml.v3) ([MIT](https://github.com/go-yaml/yaml/blob/v3.0.1/LICENSE)) + +[github/github-mcp-server]: https://github.com/github/github-mcp-server diff --git a/third-party-licenses.windows.md b/third-party-licenses.windows.md new file mode 100644 index 000000000..ff2752422 --- /dev/null +++ b/third-party-licenses.windows.md @@ -0,0 +1,34 @@ +# GitHub MCP Server dependencies + +The following open source dependencies are used to build the [github/github-mcp-server][] GitHub Model Context Protocol Server. + +## Go Packages + +Some packages may only be included on certain architectures or operating systems. + + + - [github.com/aws/smithy-go/ptr](https://pkg.go.dev/github.com/aws/smithy-go/ptr) ([Apache-2.0](https://github.com/aws/smithy-go/blob/v1.22.3/LICENSE)) + - [github.com/fsnotify/fsnotify](https://pkg.go.dev/github.com/fsnotify/fsnotify) ([BSD-3-Clause](https://github.com/fsnotify/fsnotify/blob/v1.8.0/LICENSE)) + - [github.com/github/github-mcp-server](https://pkg.go.dev/github.com/github/github-mcp-server) ([MIT](https://github.com/github/github-mcp-server/blob/HEAD/LICENSE)) + - [github.com/go-viper/mapstructure/v2](https://pkg.go.dev/github.com/go-viper/mapstructure/v2) ([MIT](https://github.com/go-viper/mapstructure/blob/v2.2.1/LICENSE)) + - [github.com/google/go-github/v69/github](https://pkg.go.dev/github.com/google/go-github/v69/github) ([BSD-3-Clause](https://github.com/google/go-github/blob/v69.2.0/LICENSE)) + - [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.1.0/LICENSE)) + - [github.com/google/uuid](https://pkg.go.dev/github.com/google/uuid) ([BSD-3-Clause](https://github.com/google/uuid/blob/v1.6.0/LICENSE)) + - [github.com/inconshreveable/mousetrap](https://pkg.go.dev/github.com/inconshreveable/mousetrap) ([Apache-2.0](https://github.com/inconshreveable/mousetrap/blob/v1.1.0/LICENSE)) + - [github.com/mark3labs/mcp-go](https://pkg.go.dev/github.com/mark3labs/mcp-go) ([MIT](https://github.com/mark3labs/mcp-go/blob/v0.18.0/LICENSE)) + - [github.com/pelletier/go-toml/v2](https://pkg.go.dev/github.com/pelletier/go-toml/v2) ([MIT](https://github.com/pelletier/go-toml/blob/v2.2.3/LICENSE)) + - [github.com/sagikazarmark/locafero](https://pkg.go.dev/github.com/sagikazarmark/locafero) ([MIT](https://github.com/sagikazarmark/locafero/blob/v0.9.0/LICENSE)) + - [github.com/sirupsen/logrus](https://pkg.go.dev/github.com/sirupsen/logrus) ([MIT](https://github.com/sirupsen/logrus/blob/v1.9.3/LICENSE)) + - [github.com/sourcegraph/conc](https://pkg.go.dev/github.com/sourcegraph/conc) ([MIT](https://github.com/sourcegraph/conc/blob/v0.3.0/LICENSE)) + - [github.com/spf13/afero](https://pkg.go.dev/github.com/spf13/afero) ([Apache-2.0](https://github.com/spf13/afero/blob/v1.14.0/LICENSE.txt)) + - [github.com/spf13/cast](https://pkg.go.dev/github.com/spf13/cast) ([MIT](https://github.com/spf13/cast/blob/v1.7.1/LICENSE)) + - [github.com/spf13/cobra](https://pkg.go.dev/github.com/spf13/cobra) ([Apache-2.0](https://github.com/spf13/cobra/blob/v1.9.1/LICENSE.txt)) + - [github.com/spf13/pflag](https://pkg.go.dev/github.com/spf13/pflag) ([BSD-3-Clause](https://github.com/spf13/pflag/blob/v1.0.6/LICENSE)) + - [github.com/spf13/viper](https://pkg.go.dev/github.com/spf13/viper) ([MIT](https://github.com/spf13/viper/blob/v1.20.1/LICENSE)) + - [github.com/subosito/gotenv](https://pkg.go.dev/github.com/subosito/gotenv) ([MIT](https://github.com/subosito/gotenv/blob/v1.6.0/LICENSE)) + - [github.com/yosida95/uritemplate/v3](https://pkg.go.dev/github.com/yosida95/uritemplate/v3) ([BSD-3-Clause](https://github.com/yosida95/uritemplate/blob/v3.0.2/LICENSE)) + - [golang.org/x/sys/windows](https://pkg.go.dev/golang.org/x/sys/windows) ([BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.31.0:LICENSE)) + - [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) ([BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.23.0:LICENSE)) + - [gopkg.in/yaml.v3](https://pkg.go.dev/gopkg.in/yaml.v3) ([MIT](https://github.com/go-yaml/yaml/blob/v3.0.1/LICENSE)) + +[github/github-mcp-server]: https://github.com/github/github-mcp-server diff --git a/third-party/github.com/inconshreveable/mousetrap/LICENSE b/third-party/github.com/inconshreveable/mousetrap/LICENSE new file mode 100644 index 000000000..5f920e973 --- /dev/null +++ b/third-party/github.com/inconshreveable/mousetrap/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Alan Shreve (@inconshreveable) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third-party/golang.org/x/sys/windows/LICENSE b/third-party/golang.org/x/sys/windows/LICENSE new file mode 100644 index 000000000..2a7cf70da --- /dev/null +++ b/third-party/golang.org/x/sys/windows/LICENSE @@ -0,0 +1,27 @@ +Copyright 2009 The Go Authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google LLC nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 989c43fb37ff20406cba23b102bd49c870162a4f Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 3 Apr 2025 13:30:28 +0200 Subject: [PATCH 09/10] Make JSONRPC easier in conformance tests --- conformance/conformance_test.go | 58 +++++++++++++-------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/conformance/conformance_test.go b/conformance/conformance_test.go index 899ce38e2..282551c13 100644 --- a/conformance/conformance_test.go +++ b/conformance/conformance_test.go @@ -130,8 +130,11 @@ func TestCapabilities(t *testing.T) { anthropicServer := start(t, anthropic) githubServer := start(t, github) - req := newInitializeRequest( - initializeRequestParams{ + req := initializeRequest{ + JSONRPC: "2.0", + ID: 1, + Method: "initialize", + Params: initializeParams{ ProtocolVersion: "2025-03-26", Capabilities: clientCapabilities{}, ClientInfo: clientInfo{ @@ -139,7 +142,7 @@ func TestCapabilities(t *testing.T) { Version: "0.0.1", }, }, - ) + } require.NoError(t, anthropicServer.send(req)) @@ -274,6 +277,14 @@ func (s server) receive(res response) error { return res.unmarshal(line) } +type request interface { + marshal() ([]byte, error) +} + +type response interface { + unmarshal([]byte) error +} + type jsonRPRCRequest[params any] struct { JSONRPC string `json:"jsonrpc"` ID int `json:"id"` @@ -281,6 +292,10 @@ type jsonRPRCRequest[params any] struct { Params params `json:"params"` } +func (r jsonRPRCRequest[any]) marshal() ([]byte, error) { + return json.Marshal(r) +} + type jsonRPRCResponse[result any] struct { JSONRPC string `json:"jsonrpc"` ID int `json:"id"` @@ -288,34 +303,13 @@ type jsonRPRCResponse[result any] struct { Result result `json:"result"` } -type request interface { - marshal() ([]byte, error) -} - -type response interface { - unmarshal([]byte) error -} - -func newInitializeRequest(params initializeRequestParams) initializeRequest { - return initializeRequest{ - jsonRPRCRequest: jsonRPRCRequest[initializeRequestParams]{ - JSONRPC: "2.0", - ID: 1, - Method: "initialize", - Params: params, - }, - } -} - -type initializeRequest struct { - jsonRPRCRequest[initializeRequestParams] +func (r *jsonRPRCResponse[any]) unmarshal(b []byte) error { + return json.Unmarshal(b, r) } -func (r initializeRequest) marshal() ([]byte, error) { - return json.Marshal(r) -} +type initializeRequest = jsonRPRCRequest[initializeParams] -type initializeRequestParams struct { +type initializeParams struct { ProtocolVersion string `json:"protocolVersion"` Capabilities clientCapabilities `json:"capabilities"` ClientInfo clientInfo `json:"clientInfo"` @@ -328,13 +322,7 @@ type clientInfo struct { Version string `json:"version"` } -type initializeResponse struct { - jsonRPRCResponse[initializeResult] -} - -func (r *initializeResponse) unmarshal(b []byte) error { - return json.Unmarshal(b, r) -} +type initializeResponse = jsonRPRCResponse[initializeResult] type initializeResult struct { ProtocolVersion string `json:"protocolVersion"` From 6f7458ae3c97f15b3e6676e7565082a1dfd98e75 Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 3 Apr 2025 22:23:10 +0200 Subject: [PATCH 10/10] Conform list tools --- README.md | 40 +++--- cmd/mcpcurl/README.md | 2 +- conformance/conformance_test.go | 85 ++++++++++++ go.mod | 1 + pkg/github/code_scanning.go | 4 +- pkg/github/code_scanning_test.go | 16 +-- pkg/github/pullrequests.go | 40 +++--- pkg/github/pullrequests_test.go | 182 ++++++++++++------------- pkg/github/repositories.go | 6 +- pkg/github/repositories_test.go | 6 +- pkg/github/repository_resource.go | 4 +- pkg/github/repository_resource_test.go | 2 +- pkg/github/search.go | 2 +- pkg/github/search_test.go | 2 +- 14 files changed, 239 insertions(+), 153 deletions(-) diff --git a/README.md b/README.md index 5b9084c4b..6c14ca756 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `direction`: Sort direction ('asc', 'desc') (string, optional) - `since`: Filter by date (ISO 8601 timestamp) (string, optional) - `page`: Page number (number, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) - **update_issue** - Update an existing issue in a GitHub repository @@ -177,7 +177,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - **list_pull_requests** - List and filter repository pull requests @@ -186,14 +186,14 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `state`: PR state (string, optional) - `sort`: Sort field (string, optional) - `direction`: Sort direction (string, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) - `page`: Page number (number, optional) - **merge_pull_request** - Merge a pull request - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - `commit_title`: Title for the merge commit (string, optional) - `commit_message`: Message for the merge commit (string, optional) - `merge_method`: Merge method (string, optional) @@ -202,41 +202,41 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - **get_pull_request_status** - Get the combined status of all status checks for a pull request - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - **update_pull_request_branch** - Update a pull request branch with the latest changes from the base branch - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) - - `expected_head_sha`: The expected SHA of the pull request's HEAD ref (string, optional) + - `pullNumber`: Pull request number (number, required) + - `expectedHeadSha`: The expected SHA of the pull request's HEAD ref (string, optional) - **get_pull_request_comments** - Get the review comments on a pull request - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - **get_pull_request_reviews** - Get the reviews on a pull request - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - **create_pull_request_review** - Create a review on a pull request review - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pull_number`: Pull request number (number, required) + - `pullNumber`: Pull request number (number, required) - `body`: Review comment text (string, optional) - `event`: Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT') (string, required) - - `commit_id`: SHA of commit to review (string, optional) + - `commitId`: SHA of commit to review (string, optional) - `comments`: Line-specific comments array of objects, each object with path (string), position (number), and body (string) (array, optional) - **create_pull_request** - Create a new pull request @@ -276,14 +276,14 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `sort`: Sort field (string, optional) - `order`: Sort order (string, optional) - `page`: Page number (number, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) - **create_repository** - Create a new GitHub repository - `name`: Repository name (string, required) - `description`: Repository description (string, optional) - `private`: Whether the repository is private (boolean, optional) - - `auto_init`: Auto-initialize with README (boolean, optional) + - `autoInit`: Auto-initialize with README (boolean, optional) - **get_file_contents** - Get contents of a file or directory @@ -311,7 +311,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `sha`: Branch name, tag, or commit SHA (string, optional) - `path`: Only commits containing this file path (string, optional) - `page`: Page number (number, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) ### Search @@ -321,14 +321,14 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `sort`: Sort field (string, optional) - `order`: Sort order (string, optional) - `page`: Page number (number, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) - **search_users** - Search for GitHub users - `query`: Search query (string, required) - `sort`: Sort field (string, optional) - `order`: Sort order (string, optional) - `page`: Page number (number, optional) - - `per_page`: Results per page (number, optional) + - `perPage`: Results per page (number, optional) ### Code Scanning @@ -336,7 +336,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `alert_number`: Alert number (number, required) + - `alertNumber`: Alert number (number, required) - **list_code_scanning_alerts** - List code scanning alerts for a repository - `owner`: Repository owner (string, required) @@ -391,11 +391,11 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description - **Get Repository Content for a Specific Pull Request** Retrieves the content of a repository at a specific path for a given pull request. - - **Template**: `repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}` + - **Template**: `repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}` - **Parameters**: - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - - `pr_number`: Pull request number (string, required) + - `prNumber`: Pull request number (string, required) - `path`: File or directory path (string, optional) ## License diff --git a/cmd/mcpcurl/README.md b/cmd/mcpcurl/README.md index f7b7ea2bf..06ce26ee0 100644 --- a/cmd/mcpcurl/README.md +++ b/cmd/mcpcurl/README.md @@ -72,7 +72,7 @@ Use "mcpcurl tools [command] --help" for more information about a command. Get help for a specific tool: ```bash - % ./mcpcurl --stdio-server-cmd "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools get_issue --help + % ./mcpcurl --stdio-server-cmd "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools get_issue --help Get details of a specific issue in a GitHub repository. Usage: diff --git a/conformance/conformance_test.go b/conformance/conformance_test.go index 282551c13..cd69e013a 100644 --- a/conformance/conformance_test.go +++ b/conformance/conformance_test.go @@ -6,6 +6,7 @@ import ( "bufio" "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -17,6 +18,8 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" ) @@ -230,6 +233,69 @@ func diffNonNilFields(a, b interface{}, path string) string { return sb.String() } +func TestListTools(t *testing.T) { + anthropicServer := start(t, anthropic) + githubServer := start(t, github) + + req := listToolsRequest{ + JSONRPC: "2.0", + ID: 1, + Method: "tools/list", + } + + require.NoError(t, anthropicServer.send(req)) + + var anthropicListToolsResponse listToolsResponse + require.NoError(t, anthropicServer.receive(&anthropicListToolsResponse)) + + require.NoError(t, githubServer.send(req)) + + var ghListToolsResponse listToolsResponse + require.NoError(t, githubServer.receive(&ghListToolsResponse)) + + require.NoError(t, isToolListSubset(anthropicListToolsResponse.Result, ghListToolsResponse.Result), "expected the github list tools response to be a subset of the anthropic list tools response") +} + +func isToolListSubset(subset, superset listToolsResult) error { + // Build a map from tool name to Tool from the superset + supersetMap := make(map[string]tool) + for _, tool := range superset.Tools { + supersetMap[tool.Name] = tool + } + + var err error + for _, tool := range subset.Tools { + sup, ok := supersetMap[tool.Name] + if !ok { + return fmt.Errorf("tool %q not found in superset", tool.Name) + } + + // Intentionally ignore the description fields because there are lots of slight differences. + // if tool.Description != sup.Description { + // return fmt.Errorf("description mismatch for tool %q, got %q expected %q", tool.Name, tool.Description, sup.Description) + // } + + // Ignore any description fields within the input schema properties for the same reason + ignoreDescOpt := cmp.FilterPath(func(p cmp.Path) bool { + // Look for a field named "Properties" somewhere in the path + for _, ps := range p { + if sf, ok := ps.(cmp.StructField); ok && sf.Name() == "Properties" { + return true + } + } + return false + }, cmpopts.IgnoreMapEntries(func(k string, _ any) bool { + return k == "description" + })) + + if diff := cmp.Diff(tool.InputSchema, sup.InputSchema, ignoreDescOpt); diff != "" { + err = errors.Join(err, fmt.Errorf("inputSchema mismatch for tool %q:\n%s", tool.Name, diff)) + } + } + + return err +} + type serverStartResult struct { server server err error @@ -348,3 +414,22 @@ type serverInfo struct { Name string `json:"name"` Version string `json:"version"` } + +type listToolsRequest = jsonRPRCRequest[struct{}] + +type listToolsResponse = jsonRPRCResponse[listToolsResult] + +type listToolsResult struct { + Tools []tool `json:"tools"` +} +type tool struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + InputSchema inputSchema `json:"inputSchema"` +} + +type inputSchema struct { + Type string `json:"type"` + Properties map[string]any `json:"properties,omitempty"` + Required []string `json:"required,omitempty"` +} diff --git a/go.mod b/go.mod index 324ebccd8..cf96ca5de 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.23.7 require ( github.com/aws/smithy-go v1.22.3 github.com/docker/docker v28.0.4+incompatible + github.com/google/go-cmp v0.7.0 github.com/google/go-github/v69 v69.2.0 github.com/mark3labs/mcp-go v0.18.0 github.com/migueleliasweb/go-github-mock v1.1.0 diff --git a/pkg/github/code_scanning.go b/pkg/github/code_scanning.go index 380dc02cf..81ee2c314 100644 --- a/pkg/github/code_scanning.go +++ b/pkg/github/code_scanning.go @@ -24,7 +24,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe mcp.Required(), mcp.Description("The name of the repository."), ), - mcp.WithNumber("alert_number", + mcp.WithNumber("alertNumber", mcp.Required(), mcp.Description("The number of the alert."), ), @@ -38,7 +38,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe if err != nil { return mcp.NewToolResultError(err.Error()), nil } - alertNumber, err := requiredInt(request, "alert_number") + alertNumber, err := requiredInt(request, "alertNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } diff --git a/pkg/github/code_scanning_test.go b/pkg/github/code_scanning_test.go index 9dd301374..ec4d671ef 100644 --- a/pkg/github/code_scanning_test.go +++ b/pkg/github/code_scanning_test.go @@ -22,8 +22,8 @@ func Test_GetCodeScanningAlert(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "alert_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "alert_number"}) + assert.Contains(t, tool.InputSchema.Properties, "alertNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "alertNumber"}) // Setup mock alert for success case mockAlert := &github.Alert{ @@ -50,9 +50,9 @@ func Test_GetCodeScanningAlert(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "alert_number": float64(42), + "owner": "owner", + "repo": "repo", + "alertNumber": float64(42), }, expectError: false, expectedAlert: mockAlert, @@ -69,9 +69,9 @@ func Test_GetCodeScanningAlert(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "alert_number": float64(9999), + "owner": "owner", + "repo": "repo", + "alertNumber": float64(9999), }, expectError: true, expectedErrMsg: "failed to get alert", diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index ddec1e6ef..c02336ca0 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -25,7 +25,7 @@ func getPullRequest(client *github.Client, t translations.TranslationHelperFunc) mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -39,7 +39,7 @@ func getPullRequest(client *github.Client, t translations.TranslationHelperFunc) if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -186,7 +186,7 @@ func mergePullRequest(client *github.Client, t translations.TranslationHelperFun mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -209,7 +209,7 @@ func mergePullRequest(client *github.Client, t translations.TranslationHelperFun if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -266,7 +266,7 @@ func getPullRequestFiles(client *github.Client, t translations.TranslationHelper mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -280,7 +280,7 @@ func getPullRequestFiles(client *github.Client, t translations.TranslationHelper if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -321,7 +321,7 @@ func getPullRequestStatus(client *github.Client, t translations.TranslationHelpe mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -335,7 +335,7 @@ func getPullRequestStatus(client *github.Client, t translations.TranslationHelpe if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -390,11 +390,11 @@ func updatePullRequestBranch(client *github.Client, t translations.TranslationHe mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), - mcp.WithString("expected_head_sha", + mcp.WithString("expectedHeadSha", mcp.Description("The expected SHA of the pull request's HEAD ref"), ), ), @@ -407,11 +407,11 @@ func updatePullRequestBranch(client *github.Client, t translations.TranslationHe if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } - expectedHeadSHA, err := optionalParam[string](request, "expected_head_sha") + expectedHeadSHA, err := optionalParam[string](request, "expectedHeadSha") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -460,7 +460,7 @@ func getPullRequestComments(client *github.Client, t translations.TranslationHel mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -474,7 +474,7 @@ func getPullRequestComments(client *github.Client, t translations.TranslationHel if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -520,7 +520,7 @@ func getPullRequestReviews(client *github.Client, t translations.TranslationHelp mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -534,7 +534,7 @@ func getPullRequestReviews(client *github.Client, t translations.TranslationHelp if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -574,7 +574,7 @@ func createPullRequestReview(client *github.Client, t translations.TranslationHe mcp.Required(), mcp.Description("Repository name"), ), - mcp.WithNumber("pull_number", + mcp.WithNumber("pullNumber", mcp.Required(), mcp.Description("Pull request number"), ), @@ -585,7 +585,7 @@ func createPullRequestReview(client *github.Client, t translations.TranslationHe mcp.Required(), mcp.Description("Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT')"), ), - mcp.WithString("commit_id", + mcp.WithString("commitId", mcp.Description("SHA of commit to review"), ), mcp.WithArray("comments", @@ -622,7 +622,7 @@ func createPullRequestReview(client *github.Client, t translations.TranslationHe if err != nil { return mcp.NewToolResultError(err.Error()), nil } - pullNumber, err := requiredInt(request, "pull_number") + pullNumber, err := requiredInt(request, "pullNumber") if err != nil { return mcp.NewToolResultError(err.Error()), nil } @@ -646,7 +646,7 @@ func createPullRequestReview(client *github.Client, t translations.TranslationHe } // Add commit ID if provided - commitID, err := optionalParam[string](request, "commit_id") + commitID, err := optionalParam[string](request, "commitId") if err != nil { return mcp.NewToolResultError(err.Error()), nil } diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index 761de5010..b666e8a8b 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -23,8 +23,8 @@ func Test_GetPullRequest(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock PR for success case mockPR := &github.PullRequest{ @@ -62,9 +62,9 @@ func Test_GetPullRequest(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedPR: mockPR, @@ -81,9 +81,9 @@ func Test_GetPullRequest(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(999), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(999), }, expectError: true, expectedErrMsg: "failed to get pull request", @@ -265,11 +265,11 @@ func Test_MergePullRequest(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") assert.Contains(t, tool.InputSchema.Properties, "commit_title") assert.Contains(t, tool.InputSchema.Properties, "commit_message") assert.Contains(t, tool.InputSchema.Properties, "merge_method") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock merge result for success case mockMergeResult := &github.PullRequestMergeResult{ @@ -303,7 +303,7 @@ func Test_MergePullRequest(t *testing.T) { requestArgs: map[string]interface{}{ "owner": "owner", "repo": "repo", - "pull_number": float64(42), + "pullNumber": float64(42), "commit_title": "Merge PR #42", "commit_message": "Merging awesome feature", "merge_method": "squash", @@ -323,9 +323,9 @@ func Test_MergePullRequest(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: true, expectedErrMsg: "failed to merge pull request", @@ -376,8 +376,8 @@ func Test_GetPullRequestFiles(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock PR files for success case mockFiles := []*github.CommitFile{ @@ -416,9 +416,9 @@ func Test_GetPullRequestFiles(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedFiles: mockFiles, @@ -435,9 +435,9 @@ func Test_GetPullRequestFiles(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(999), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(999), }, expectError: true, expectedErrMsg: "failed to get pull request files", @@ -492,8 +492,8 @@ func Test_GetPullRequestStatus(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock PR for successful PR fetch mockPR := &github.PullRequest{ @@ -553,9 +553,9 @@ func Test_GetPullRequestStatus(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedStatus: mockStatus, @@ -572,9 +572,9 @@ func Test_GetPullRequestStatus(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(999), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(999), }, expectError: true, expectedErrMsg: "failed to get pull request", @@ -595,9 +595,9 @@ func Test_GetPullRequestStatus(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: true, expectedErrMsg: "failed to get combined status", @@ -653,9 +653,9 @@ func Test_UpdatePullRequestBranch(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.Contains(t, tool.InputSchema.Properties, "expected_head_sha") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.Contains(t, tool.InputSchema.Properties, "expectedHeadSha") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock update result for success case mockUpdateResult := &github.PullRequestBranchUpdateResponse{ @@ -684,10 +684,10 @@ func Test_UpdatePullRequestBranch(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "expected_head_sha": "abcd1234", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "expectedHeadSha": "abcd1234", }, expectError: false, expectedUpdateResult: mockUpdateResult, @@ -703,9 +703,9 @@ func Test_UpdatePullRequestBranch(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedUpdateResult: mockUpdateResult, @@ -722,9 +722,9 @@ func Test_UpdatePullRequestBranch(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: true, expectedErrMsg: "failed to update pull request branch", @@ -769,8 +769,8 @@ func Test_GetPullRequestComments(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock PR comments for success case mockComments := []*github.PullRequestComment{ @@ -819,9 +819,9 @@ func Test_GetPullRequestComments(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedComments: mockComments, @@ -838,9 +838,9 @@ func Test_GetPullRequestComments(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(999), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(999), }, expectError: true, expectedErrMsg: "failed to get pull request comments", @@ -896,8 +896,8 @@ func Test_GetPullRequestReviews(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number"}) + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"}) // Setup mock PR reviews for success case mockReviews := []*github.PullRequestReview{ @@ -942,9 +942,9 @@ func Test_GetPullRequestReviews(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), }, expectError: false, expectedReviews: mockReviews, @@ -961,9 +961,9 @@ func Test_GetPullRequestReviews(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(999), + "owner": "owner", + "repo": "repo", + "pullNumber": float64(999), }, expectError: true, expectedErrMsg: "failed to get pull request reviews", @@ -1019,12 +1019,12 @@ func Test_CreatePullRequestReview(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "owner") assert.Contains(t, tool.InputSchema.Properties, "repo") - assert.Contains(t, tool.InputSchema.Properties, "pull_number") + assert.Contains(t, tool.InputSchema.Properties, "pullNumber") assert.Contains(t, tool.InputSchema.Properties, "body") assert.Contains(t, tool.InputSchema.Properties, "event") - assert.Contains(t, tool.InputSchema.Properties, "commit_id") + assert.Contains(t, tool.InputSchema.Properties, "commitId") assert.Contains(t, tool.InputSchema.Properties, "comments") - assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pull_number", "event"}) + assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber", "event"}) // Setup mock review for success case mockReview := &github.PullRequestReview{ @@ -1061,17 +1061,17 @@ func Test_CreatePullRequestReview(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "body": "Looks good!", - "event": "APPROVE", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "body": "Looks good!", + "event": "APPROVE", }, expectError: false, expectedReview: mockReview, }, { - name: "successful review creation with commit_id", + name: "successful review creation with commitId", mockedClient: mock.NewMockedHTTPClient( mock.WithRequestMatchHandler( mock.PostReposPullsReviewsByOwnerByRepoByPullNumber, @@ -1085,12 +1085,12 @@ func Test_CreatePullRequestReview(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "body": "Looks good!", - "event": "APPROVE", - "commit_id": "abcdef123456", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "body": "Looks good!", + "event": "APPROVE", + "commitId": "abcdef123456", }, expectError: false, expectedReview: mockReview, @@ -1121,11 +1121,11 @@ func Test_CreatePullRequestReview(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "body": "Some issues to fix", - "event": "REQUEST_CHANGES", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "body": "Some issues to fix", + "event": "REQUEST_CHANGES", "comments": []interface{}{ map[string]interface{}{ "path": "file1.go", @@ -1154,10 +1154,10 @@ func Test_CreatePullRequestReview(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "event": "REQUEST_CHANGES", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "event": "REQUEST_CHANGES", "comments": []interface{}{ map[string]interface{}{ "path": "file1.go", @@ -1181,11 +1181,11 @@ func Test_CreatePullRequestReview(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "pull_number": float64(42), - "body": "Looks good!", - "event": "APPROVE", + "owner": "owner", + "repo": "repo", + "pullNumber": float64(42), + "body": "Looks good!", + "event": "APPROVE", }, expectError: true, expectedErrMsg: "failed to create pull request review", diff --git a/pkg/github/repositories.go b/pkg/github/repositories.go index e4302b889..112eb3740 100644 --- a/pkg/github/repositories.go +++ b/pkg/github/repositories.go @@ -32,7 +32,7 @@ func listCommits(client *github.Client, t translations.TranslationHelperFunc) (t mcp.WithNumber("page", mcp.Description("Page number"), ), - mcp.WithNumber("per_page", + mcp.WithNumber("perPage", mcp.Description("Number of records per page"), ), ), @@ -204,7 +204,7 @@ func createRepository(client *github.Client, t translations.TranslationHelperFun mcp.WithBoolean("private", mcp.Description("Whether repo should be private"), ), - mcp.WithBoolean("auto_init", + mcp.WithBoolean("autoInit", mcp.Description("Initialize with README"), ), ), @@ -221,7 +221,7 @@ func createRepository(client *github.Client, t translations.TranslationHelperFun if err != nil { return mcp.NewToolResultError(err.Error()), nil } - autoInit, err := optionalParam[bool](request, "auto_init") + autoInit, err := optionalParam[bool](request, "autoInit") if err != nil { return mcp.NewToolResultError(err.Error()), nil } diff --git a/pkg/github/repositories_test.go b/pkg/github/repositories_test.go index 4ae450831..bb6579f85 100644 --- a/pkg/github/repositories_test.go +++ b/pkg/github/repositories_test.go @@ -486,7 +486,7 @@ func Test_ListCommits(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "repo") assert.Contains(t, tool.InputSchema.Properties, "sha") assert.Contains(t, tool.InputSchema.Properties, "page") - assert.Contains(t, tool.InputSchema.Properties, "per_page") + assert.Contains(t, tool.InputSchema.Properties, "perPage") assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"}) // Setup mock commits for success case @@ -822,7 +822,7 @@ func Test_CreateRepository(t *testing.T) { assert.Contains(t, tool.InputSchema.Properties, "name") assert.Contains(t, tool.InputSchema.Properties, "description") assert.Contains(t, tool.InputSchema.Properties, "private") - assert.Contains(t, tool.InputSchema.Properties, "auto_init") + assert.Contains(t, tool.InputSchema.Properties, "autoInit") assert.ElementsMatch(t, tool.InputSchema.Required, []string{"name"}) // Setup mock repository response @@ -868,7 +868,7 @@ func Test_CreateRepository(t *testing.T) { "name": "test-repo", "description": "Test repository", "private": true, - "auto_init": true, + "autoInit": true, }, expectError: false, expectedRepo: mockRepo, diff --git a/pkg/github/repository_resource.go b/pkg/github/repository_resource.go index 9fa74c3c6..8efb67e6a 100644 --- a/pkg/github/repository_resource.go +++ b/pkg/github/repository_resource.go @@ -56,7 +56,7 @@ func getRepositoryResourceTagContent(client *github.Client, t translations.Trans // getRepositoryResourcePrContent defines the resource template and handler for getting repository content for a pull request. func getRepositoryResourcePrContent(client *github.Client, t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) { return mcp.NewResourceTemplate( - "repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}", // Resource template + "repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}", // Resource template t("RESOURCE_REPOSITORY_CONTENT_PR_DESCRIPTION", "Repository Content for specific pull request"), ), repositoryResourceContentsHandler(client) @@ -101,7 +101,7 @@ func repositoryResourceContentsHandler(client *github.Client) func(ctx context.C if ok && len(tag) > 0 { opts.Ref = "refs/tags/" + tag[0] } - prNumber, ok := request.Params.Arguments["pr_number"].([]string) + prNumber, ok := request.Params.Arguments["prNumber"].([]string) if ok && len(prNumber) > 0 { opts.Ref = "refs/pull/" + prNumber[0] + "/head" } diff --git a/pkg/github/repository_resource_test.go b/pkg/github/repository_resource_test.go index 0a5b0b0f0..adad8744d 100644 --- a/pkg/github/repository_resource_test.go +++ b/pkg/github/repository_resource_test.go @@ -279,5 +279,5 @@ func Test_getRepositoryResourceTagContent(t *testing.T) { func Test_getRepositoryResourcePrContent(t *testing.T) { tmpl, _ := getRepositoryResourcePrContent(nil, translations.NullTranslationHelper) - require.Equal(t, "repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}", tmpl.URITemplate.Raw()) + require.Equal(t, "repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}", tmpl.URITemplate.Raw()) } diff --git a/pkg/github/search.go b/pkg/github/search.go index e02c3d0c0..f9a20be14 100644 --- a/pkg/github/search.go +++ b/pkg/github/search.go @@ -23,7 +23,7 @@ func searchRepositories(client *github.Client, t translations.TranslationHelperF mcp.WithNumber("page", mcp.Description("Page number for pagination"), ), - mcp.WithNumber("per_page", + mcp.WithNumber("perPage", mcp.Description("Results per page (max 100)"), ), ), diff --git a/pkg/github/search_test.go b/pkg/github/search_test.go index 44513b1f5..2485c4c26 100644 --- a/pkg/github/search_test.go +++ b/pkg/github/search_test.go @@ -22,7 +22,7 @@ func Test_SearchRepositories(t *testing.T) { assert.NotEmpty(t, tool.Description) assert.Contains(t, tool.InputSchema.Properties, "query") assert.Contains(t, tool.InputSchema.Properties, "page") - assert.Contains(t, tool.InputSchema.Properties, "per_page") + assert.Contains(t, tool.InputSchema.Properties, "perPage") assert.ElementsMatch(t, tool.InputSchema.Required, []string{"query"}) // Setup mock search results