Skip to main content
Glama
talhaorak

Taiga MCP Bridge

by talhaorak

unassign_epic_from_user

Remove user assignment from a specific epic in Taiga by setting the assigned user to null, ensuring epics are managed accurately within the project management platform.

Instructions

Unassigns a specific epic (sets assigned user to null).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
epic_idYes
session_idYes

Implementation Reference

  • The main handler function for the 'unassign_epic_from_user' tool, registered via the @mcp.tool decorator. It authenticates the session, logs the action, and delegates to the update_epic helper by passing assigned_to=None to unassign the epic.
    @mcp.tool("unassign_epic_from_user", description="Unassigns a specific epic (sets assigned user to null).")
    def unassign_epic_from_user(session_id: str, epic_id: int) -> Dict[str, Any]:
        """Unassigns an epic."""
        logger.info(
            f"Executing unassign_epic_from_user: Epic {epic_id}, session {session_id[:8]}...")
        # Delegate to update_epic
        return update_epic(session_id, epic_id, assigned_to=None)
  • Supporting helper function 'update_epic' that performs the core logic of updating an epic via the Taiga API (api.epics.edit), including version handling and error management. Called by unassign_epic_from_user with assigned_to=None.
    @mcp.tool("update_epic", description="Updates details of an existing epic.")
    def update_epic(session_id: str, epic_id: int, **kwargs) -> Dict[str, Any]:
        """Updates an epic. Pass fields to update as keyword arguments (e.g., subject, description, status_id, assigned_to, color)."""
        logger.info(
            f"Executing update_epic ID {epic_id} for session {session_id[:8]} with data: {kwargs}")
        taiga_client_wrapper = _get_authenticated_client(session_id) # Use wrapper variable name
        try:
            # Use pytaigaclient edit pattern for partial updates
            if not kwargs:
                 logger.info(f"No fields provided for update on epic {epic_id}")
                 return taiga_client_wrapper.api.epics.get(epic_id)
    
            # Get current epic data to retrieve version
            current_epic = taiga_client_wrapper.api.epics.get(epic_id)
            version = current_epic.get('version')
            if not version:
                raise ValueError(f"Could not determine version for epic {epic_id}")
                
            # Use edit method for partial updates with keyword arguments
            updated_epic = taiga_client_wrapper.api.epics.edit(
                epic_id=epic_id,
                version=version,
                **kwargs
            )
            logger.info(f"Epic {epic_id} update request sent.")
            return updated_epic
        except TaigaException as e:
            logger.error(
                f"Taiga API error updating epic {epic_id}: {e}", exc_info=False)
            raise e
        except Exception as e:
            logger.error(
                f"Unexpected error updating epic {epic_id}: {e}", exc_info=True)
            raise RuntimeError(f"Server error updating epic: {e}")
  • Helper function to retrieve and validate the authenticated TaigaClientWrapper from the session store, used by all authenticated tools including unassign_epic_from_user.
    def _get_authenticated_client(session_id: str) -> TaigaClientWrapper:
        """
        Retrieves the authenticated TaigaClientWrapper for a given session ID.
        Raises PermissionError if the session is invalid or not found.
        """
        client = active_sessions.get(session_id)
        # Also check if the client object itself exists and is authenticated
        if not client or not client.is_authenticated:
            logger.warning(f"Invalid or expired session ID provided: {session_id}")
            # Raise PermissionError - FastMCP will map this to an appropriate error response
            raise PermissionError(
                f"Invalid or expired session ID: '{session_id}'. Please login again.")
        logger.debug(f"Retrieved valid client for session ID: {session_id}")
        return client
  • The TaigaClientWrapper class provides the API client instance (self.api.epics.edit is ultimately called) and authentication management used by the tools.
    class TaigaClientWrapper:
        """
        A wrapper around the pytaiga-client library to manage API instance
        and authentication state.
        """
    
        def __init__(self, host: str):
            if not host:
                raise ValueError("Taiga host URL cannot be empty.")
            # Store host, but initialize client later during login/token auth
            self.host = host
            # Use the new client type
            self.api: Optional[TaigaClient] = None
            logger.info(f"TaigaClientWrapper initialized for host: {self.host}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/talhaorak/pytaiga-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server