feat: Add output schema to select readonly tools under opt-in feature flag - #2468
Open
RossTarrant wants to merge 3 commits into
Open
feat: Add output schema to select readonly tools under opt-in feature flag#2468RossTarrant wants to merge 3 commits into
RossTarrant wants to merge 3 commits into
Conversation
RossTarrant
marked this pull request as ready for review
May 18, 2026 14:42
Contributor
There was a problem hiding this comment.
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_schemasfeature 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", |
pachecocordovamoiseseduardo-byte
approved these changes
May 23, 2026
13 tasks
olaservo
added a commit
to olaservo/github-mcp-server
that referenced
this pull request
Aug 10, 2026
Adds feature-gated MCP `outputSchema` and `structuredContent`, targeting the tools whose response shape varies by their `method` argument — the ones both existing upstream attempts (github#2382, github#2468) explicitly set aside as "multi-method tool returning different shapes". Protocol revision 2026-07-28 (SEP-2106) is what makes these expressible. 2025-11-25 typed `outputSchema` as a closed object shape restricted to `type: "object"` at the root, and `structuredContent` as a JSON object; the draft widens both to any valid JSON Schema 2020-12 and any JSON value. Two orthogonal gates: - `output_schemas` feature flag controls rollout. - The negotiated protocol version, read per request, controls which schema shapes are legal. Object-root schemas ship to every client; non-object roots and non-object structuredContent are withheld below 2026-07-28. Unions use `anyOf`, never `oneOf`. `oneOf` requires exactly one branch to match and provably fails here: actions_run_trigger has four structurally identical branches, an empty array satisfies every array branch, and an issue_read `get` on a sub-issue also satisfies the `get_parent` branch. A test asserts no schema ever contains "oneOf". Handlers are unchanged. Rather than thread typed values out of ~20 call sites, structuredContent is mirrored from the serialized-JSON text block each handler already emits — the relationship the spec itself describes. This is byte-exact, so it cannot drift from the text content and preserves number formatting a re-marshal would lose. It applies only to tools that declare a schema, leaving the other ~120 tools byte-identical on the wire. Because the schema lives on ServerTool and is copied onto a duplicate mcp.Tool at registration, Tool.OutputSchema stays nil in the default surface and none of the 123 committed toolsnaps change. Tools covered: actions_get, actions_list, actions_run_trigger, discussion_comment_write, issue_dependency_read (single shape, not a union), issue_read, pull_request_read. Also fixes three adjacent bugs found along the way: - GetSubIssues could emit the literal `null`: go-github declares `var subIssues []*SubIssue` and leaves it nil on an empty body, which marshals to null rather than []. Every sibling method normalises; this one did not. - sub_issue_write's `method` property had no `enum`, so its values existed only in prose while dispatch accepted exactly add/remove/reprioritize. - convertJSONTextResultToCSV cleared StructuredContent, which would have made csv_output silently disable output_schemas for every list_* tool. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds feature-gated MCP
outputSchemafor 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
output_schemasfeature flag and inventory registration support for gated tool output schemas.contentresponses for back-compat when structured output is enabled.MCP impact
output_schemasis enabled, selected tools includeoutputSchemain tool definitions and return matchingstructuredContent.Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs