Overview
MCP Blacksmith auto-detects authentication requirements from your OpenAPI specification’ssecuritySchemes and generates the appropriate handlers. You only need to provide credentials in the .env file.
Each operation is mapped to its required authentication scheme. The server automatically injects the correct credentials into every request.
Supported authentication types
API Key
Used when the API requires a key passed as a header, query parameter, or cookie..env
X-API-Key header, the server automatically sends:
Bearer Token
Used for APIs that accept a static token in theAuthorization header.
.env
Authorization: Bearer your-bearer-token with each request.
HTTP Basic
Used for username/password authentication..env
Authorization: Basic <encoded>.
OAuth 2.0
Used for APIs requiring OAuth2 flows (Authorization Code, Client Credentials, Password)..env
- On first run, the server opens your browser for authorization
- You authorize the application on the API provider’s consent page
- The server receives the authorization code via a local callback server
- Tokens are exchanged and saved to
oauth2_tokens.json - On subsequent runs, saved tokens are reused
- Expired tokens are automatically refreshed
8090 by default. This is configurable in the generated _auth.py file.
OpenID Connect (OIDC)
Extends OAuth2 with ID token validation and automatic discovery..env
- Automatic discovery from the OIDC Discovery endpoint
- ID token validation
- Tokens saved to
oidc_tokens.json
JWT
Used for APIs that require a signed JSON Web Token..env
Authorization: Bearer <jwt>.
Mutual TLS (mTLS)
Used for APIs requiring client certificate authentication..env
Per-operation authentication
Not every operation uses the same auth. The generated server maps each operation to its required schemes:- Outer list = OR — any one of these options works
- Inner list = AND — all schemes in this group are required together
Security best practices
- Store credentials in the
.envfile, not in code - Use the minimum required scopes for OAuth2/OIDC
- Rotate API keys and tokens regularly
- For production deployments, consider using a secrets manager and injecting credentials as environment variables