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

Commitf9427ab

Browse files
committed
Ensure toolsets are configurable via env var
1 parent4a39c03 commitf9427ab

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ var (
4545
stdlog.Fatal("Failed to initialize logger:",err)
4646
}
4747

48-
enabledToolsets:=viper.GetStringSlice("toolsets")
48+
// If you're wondering why we're not using viper.GetStringSlice("toolsets"),
49+
// it's because viper doesn't handle comma-separated values correctly for env
50+
// vars when using GetStringSlice.
51+
// https://github.com/spf13/viper/issues/380
52+
varenabledToolsets []string
53+
err=viper.UnmarshalKey("toolsets",&enabledToolsets)
54+
iferr!=nil {
55+
stdlog.Fatal("Failed to unmarshal toolsets:",err)
56+
}
4957

5058
logCommands:=viper.GetBool("enable-command-logging")
5159
cfg:=runConfig{

‎e2e/e2e_test.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"os"
99
"os/exec"
10+
"slices"
1011
"sync"
1112
"testing"
1213
"time"
@@ -115,6 +116,9 @@ func setupMCPClient(t *testing.T, options ...ClientOption) *mcpClient.Client {
115116
t.Log("Starting Stdio MCP client...")
116117
client,err:=mcpClient.NewStdioMCPClient(args[0], []string{},args[1:]...)
117118
require.NoError(t,err,"expected to create client successfully")
119+
t.Cleanup(func() {
120+
require.NoError(t,client.Close(),"expected to close client successfully")
121+
})
118122

119123
// Initialize the client
120124
ctx,cancel:=context.WithTimeout(context.Background(),5*time.Second)
@@ -166,5 +170,33 @@ func TestGetMe(t *testing.T) {
166170
require.NoError(t,err,"expected to get user successfully")
167171
require.Equal(t,trimmedContent.Login,*user.Login,"expected login to match")
168172

169-
require.NoError(t,mcpClient.Close(),"expected to close client successfully")
173+
}
174+
175+
funcTestToolsets(t*testing.T) {
176+
mcpClient:=setupMCPClient(
177+
t,
178+
WithEnvVars(map[string]string{
179+
"GITHUB_TOOLSETS":"repos,issues",
180+
}),
181+
)
182+
183+
ctx,cancel:=context.WithTimeout(context.Background(),5*time.Second)
184+
defercancel()
185+
186+
request:= mcp.ListToolsRequest{}
187+
response,err:=mcpClient.ListTools(ctx,request)
188+
require.NoError(t,err,"expected to list tools successfully")
189+
190+
// We could enumerate the tools here, but we'll need to expose that information
191+
// declaratively in the MCP server, so for the moment let's just check the existence
192+
// of an issue and repo tool, and the non-existence of a pull_request tool.
193+
vartoolsContains=func(expectedNamestring)bool {
194+
returnslices.ContainsFunc(response.Tools,func(tool mcp.Tool)bool {
195+
returntool.Name==expectedName
196+
})
197+
}
198+
199+
require.True(t,toolsContains("get_issue"),"expected to find 'get_issue' tool")
200+
require.True(t,toolsContains("list_branches"),"expected to find 'list_branches' tool")
201+
require.False(t,toolsContains("get_pull_request"),"expected not to find 'get_pull_request' tool")
170202
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp