Skip to main content
Glama

FHIR MCP Server

by the-momentum
errors.pyβ€’1.46 kB
from fastapi import status from requests.exceptions import HTTPError, RequestException from app.mcp.exceptions import APICustomError def handle_requests_exceptions(e: Exception, url: str) -> None: """ Handle all possible request exceptions from the FHIR API. Args: e: The caught exception url: The URL that was being accessed when the error occurred Raises: APICustomError: A standardized API error with appropriate status and message """ if isinstance(e, HTTPError): response = e.response raise APICustomError( status=response.status_code if response else status.HTTP_500_INTERNAL_SERVER_ERROR, code="fhir_api_error", message=f"FHIR API returned HTTP error: {response.text if response else str(e)}", ctx={"url": url}, ) if isinstance(e, RequestException): raise APICustomError( status=status.HTTP_502_BAD_GATEWAY, code="fhir_connection_error", message="Failed to connect to FHIR API.", ) if isinstance(e, ValueError): raise APICustomError( status=status.HTTP_500_INTERNAL_SERVER_ERROR, code="fhir_invalid_response", message="FHIR API returned invalid JSON.", ) raise APICustomError( status=status.HTTP_500_INTERNAL_SERVER_ERROR, code="unknown_error", message="Unexpected error occurred.", )

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/the-momentum/fhir-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server