-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Problem
The MCP server supports authentication/connection via:
--private-keyCLI flagSNOWFLAKE_PRIVATE_KEYenvironment variable
Documentation and CLI args suggest you can pass the PEM text (i.e. the output of cat mykey.p8).
However, tracing the usage in the code reveals that:
- The raw PEM string (i.e.
-----BEGIN PRIVATE KEY-----...) is passed straight into theprivate_keyparameter ofsnowflake.connector.connect() - The Snowflake connector does NOT accept PEM strings here. It expects DER-encoded bytes (or an in-memory key object)
- Result: any attempt to use
SNOWFLAKE_PRIVATE_KEYor--private-key(PEM string) fails with:Failed to load private key: Could not deserialize key data. Please provide a valid unencrypted rsa private key in DER format as bytes object
This is a code bug:
- There is currently NO code in MCP that deserializes the PEM content before passing to the connector
- So the
--private-keyandSNOWFLAKE_PRIVATE_KEYfeatures are effectively nonfunctional
Steps to reproduce
- Place your PEM key in the env:
export SNOWFLAKE_PRIVATE_KEY="$(cat mykey.p8)"
- Run MCP with key pair auth using the above
- Observe error
Expected
- Setting
SNOWFLAKE_PRIVATE_KEYto PEM content should "just work" as documented/expected - Server should deserialize the PEM to DER bytes before passing to connector
- (Bonus) Deserializing to in-memory key object would also enable auto-re-auth (fix token expiry)
Actual
- Server passes raw PEM text to
connect()→ connector fails withCould not deserialize key dataerror - Only
--private-key-file/SNOWFLAKE_PRIVATE_KEY_FILEworks, but does not support seamless session re-authentication
Impact
- Key pair authentication via env-only and Docker secrets is essentially broken
- Documentation and flags are misleading and do not work as advertised
- Related: auto-re-authentication for token expiry (Authentication token expiry causes all tool calls to fail until server restart (no auto-reconnect on expired token) #176) is impossible, since only DER bytes/in-memory key would enable it
References
- Snowflake Python Connector: private_key format docs
- Related issue (token expiry bug): Authentication token expiry causes all tool calls to fail until server restart (no auto-reconnect on expired token) #176
Please fix the code to support PEM private key in env / CLI, converting it to DER or key object as required by the connector.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels