create_story
Create a new story in ServiceNow to track agile development work, including descriptions, acceptance criteria, assignments, and project details.
Instructions
Create a new story in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| short_description | Yes | Short description of the story | |
| acceptance_criteria | Yes | Acceptance criteria for the story | |
| description | No | Detailed description of the story | |
| state | No | State of story (-6 is Draft,-7 is Ready for Testing,-8 is Testing,1 is Ready, 2 is Work in progress, 3 is Complete, 4 is Cancelled) | |
| assignment_group | No | Group assigned to the story | |
| story_points | No | Points value for the story | |
| assigned_to | No | User assigned to the story | |
| epic | No | Epic that the story belongs to. It requires the System ID of the epic. | |
| project | No | Project that the story belongs to. It requires the System ID of the project. | |
| work_notes | No | Work notes to add to the story. Used for adding notes and comments to a story |
Implementation Reference
- The main handler function that implements the create_story tool logic. It validates parameters using CreateStoryParams, prepares data, makes a POST request to ServiceNow API /api/now/table/rm_story, and returns the created story or error.def create_story( auth_manager: AuthManager, server_config: ServerConfig, params: Dict[str, Any], ) -> Dict[str, Any]: """ Create a new story in ServiceNow. Args: auth_manager: The authentication manager. server_config: The server configuration. params: The parameters for creating the story. Returns: The created story. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, CreateStoryParams, required_fields=["short_description", "acceptance_criteria"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = { "short_description": validated_params.short_description, "acceptance_criteria": validated_params.acceptance_criteria, } # Add optional fields if provided if validated_params.description: data["description"] = validated_params.description if validated_params.state: data["state"] = validated_params.state if validated_params.assignment_group: data["assignment_group"] = validated_params.assignment_group if validated_params.story_points: data["story_points"] = validated_params.story_points if validated_params.assigned_to: data["assigned_to"] = validated_params.assigned_to if validated_params.epic: data["epic"] = validated_params.epic if validated_params.project: data["project"] = validated_params.project if validated_params.work_notes: data["work_notes"] = validated_params.work_notes # Get the instance URL instance_url = _get_instance_url(auth_manager, server_config) if not instance_url: return { "success": False, "message": "Cannot find instance_url in either server_config or auth_manager", } # Get the headers headers = _get_headers(auth_manager, server_config) if not headers: return { "success": False, "message": "Cannot find get_headers method in either auth_manager or server_config", } # Add Content-Type header headers["Content-Type"] = "application/json" # Make the API request url = f"{instance_url}/api/now/table/rm_story" try: response = requests.post(url, json=data, headers=headers) response.raise_for_status() result = response.json() return { "success": True, "message": "Story created successfully", "story": result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error creating story: {e}") return { "success": False, "message": f"Error creating story: {str(e)}", }
- Pydantic model defining the input parameters and validation schema for the create_story tool.class CreateStoryParams(BaseModel): """Parameters for creating a story.""" short_description: str = Field(..., description="Short description of the story") acceptance_criteria: str = Field(..., description="Acceptance criteria for the story") description: Optional[str] = Field(None, description="Detailed description of the story") state: Optional[str] = Field(None, description="State of story (-6 is Draft,-7 is Ready for Testing,-8 is Testing,1 is Ready, 2 is Work in progress, 3 is Complete, 4 is Cancelled)") assignment_group: Optional[str] = Field(None, description="Group assigned to the story") story_points: Optional[int] = Field(10, description="Points value for the story") assigned_to: Optional[str] = Field(None, description="User assigned to the story") epic: Optional[str] = Field(None, description="Epic that the story belongs to. It requires the System ID of the epic.") project: Optional[str] = Field(None, description="Project that the story belongs to. It requires the System ID of the project.") work_notes: Optional[str] = Field(None, description="Work notes to add to the story. Used for adding notes and comments to a story")
- src/servicenow_mcp/utils/tool_utils.py:837-843 (registration)Registration of the create_story tool in the central tool definitions dictionary, mapping name to (handler, schema, return_type, description, serialization)."create_story": ( create_story_tool, CreateStoryParams, str, "Create a new story in ServiceNow", "str", ),