skill_to_mcp.skill_parser
=========================

.. py:module:: skill_to_mcp.skill_parser

.. autoapi-nested-parse::

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



Classes
-------

.. autoapisummary::

   skill_to_mcp.skill_parser.SkillMetadata
   skill_to_mcp.skill_parser.SkillParser


Module Contents
---------------

.. py:class:: SkillMetadata(name: str, description: str, skill_path: pathlib.Path)

   Represents metadata from a SKILL.md file.


   .. py:attribute:: name


   .. py:attribute:: description


   .. py:attribute:: skill_path


   .. py:method:: to_dict() -> dict[str, str]

      Convert metadata to dictionary.

      :returns: Dictionary with name, description, and path.
      :rtype: dict[str, str]



.. py:class:: SkillParser(skills_directory: pathlib.Path | str = 'skills')

   Parser for Claude Skills following the SKILL.md format.


   .. py:attribute:: skills_directory


   .. py:method:: find_all_skills() -> list[SkillMetadata]

      Find all SKILL.md files and parse their metadata.

      :returns: List of skill metadata objects.
      :rtype: list[SkillMetadata]



   .. py:method:: parse_skill_metadata(skill_md_path: pathlib.Path) -> SkillMetadata

      Parse frontmatter from a SKILL.md file.

      :param skill_md_path: Path to the SKILL.md file.
      :type skill_md_path: Path

      :returns: Parsed skill metadata.
      :rtype: SkillMetadata

      :raises ValueError: If frontmatter is missing or invalid.



   .. py:method:: _extract_frontmatter(content: str) -> dict[str, Any]

      Extract YAML frontmatter from SKILL.md content.

      :param content: Full content of SKILL.md file.
      :type content: str

      :returns: Parsed frontmatter as dictionary.
      :rtype: dict[str, Any]

      :raises ValueError: If frontmatter is not found or invalid.



   .. py:method:: 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.

      :param skill_name: Name of the skill.
      :type skill_name: str
      :param return_type: Type of data to return: "content", "file_path", or "both" (default).
      :type return_type: str

      :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.
      :rtype: str | dict[str, str]

      :raises ValueError: If skill is not found or return_type is invalid.



   .. py:method:: list_skill_files(skill_name: str, relative: bool = True) -> list[str]

      List all files in a skill directory recursively.

      :param skill_name: Name of the skill.
      :type skill_name: str
      :param relative: If True, return paths relative to skill directory. Default: True.
      :type relative: bool

      :returns: List of file paths in the skill directory.
      :rtype: list[str]

      :raises ValueError: If skill is not found.



   .. py:method:: 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.

      :param skill_name: Name of the skill.
      :type skill_name: str
      :param relative_path: Path relative to the skill directory.
      :type relative_path: str
      :param return_type: Type of data to return: "content", "file_path", or "both" (default).
      :type return_type: str

      :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.
      :rtype: str | dict[str, str]

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



