A Model Context Protocol (MCP) server implementation for Azure Health Data Services FHIR (Fast Healthcare Interoperability Resources). This service provides a standardized interface for interacting with Azure FHIR servers, enabling healthcare data operations through MCP tools.
The OAuth on-behalf-of flow requires a confidential Azure AD application that represents the MCP server.
In the Azure portal, go to Microsoft Entra ID ➜ App registrations ➜ New registration. Give it a descriptive name such as FHIR-MCP-Server, set Supported account types to Single tenant, and leave the redirect URI unset for now.
After the app is created, capture the generated Application (client) ID and Directory (tenant) ID for later use.
Under Expose an API, select Set for the Application ID URI and accept the suggested value api://{appId}. Add a scope named user_impersonation with admin consent display/description also set to user_impersonation.
Under Certificates & secrets, create a New client secret (for example FHIR-MCP-Secret-New). Copy the secret value immediately; it is required for the MCP server clientSecret setting.
Under Authentication, add the following Web redirect URIs to support the FastMCP OAuth proxy:
http://localhost:9002/auth/callback
Ensure Default client type remains No so the app stays confidential.
Under API permissions, choose Add a permission ➜ APIs my organization uses, search for your Azure Health Data Services FHIR server, and add the delegated scopes required for your scenario. Grant admin consent so the FastMCP proxy can request tokens without an interactive prompt.
Environment variables:
Set USE_FAST_MCP_OAUTH_PROXY=true
Requires HTTP_TRANSPORT=true
Start the MCP server with:
uv pip install -e .
uv run --env-file .env azure-fhir-mcp-server
# Run all tests
python -m pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src/azure_fhir_mcp_server
# Run specific test
pytest tests/test_fastmcp_metadata.py::TestFastMCPMetadata::test_fastmcp_server_discovery -v
# Run with detailed output
pytest tests/test_fastmcp_metadata.py::TestFastMCPMetadata::test_output_detailed_metadata -v -s
Contributions 🤝
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (git checkout -b feature/AmazingFeature)
Commit your changes (git commit -m '✨ Add some AmazingFeature')
Push to the branch (git push origin feature/AmazingFeature)