get_targets
Retrieve detailed information about all scrape targets in Prometheus to monitor and analyze metrics effectively using standardized MCP interfaces.
Instructions
Get information about all scrape targets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The async handler function that implements the get_targets tool. It calls the Prometheus /api/v1/targets endpoint via make_prometheus_request and returns a dictionary containing activeTargets and droppedTargets lists.async def get_targets() -> Dict[str, List[Dict[str, Any]]]: """Get information about all Prometheus scrape targets. Returns: Dictionary with active and dropped targets information """ logger.info("Retrieving scrape targets information") data = make_prometheus_request("targets") result = { "activeTargets": data["activeTargets"], "droppedTargets": data["droppedTargets"] } logger.info("Scrape targets retrieved", active_targets=len(data["activeTargets"]), dropped_targets=len(data["droppedTargets"])) return result
- src/prometheus_mcp_server/server.py:473-483 (registration)The @mcp.tool decorator that registers the get_targets function as an MCP tool, providing its description and annotations.@mcp.tool( description="Get information about all scrape targets", annotations={ "title": "Get Scrape Targets", "icon": "🎯", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True } )