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
| Name | Required | Description | Default |
|---|---|---|---|
| kwargs | Yes | ||
| project_id | Yes | ||
| session_id | Yes | ||
| subject | Yes |
Implementation Reference
- src/server.py:295-318 (handler)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}")
- src/server.py:39-52 (helper)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