Repository: gradio-app/gradio
File: gradio/mcp.py (Python)

Code before:
            description, parameters = self.get_fn_description(block_fn, tool_name)
            schema, filedata_positions = self.get_input_schema(tool_name, parameters)
            if len(filedata_positions) > 0 and not file_data_present:
                file_data_present = True

            type_hints = utils.get_type_hints(block_fn.fn)
            required_headers = []
            for param_name, type_hint in type_hints.items():
                if type_hint is Header or type_hint is Optional[Header]:
                    header_name = param_name.replace("_", "-").lower()
                    required_headers.append(header_name)

            mcp_type = "tool"  # Default
            if hasattr(block_fn.fn, "_mcp_type"):
                mcp_type = block_fn.fn._mcp_type

            meta = {"file_data_present": file_data_present, "mcp_type": mcp_type}
            if required_headers:
                meta["headers"] = required_headers

            info = {
                "name": tool_name,
                "description": description,
                "inputSchema": schema,
                "meta": meta,
                "endpoint_name": block_fn.api_name,
            }
            schemas.append(info)

        return JSONResponse(schemas)

    def simplify_filedata_schema(
        self, schema: dict[str, Any]
    ) -> tuple[dict[str, Any], list[list[str | int]]]:
        """
        Parses a schema of a Gradio app API to identify positions of FileData objects. Replaces them with base64
        strings while keeping track of their positions so that they can be converted back to FileData objects
        later.

        Parameters:
            schema: The original schema of the Gradio app API.

        Returns:
            A tuple containing the simplified schema and the positions of the FileData objects.
        """

        def is_gradio_filedata(obj: Any, defs: dict[str, Any]) -> bool:
            if not isinstance(obj, dict):
                return False

            if "$ref" in obj:

Review comment (suggestion):
Should we just include this in the "meta" dict, less likely to break any downstream usage (I'm thinking of HF MCP in particular)

Code after:
            description, parameters = self.get_fn_description(block_fn, tool_name)
            schema, filedata_positions = self.get_input_schema(tool_name, parameters)
            if len(filedata_positions) > 0 and not file_data_present:
                file_data_present = True

            type_hints = utils.get_type_hints(block_fn.fn)
            required_headers = []
            for param_name, type_hint in type_hints.items():
                if type_hint is Header or type_hint is Optional[Header]:
                    header_name = param_name.replace("_", "-").lower()
                    required_headers.append(header_name)

            mcp_type = "tool"  # Default
            if hasattr(block_fn.fn, "_mcp_type"):
                mcp_type = block_fn.fn._mcp_type

            meta = {
                "file_data_present": file_data_present,
                "mcp_type": mcp_type,
                "endpoint_name": block_fn.api_name,
            }
            if required_headers:
                meta["headers"] = required_headers

            info = {
                "name": tool_name,
                "description": description,
                "inputSchema": schema,
                "meta": meta,
            }
            schemas.append(info)

        return JSONResponse(schemas)

    def simplify_filedata_schema(
        self, schema: dict[str, Any]
    ) -> tuple[dict[str, Any], list[list[str | int]]]:
        """
        Parses a schema of a Gradio app API to identify positions of FileData objects. Replaces them with base64
        strings while keeping track of their positions so that they can be converted back to FileData objects
        later.

        Parameters:
            schema: The original schema of the Gradio app API.

        Returns:
            A tuple containing the simplified schema and the positions of the FileData objects.
        """

        def is_gradio_filedata(obj: Any, defs: dict[str, Any]) -> bool:
            if not isinstance(obj, dict):