Skip to content

Commit 905f094

Browse files
olaservoclaude
andcommitted
refactor(server): remove legacy InstructionsFunc / WithServerInstructions machinery
Skills are the only guidance surface going forward; the per-toolset inline instruction system is no longer needed. This removes ~308 lines of toolset instruction generation. - Delete pkg/github/toolset_instructions.go (5 generate*ToolsetInstructions helpers), pkg/inventory/instructions.go (generateInstructions aggregator), and pkg/inventory/instructions_test.go (~265 lines of tests). - Remove the InstructionsFunc field from inventory.ToolsetMetadata, and drop it from the 5 toolsets that used it (Context, Issues, PullRequests, Discussions, Projects). - Remove the generateInstructions field, WithServerInstructions() method, and the conditional in Builder.Build() that called generateInstructions(r). - Remove the instructions field and Instructions() method from Inventory. - Drop the .WithServerInstructions() call from NewStdioMCPServer (internal/ghmcp/server.go) and from DefaultInventoryFactory (pkg/http/handler.go). - Drop `Instructions: inv.Instructions(),` from the serverOpts assembled in NewMCPServer (pkg/github/server.go). Inspired by the cleanup in github#2374. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 86f0549 commit 905f094

10 files changed

Lines changed: 20 additions & 463 deletions

File tree

internal/ghmcp/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ func NewStdioMCPServer(ctx context.Context, cfg github.MCPServerConfig) (*mcp.Se
143143
WithToolsets(github.ResolvedEnabledToolsets(cfg.DynamicToolsets, cfg.EnabledToolsets, cfg.EnabledTools)).
144144
WithTools(github.CleanTools(cfg.EnabledTools)).
145145
WithExcludeTools(cfg.ExcludeTools).
146-
WithServerInstructions().
147146
WithFeatureChecker(featureChecker)
148147

149148
// Apply token scope filtering if scopes are known (for PAT filtering)

pkg/github/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ type MCPServerOption func(*mcp.ServerOptions)
8181
func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependencies, inv *inventory.Inventory, middleware ...mcp.Middleware) (*mcp.Server, error) {
8282
// Create the MCP server
8383
serverOpts := &mcp.ServerOptions{
84-
Instructions: inv.Instructions(),
8584
Logger: cfg.Logger,
8685
CompletionHandler: CompletionsHandler(deps.GetClient),
8786
}

pkg/github/tools.go

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ var (
2929
Icon: "check-circle",
3030
}
3131
ToolsetMetadataContext = inventory.ToolsetMetadata{
32-
ID: "context",
33-
Description: "Tools that provide context about the current user and GitHub context you are operating in",
34-
Default: true,
35-
Icon: "person",
36-
InstructionsFunc: generateContextToolsetInstructions,
32+
ID: "context",
33+
Description: "Tools that provide context about the current user and GitHub context you are operating in",
34+
Default: true,
35+
Icon: "person",
3736
}
3837
ToolsetMetadataRepos = inventory.ToolsetMetadata{
3938
ID: "repos",
@@ -47,18 +46,16 @@ var (
4746
Icon: "git-branch",
4847
}
4948
ToolsetMetadataIssues = inventory.ToolsetMetadata{
50-
ID: "issues",
51-
Description: "GitHub Issues related tools",
52-
Default: true,
53-
Icon: "issue-opened",
54-
InstructionsFunc: generateIssuesToolsetInstructions,
49+
ID: "issues",
50+
Description: "GitHub Issues related tools",
51+
Default: true,
52+
Icon: "issue-opened",
5553
}
5654
ToolsetMetadataPullRequests = inventory.ToolsetMetadata{
57-
ID: "pull_requests",
58-
Description: "GitHub Pull Request related tools",
59-
Default: true,
60-
Icon: "git-pull-request",
61-
InstructionsFunc: generatePullRequestsToolsetInstructions,
55+
ID: "pull_requests",
56+
Description: "GitHub Pull Request related tools",
57+
Default: true,
58+
Icon: "git-pull-request",
6259
}
6360
ToolsetMetadataUsers = inventory.ToolsetMetadata{
6461
ID: "users",
@@ -97,10 +94,9 @@ var (
9794
Icon: "bell",
9895
}
9996
ToolsetMetadataDiscussions = inventory.ToolsetMetadata{
100-
ID: "discussions",
101-
Description: "GitHub Discussions related tools",
102-
Icon: "comment-discussion",
103-
InstructionsFunc: generateDiscussionsToolsetInstructions,
97+
ID: "discussions",
98+
Description: "GitHub Discussions related tools",
99+
Icon: "comment-discussion",
104100
}
105101
ToolsetMetadataGists = inventory.ToolsetMetadata{
106102
ID: "gists",
@@ -113,10 +109,9 @@ var (
113109
Icon: "shield",
114110
}
115111
ToolsetMetadataProjects = inventory.ToolsetMetadata{
116-
ID: "projects",
117-
Description: "GitHub Projects related tools",
118-
Icon: "project",
119-
InstructionsFunc: generateProjectsToolsetInstructions,
112+
ID: "projects",
113+
Description: "GitHub Projects related tools",
114+
Icon: "project",
120115
}
121116
ToolsetMetadataStargazers = inventory.ToolsetMetadata{
122117
ID: "stargazers",

pkg/github/toolset_instructions.go

Lines changed: 0 additions & 108 deletions
This file was deleted.

pkg/http/handler.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ func DefaultInventoryFactory(cfg *ServerConfig, t translations.TranslationHelper
284284
b = InventoryFiltersForRequest(r, b)
285285
b = PATScopeFilter(b, r, scopeFetcher)
286286

287-
b.WithServerInstructions()
288-
289287
return b.Build()
290288
}
291289
}

pkg/inventory/builder.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ type Builder struct {
5050
toolsetIDs []string // raw input, processed at Build()
5151
toolsetIDsIsNil bool // tracks if nil was passed (nil = defaults)
5252
additionalTools []string // raw input, processed at Build()
53-
featureChecker FeatureFlagChecker
54-
filters []ToolFilter // filters to apply to all tools
55-
generateInstructions bool
53+
featureChecker FeatureFlagChecker
54+
filters []ToolFilter // filters to apply to all tools
5655
}
5756

5857
// NewBuilder creates a new Builder.
@@ -95,11 +94,6 @@ func (b *Builder) WithReadOnly(readOnly bool) *Builder {
9594
return b
9695
}
9796

98-
func (b *Builder) WithServerInstructions() *Builder {
99-
b.generateInstructions = true
100-
return b
101-
}
102-
10397
// WithToolsets specifies which toolsets should be enabled.
10498
// Special keywords:
10599
// - "all": enables all toolsets
@@ -267,10 +261,6 @@ func (b *Builder) Build() (*Inventory, error) {
267261
}
268262
}
269263

270-
if b.generateInstructions {
271-
r.instructions = generateInstructions(r)
272-
}
273-
274264
return r, nil
275265
}
276266

pkg/inventory/instructions.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)