Skip to content

compress_schema strips user-defined 'title' properties from tool inputSchema #3576

@roanny

Description

@roanny

Problem

_single_pass_optimize() strips user-defined title property from tool inputSchema.properties when another property is named type. The title key remains in required, creating an unsatisfiable schema.

MRE

from fastmcp import FastMCP
import asyncio

mcp = FastMCP("test")

@mcp.tool()
def broken(dashboard_id: str, title: str, type: str = "vis") -> str:
    return ""

async def main():
    tools = await mcp.list_tools()
    schema = tools[0].to_mcp_tool().inputSchema
    print("title" in schema["properties"])  # False
    print("title" in schema["required"])    # True

asyncio.run(main())

Output: False then True. Expected: both True.

Cause

prune_titles heuristic in _single_pass_optimize pops title from any dict that also contains a JSON Schema keyword key (type, required, etc.) — but in the properties dict these are parameter names, not schema keywords.

FastMCP 3.1.1, Python 3.13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    too-longExcessively verbose or unedited LLM output. Condense before triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions