feat(mcp): add structured output schemas for existing tools - #344
Merged
Conversation
Adds MCP-native output schemas to 11 machine-readable tools so modern clients can discover and validate Gittensory responses. Existing CLI JSON behavior and tool result shapes are unchanged — outputSchema is metadata plus server-side validation only. Tools covered (outputSchema added): - gittensory_get_repo_context (repoContextOutputSchema) - gittensory_get_burden_forecast (freshnessResponseOutputSchema) - gittensory_get_repo_outcome_patterns (freshnessResponseOutputSchema) - gittensory_get_issue_quality (freshnessResponseOutputSchema) - gittensory_get_contributor_profile (contributorProfileOutputSchema) - gittensory_get_decision_pack (decisionPackOutputSchema) - gittensory_monitor_open_prs (openPrMonitorOutputSchema) - gittensory_explain_repo_decision (explainRepoDecisionOutputSchema) - gittensory_get_registry_changes (registryChangesOutputSchema) - gittensory_get_upstream_drift (upstreamDriftOutputSchema) - gittensory_local_status (localStatusOutputSchema) Schema design: - Declares documented top-level fields; complex/nullable/variant fields use a permissive type so validation never rejects a real response (the SDK strips unknown keys and accepts them). - All fields optional because several tools return either a result payload or a not_found / refresh envelope. - No schema declares wallet/hotkey/coldkey/financial property names, so public/private boundaries are preserved across surfaces. test/unit/mcp-output-schemas.test.ts (new, 9 tests): - Discovery: every covered tool exposes an object outputSchema; documented top-level properties present; full tool inventory preserved. - Validation: local_status, upstream_drift, registry_changes, and repo_context calls return schema-valid structuredContent (the SDK validates server-side before returning). - Safety: no output schema declares private financial field names; public tool structured content never leaks redacted financial keys. The full suite (including the api.test.ts integration tests that call these tools with seeded data) passes, confirming the schemas validate against real responses.
JSONbored
approved these changes
Jun 3, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@web-dev0521 this is a useful contract-hardening change.
A few notes:
- Adding structured output schemas to existing MCP tools makes the interface easier to consume without expanding behavior.
- The test coverage is in the right place for the server contract.
- I do not see a current-main conflict.
No code changes requested.
Validation expected:
- Keep the MCP/unit suite green through merge.
Closed
12 tasks
This was referenced Jul 2, 2026
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
outputSchemais discovery metadata plus server-side validation onlytest/unit/mcp-output-schemas.test.ts(9 tests) for schema discovery, structured-content validation, and safetyScope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typecheck— cleannpm run test:coveragelocally — 794 pass (1 skipped); pre-existing Windows failures confirmed onmainbefore this branch; coverage stays above 97%npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run build:mcpandnpm run test:mcp-packrequire the local MCP environment; the api.test.ts integration tests (which call these tools with seeded data) pass, confirming schemas validate against real responsesSafety
tools/listand validated server-side on everytools/call.Notes
Tools covered (outputSchema added):
gittensory_get_repo_contextrepoContextOutputSchemagittensory_get_burden_forecastfreshnessResponseOutputSchemagittensory_get_repo_outcome_patternsfreshnessResponseOutputSchemagittensory_get_issue_qualityfreshnessResponseOutputSchemagittensory_get_contributor_profilecontributorProfileOutputSchemagittensory_get_decision_packdecisionPackOutputSchemagittensory_monitor_open_prsopenPrMonitorOutputSchemagittensory_explain_repo_decisionexplainRepoDecisionOutputSchemagittensory_get_registry_changesregistryChangesOutputSchemagittensory_get_upstream_driftupstreamDriftOutputSchemagittensory_local_statuslocalStatusOutputSchemaSchema design rationale:
z.unknown()) so validation never rejects a real response — the MCP SDK strips unknown keys and accepts them..optional()because several tools return either a result payload or a{ status: "not_found" }/ refresh envelope depending on cache state.structuredContentagainst the schema on every call; the full integration suite calling these tools passes, proving the schemas match real outputs.Test structure (9 tests):
outputSchema; documented top-level properties present; full tool inventory preservedlocal_status,upstream_drift,registry_changes,repo_contextreturn schema-validstructuredContent