get_me
Retrieve current API key details: user name and remaining credits to track usage.
Instructions
Get details about the current API key (user_name and remaining credits).Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- slidespeak.py:108-119 (handler)Handler for the 'get_me' tool. Calls the SlideSpeak API GET /me endpoint to fetch current user details (user_name and remaining credits) and returns them as JSON with a note about credit usage.
@mcp.tool() async def get_me() -> str: """ Get details about the current API key (user_name and remaining credits). """ if not API_KEY: return "API Key is missing. Cannot process any requests." result = await _make_api_request("GET", "/me") if not result: return "Failed to fetch current user details." return json.dumps(result) + "\n Note: Generating slides costs 1 credit / slide" - slidespeak.py:108-109 (registration)Registration of the 'get_me' tool using the @mcp.tool() decorator on the FastMCP server instance.
@mcp.tool() async def get_me() -> str: - slidespeak.py:28-78 (helper)Helper function used by get_me to make HTTP requests to the SlideSpeak API. Handles authentication via X-API-Key header, error logging, and response parsing.
async def _make_api_request( method: Literal["GET", "POST"], endpoint: str, payload: Optional[dict[str, Any]] = None, timeout: float = DEFAULT_TIMEOUT ) -> Optional[dict[str, Any]]: """ Makes an HTTP request to the SlideSpeak API. Args: method: HTTP method ('GET' or 'POST'). endpoint: API endpoint path (e.g., '/presentation/templates'). payload: JSON payload for POST requests. Ignored for GET. timeout: Request timeout in seconds. Returns: The parsed JSON response as a dictionary on success, None on failure. """ if not API_KEY: logging.error("API Key is missing. Cannot make API request.") return None headers = { "User-Agent": USER_AGENT, "Accept": "application/json", "X-API-Key": API_KEY, } url = f"{API_BASE}{endpoint}" req_start = time.time() async with httpx.AsyncClient() as client: try: if method == "POST": response = await client.post(url, json=payload, headers=headers, timeout=timeout) else: response = await client.get(url, headers=headers, timeout=timeout) elapsed = time.time() - req_start logging.info(f"{method} {url} | status={response.status_code} | elapsed={elapsed:.2f}s") response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: logging.error(f"HTTP error {method} {url}: {e.response.status_code} - {e.response.text}") except httpx.RequestError as e: logging.error(f"Request error {method} {url}: {str(e)}") except Exception as e: logging.error(f"Unexpected error {method} {url}: {str(e)}") return None