get_countermeasure
Retrieve detailed information about a specific security countermeasure by providing its unique ID. Integrates with SD Elements MCP Server for security development lifecycle management.
Instructions
Get detailed information about a specific countermeasure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| countermeasure_id | Yes | The ID of the countermeasure to retrieve |
Implementation Reference
- The core handler function for the 'get_countermeasure' MCP tool. Decorated with @mcp.tool() for automatic registration. Normalizes the ID, fetches data via API client, and returns formatted JSON.@mcp.tool() async def get_countermeasure(ctx: Context, project_id: int, countermeasure_id: Union[int, str], risk_relevant: bool = True) -> str: """Get details of a SPECIFIC countermeasure by its ID. Use this when the user asks about a particular countermeasure (e.g., "countermeasure 123", "T21", "countermeasure 456"). Accepts countermeasure ID as integer (e.g., 21) or string (e.g., "T21" or "31244-T21"). Filter by risk relevance - if true, only return risk-relevant countermeasures. Defaults to true. Do NOT use this tool when the user asks about available status choices or what statuses are valid - use get_task_status_choices instead.""" global api_client if api_client is None: api_client = init_api_client() normalized_id = normalize_countermeasure_id(project_id, countermeasure_id) params = {"risk_relevant": risk_relevant} result = api_client.get_countermeasure(project_id, normalized_id, params) return json.dumps(result, indent=2)
- Supporting utility function used by get_countermeasure to normalize countermeasure IDs into the full '{project_id}-{task_id}' format.def normalize_countermeasure_id(project_id: int, countermeasure_id: Union[int, str]) -> str: """ Normalize countermeasure ID to full format (project_id-task_id). Accepts: - Integer: 21 -> "T21" -> "{project_id}-T21" - String starting with "T": "T21" -> "{project_id}-T21" - String in full format: "31244-T21" -> "31244-T21" (as-is) Args: project_id: The project ID countermeasure_id: Countermeasure ID as int or str Returns: Full task ID format: "{project_id}-T{number}" or existing full format """ # If integer, convert to "T{number}" format if isinstance(countermeasure_id, int): task_id = f"T{countermeasure_id}" else: # Already a string task_id = countermeasure_id # If already in full format (contains project_id), return as-is if task_id.startswith(f"{project_id}-"): return task_id # Otherwise, construct full format return f"{project_id}-{task_id}"
- src/sde_mcp_server/tools/__init__.py:6-6 (registration)Import that loads the countermeasures.py module into tools.__init__.py, executing the @mcp.tool() decorators to register 'get_countermeasure' with the MCP server.from .countermeasures import *
- src/sde_mcp_server/server.py:296-296 (registration)Import of the tools package in the main server.py file, which triggers the registration of all tools including 'get_countermeasure' via the chain of imports.from . import tools # noqa: F401
- src/sde_mcp_server/server.py:27-27 (registration)Creation of the FastMCP server instance to which all tools are registered.mcp = FastMCP("sdelements-mcp")