update_project
Modify project details such as name, description, and status using the project ID. Integrates with SD Elements MCP Server for streamlined security development lifecycle management.
Instructions
Update an existing project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Updated project description | |
| name | No | Updated project name | |
| project_id | Yes | The ID of the project to update | |
| status | No | Project status |
Implementation Reference
- Implements the 'update_project' MCP tool handler. Decorated with @mcp.tool() for automatic registration. Validates inputs, especially risk_policy ID, constructs update data, calls api_client.update_project, and returns JSON result or error.@mcp.tool() async def update_project(ctx: Context, project_id: int, name: Optional[str] = None, description: Optional[str] = None, status: Optional[str] = None, risk_policy: Optional[Union[int, str]] = None) -> str: """Update an existing project (name, description, status, or risk_policy). Use when user says 'update', 'change', 'modify', or 'rename'. Do NOT use for 'archive', 'delete', or 'remove' - use delete_project instead. IMPORTANT: risk_policy must be the numeric ID of the risk policy (e.g., 1, 2, 3), not the name. Use list_risk_policies to find the correct ID. According to the API documentation (https://docs.sdelements.com/master/api/docs/projects/), risk_policy is an optional field that accepts the ID of the Risk Policy that applies to this project.""" global api_client if api_client is None: api_client = init_api_client() # Validate risk_policy is an integer if provided if risk_policy is not None: # Handle string-to-int conversion (MCP framework may pass as string) if isinstance(risk_policy, str): try: risk_policy = int(risk_policy) except ValueError: return json.dumps({ "error": f"risk_policy must be an integer ID, got string that cannot be converted: {risk_policy}", "suggestion": "Use list_risk_policies to find the correct risk policy ID (numeric value)" }, indent=2) elif not isinstance(risk_policy, int): return json.dumps({ "error": f"risk_policy must be an integer ID, got {type(risk_policy).__name__}: {risk_policy}", "suggestion": "Use list_risk_policies to find the correct risk policy ID (numeric value)" }, indent=2) data = {} if name is not None: data["name"] = name if description is not None: data["description"] = description if status is not None: data["status"] = status if risk_policy is not None: data["risk_policy"] = risk_policy if not data: return json.dumps({"error": "No update data provided. Specify at least one field to update (name, description, status, or risk_policy)."}, indent=2) try: result = api_client.update_project(project_id, data) return json.dumps(result, indent=2) except Exception as e: error_msg = str(e) # Check if it's a risk_policy related error if "risk_policy" in error_msg.lower() or "risk policy" in error_msg.lower(): return json.dumps({ "error": f"Failed to update risk_policy: {error_msg}", "suggestion": "Verify the risk_policy ID exists using list_risk_policies. Risk policy must be a valid numeric ID." }, indent=2) return json.dumps({"error": f"Failed to update project: {error_msg}"}, indent=2)