Skip to main content
Glama
talhaorak

Taiga MCP Bridge

by talhaorak

create_user_story

Create a new user story in Taiga projects by providing session ID, project ID, subject, and additional details. Streamline project management tasks through AI integration with the Taiga MCP Bridge.

Instructions

Creates a new user story within a project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes
project_idYes
session_idYes
subjectYes

Implementation Reference

  • The handler function for the 'create_user_story' MCP tool. It authenticates the session, validates input, creates a new user story via the Taiga API, and returns the created story details.
    @mcp.tool("create_user_story", description="Creates a new user story within a project.")
    def create_user_story(session_id: str, project_id: int, subject: str, **kwargs) -> Dict[str, Any]:
        """Creates a user story. Requires project_id and subject. Optional fields (description, milestone_id, status_id, assigned_to_id, etc.) via kwargs."""
        logger.info(
            f"Executing create_user_story '{subject}' in project {project_id}, session {session_id[:8]}...")
        taiga_client_wrapper = _get_authenticated_client(session_id) # Use wrapper variable name
        if not subject:
            raise ValueError("User story subject cannot be empty.")
        try:
            # Use pytaigaclient syntax: client.resource.create(project=..., subject=..., **kwargs)
            story = taiga_client_wrapper.api.user_stories.create(
                project=project_id, subject=subject, **kwargs)
            logger.info(
                f"User story '{subject}' created successfully (ID: {story.get('id', 'N/A')}).") # Use .get() for safety
            # return story.to_dict() # Remove .to_dict()
            return story # Return directly
        except TaigaException as e:
            logger.error(
                f"Taiga API error creating user story '{subject}': {e}", exc_info=False)
            raise e
        except Exception as e:
            logger.error(
                f"Unexpected error creating user story '{subject}': {e}", exc_info=True)
            raise RuntimeError(f"Server error creating user story: {e}")
  • Helper function used by create_user_story (and other tools) to retrieve and validate the authenticated Taiga client wrapper for the given session_id.
    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

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