Skip to content

fix(codegen): sanitize progressive JSDoc metadata#100

Merged
bug-ops merged 2 commits into
bug-ops:masterfrom
sarvesh1327:fix/progressive-jsdoc-sanitization
Jun 7, 2026
Merged

fix(codegen): sanitize progressive JSDoc metadata#100
bug-ops merged 2 commits into
bug-ops:masterfrom
sarvesh1327:fix/progressive-jsdoc-sanitization

Conversation

@sarvesh1327

Copy link
Copy Markdown
Contributor

Summary

  • sanitize schema descriptions before rendering them into generated progressive tool JSDoc
  • sanitize property descriptions plus category/keyword/short-description metadata in tool and index contexts
  • add a regression test covering raw */ and newline injection from schema/category metadata

Test Plan

  • cargo test -p mcp-execution-codegen progressive::generator --quiet
  • cargo fmt --check
  • cargo test -p mcp-execution-codegen --quiet
  • cargo clippy -p mcp-execution-codegen --all-targets --all-features -- -D warnings

@codecov-commenter

codecov-commenter commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   89.83%   89.93%   +0.10%     
==========================================
  Files          33       33              
  Lines        7830     7891      +61     
==========================================
+ Hits         7034     7097      +63     
+ Misses        796      794       -2     
Flag Coverage Δ
mcp-cli 89.93% <100.00%> (+0.10%) ⬆️
mcp-codegen 89.93% <100.00%> (+0.10%) ⬆️
mcp-core 89.93% <100.00%> (+0.10%) ⬆️
mcp-files 89.93% <100.00%> (+0.10%) ⬆️
mcp-introspector 89.93% <100.00%> (+0.10%) ⬆️
mcp-server 89.93% <100.00%> (+0.10%) ⬆️
mcp-skill 89.93% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
crates/mcp-codegen/src/progressive/generator.rs 97.05% <100.00%> (+0.80%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the progressive TypeScript code generator against JSDoc comment injection by sanitizing server-controlled schema descriptions and categorization metadata before they’re interpolated into generated /** ... */ blocks.

Changes:

  • Sanitize input_schema description fields (via recursive traversal) before rendering JSDoc in progressive tool templates.
  • Sanitize tool categorization metadata (category, keywords, short_description) in both per-tool and index contexts.
  • Add a regression test to ensure raw */ and newline injection content does not appear in generated output.

Comment thread crates/mcp-codegen/src/progressive/generator.rs Outdated
@bug-ops
bug-ops force-pushed the fix/progressive-jsdoc-sanitization branch from 11f9c14 to e49ce37 Compare June 4, 2026 19:14
@github-actions github-actions Bot added area: codegen Code generation crate: mcp-codegen Changes to mcp-codegen crate (TypeScript code generation) labels Jun 4, 2026
@bug-ops
bug-ops force-pushed the fix/progressive-jsdoc-sanitization branch from e49ce37 to 2e51e28 Compare June 4, 2026 19:19
@bug-ops

bug-ops commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Thank you!

@bug-ops
bug-ops merged commit 7b4c953 into bug-ops:master Jun 7, 2026
13 checks passed
@bug-ops bug-ops mentioned this pull request Jun 7, 2026
5 tasks
bug-ops added a commit that referenced this pull request Jun 7, 2026
* release: prepare v0.7.1

Bump workspace version from 0.7.0 to 0.7.1 and finalize CHANGELOG.md
release section with all fixes accumulated since v0.7.0.

* docs(changelog): add missing entries for 0.7.1 from git history

Add #100 (codegen: extended JSDoc sanitization to input_schema and
categorization fields), #98 (cli: corrected binary name in help text),
and all dependabot dependency bumps (#95#101) to the [0.7.1] section.

* docs: update all README files for v0.7.1

- Root README: update test count to 657
- mcp-cli: add --name and --dry-run flags to generate command docs
- mcp-codegen: add Security section documenting JSDoc sanitization scope
- mcp-server: fix config path (~/.config/claude/ -> ~/.claude/)
bug-ops added a commit that referenced this pull request Jul 9, 2026
#122)

create_tool_context() now falls back short_description to the tool's own
description when no LLM categorization is available, so the generated
header JSDoc always includes @description. Previously this tag was
omitted on the plain generate CLI path, causing the skill command to
fall back to uninformative "{tool_name} tool" placeholders in SKILL.md.

Also documents that ToolContext.input_schema always holds the
JSDoc-sanitized schema (already the case since PR #100) and adds a
regression test locking in that invariant.

Closes #94, closes #102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: codegen Code generation crate: mcp-codegen Changes to mcp-codegen crate (TypeScript code generation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants