skill_to_mcp.skill_parser#
Skill parser module for processing SKILL.md files and skill directories.
Classes#
Represents metadata from a SKILL.md file. |
|
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#
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- Returns:
List of file paths in the skill directory.
- Return type:
- 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:
- 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:
- Raises:
ValueError – If skill or file is not found, if path is invalid, or if return_type is invalid.