A JSON array containing a list of connection Ids accessible to the end user (required when calling the per-connection MCP endpoint; otherwise optional). Must be a JSON array of strings (such as ["id-1","id-2"]), not a JSON-encoded string. Passing a stringified array causes the per-connection MCP endpoint to return 403.
The following is an example JSON Claim Set for the JWT:
Sign the token with your private key and format the token.
7
Register the public key certificate in Privacy-Enhanced Mail (PEM) format in the management account. Open a support ticket with Connect AI to register the public key.
A JWT requires a public and private key in PEM format. You sign the JWT with your private key and you register the public key with CData. There are several ways to generate JWT keys. The examples below use openssl.
Click the relevant tab for the code sample for creating a JWT.
Java
Python
C#
node.js
Creating a JWT in Java:Add the com.auth0:java-jwt dependency to your project (Maven: com.auth0:java-jwt:4.4.0, Gradle: implementation 'com.auth0:java-jwt:4.4.0').
Creating a JWT in Python:Use the PyJWT and cryptography packages in Python. You can install these via pip: pip install pyjwt and pip install cryptography.
import jwtimport datetime# Secret key used to sign the JWTsecret_key = """your_secret_key_here"""# Payload (claims) for the JWTcurrent_datetime_seconds = datetime.datetime.today().timestamp()expiration_datetime_seconds = (datetime.datetime.today() + datetime.timedelta(minutes=5)).timestamp();payload = { 'tokenType': 'powered-by', 'iat': current_datetime_seconds, 'exp': expiration_datetime_seconds, 'iss': 'your_oem_account_id_here', 'sub': 'your_sub_account_id_here', 'connection_ids': ['your_connection_id_1_here', 'your_connection_id_2_here'], # optional: required for scoped MCP server access }# Create the JWT tokentoken = jwt.encode(payload, secret_key, algorithm='RS256')print(token)
Creating a JWT in C#:Use the Nuget Package Manager Console to install the System.IdentityModel.Tokens.Jwt library with the following command:Install-Package System.IdentityModel.Tokens.Jwt.
using System.Collections.Generic;using System.IdentityModel.Tokens.Jwt;using System.Security.Cryptography;using Microsoft.IdentityModel.Tokens;var secretKey = "your_secret_key_here";var rsa = new RSACryptoServiceProvider();rsa.ImportFromPem(secretKey.ToCharArray());var signingCredentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256);var currentTime = DateTime.UtcNow;var expirationTime = currentTime.AddMinutes(5);var payload = new JwtPayload{ { "tokenType", "powered-by" }, { "iss", "your_oem_account_id_here" }, { "sub", "your_sub_account_id_here" }, { "connection_ids", new List<string> { "your_connection_id_1_here", "your_connection_id_2_here" } }, // List<string> serializes as a JSON array in the token payload. Optional: required for scoped MCP server access { "iat", EpochTime.GetIntDate(currentTime) }, { "exp", EpochTime.GetIntDate(expirationTime) },};var token = new JwtSecurityToken(new JwtHeader(signingCredentials), payload);var tokenString = new JwtSecurityTokenHandler().WriteToken(token);Console.WriteLine(tokenString);