create_story
Create new stories in ServiceNow with required details like short description and acceptance criteria, plus optional fields for state, assignment, and project tracking.
Instructions
Create a new story in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| acceptance_criteria | Yes | Acceptance criteria for the story | |
| assigned_to | No | User assigned to the story | |
| assignment_group | No | Group assigned to the story | |
| description | No | Detailed description of 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. | |
| short_description | Yes | Short 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) | |
| story_points | No | Points value for the story | |
| 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 by validating parameters and making a POST request to the ServiceNow rm_story table API.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 BaseModel defining the input schema/parameters 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)The registration of the 'create_story' tool in the central tool_definitions dictionary used by the MCP server, linking the handler function, input schema, description, and serialization method."create_story": ( create_story_tool, CreateStoryParams, str, "Create a new story in ServiceNow", "str", ),
- src/servicenow_mcp/tools/__init__.py:92-93 (registration)Import of the create_story handler into the tools package __init__.py, exposing it for use in other modules like tool_utils.py.from servicenow_mcp.tools.story_tools import ( create_story,