home / mcp / health api mcp server
FastAPI health service with JWT auth, PostgreSQL, Alembic migrations, and MCP integration.
Configuration
View docs{
"mcpServers": {
"alwayssany-health-api": {
"url": "http://localhost:5000/mcp",
"headers": {
"Authorization": "Bearer <put_your_bearer_token_here>"
}
}
}
}This Health Microservice API MCP server provides a FastAPI-based backend for health-related operations, secured with JWT authentication and backed by PostgreSQL. It exposes a comprehensive set of REST endpoints for health entities and integrates with MCP to enable centralized, scalable client access across services.
After you have a running MCP-enabled health API, you can connect your MCP client to manage data and perform actions across doctors, patients, medical records, appointments, and related health services. Authenticate first to retrieve a JWT access token, then include the token in the Authorization header for subsequent requests. Use the interactive API docs (Swagger UI) to explore available endpoints, request bodies, and responses, and leverage MCP to streamline cross-service requests and secure access.
Prerequisites you need before installation:
Step by step install and run flow:
1) Install the UV package manager if not already present.
2) Install UV or use pip as an alternative.
3) Clone the project repository and navigate into the project directory.
4) Synchronize dependencies with UV.
5) Copy the example environment file and update credentials.
6) Create and migrate the database using Alembic migrations via UV.
7) Start the application using the recommended command.
# Install UV (example)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or via pip
pip install uv
# Clone the project
git clone <repository-url>
cd health-api
# Install dependencies
uv sync
# Set up environment
cp .env.example .env
# Edit .env with your database credentials and secret key
# Prepare the database (PostgreSQL must be running)
CREATE DATABASE health_db;
# Generate and apply migrations
uv run alembic revision --autogenerate -m "Your migration message"
uv run alembic upgrade head
# Start the application
uv run uvicorn app.main:app --host 0.0.0.0 --port 5000 --reloadIf you prefer a convenience script, you can use the provided startup script once you have dependencies installed.
The MCP integration is used to connect this FastAPI application to an MCP server. The MCP client is wired into the FastAPI app using the FastApiMCP integration, and the MCP endpoint is exposed at the /mcp path for cross-service interactions.
{
"mcpServers": {
"health_api": {
"serverUrl": "http://localhost:5000/mcp",
"headers": {
"Authorization": "Bearer <put_your_bearer_token_here>"
},
"name": "health_api"
}
}
}If you are using a client that reads MCP configuration in JSON, you can configure the HTTP MCP server as shown above. Ensure the URL points to your running MCP endpoint and include the Authorization header with a valid token.
Use JWT-based authentication for all protected endpoints. Register a user to obtain credentials, log in to receive a token, and attach the token to the Authorization header in subsequent requests.
A modular project structure separates models, schemas, routes, and business logic for easier maintenance. Alembic handles database migrations, and the UV package manager enables fast dependency resolution during development.
Once the application is running, you can access interactive API documentation to explore available endpoints, request bodies, and responses at the following paths: /docs and /redoc.
If you encounter connection issues, verify that the MCP server URL is accessible, the Authorization header contains a valid token, and the database is up and reachable. Review environment variables in the .env file to ensure database credentials and secret keys are correct.