Problem
The MCP server supports authentication/connection via:
--private-key CLI flag
SNOWFLAKE_PRIVATE_KEY environment 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 the private_key parameter of snowflake.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_KEY or --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-key and SNOWFLAKE_PRIVATE_KEY features 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_KEY to 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 with Could not deserialize key data error
- Only
--private-key-file/SNOWFLAKE_PRIVATE_KEY_FILE works, but does not support seamless session re-authentication
Impact
References
Please fix the code to support PEM private key in env / CLI, converting it to DER or key object as required by the connector.
Problem
The MCP server supports authentication/connection via:
--private-keyCLI flagSNOWFLAKE_PRIVATE_KEYenvironment variableDocumentation 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:
-----BEGIN PRIVATE KEY-----...) is passed straight into theprivate_keyparameter ofsnowflake.connector.connect()SNOWFLAKE_PRIVATE_KEYor--private-key(PEM string) fails with:This is a code bug:
--private-keyandSNOWFLAKE_PRIVATE_KEYfeatures are effectively nonfunctionalSteps to reproduce
Expected
SNOWFLAKE_PRIVATE_KEYto PEM content should "just work" as documented/expectedActual
connect()→ connector fails withCould not deserialize key dataerror--private-key-file/SNOWFLAKE_PRIVATE_KEY_FILEworks, but does not support seamless session re-authenticationImpact
References
Please fix the code to support PEM private key in env / CLI, converting it to DER or key object as required by the connector.