Skip to content

feat: Add output schema to select readonly tools under opt-in feature flag#2468

Open
RossTarrant wants to merge 3 commits into
mainfrom
rosstarrant/add-output-schema
Open

feat: Add output schema to select readonly tools under opt-in feature flag#2468
RossTarrant wants to merge 3 commits into
mainfrom
rosstarrant/add-output-schema

Conversation

@RossTarrant
Copy link
Copy Markdown
Contributor

@RossTarrant RossTarrant commented May 13, 2026

Summary

Adds feature-gated MCP outputSchema for selected read-only tools.

Why

Output schemas allow LLMs to anticipate the response from a tool. This proves useful to Code Mode, which needs machine-readable MCP responses for multi-step workflows.

What changed

  • Added the output_schemas feature flag and inventory registration support for gated tool output schemas.
  • Added minimal structured response types and schema inference helpers.
  • Added structured outputs for selected context, issue, label, pull request, repository, and search tools.
  • Preserved existing text content responses for back-compat when structured output is enabled.
  • Added tests for feature-flag resolution, schema registration, toolsnap handling, and structured content gating.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
    • When output_schemas is enabled, selected tools include outputSchema in tool definitions and return matching structuredContent.
  • New tool added

Prompts tested (tool changes only)

  • "List open issues in github/github-mcp-server"
  • "Search pull requests in github/github-mcp-server about output schemas"
  • "Search code in github/github-mcp-server for StructuredContent"
  • "List recent releases for github/github-mcp-server"

Security / limits

  • No security or limits impact
  • Auth / permissions considered
    • Existing tool scopes and permissions are unchanged.
  • Data exposure, filtering, or token/size limits considered
    • Structured payloads are feature-gated and use minimal response shapes while keeping legacy content populated.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
  • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

@RossTarrant RossTarrant changed the title [WIP] Add output schema to select readonly tools feat: Add output schema to select readonly tools under feature flag May 18, 2026
@RossTarrant RossTarrant changed the title feat: Add output schema to select readonly tools under feature flag feat: Add output schema to select readonly tools under opt-in feature flag May 18, 2026
@RossTarrant RossTarrant marked this pull request as ready for review May 18, 2026 14:42
@RossTarrant RossTarrant requested a review from a team as a code owner May 18, 2026 14:42
Copilot AI review requested due to automatic review settings May 18, 2026 14:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in MCP outputSchema support for selected read-only GitHub tools, with matching gated structuredContent responses while preserving legacy text responses.

Changes:

  • Adds output_schemas feature flag plumbing and registration-time output schema attachment.
  • Introduces schema inference/result helpers plus minimal response wrapper types.
  • Adds structured outputs for selected context, issue, label, PR, repository, release, and search tools, with tests and toolsnap normalization updates.
Show a summary per file
File Description
pkg/inventory/server_tool.go Adds OutputSchema, registration options, and gated schema attachment.
pkg/inventory/registry.go Enables output schema registration based on feature flag.
pkg/inventory/registry_test.go Tests feature-gated registration behavior.
pkg/inventory/builder.go Adds inventory-side output schema feature flag constant.
pkg/http/middleware/cors.go Adds a new allowed CORS request header.
pkg/github/tools_validation_test.go Validates expected tools have gated output schemas.
pkg/github/search.go Adds structured outputs/schemas to search tools.
pkg/github/search_utils.go Passes dependencies to shared search handler for feature-gated structured output.
pkg/github/repositories.go Adds structured outputs/schemas to selected repository/release tools.
pkg/github/pullrequests.go Adds structured outputs/schemas to PR listing/search tools.
pkg/github/output_schema.go Adds output schema inference and structured text result helpers.
pkg/github/output_schema_test.go Tests schema inference and structured content gating.
pkg/github/minimal_types.go Adds minimal response wrapper/result types and converters.
pkg/github/labels.go Adds structured output/schema for get_label.
pkg/github/issues.go Adds structured outputs/schemas to selected issue tools.
pkg/github/feature_flags.go Adds output_schemas to allowed feature flags.
pkg/github/feature_flags_test.go Tests explicit output schema feature resolution.
pkg/github/context_tools.go Adds structured outputs/schemas to selected context tools.
internal/toolsnaps/toolsnaps.go Normalizes snapshots and strips gated outputSchema.
internal/toolsnaps/toolsnaps_test.go Tests output schema stripping in toolsnap normalization.

Copilot's findings

  • Files reviewed: 20/20 changed files
  • Comments generated: 2

// A shallow copy of the tool is made to avoid mutating the original ServerTool.
// Panics if the tool has no handler - all tools should have handlers.
func (st *ServerTool) RegisterFunc(s *mcp.Server, deps any) {
st.RegisterFuncWithOptions(s, deps, RegisterToolOptions{})
"Mcp-Session-Id",
"Mcp-Protocol-Version",
"Last-Event-ID",
"X-Custom-Auth-Headers",
@RossTarrant RossTarrant self-assigned this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants