create_project
Create new projects in ServiceNow with essential details like name, description, status, dates, and assigned team members to initiate project tracking.
Instructions
Create a new project in ServiceNow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| short_description | Yes | Project name of the project | |
| description | No | Detailed description of the project | |
| status | No | Status of the project (green, yellow, red) | |
| state | No | State of project (-5 is Pending,1 is Open, 2 is Work in progress, 3 is Closed Complete, 4 is Closed Incomplete, 5 is Closed Skipped) | |
| project_manager | No | Project manager for the project | |
| percentage_complete | No | Percentage complete for the project | |
| assignment_group | No | Group assigned to the project | |
| assigned_to | No | User assigned to the project | |
| start_date | No | Start date for the project | |
| end_date | No | End date for the project |
Implementation Reference
- Main handler function for the create_project tool. Validates input parameters using CreateProjectParams, constructs the request data, makes a POST request to ServiceNow's pm_project table, and returns the created project or error.def create_project( config: ServerConfig, # Changed from auth_manager auth_manager: AuthManager, # Changed from server_config params: Dict[str, Any], ) -> Dict[str, Any]: """ Create a new project in ServiceNow. Args: config: The server configuration. auth_manager: The authentication manager. params: The parameters for creating the project. Returns: The created project. """ # Unwrap and validate parameters result = _unwrap_and_validate_params( params, CreateProjectParams, required_fields=["short_description"] ) if not result["success"]: return result validated_params = result["params"] # Prepare the request data data = { "short_description": validated_params.short_description, } # Add optional fields if provided if validated_params.description: data["description"] = validated_params.description if validated_params.status: data["status"] = validated_params.status if validated_params.state: data["state"] = validated_params.state if validated_params.assignment_group: data["assignment_group"] = validated_params.assignment_group if validated_params.percentage_complete: data["percentage_complete"] = validated_params.percentage_complete if validated_params.assigned_to: data["assigned_to"] = validated_params.assigned_to if validated_params.project_manager: data["project_manager"] = validated_params.project_manager if validated_params.start_date: data["start_date"] = validated_params.start_date if validated_params.end_date: data["end_date"] = validated_params.end_date # Get the instance URL instance_url = _get_instance_url(auth_manager, 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, 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/pm_project" try: response = requests.post(url, json=data, headers=headers) response.raise_for_status() result = response.json() return { "success": True, "message": "Project created successfully", "project": result["result"], } except requests.exceptions.RequestException as e: logger.error(f"Error creating project: {e}") return { "success": False, "message": f"Error creating project: {str(e)}", }
- Pydantic BaseModel defining the input schema (parameters) for the create_project tool, including required short_description and various optional fields.class CreateProjectParams(BaseModel): """Parameters for creating a project.""" short_description: str = Field(..., description="Project name of the project") description: Optional[str] = Field(None, description="Detailed description of the project") status: Optional[str] = Field(None, description="Status of the project (green, yellow, red)") state: Optional[str] = Field(None, description="State of project (-5 is Pending,1 is Open, 2 is Work in progress, 3 is Closed Complete, 4 is Closed Incomplete, 5 is Closed Skipped)") project_manager: Optional[str] = Field(None, description="Project manager for the project") percentage_complete: Optional[int] = Field(None, description="Percentage complete for the project") assignment_group: Optional[str] = Field(None, description="Group assigned to the project") assigned_to: Optional[str] = Field(None, description="User assigned to the project") start_date: Optional[str] = Field(None, description="Start date for the project") end_date: Optional[str] = Field(None, description="End date for the project")
- src/servicenow_mcp/utils/tool_utils.py:924-930 (registration)Registration of the create_project tool in the central tool_definitions dictionary used by the MCP server. Maps the tool name to its implementation function (aliased), params model, return type hint, description, and serialization method."create_project": ( create_project_tool, CreateProjectParams, str, "Create a new project in ServiceNow", "str", ),
- src/servicenow_mcp/tools/__init__.py:110-114 (registration)Import of the create_project function from project_tools.py into the tools package __init__.py, making it available for use and export via __all__.from servicenow_mcp.tools.project_tools import ( create_project, update_project, list_projects, )
- src/servicenow_mcp/utils/tool_utils.py:331-335 (registration)Import and aliasing of the create_project function as create_project_tool in tool_utils.py, used in the tool_definitions registration.from servicenow_mcp.tools.project_tools import ( create_project as create_project_tool, update_project as update_project_tool, list_projects as list_projects_tool, )