"""MCP tool registrations for projects."""

from mcp.server.fastmcp import Context


def register_tools(mcp, api_fn):
    @mcp.tool()
    async def create_project(
        project_id: str,
        github_url: str = "",
        path: str = "",
        ctx: Context = None,
    ) -> dict:
        """Register a project so tasks can be scoped to it.

        The project must already exist. If it does not, call create_project first
        to register it, then retry create_task.

        Args:
            project_id: Unique identifier for the project in org/repo format (e.g. 'pyrabbit/peon-mcp').
            github_url: GitHub repository URL (e.g. 'https://github.com/org/repo'). Used by peon-loop to clone the repo if it doesn't exist locally.
            path: Absolute path to the project on disk (optional, e.g. '/Users/me/projects/peon-mcp').
        """
        return await api_fn(ctx).create_project(project_id, github_url, path)

    @mcp.tool()
    async def get_project(project_id: str, ctx: Context = None) -> dict | str:
        """Get a project by its ID.

        Args:
            project_id: The project identifier in org/repo format (e.g. 'pyrabbit/peon-mcp').
        """
        return await api_fn(ctx).get_project(project_id)
