Skip to content

Skills with a UTF-8 BOM lose their frontmatter metadata #4532

Closed

Description

@ShuyingZhang

What happened?

A SKILL.md file saved as UTF-8 with a byte order mark (BOM) is discovered as a skill, but its YAML frontmatter is not parsed. The skill's frontmatter becomes empty and its description becomes the literal opening delimiter ("\ufeff---") instead of the configured description.

YAML 1.2 permits a BOM at the beginning of a character stream, and UTF-8-with-BOM files are still produced by some editors, particularly on Windows.

Example Code

from pathlib import Path
from tempfile import TemporaryDirectory

from fastmcp.server.providers.skills import SkillProvider

with TemporaryDirectory() as temp_dir:
    skill_dir = Path(temp_dir) / "bom-skill"
    skill_dir.mkdir()
    (skill_dir / "SKILL.md").write_text(
        "\ufeff---\n"
        "name: bom-skill\n"
        "description: Skill saved with a UTF-8 BOM\n"
        "---\n"
        "# BOM Skill\n",
        encoding="utf-8",
    )

    provider = SkillProvider(skill_dir)
    print(provider.skill_info.description)
    print(provider.skill_info.frontmatter)

Actual output:

---
{}

Expected output:

Skill saved with a UTF-8 BOM
{'name': 'bom-skill', 'description': 'Skill saved with a UTF-8 BOM'}

Version Information

FastMCP: main at 66c0270
Python: 3.12.12
Platform: macOS arm64

Activity

  1. hxaxd commented on Jul 18, 2026

    @hxaxd
    Contributor

    I reproduced this in SkillProvider. Python's UTF-8 decoder correctly preserves a leading BOM, but parse_frontmatter() checks for --- at index zero, so it misses the otherwise valid metadata and treats \ufeff--- as the skill description.

    I'd like to submit a small PR that removes one leading BOM at the parser boundary before delimiter detection and adds provider-level regression coverage. This would leave file decoding and the served SKILL.md resource unchanged.

    Would you be open to a PR with this approach?

  2. Solaris-star commented on Jul 20, 2026

    @Solaris-star

    I'd like to take this — PR already up at #4563 (strips UTF-8 BOM in parse_frontmatter + unit test). Please assign me so the PR assignment gate can reopen it.

  3. added
    bug
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions