Files
Sam Morrow 014fd17fa3 feat: gate issue_write and get_issue behind remote_mcp_issue_fields flag
Ports the gating from PR #2553 onto main (the original merge landed on a
stack base that did not make it to main).

Changes:
- pkg/inventory: FeatureFlagDisable becomes []string (any-listed-on → hide).
  FeatureFlagEnable stays as a single string. This avoids the AND-of-enable
  semantics from the earlier proposal, which encoded dependencies rather
  than rollout knobs and had no real call site. Disable-OR is the case
  that does need the slice (LegacyIssueWrite below).
- pkg/github/issues.go: split IssueWrite into IssueWrite (flag-enabled,
  exposes issue_fields) and LegacyIssueWrite (flag-disabled, omits it).
  Both register as 'issue_write'; mutually exclusive flag annotations
  pick exactly one at runtime. Refactored into a shared buildIssueWrite
  helper instead of duplicating the ~250-line tool definition.
- pkg/github/issues.go: GetIssue field_values enrichment now requires
  the flag at runtime. The verbose REST IssueFieldValues is always
  cleared from the response.
- Existing single-flag Disable call sites converted to slices.
- New toolsnap variant issue_write_ff_remote_mcp_issue_fields.snap; the
  canonical issue_write.snap is owned by LegacyIssueWrite.
- README + flag docs regenerated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-28 13:11:29 +02:00

49 lines
2.0 KiB
Go

package inventory
import "github.com/modelcontextprotocol/go-sdk/mcp"
// ResourceHandlerFunc is a function that takes dependencies and returns an MCP resource handler.
// This allows resources to be defined statically while their handlers are generated
// on-demand with the appropriate dependencies.
type ResourceHandlerFunc func(deps any) mcp.ResourceHandler
// ServerResourceTemplate pairs a resource template with its toolset metadata.
type ServerResourceTemplate struct {
Template mcp.ResourceTemplate
// HandlerFunc generates the handler when given dependencies.
// This allows resources to be passed around without handlers being set up,
// and handlers are only created when needed.
HandlerFunc ResourceHandlerFunc
// Toolset identifies which toolset this resource belongs to
Toolset ToolsetMetadata
// FeatureFlagEnable specifies a feature flag that must be enabled for this resource
// to be available. If set and the flag is not enabled, the resource is omitted.
FeatureFlagEnable string
// FeatureFlagDisable specifies feature flags that, when any is enabled, cause this
// resource to be omitted. Used to disable resources when a feature flag is on.
FeatureFlagDisable []string
}
// HasHandler returns true if this resource has a handler function.
func (sr *ServerResourceTemplate) HasHandler() bool {
return sr.HandlerFunc != nil
}
// Handler returns a resource handler by calling HandlerFunc with the given dependencies.
// Panics if HandlerFunc is nil - all resources should have handlers.
func (sr *ServerResourceTemplate) Handler(deps any) mcp.ResourceHandler {
if sr.HandlerFunc == nil {
panic("HandlerFunc is nil for resource: " + sr.Template.Name)
}
return sr.HandlerFunc(deps)
}
// NewServerResourceTemplate creates a new ServerResourceTemplate with toolset metadata.
func NewServerResourceTemplate(toolset ToolsetMetadata, resourceTemplate mcp.ResourceTemplate, handlerFn ResourceHandlerFunc) ServerResourceTemplate {
return ServerResourceTemplate{
Template: resourceTemplate,
HandlerFunc: handlerFn,
Toolset: toolset,
}
}