invite_project_user
Enable project collaboration by inviting users via email with assigned roles. Streamline user onboarding for Taiga projects through automated invitations.
Instructions
Invites a user to a project by email with a specific role.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | |||
| project_id | Yes | ||
| role_id | Yes | ||
| session_id | Yes |
Implementation Reference
- src/server.py:1165-1189 (handler)The handler function for the 'invite_project_user' MCP tool. It authenticates the session, validates input, calls the Taiga API's memberships.invite method to send an invitation by email to a project with a specified role, handles errors, and returns the result.@mcp.tool("invite_project_user", description="Invites a user to a project by email with a specific role.") def invite_project_user(session_id: str, project_id: int, email: str, role_id: int) -> Dict[str, Any]: """Invites a user via email to join the project with the specified role ID.""" logger.info( f"Executing invite_project_user {email} to project {project_id} (role {role_id}), session {session_id[:8]}...") taiga_client_wrapper = _get_authenticated_client(session_id) # Use wrapper variable name if not email: raise ValueError("Email cannot be empty.") try: # Use pytaigaclient memberships resource invite method # Check pytaigaclient signature for param names (project, email, role_id) invitation_result = taiga_client_wrapper.api.memberships.invite( project=project_id, email=email, role_id=role_id # Changed project_id to project ) logger.info(f"Invitation request sent to {email} for project {project_id}.") # Return the result from the invite call (might be dict or status) return invitation_result if isinstance(invitation_result, dict) else {"status": "invited", "email": email, "details": invitation_result} except TaigaException as e: logger.error( f"Taiga API error inviting user {email} to project {project_id}: {e}", exc_info=False) raise e except Exception as e: logger.error( f"Unexpected error inviting user {email} to project {project_id}: {e}", exc_info=True) raise RuntimeError(f"Server error inviting user: {e}")
- src/server.py:39-52 (helper)Shared helper function used by 'invite_project_user' (and other tools) to retrieve and validate the TaigaClientWrapper instance for the given session_id, raising PermissionError if invalid.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
- src/server.py:1165-1165 (registration)The @mcp.tool decorator registers the 'invite_project_user' function as an MCP tool with the specified name and description.@mcp.tool("invite_project_user", description="Invites a user to a project by email with a specific role.")