get_components
Retrieve components from the Devici API with pagination support, enabling efficient management of threat modeling resources through structured data access.
Instructions
Get components from Devici with pagination
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| page | No |
Implementation Reference
- src/devici_mcp_server/server.py:121-126 (handler)The MCP tool handler for get_components, registered via @mcp.tool() decorator. Executes the tool logic by calling the API client to fetch paginated components from Devici and returns the result as a string.@mcp.tool() async def get_components(limit: int = 20, page: int = 0) -> str: """Get components from Devici with pagination""" async with create_client_from_env() as client: result = await client.get_components(limit=limit, page=page) return str(result)
- Helper method in the DeviciAPIClient class that performs the HTTP GET request to retrieve components with pagination, called by the MCP tool handler.async def get_components(self, limit: int = 20, page: int = 0) -> Dict[str, Any]: """Get all components.""" params = {"limit": limit, "page": page} return await self._make_request("GET", "/components/", params=params)
- Factory function used by the tool handler to create an authenticated API client instance from environment variables.def create_client_from_env() -> DeviciAPIClient: """Create API client from environment variables.""" config = DeviciConfig( api_base_url=os.getenv("DEVICI_API_BASE_URL", "https://api.devici.com/api/v1"), client_id=os.getenv("DEVICI_CLIENT_ID", ""), client_secret=os.getenv("DEVICI_CLIENT_SECRET", ""), debug=os.getenv("DEBUG", "false").lower() == "true" ) if not config.client_id or not config.client_secret: raise ValueError("DEVICI_CLIENT_ID and DEVICI_CLIENT_SECRET must be set") return DeviciAPIClient(config)