Skip to content

Commit 3c3e6e4

Browse files
Merge branch 'main' into repo-resource
2 parents 59ae504 + b2e869d commit 3c3e6e4

18 files changed

+3371
-25
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ and set it as the GITHUB_PERSONAL_ACCESS_TOKEN environment variable.
184184
## Standard input/output server
185185

186186
```sh
187-
go run cmd/server/main.go stdio
187+
go run cmd/github-mcp-server/main.go stdio
188188
```
189189

190190
E.g:
@@ -214,6 +214,48 @@ GitHub MCP Server running on stdio
214214
215215
```
216216
217+
## Testing on VS Code Insiders
218+
219+
First of all, install `github-mcp-server` with:
220+
221+
```bash
222+
go install ./cmd/github-mcp-server
223+
```
224+
225+
Make sure you:
226+
227+
1. Set your `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable and ensure VS Code has access to it.
228+
2. VS Code Insiders has access to the `github-mcp-server` binary
229+
230+
Go to settings, find the MCP related settings, and set them to:
231+
232+
```json
233+
{
234+
"mcp": {
235+
"inputs": [],
236+
"servers": {
237+
"mcp-github-server": {
238+
"command": "path-to-your/github-mcp-server",
239+
"args": [
240+
"stdio"
241+
],
242+
"env": {}
243+
}
244+
}
245+
}
246+
}
247+
```
248+
249+
In `Copilot Edits`, you should now see an option to reload the available `tools`.
250+
Reload, and you should be good to go.
251+
252+
Try something like the following prompt to verify that it works:
253+
254+
```
255+
I'd like to know more about my GitHub profile.
256+
```
257+
258+
217259
## TODO
218260
219261
Lots of things!

cmd/server/main.go renamed to cmd/github-mcp-server/main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ package main
33
import (
44
"context"
55
"fmt"
6+
"io"
67
stdlog "log"
78
"os"
89
"os/signal"
910
"syscall"
1011

1112
"github.com/github/github-mcp-server/pkg/github"
13+
iolog "github.com/github/github-mcp-server/pkg/log"
1214
gogithub "github.com/google/go-github/v69/github"
1315
"github.com/mark3labs/mcp-go/server"
1416
log "github.com/sirupsen/logrus"
@@ -33,7 +35,8 @@ var (
3335
if err != nil {
3436
stdlog.Fatal("Failed to initialize logger:", err)
3537
}
36-
if err := runStdioServer(logger); err != nil {
38+
logCommands := viper.GetBool("enable-command-logging")
39+
if err := runStdioServer(logger, logCommands); err != nil {
3740
stdlog.Fatal("failed to run stdio server:", err)
3841
}
3942
},
@@ -45,9 +48,11 @@ func init() {
4548

4649
// Add global flags that will be shared by all commands
4750
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
51+
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
4852

4953
// Bind flag to viper
5054
viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
55+
viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
5156

5257
// Add subcommands
5358
rootCmd.AddCommand(stdioCmd)
@@ -70,12 +75,13 @@ func initLogger(outPath string) (*log.Logger, error) {
7075
}
7176

7277
logger := log.New()
78+
logger.SetLevel(log.DebugLevel)
7379
logger.SetOutput(file)
7480

7581
return logger, nil
7682
}
7783

78-
func runStdioServer(logger *log.Logger) error {
84+
func runStdioServer(logger *log.Logger, logCommands bool) error {
7985
// Create app context
8086
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
8187
defer stop()
@@ -97,7 +103,14 @@ func runStdioServer(logger *log.Logger) error {
97103
// Start listening for messages
98104
errC := make(chan error, 1)
99105
go func() {
100-
errC <- stdioServer.Listen(ctx, os.Stdin, os.Stdout)
106+
in, out := io.Reader(os.Stdin), io.Writer(os.Stdout)
107+
108+
if logCommands {
109+
loggedIO := iolog.NewIOLogger(in, out, logger)
110+
in, out = loggedIO, loggedIO
111+
}
112+
113+
errC <- stdioServer.Listen(ctx, in, out)
101114
}()
102115

103116
// Output github-mcp-server string

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ require (
66
github.com/aws/smithy-go v1.22.3
77
github.com/google/go-github/v69 v69.2.0
88
github.com/mark3labs/mcp-go v0.14.1
9+
github.com/migueleliasweb/go-github-mock v1.1.0
910
github.com/sirupsen/logrus v1.9.3
1011
github.com/spf13/cobra v1.9.1
1112
github.com/spf13/viper v1.19.0
13+
github.com/stretchr/testify v1.9.0
1214
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
1315
)
1416

1517
require (
18+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1619
github.com/fsnotify/fsnotify v1.7.0 // indirect
20+
github.com/google/go-github/v64 v64.0.0 // indirect
1721
github.com/google/go-querystring v1.1.0 // indirect
1822
github.com/google/uuid v1.6.0 // indirect
23+
github.com/gorilla/mux v1.8.0 // indirect
1924
github.com/hashicorp/hcl v1.0.0 // indirect
2025
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2126
github.com/magiconair/properties v1.8.7 // indirect
2227
github.com/mitchellh/mapstructure v1.5.0 // indirect
2328
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
29+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2430
github.com/sagikazarmark/locafero v0.4.0 // indirect
2531
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
2632
github.com/sourcegraph/conc v0.3.0 // indirect
@@ -33,6 +39,7 @@ require (
3339
go.uber.org/multierr v1.9.0 // indirect
3440
golang.org/x/sys v0.28.0 // indirect
3541
golang.org/x/text v0.21.0 // indirect
42+
golang.org/x/time v0.5.0 // indirect
3643
gopkg.in/ini.v1 v1.67.0 // indirect
3744
gopkg.in/yaml.v3 v3.0.1 // indirect
3845
)

go.sum

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT
1212
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1313
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1414
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
15+
github.com/google/go-github/v64 v64.0.0 h1:4G61sozmY3eiPAjjoOHponXDBONm+utovTKbyUb2Qdg=
16+
github.com/google/go-github/v64 v64.0.0/go.mod h1:xB3vqMQNdHzilXBiO2I+M7iEFtHf+DP/omBOv6tQzVo=
1517
github.com/google/go-github/v69 v69.2.0 h1:wR+Wi/fN2zdUx9YxSmYE0ktiX9IAR/BeePzeaUUbEHE=
1618
github.com/google/go-github/v69 v69.2.0/go.mod h1:xne4jymxLR6Uj9b7J7PyTpkMYstEMMwGZa0Aehh1azM=
1719
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
1820
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
1921
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2022
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
23+
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
24+
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
2125
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
2226
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
2327
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -28,10 +32,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2832
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2933
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
3034
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
31-
github.com/mark3labs/mcp-go v0.11.2 h1:mCxWFUTrcXOtJIn9t7F8bxAL8rpE/ZZTTnx3PU/VNdA=
32-
github.com/mark3labs/mcp-go v0.11.2/go.mod h1:cjMlBU0cv/cj9kjlgmRhoJ5JREdS7YX83xeIG9Ko/jE=
3335
github.com/mark3labs/mcp-go v0.14.0 h1:/bASI77oZbDKTQoCIxxPFu+UKn0o6OeA9C3cBrbapxM=
3436
github.com/mark3labs/mcp-go v0.14.0/go.mod h1:xBB350hekQsJAK7gJAii8bcEoWemboLm2mRm5/+KBaU=
37+
github.com/migueleliasweb/go-github-mock v1.1.0 h1:GKaOBPsrPGkAKgtfuWY8MclS1xR6MInkx1SexJucMwE=
38+
github.com/migueleliasweb/go-github-mock v1.1.0/go.mod h1:pYe/XlGs4BGMfRY4vmeixVsODHnVDDhJ9zoi0qzSMHc=
3539
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
3640
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
3741
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
@@ -84,8 +88,10 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqR
8488
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8589
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
8690
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
87-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
88-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
91+
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
92+
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
93+
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
94+
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
8995
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
9096
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9197
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=

pkg/github/code_scanning.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8+
"net/http"
89

910
"github.com/google/go-github/v69/github"
1011
"github.com/mark3labs/mcp-go/mcp"
@@ -38,7 +39,7 @@ func getCodeScanningAlert(client *github.Client) (tool mcp.Tool, handler server.
3839
}
3940
defer func() { _ = resp.Body.Close() }()
4041

41-
if resp.StatusCode != 200 {
42+
if resp.StatusCode != http.StatusOK {
4243
body, err := io.ReadAll(resp.Body)
4344
if err != nil {
4445
return nil, fmt.Errorf("failed to read response body: %w", err)
@@ -90,7 +91,7 @@ func listCodeScanningAlerts(client *github.Client) (tool mcp.Tool, handler serve
9091
}
9192
defer func() { _ = resp.Body.Close() }()
9293

93-
if resp.StatusCode != 200 {
94+
if resp.StatusCode != http.StatusOK {
9495
body, err := io.ReadAll(resp.Body)
9596
if err != nil {
9697
return nil, fmt.Errorf("failed to read response body: %w", err)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy