Skip to content

Windows startup crash due to UnicodeDecodeError when loading skills #4084

Closed

Description

@jmarenin

What happened?

Description

SkillProvider._load_skill() calls Path.read_text() without specifying an encoding parameter. On Windows, this defaults to the system locale encoding (typically cp1252), which fails when SKILL.md files contain UTF-8 characters like emoji (✅, ❌, →).

This causes the MCP server to exit immediately with exit code 1 on Windows when loading skills that contain UTF-8 characters.

Error

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position XXX: character maps to <undefined>

Root Cause

In fastmcp/server/providers/skills/skill_provider.py, approximately line 13:

content = main_file.read_text()  # ❌ No encoding specified

Without an explicit encoding parameter, Python uses the system's default encoding, which is cp1252 on Windows. This cannot decode UTF-8 emoji and special characters.

Example Code

from pathlib import Path
from tempfile import TemporaryDirectory
from fastmcp.server.providers.skills import SkillsDirectoryProvider

# Create a temporary skill directory with UTF-8 content
with TemporaryDirectory() as tmpdir:
    skill_dir = Path(tmpdir) / "test-skill"
    skill_dir.mkdir()
    
    # Create SKILL.md with UTF-8 emoji characters
    skill_file = skill_dir / "SKILL.md"
    skill_file.write_text(
        """---
name: test-skill
description: Test skill with UTF-8 characters
---

# Test Skill

- ✅ Success indicator
- ❌ Failure indicator  
- → Arrow symbol
""",
        encoding="utf-8"
    )
    
    # This will fail on Windows with UnicodeDecodeError
    provider = SkillsDirectoryProvider(roots=skill_dir.parent)
    print("Skills loaded successfully")

Version Information

FastMCP version:                                                         3.2.4
MCP version:                                                            1.27.0
Python version:                                                         3.12.0

Activity

  1. added
    bug
    on Apr 29, 2026
  2. added
    server
    on Apr 29, 2026
  3. doneman536 commented on May 3, 2026

    @doneman536
    Contributor

    In upcoming versions of python utf-8 is supported by default. Till then we can have this.

  4. added a commit that references this issue on May 7, 2026
  5. jlowin commented on May 20, 2026

    @jlowin
    Member

    Closed in #4092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugserver

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions