MEDIUM SEVERITYCONFIRMED
compress_schema mutates input dict in-place despite immutable design claim
Package
fastmcp
Version
2.14.5
Verified
2026-03-28
Description
fastmcp's `compress_schema` function mutates its input dictionary in-place: `result is schema` is `True` after the call, the original title is removed, and pruned properties are deleted from the original. The docstring claims 'immutable design' — this is false.
Reproduction
from fastmcp.utilities.json_schema import compress_schema
schema = {'type': 'object', 'title': 'Test', 'properties': {'ctx': {}, 'name': {}}, 'required': ['name']}
result = compress_schema(schema, prune_params=['ctx'], prune_titles=True)
assert result is schema # True — same object
assert 'title' not in schema # True — original mutated