Skip to content

Commit c38802a

Browse files
tommaso-moroSamMorrowDrums
authored andcommitted
rename to --exclude-tools
1 parent 9c8f96f commit c38802a

File tree

11 files changed

+86
-86
lines changed

11 files changed

+86
-86
lines changed

cmd/github-mcp-server/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ var (
6161
}
6262
}
6363

64-
// Parse disallowed tools (similar to tools)
65-
var disallowedTools []string
66-
if viper.IsSet("disallowed_tools") {
67-
if err := viper.UnmarshalKey("disallowed_tools", &disallowedTools); err != nil {
68-
return fmt.Errorf("failed to unmarshal disallowed-tools: %w", err)
64+
// Parse excluded tools (similar to tools)
65+
var excludeTools []string
66+
if viper.IsSet("exclude_tools") {
67+
if err := viper.UnmarshalKey("exclude_tools", &excludeTools); err != nil {
68+
return fmt.Errorf("failed to unmarshal exclude-tools: %w", err)
6969
}
7070
}
7171

@@ -93,7 +93,7 @@ var (
9393
ContentWindowSize: viper.GetInt("content-window-size"),
9494
LockdownMode: viper.GetBool("lockdown-mode"),
9595
InsidersMode: viper.GetBool("insiders"),
96-
DisallowedTools: disallowedTools,
96+
ExcludeTools: excludeTools,
9797
RepoAccessCacheTTL: &ttl,
9898
}
9999
return ghmcp.RunStdioServer(stdioServerConfig)
@@ -135,7 +135,7 @@ func init() {
135135
// Add global flags that will be shared by all commands
136136
rootCmd.PersistentFlags().StringSlice("toolsets", nil, github.GenerateToolsetsHelp())
137137
rootCmd.PersistentFlags().StringSlice("tools", nil, "Comma-separated list of specific tools to enable")
138-
rootCmd.PersistentFlags().StringSlice("disallowed-tools", nil, "Comma-separated list of tool names to disable regardless of other settings")
138+
rootCmd.PersistentFlags().StringSlice("exclude-tools", nil, "Comma-separated list of tool names to disable regardless of other settings")
139139
rootCmd.PersistentFlags().StringSlice("features", nil, "Comma-separated list of feature flags to enable")
140140
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
141141
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
@@ -157,7 +157,7 @@ func init() {
157157
// Bind flag to viper
158158
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
159159
_ = viper.BindPFlag("tools", rootCmd.PersistentFlags().Lookup("tools"))
160-
_ = viper.BindPFlag("disallowed_tools", rootCmd.PersistentFlags().Lookup("disallowed-tools"))
160+
_ = viper.BindPFlag("exclude_tools", rootCmd.PersistentFlags().Lookup("exclude-tools"))
161161
_ = viper.BindPFlag("features", rootCmd.PersistentFlags().Lookup("features"))
162162
_ = viper.BindPFlag("dynamic_toolsets", rootCmd.PersistentFlags().Lookup("dynamic-toolsets"))
163163
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))

docs/server-configuration.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We currently support the following ways in which the GitHub MCP Server can be co
99
|---------------|---------------|--------------|
1010
| Toolsets | `X-MCP-Toolsets` header or `/x/{toolset}` URL | `--toolsets` flag or `GITHUB_TOOLSETS` env var |
1111
| Individual Tools | `X-MCP-Tools` header | `--tools` flag or `GITHUB_TOOLS` env var |
12-
| Disallowed Tools | `X-MCP-Disallowed-Tools` header | `--disallowed-tools` flag or `GITHUB_DISALLOWED_TOOLS` env var |
12+
| Exclude Tools | `X-MCP-Exclude-Tools` header | `--exclude-tools` flag or `GITHUB_EXCLUDE_TOOLS` env var |
1313
| Read-Only Mode | `X-MCP-Readonly` header or `/readonly` URL | `--read-only` flag or `GITHUB_READ_ONLY` env var |
1414
| Dynamic Mode | Not available | `--dynamic-toolsets` flag or `GITHUB_DYNAMIC_TOOLSETS` env var |
1515
| Lockdown Mode | `X-MCP-Lockdown` header | `--lockdown-mode` flag or `GITHUB_LOCKDOWN_MODE` env var |
@@ -21,11 +21,11 @@ We currently support the following ways in which the GitHub MCP Server can be co
2121

2222
## How Configuration Works
2323

24-
All configuration options are **composable**: you can combine toolsets, individual tools, disallowed tools, dynamic discovery, read-only mode and lockdown mode in any way that suits your workflow.
24+
All configuration options are **composable**: you can combine toolsets, individual tools, excluded tools, dynamic discovery, read-only mode and lockdown mode in any way that suits your workflow.
2525

2626
Note: **read-only** mode acts as a strict security filter that takes precedence over any other configuration, by disabling write tools even when explicitly requested.
2727

28-
Note: **disallowed tools** takes precedence over toolsets and individual tools — listed tools are always excluded, even if their toolset is enabled or they are explicitly added via `--tools` / `X-MCP-Tools`.
28+
Note: **excluded tools** takes precedence over toolsets and individual tools — listed tools are always excluded, even if their toolset is enabled or they are explicitly added via `--tools` / `X-MCP-Tools`.
2929

3030
---
3131

@@ -173,7 +173,7 @@ Enable entire toolsets, then add individual tools from toolsets you don't want f
173173

174174
---
175175

176-
### Disallowing Specific Tools
176+
### Excluding Specific Tools
177177

178178
**Best for:** Users who want to enable a broad toolset but need to exclude specific tools for security, compliance, or to prevent undesired behavior.
179179

@@ -190,7 +190,7 @@ Listed tools are removed regardless of any other configuration — even if their
190190
"url": "https://api.githubcopilot.com/mcp/",
191191
"headers": {
192192
"X-MCP-Toolsets": "pull_requests",
193-
"X-MCP-Disallowed-Tools": "create_pull_request,merge_pull_request"
193+
"X-MCP-Exclude-Tools": "create_pull_request,merge_pull_request"
194194
}
195195
}
196196
```
@@ -207,7 +207,7 @@ Listed tools are removed regardless of any other configuration — even if their
207207
"./cmd/github-mcp-server",
208208
"stdio",
209209
"--toolsets=pull_requests",
210-
"--disallowed-tools=create_pull_request,merge_pull_request"
210+
"--exclude-tools=create_pull_request,merge_pull_request"
211211
],
212212
"env": {
213213
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"

internal/ghmcp/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func NewStdioMCPServer(ctx context.Context, cfg github.MCPServerConfig) (*mcp.Se
135135
WithReadOnly(cfg.ReadOnly).
136136
WithToolsets(github.ResolvedEnabledToolsets(cfg.DynamicToolsets, cfg.EnabledToolsets, cfg.EnabledTools)).
137137
WithTools(github.CleanTools(cfg.EnabledTools)).
138-
WithDisallowedTools(cfg.DisallowedTools).
138+
WithExcludeTools(cfg.ExcludeTools).
139139
WithServerInstructions().
140140
WithFeatureChecker(featureChecker).
141141
WithInsidersMode(cfg.InsidersMode)
@@ -215,10 +215,10 @@ type StdioServerConfig struct {
215215
// InsidersMode indicates if we should enable experimental features
216216
InsidersMode bool
217217

218-
// DisallowedTools is a list of tool names to disable regardless of other settings.
218+
// ExcludeTools is a list of tool names to disable regardless of other settings.
219219
// These tools will be excluded even if their toolset is enabled or they are
220220
// explicitly listed in EnabledTools.
221-
DisallowedTools []string
221+
ExcludeTools []string
222222

223223
// RepoAccessCacheTTL overrides the default TTL for repository access cache entries.
224224
RepoAccessCacheTTL *time.Duration
@@ -277,7 +277,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
277277
ContentWindowSize: cfg.ContentWindowSize,
278278
LockdownMode: cfg.LockdownMode,
279279
InsidersMode: cfg.InsidersMode,
280-
DisallowedTools: cfg.DisallowedTools,
280+
ExcludeTools: cfg.ExcludeTools,
281281
Logger: logger,
282282
RepoAccessTTL: cfg.RepoAccessCacheTTL,
283283
TokenScopes: tokenScopes,

pkg/context/request.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ func IsInsidersMode(ctx context.Context) bool {
8282
return false
8383
}
8484

85-
// disallowedToolsCtxKey is a context key for disallowed tools
86-
type disallowedToolsCtxKey struct{}
85+
// excludeToolsCtxKey is a context key for excluded tools
86+
type excludeToolsCtxKey struct{}
8787

88-
// WithDisallowedTools adds the disallowed tools to the context
89-
func WithDisallowedTools(ctx context.Context, tools []string) context.Context {
90-
return context.WithValue(ctx, disallowedToolsCtxKey{}, tools)
88+
// WithExcludeTools adds the excluded tools to the context
89+
func WithExcludeTools(ctx context.Context, tools []string) context.Context {
90+
return context.WithValue(ctx, excludeToolsCtxKey{}, tools)
9191
}
9292

93-
// GetDisallowedTools retrieves the disallowed tools from the context
94-
func GetDisallowedTools(ctx context.Context) []string {
95-
if tools, ok := ctx.Value(disallowedToolsCtxKey{}).([]string); ok {
93+
// GetExcludeTools retrieves the excluded tools from the context
94+
func GetExcludeTools(ctx context.Context) []string {
95+
if tools, ok := ctx.Value(excludeToolsCtxKey{}).([]string); ok {
9696
return tools
9797
}
9898
return nil

pkg/github/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ type MCPServerConfig struct {
6262
// RepoAccessTTL overrides the default TTL for repository access cache entries.
6363
RepoAccessTTL *time.Duration
6464

65-
// DisallowedTools is a list of tool names that should be disabled regardless of
65+
// ExcludeTools is a list of tool names that should be disabled regardless of
6666
// other configuration. These tools will be excluded even if their toolset is enabled
6767
// or they are explicitly listed in EnabledTools.
68-
DisallowedTools []string
68+
ExcludeTools []string
6969

7070
// TokenScopes contains the OAuth scopes available to the token.
7171
// When non-nil, tools requiring scopes not in this list will be hidden.

pkg/http/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ func InventoryFiltersForRequest(r *http.Request, builder *inventory.Builder) *in
275275
builder = builder.WithTools(github.CleanTools(tools))
276276
}
277277

278-
if disallowed := ghcontext.GetDisallowedTools(ctx); len(disallowed) > 0 {
279-
builder = builder.WithDisallowedTools(disallowed)
278+
if excluded := ghcontext.GetExcludeTools(ctx); len(excluded) > 0 {
279+
builder = builder.WithExcludeTools(excluded)
280280
}
281281

282282
return builder

pkg/http/handler_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,26 @@ func TestInventoryFiltersForRequest(t *testing.T) {
105105
expectedTools: []string{"get_file_contents", "create_repository", "list_issues"},
106106
},
107107
{
108-
name: "disallowed tools removes specific tools",
108+
name: "excluded tools removes specific tools",
109109
contextSetup: func(ctx context.Context) context.Context {
110-
return ghcontext.WithDisallowedTools(ctx, []string{"create_repository", "issue_write"})
110+
return ghcontext.WithExcludeTools(ctx, []string{"create_repository", "issue_write"})
111111
},
112112
expectedTools: []string{"get_file_contents", "list_issues"},
113113
},
114114
{
115-
name: "disallowed tools overrides explicit tools",
115+
name: "excluded tools overrides explicit tools",
116116
contextSetup: func(ctx context.Context) context.Context {
117117
ctx = ghcontext.WithTools(ctx, []string{"list_issues", "create_repository"})
118-
ctx = ghcontext.WithDisallowedTools(ctx, []string{"create_repository"})
118+
ctx = ghcontext.WithExcludeTools(ctx, []string{"create_repository"})
119119
return ctx
120120
},
121121
expectedTools: []string{"list_issues"},
122122
},
123123
{
124-
name: "disallowed tools combines with readonly",
124+
name: "excluded tools combines with readonly",
125125
contextSetup: func(ctx context.Context) context.Context {
126126
ctx = ghcontext.WithReadonly(ctx, true)
127-
ctx = ghcontext.WithDisallowedTools(ctx, []string{"list_issues"})
127+
ctx = ghcontext.WithExcludeTools(ctx, []string{"list_issues"})
128128
return ctx
129129
},
130130
expectedTools: []string{"get_file_contents"},
@@ -293,36 +293,36 @@ func TestHTTPHandlerRoutes(t *testing.T) {
293293
expectedTools: []string{"get_file_contents", "create_repository", "list_issues", "create_issue", "list_pull_requests", "create_pull_request", "hidden_by_holdback"},
294294
},
295295
{
296-
name: "X-MCP-Disallowed-Tools header removes specific tools",
296+
name: "X-MCP-Exclude-Tools header removes specific tools",
297297
path: "/",
298298
headers: map[string]string{
299-
headers.MCPDisallowedToolsHeader: "create_issue,create_pull_request",
299+
headers.MCPExcludeToolsHeader: "create_issue,create_pull_request",
300300
},
301301
expectedTools: []string{"get_file_contents", "create_repository", "list_issues", "list_pull_requests", "hidden_by_holdback"},
302302
},
303303
{
304-
name: "X-MCP-Disallowed-Tools with toolset header",
304+
name: "X-MCP-Exclude-Tools with toolset header",
305305
path: "/",
306306
headers: map[string]string{
307-
headers.MCPToolsetsHeader: "issues",
308-
headers.MCPDisallowedToolsHeader: "create_issue",
307+
headers.MCPToolsetsHeader: "issues",
308+
headers.MCPExcludeToolsHeader: "create_issue",
309309
},
310310
expectedTools: []string{"list_issues"},
311311
},
312312
{
313-
name: "X-MCP-Disallowed-Tools overrides X-MCP-Tools",
313+
name: "X-MCP-Exclude-Tools overrides X-MCP-Tools",
314314
path: "/",
315315
headers: map[string]string{
316-
headers.MCPToolsHeader: "list_issues,create_issue",
317-
headers.MCPDisallowedToolsHeader: "create_issue",
316+
headers.MCPToolsHeader: "list_issues,create_issue",
317+
headers.MCPExcludeToolsHeader: "create_issue",
318318
},
319319
expectedTools: []string{"list_issues"},
320320
},
321321
{
322-
name: "X-MCP-Disallowed-Tools with readonly path",
322+
name: "X-MCP-Exclude-Tools with readonly path",
323323
path: "/readonly",
324324
headers: map[string]string{
325-
headers.MCPDisallowedToolsHeader: "list_issues",
325+
headers.MCPExcludeToolsHeader: "list_issues",
326326
},
327327
expectedTools: []string{"get_file_contents", "list_pull_requests", "hidden_by_holdback"},
328328
},

pkg/http/headers/headers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const (
4141
MCPLockdownHeader = "X-MCP-Lockdown"
4242
// MCPInsidersHeader indicates whether insiders mode is enabled for early access features.
4343
MCPInsidersHeader = "X-MCP-Insiders"
44-
// MCPDisallowedToolsHeader is a comma-separated list of MCP tools that should be
44+
// MCPExcludeToolsHeader is a comma-separated list of MCP tools that should be
4545
// disabled regardless of other settings or header values.
46-
MCPDisallowedToolsHeader = "X-MCP-Disallowed-Tools"
46+
MCPExcludeToolsHeader = "X-MCP-Exclude-Tools"
4747
// MCPFeaturesHeader is a comma-separated list of feature flags to enable.
4848
MCPFeaturesHeader = "X-MCP-Features"
4949

pkg/http/middleware/request_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func WithRequestConfig(next http.Handler) http.Handler {
3535
ctx = ghcontext.WithLockdownMode(ctx, true)
3636
}
3737

38-
// Disallowed tools
39-
if disallowedTools := headers.ParseCommaSeparated(r.Header.Get(headers.MCPDisallowedToolsHeader)); len(disallowedTools) > 0 {
40-
ctx = ghcontext.WithDisallowedTools(ctx, disallowedTools)
38+
// Excluded tools
39+
if excludeTools := headers.ParseCommaSeparated(r.Header.Get(headers.MCPExcludeToolsHeader)); len(excludeTools) > 0 {
40+
ctx = ghcontext.WithExcludeTools(ctx, excludeTools)
4141
}
4242

4343
// Insiders mode

pkg/inventory/builder.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ func (b *Builder) WithFilter(filter ToolFilter) *Builder {
141141
return b
142142
}
143143

144-
// WithDisallowedTools specifies tools that should be disabled regardless of other settings.
144+
// WithExcludeTools specifies tools that should be disabled regardless of other settings.
145145
// These tools will be excluded even if their toolset is enabled or they are in the
146146
// additional tools list. This takes precedence over all other tool enablement settings.
147147
// Input is cleaned (trimmed, deduplicated) before applying.
148148
// Returns self for chaining.
149-
func (b *Builder) WithDisallowedTools(toolNames []string) *Builder {
149+
func (b *Builder) WithExcludeTools(toolNames []string) *Builder {
150150
cleaned := cleanTools(toolNames)
151151
if len(cleaned) > 0 {
152-
b.filters = append(b.filters, CreateDisallowedToolsFilter(cleaned))
152+
b.filters = append(b.filters, CreateExcludeToolsFilter(cleaned))
153153
}
154154
return b
155155
}
@@ -163,12 +163,12 @@ func (b *Builder) WithInsidersMode(enabled bool) *Builder {
163163
return b
164164
}
165165

166-
// CreateDisallowedToolsFilter creates a ToolFilter that excludes tools by name.
167-
// Any tool whose name appears in the disallowed list will be filtered out.
166+
// CreateExcludeToolsFilter creates a ToolFilter that excludes tools by name.
167+
// Any tool whose name appears in the excluded list will be filtered out.
168168
// The input slice should already be cleaned (trimmed, deduplicated).
169-
func CreateDisallowedToolsFilter(disallowed []string) ToolFilter {
170-
set := make(map[string]struct{}, len(disallowed))
171-
for _, name := range disallowed {
169+
func CreateExcludeToolsFilter(excluded []string) ToolFilter {
170+
set := make(map[string]struct{}, len(excluded))
171+
for _, name := range excluded {
172172
set[name] = struct{}{}
173173
}
174174
return func(_ context.Context, tool *ServerTool) (bool, error) {

0 commit comments

Comments
 (0)