Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5b3211

Browse files
Merge branch 'main' into notifications-tooling
2 parentsbdb59e0 +bbba3bb commitb5b3211

33 files changed

+2386
-635
lines changed

‎.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@juruen@sammorrowdrums@williammartin@toby
1+
*@juruen@sammorrowdrums@williammartin@toby

‎.github/workflows/docker-publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ jobs:
6666
uses:docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934# v5.0.0
6767
with:
6868
images:${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
69+
tags:|
70+
type=schedule
71+
type=ref,event=branch
72+
type=ref,event=tag
73+
type=ref,event=pr
74+
type=semver,pattern={{version}}
75+
type=semver,pattern={{major}}.{{minor}}
76+
type=semver,pattern={{major}}
77+
type=sha
78+
type=edge
79+
# Custom rule to prevent pre-releases from getting latest tag
80+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
6981
7082
-name:Go Build Cache for Docker
7183
uses:actions/cache@v4

‎.github/workflows/goreleaser.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
-"v*"
66
permissions:
77
contents:write
8+
id-token:write
9+
attestations:write
810

911
jobs:
1012
release:
@@ -33,3 +35,11 @@ jobs:
3335
workdir:.
3436
env:
3537
GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}
38+
39+
-name:Generate signed build provenance attestations for workflow artifacts
40+
uses:actions/attest-build-provenance@v2
41+
with:
42+
subject-path:|
43+
dist/*.tar.gz
44+
dist/*.zip
45+
dist/*.txt

‎CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[fork]:https://github.com/github/github-mcp-server/fork
44
[pr]:https://github.com/github/github-mcp-server/compare
5-
[style]:https://github.com/github/github-mcp-server/blob/main/.golangci.yaml
5+
[style]:https://github.com/github/github-mcp-server/blob/main/.golangci.yml
66

77
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
88

‎README.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ automation and interaction capabilities for developers and tools.
1515
##Prerequisites
1616

1717
1. To run the server in a container, you will need to have[Docker](https://www.docker.com/) installed.
18-
2.[Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new).
18+
2. Once Docker is installed, you will also need to ensure Docker is running.
19+
3. Lastly you will need to[Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new).
1920
The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the[documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
2021

2122

@@ -153,6 +154,12 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
153154
-`repo`: Repository name (string, required)
154155
-`issue_number`: Issue number (number, required)
155156

157+
-**get_issue_comments** - Get comments for a GitHub issue
158+
159+
-`owner`: Repository owner (string, required)
160+
-`repo`: Repository name (string, required)
161+
-`issue_number`: Issue number (number, required)
162+
156163
-**create_issue** - Create a new issue in a GitHub repository
157164

158165
-`owner`: Repository owner (string, required)
@@ -198,7 +205,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
198205
-`sort`: Sort field (string, optional)
199206
-`order`: Sort order (string, optional)
200207
-`page`: Page number (number, optional)
201-
-`per_page`: Results per page (number, optional)
208+
-`perPage`: Results per page (number, optional)
202209

203210
###Pull Requests
204211

@@ -266,7 +273,9 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
266273
-`body`: Review comment text (string, optional)
267274
-`event`: Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT') (string, required)
268275
-`commitId`: SHA of commit to review (string, optional)
269-
-`comments`: Line-specific comments array of objects, each object with path (string), position (number), and body (string) (array, optional)
276+
-`comments`: Line-specific comments array of objects to place comments on pull request changes (array, optional)
277+
- For inline comments: provide`path`,`position` (or`line`), and`body`
278+
- For multi-line comments: provide`path`,`start_line`,`line`, optional`side`/`start_side`, and`body`
270279

271280
-**create_pull_request** - Create a new pull request
272281

@@ -279,6 +288,32 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
279288
-`draft`: Create as draft PR (boolean, optional)
280289
-`maintainer_can_modify`: Allow maintainer edits (boolean, optional)
281290

291+
-**add_pull_request_review_comment** - Add a review comment to a pull request or reply to an existing comment
292+
293+
-`owner`: Repository owner (string, required)
294+
-`repo`: Repository name (string, required)
295+
-`pull_number`: Pull request number (number, required)
296+
-`body`: The text of the review comment (string, required)
297+
-`commit_id`: The SHA of the commit to comment on (string, required unless using in_reply_to)
298+
-`path`: The relative path to the file that necessitates a comment (string, required unless using in_reply_to)
299+
-`line`: The line of the blob in the pull request diff that the comment applies to (number, optional)
300+
-`side`: The side of the diff to comment on (LEFT or RIGHT) (string, optional)
301+
-`start_line`: For multi-line comments, the first line of the range (number, optional)
302+
-`start_side`: For multi-line comments, the starting side of the diff (LEFT or RIGHT) (string, optional)
303+
-`subject_type`: The level at which the comment is targeted (line or file) (string, optional)
304+
-`in_reply_to`: The ID of the review comment to reply to (number, optional). When specified, only body is required and other parameters are ignored.
305+
306+
-**update_pull_request** - Update an existing pull request in a GitHub repository
307+
308+
-`owner`: Repository owner (string, required)
309+
-`repo`: Repository name (string, required)
310+
-`pullNumber`: Pull request number to update (number, required)
311+
-`title`: New title (string, optional)
312+
-`body`: New description (string, optional)
313+
-`state`: New state ('open' or 'closed') (string, optional)
314+
-`base`: New base branch name (string, optional)
315+
-`maintainer_can_modify`: Allow maintainer edits (boolean, optional)
316+
282317
###Repositories
283318

284319
-**create_or_update_file** - Create or update a single file in a repository
@@ -291,6 +326,13 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
291326
-`branch`: Branch name (string, optional)
292327
-`sha`: File SHA if updating (string, optional)
293328

329+
-**list_branches** - List branches in a GitHub repository
330+
331+
-`owner`: Repository owner (string, required)
332+
-`repo`: Repository name (string, required)
333+
-`page`: Page number (number, optional)
334+
-`perPage`: Results per page (number, optional)
335+
294336
-**push_files** - Push multiple files in a single commit
295337

296338
-`owner`: Repository owner (string, required)
@@ -334,14 +376,21 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
334376
-`branch`: New branch name (string, required)
335377
-`sha`: SHA to create branch from (string, required)
336378

337-
-**list_commits** -Gets commits of a branch in a repository
379+
-**list_commits** -Get a list of commits of a branch in a repository
338380
-`owner`: Repository owner (string, required)
339381
-`repo`: Repository name (string, required)
340382
-`sha`: Branch name, tag, or commit SHA (string, optional)
341383
-`path`: Only commits containing this file path (string, optional)
342384
-`page`: Page number (number, optional)
343385
-`perPage`: Results per page (number, optional)
344386

387+
-**get_commit** - Get details for a commit from a repository
388+
-`owner`: Repository owner (string, required)
389+
-`repo`: Repository name (string, required)
390+
-`sha`: Commit SHA, branch name, or tag name (string, required)
391+
-`page`: Page number, for files in the commit (number, optional)
392+
-`perPage`: Results per page, for files in the commit (number, optional)
393+
345394
###Search
346395

347396
-**search_code** - Search for code across GitHub repositories
@@ -427,6 +476,10 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
427476
-`prNumber`: Pull request number (string, required)
428477
-`path`: File or directory path (string, optional)
429478

479+
##Library Usage
480+
481+
The exported Go API of this module should currently be considered unstable, and subject to breaking changes. In the future, we may offer stability; please file an issue if there is a use case where this would be valuable.
482+
430483
##License
431484

432485
This project is licensed under the terms of the MIT open source license. Please refer to[MIT](./LICENSE) for the full terms.

‎cmd/github-mcp-server/main.go

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package main
22

33
import (
4-
"bytes"
54
"context"
6-
"encoding/json"
75
"fmt"
86
"io"
97
stdlog"log"
@@ -15,6 +13,7 @@ import (
1513
iolog"github.com/github/github-mcp-server/pkg/log"
1614
"github.com/github/github-mcp-server/pkg/translations"
1715
gogithub"github.com/google/go-github/v69/github"
16+
"github.com/mark3labs/mcp-go/mcp"
1817
"github.com/mark3labs/mcp-go/server"
1918
log"github.com/sirupsen/logrus"
2019
"github.com/spf13/cobra"
@@ -41,7 +40,6 @@ var (
4140
logFile:=viper.GetString("log-file")
4241
readOnly:=viper.GetBool("read-only")
4342
exportTranslations:=viper.GetBool("export-translations")
44-
prettyPrintJSON:=viper.GetBool("pretty-print-json")
4543
logger,err:=initLogger(logFile)
4644
iferr!=nil {
4745
stdlog.Fatal("Failed to initialize logger:",err)
@@ -52,7 +50,6 @@ var (
5250
logger:logger,
5351
logCommands:logCommands,
5452
exportTranslations:exportTranslations,
55-
prettyPrintJSON:prettyPrintJSON,
5653
}
5754
iferr:=runStdioServer(cfg);err!=nil {
5855
stdlog.Fatal("failed to run stdio server:",err)
@@ -70,15 +67,13 @@ func init() {
7067
rootCmd.PersistentFlags().Bool("enable-command-logging",false,"When enabled, the server will log all command requests and responses to the log file")
7168
rootCmd.PersistentFlags().Bool("export-translations",false,"Save translations to a JSON file")
7269
rootCmd.PersistentFlags().String("gh-host","","Specify the GitHub hostname (for GitHub Enterprise etc.)")
73-
rootCmd.PersistentFlags().Bool("pretty-print-json",false,"Pretty print JSON output")
7470

7571
// Bind flag to viper
7672
_=viper.BindPFlag("read-only",rootCmd.PersistentFlags().Lookup("read-only"))
7773
_=viper.BindPFlag("log-file",rootCmd.PersistentFlags().Lookup("log-file"))
7874
_=viper.BindPFlag("enable-command-logging",rootCmd.PersistentFlags().Lookup("enable-command-logging"))
7975
_=viper.BindPFlag("export-translations",rootCmd.PersistentFlags().Lookup("export-translations"))
8076
_=viper.BindPFlag("gh-host",rootCmd.PersistentFlags().Lookup("gh-host"))
81-
_=viper.BindPFlag("pretty-print-json",rootCmd.PersistentFlags().Lookup("pretty-print-json"))
8277

8378
// Add subcommands
8479
rootCmd.AddCommand(stdioCmd)
@@ -112,20 +107,6 @@ type runConfig struct {
112107
logger*log.Logger
113108
logCommandsbool
114109
exportTranslationsbool
115-
prettyPrintJSONbool
116-
}
117-
118-
// JSONPrettyPrintWriter is a Writer that pretty prints input to indented JSON
119-
typeJSONPrettyPrintWriterstruct {
120-
writer io.Writer
121-
}
122-
123-
func (jJSONPrettyPrintWriter)Write(p []byte) (nint,errerror) {
124-
varprettyJSON bytes.Buffer
125-
iferr:=json.Indent(&prettyJSON,p,"","\t");err!=nil {
126-
return0,err
127-
}
128-
returnj.writer.Write(prettyJSON.Bytes())
129110
}
130111

131112
funcrunStdioServer(cfgrunConfig)error {
@@ -157,8 +138,19 @@ func runStdioServer(cfg runConfig) error {
157138

158139
t,dumpTranslations:=translations.TranslationHelper()
159140

141+
beforeInit:=func(_ context.Context,_any,message*mcp.InitializeRequest) {
142+
ghClient.UserAgent=fmt.Sprintf("github-mcp-server/%s (%s/%s)",version,message.Params.ClientInfo.Name,message.Params.ClientInfo.Version)
143+
}
144+
145+
getClient:=func(_ context.Context) (*gogithub.Client,error) {
146+
returnghClient,nil// closing over client
147+
}
148+
149+
hooks:=&server.Hooks{
150+
OnBeforeInitialize: []server.OnBeforeInitializeFunc{beforeInit},
151+
}
160152
// Create
161-
ghServer:=github.NewServer(ghClient,cfg.readOnly,t)
153+
ghServer:=github.NewServer(getClient,version,cfg.readOnly,t,server.WithHooks(hooks))
162154
stdioServer:=server.NewStdioServer(ghServer)
163155

164156
stdLogger:=stdlog.New(cfg.logger.Writer(),"stdioserver",0)
@@ -179,9 +171,6 @@ func runStdioServer(cfg runConfig) error {
179171
in,out=loggedIO,loggedIO
180172
}
181173

182-
ifcfg.prettyPrintJSON {
183-
out=JSONPrettyPrintWriter{writer:out}
184-
}
185174
errC<-stdioServer.Listen(ctx,in,out)
186175
}()
187176

‎cmd/mcpcurl/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Available Commands:
4949
create_repository Create a new GitHub repositoryin your account
5050
fork_repository Fork a GitHub repository to your account or specified organization
5151
get_file_contents Get the contents of a file or directory from a GitHub repository
52-
get_issue Get details of a specific issuein a GitHub repository.
52+
get_issue Get details of a specific issuein a GitHub repository
53+
get_issue_comments Get commentsfor a GitHub issue
5354
list_commits Get list of commits of a branchin a GitHub repository
5455
list_issues List issuesin a GitHub repository with filtering options
5556
push_files Push multiple files to a GitHub repositoryin a single commit
@@ -73,7 +74,7 @@ Get help for a specific tool:
7374

7475
```bash
7576
% ./mcpcurl --stdio-server-cmd"docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools get_issue --help
76-
Get details of a specific issuein a GitHub repository.
77+
Get details of a specific issuein a GitHub repository
7778

7879
Usage:
7980
mcpcurl tools get_issue [flags]

‎cmd/mcpcurl/main.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"bytes"
5+
"crypto/rand"
56
"encoding/json"
67
"fmt"
78
"io"
@@ -11,8 +12,6 @@ import (
1112
"slices"
1213
"strings"
1314

14-
"crypto/rand"
15-
1615
"github.com/spf13/cobra"
1716
"github.com/spf13/viper"
1817
)
@@ -161,7 +160,7 @@ func main() {
161160
_=rootCmd.MarkPersistentFlagRequired("stdio-server-cmd")
162161

163162
// Add global flag for pretty printing
164-
rootCmd.PersistentFlags().Bool("pretty",true,"Pretty print MCP response (only for JSON responses)")
163+
rootCmd.PersistentFlags().Bool("pretty",true,"Pretty print MCP response (only for JSONor JSONLresponses)")
165164

166165
// Add the tools command to the root command
167166
rootCmd.AddCommand(toolsCmd)
@@ -426,15 +425,26 @@ func printResponse(response string, prettyPrint bool) error {
426425
// Extract text from content items of type "text"
427426
for_,content:=rangeresp.Result.Content {
428427
ifcontent.Type=="text" {
429-
// Unmarshal the text content
430-
vartextContentmap[string]interface{}
431-
iferr:=json.Unmarshal([]byte(content.Text),&textContent);err!=nil {
432-
returnfmt.Errorf("failed to parse text content: %w",err)
428+
vartextContentObjmap[string]interface{}
429+
err:=json.Unmarshal([]byte(content.Text),&textContentObj)
430+
431+
iferr==nil {
432+
prettyText,err:=json.MarshalIndent(textContentObj,""," ")
433+
iferr!=nil {
434+
returnfmt.Errorf("failed to pretty print text content: %w",err)
435+
}
436+
fmt.Println(string(prettyText))
437+
continue
438+
}
439+
440+
// Fallback parsing as JSONL
441+
vartextContentList []map[string]interface{}
442+
iferr:=json.Unmarshal([]byte(content.Text),&textContentList);err!=nil {
443+
returnfmt.Errorf("failed to parse text content as a list: %w",err)
433444
}
434-
// Pretty print the text content
435-
prettyText,err:=json.MarshalIndent(textContent,""," ")
445+
prettyText,err:=json.MarshalIndent(textContentList,""," ")
436446
iferr!=nil {
437-
returnfmt.Errorf("failed to pretty printtext content: %w",err)
447+
returnfmt.Errorf("failed to pretty printarray content: %w",err)
438448
}
439449
fmt.Println(string(prettyText))
440450
}

‎go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/github/github-mcp-server
33
go1.23.7
44

55
require (
6-
github.com/aws/smithy-gov1.22.3
76
github.com/docker/dockerv28.0.4+incompatible
87
github.com/google/go-cmpv0.7.0
98
github.com/google/go-github/v69v69.2.0

‎go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOEl
22
github.com/Azure/go-ansitermv0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
33
github.com/Microsoft/go-winiov0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
44
github.com/Microsoft/go-winiov0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
5-
github.com/aws/smithy-gov1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k=
6-
github.com/aws/smithy-gov1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI=
75
github.com/cenkalti/backoff/v4v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
86
github.com/cenkalti/backoff/v4v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
97
github.com/containerd/logv0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp