skill_to_mcp.skill_parser#

Skill parser module for processing SKILL.md files and skill directories.

Classes#

SkillMetadata

Represents metadata from a SKILL.md file.

SkillParser

Parser for Claude Skills following the SKILL.md format.

Module Contents#

class skill_to_mcp.skill_parser.SkillMetadata(name: str, description: str, skill_path: pathlib.Path)#

Represents metadata from a SKILL.md file.

name#
description#
skill_path#
to_dict() dict[str, str]#

Convert metadata to dictionary.

Returns:

Dictionary with name, description, and path.

Return type:

dict[str, str]

class skill_to_mcp.skill_parser.SkillParser(skills_directory: pathlib.Path | str = 'skills')#

Parser for Claude Skills following the SKILL.md format.

skills_directory#
find_all_skills() list[SkillMetadata]#

Find all SKILL.md files and parse their metadata.

Returns:

List of skill metadata objects.

Return type:

list[SkillMetadata]

parse_skill_metadata(skill_md_path: pathlib.Path) SkillMetadata#

Parse frontmatter from a SKILL.md file.

Parameters:

skill_md_path (Path) – Path to the SKILL.md file.

Returns:

Parsed skill metadata.

Return type:

SkillMetadata

Raises:

ValueError – If frontmatter is missing or invalid.

_extract_frontmatter(content: str) dict[str, Any]#

Extract YAML frontmatter from SKILL.md content.

Parameters:

content (str) – Full content of SKILL.md file.

Returns:

Parsed frontmatter as dictionary.

Return type:

dict[str, Any]

Raises:

ValueError – If frontmatter is not found or invalid.

get_skill_content(skill_name: str, return_type: str = 'both') str | dict[str, str]#

Get the full content of a SKILL.md file by skill name.

Parameters:
  • skill_name (str) – Name of the skill.

  • return_type (str) – Type of data to return: “content”, “file_path”, or “both” (default).

Returns:

If return_type is “content”: Full content of the SKILL.md file. If return_type is “file_path”: Absolute path to the SKILL.md file. If return_type is “both”: Dictionary with “content” and “file_path” keys.

Return type:

str | dict[str, str]

Raises:

ValueError – If skill is not found or return_type is invalid.

list_skill_files(skill_name: str, relative: bool = True) list[str]#

List all files in a skill directory recursively.

Parameters:
  • skill_name (str) – Name of the skill.

  • relative (bool) – If True, return paths relative to skill directory. Default: True.

Returns:

List of file paths in the skill directory.

Return type:

list[str]

Raises:

ValueError – If skill is not found.

get_skill_file(skill_name: str, relative_path: str, return_type: str = 'both') str | dict[str, str]#

Get content of a specific file within a skill directory.

Parameters:
  • skill_name (str) – Name of the skill.

  • relative_path (str) – Path relative to the skill directory.

  • return_type (str) – Type of data to return: “content”, “file_path”, or “both” (default).

Returns:

If return_type is “content”: Content of the requested file. If return_type is “file_path”: Absolute path to the file. If return_type is “both”: Dictionary with “content” and “file_path” keys.

Return type:

str | dict[str, str]

Raises:

ValueError – If skill or file is not found, if path is invalid, or if return_type is invalid.