Integrating LangGraph with PingOne Data via CData Connect AI

Dibyendu Datta
Dibyendu Datta
Lead Technology Evangelist
Leverage CData Connect AI to enable LangGraph agents to securely access and act on PingOne data within automated workflows.

LangGraph is a framework for building and visualizing intelligent, graph-based AI workflows that combine reasoning models (LLMs) with tool integrations and data operations. By integrating it with the CData Connect AI, you can enable agents to securely access, query, and act on live enterprise data in real-time via a standardized toolset.

CData Connect AI is a managed MCP-platform that allows you to expose your data sources (such as PingOne) through the Model Context Protocol (MCP). This means your AI agents can work with metadata, catalogs, tables, and SQL-enabled data access from hundreds of data sources, without complex ETL or custom integrations.

This article explores how to register the MCP endpoint in LangGraph, configure data source connectivity via CData Connect AI, and build a workflow that queries and visualizes live data (for example, PingOne objects) on demand. It demonstrates how to use the built-in MCP toolset (getCatalogs, getSchemas, getTables, queryData, etc.) to enable natural-language agents to interact with your enterprise data securely and interactively.

Prerequisites

Step 1: Configure PingOne Connectivity for LangGraph

Before LangGraph can access PingOne, a PingOne connection must be created in CData Connect AI. This connection is then exposed to LangGraph through the remote MCP server.

  1. Log in to Connect AI click Sources, and then click + Add Connection Adding a Connection
  2. From the available data sources, choose PingOne Selecting a data source
  3. Enter the necessary authentication properties to connect to PingOne.

    To connect to PingOne, configure these properties:

    • Region: The region where the data for your PingOne organization is being hosted.
    • AuthScheme: The type of authentication to use when connecting to PingOne.
    • Either WorkerAppEnvironmentId (required when using the default PingOne domain) or AuthorizationServerURL, configured as described below.

    Configuring WorkerAppEnvironmentId

    WorkerAppEnvironmentId is the ID of the PingOne environment in which your Worker application resides. This parameter is used only when the environment is using the default PingOne domain (auth.pingone). It is configured after you have created the custom OAuth application you will use to authenticate to PingOne, as described in Creating a Custom OAuth Application in the Help documentation.

    First, find the value for this property:

    1. From the home page of your PingOne organization, move to the navigation sidebar and click Environments.
    2. Find the environment in which you have created your custom OAuth/Worker application (usually Administrators), and click Manage Environment. The environment's home page displays.
    3. In the environment's home page navigation sidebar, click Applications.
    4. Find your OAuth or Worker application details in the list.
    5. Copy the value in the Environment ID field. It should look similar to:
      WorkerAppEnvironmentId='11e96fc7-aa4d-4a60-8196-9acf91424eca'

    Now set WorkerAppEnvironmentId to the value of the Environment ID field.

    Configuring AuthorizationServerURL

    AuthorizationServerURL is the base URL of the PingOne authorization server for the environment where your application is located. This property is only used when you have set up a custom domain for the environment, as described in the PingOne platform API documentation. See Custom Domains.

    Authenticating to PingOne with OAuth

    PingOne supports both OAuth and OAuthClient authentication. In addition to performing the configuration steps described above, there are two more steps to complete to support OAuth or OAuthCliet authentication:

    • Create and configure a custom OAuth application, as described in Creating a Custom OAuth Application in the Help documentation.
    • To ensure that the driver can access the entities in Data Model, confirm that you have configured the correct roles for the admin user/worker application you will be using, as described in Administrator Roles in the Help documentation.
    • Set the appropriate properties for the authscheme and authflow of your choice, as described in the following subsections.

    OAuth (Authorization Code grant)

    Set AuthScheme to OAuth.

    Desktop Applications

    Get and Refresh the OAuth Access Token

    After setting the following, you are ready to connect:

    • InitiateOAuth: GETANDREFRESH. To avoid the need to repeat the OAuth exchange and manually setting the OAuthAccessToken each time you connect, use InitiateOAuth.
    • OAuthClientId: The Client ID you obtained when you created your custom OAuth application.
    • OAuthClientSecret: The Client Secret you obtained when you created your custom OAuth application.
    • CallbackURL: The redirect URI you defined when you registered your custom OAuth application. For example: https://localhost:3333

    When you connect, the driver opens PingOne's OAuth endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the OAuth process:

    1. The driver obtains an access token from PingOne and uses it to request data.
    2. The OAuth values are saved in the location specified in OAuthSettingsLocation, to be persisted across connections.

    The driver refreshes the access token automatically when it expires.

    For other OAuth methods, including Web Applications, Headless Machines, or Client Credentials Grant, refer to the Help documentation.

    Configuring a connection (Salesforce is shown)
  4. Click Save & Test
  5. Once authenticated, open the Permissions tab in the PingOne connection and configure user-based permissions as required Updating permissions

Generate a Personal Access Token (PAT)

LangGraph authenticates to Connect AI using an account email and a Personal Access Token (PAT). Creating separate PATs for each integration is recommended to maintain granular access control.

  1. In Connect AI, select the Gear icon in the top-right to open Settings
  2. Under Access Tokens, select Create PAT
  3. Provide a descriptive name for the token and select Create Creating a new PAT
  4. Copy the token and store it securely. The PAT will only be visible during creation

With the PingOne connection configured and a PAT generated, LangGraph is prepared to connect to PingOne data through the CData MCP server.

Step 2: Set up your development environment

Set up your project directory and install the required dependencies to connect LangGraph with CData Connect AI and use OpenAI LLM for reasoning. This setup enables LangGraph to call the PingOne MCP server tools exposed by Connect AI while OpenAI processes the natural language reasoning.

  1. Create a new folder for your LangGraph project:
    mkdir LangGraph cd LangGraph
  2. Install the required Python packages:
    pip install langgraph langchain-openai langchain-mcp-adapters python-dotenv "langgraph-cli[inmem]"
  3. Ensure you have Python 3.10+ and a valid OpenAI API key configured in your environment.

Step 3: Configure the MCP connection environment variables

LangGraph uses environment variables to connect to the CData Connect AI and define the API credentials and configuration settings. Store these credentials in a .env file to keep them secure and reusable. LangGraph automatically reads this file at runtime, so the script can authenticate and communicate with the MCP server without hardcoding sensitive information.

  1. Create a new file named .env in your project directory.
  2. Add the following environment variables to define your LangGraph, CData Connect AI, and OpenAI configuration:
    # LangSmith (Optional) 
    LANGSMITH_API_KEY=lsv2_pt_xxxx   #LangSmith API Key
    LANGCHAIN_TRACING_V2=true 
    LANGCHAIN_PROJECT=LangGraph-Demo 
    
    # MCP Configuration 
    MCP_BASE_URL=https://mcp.cloud.cdata.com/mcp   #MCP Server URL
    MCP_AUTH=base64encoded(EMAIL:PAT)   #Base64 encoded Connect AI Email:PAT
    OPENAI_API_KEY=sk-proj-xxxx 
    
  3. Save the file. LangGraph uses these values to authenticate with the CData Connect AI PingOne MCP server to connect with the PingOne data and initialize the OpenAI model for reasoning.

Note: You can generate the Base64-encoded authorization string using any online Base64 encoder, such as Base64 encoding tool. Encode your CData Connect AI username and PAT (obtained in the prerequisites).

Step 4: Create the LangGraph agent script

In this step, you need to create a Python script that connects LangGraph to your CData Connect AI MCP server. The script retrieves the available MCP tools, such as getCatalogs, getSchemas, and queryData, builds a LangGraph workflow, and runs a natural language prompt against your connected PingOne data.

The workflow uses the MCP to securely retrieve live PingOne data from Connect AI and uses OpenAI GPT-4o to interpret and reason over that data. You also expose the graph so you can visualize it later in LangGraph Studio.

Create the file

Create a new Python file named test.py inside your LangGraph project folder.

Add the following code

Use the following script into test.py:


import asyncio
import os
import operator
from typing_extensions import TypedDict, Annotated
from dotenv import load_dotenv

from langgraph.graph import StateGraph, START, END
from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langchain_core.messages import BaseMessage, HumanMessage

# Load environment variables
load_dotenv()

# Define the agent state
class AgentState(TypedDict):
    messages: Annotated[list[BaseMessage], operator.add]

# Define the async agent logic
async def run_agent(user_prompt: str) -> str:
    MCP_BASE_URL = os.getenv("MCP_BASE_URL")
    MCP_AUTH = os.getenv("MCP_AUTH")
    OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

    print("Connecting to the MCP server...")
    mcp_client = MultiServerMCPClient(
        connections={
            "default": {
                "transport": "streamable_http",
                "url": MCP_BASE_URL,
                "headers": {"Authorization": f"Basic {MCP_AUTH}"} if MCP_AUTH else {},
            }
        }
    )

    print("Loading available MCP tools...")
    all_mcp_tools = await mcp_client.get_tools()
    print(f"Loaded tools: {[tool.name for tool in all_mcp_tools]}")

    # Initialize the LLM
    llm = ChatOpenAI(model="gpt-4o", temperature=0.2, api_key=OPENAI_API_KEY)

    print("Creating the LangGraph agent...")
    agent = create_agent(
        model=llm,
        tools=all_mcp_tools,
        system_prompt="You are a helpful assistant. Use tools when needed."
    )

    # Build the workflow graph
    builder = StateGraph(AgentState)
    builder.add_node("agent", agent)
    builder.add_edge(START, "agent")
    builder.add_edge("agent", END)
    graph_instance = builder.compile()

    print(f"Processing user query: {user_prompt}\n")
    initial_state = {"messages": [HumanMessage(content=user_prompt)]}
    result = await graph_instance.ainvoke(initial_state)
    print(f"Agent Response:\n{result['messages'][-1].content}")

# Expose the graph for visualization
builder = StateGraph(AgentState)
builder.add_node(
    "agent",
    create_agent(
        model=ChatOpenAI(model="gpt-4o", temperature=0.2, api_key=os.getenv("OPENAI_API_KEY")),
        tools=[],
        system_prompt="You are a helpful assistant."
    )
)
builder.add_edge(START, "agent")
builder.add_edge("agent", END)
graph = builder.compile()

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--serve", action="store_true", help="Run visualization server")
    args = parser.parse_args()

    if args.serve:
        print("To visualize the graph, run:")
        print("langgraph dev")
    else:
        asyncio.run(run_agent("List the first 2 catalogs available"))

Step 5: Configure the LangGraph project

Configure the LangGraph project so the CLI recognizes the workflow graph and environment settings. Create a configuration file that registers the graph for use in LangGraph Studio or during local visualization runs.

Create the configuration file

Create a new file named langgraph.json in your project directory.

Add the following configuration

Use the content below in the langgraph.json file:


{
  "dependencies": ["."],
  "graphs": {
    "agent": "./test.py:graph"
  },
  "env": ".env"
}

Step 6: Prompt PingOne using LangGraph (via Connect AI)

Run the LangGraph development server to view and interact with your workflow in LangGraph Studio. This allows direct visualization of how the agent processes prompts, invokes tools, and retrieves PingOne data through the MCP server.

Start the LangGraph development server

Open a terminal in your project directory and run:

langgraph dev
Start the LangGraph development server

Access the Studio interface

After the server starts, LangGraph launches a local API and provides a link to the Studio UI:

https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

Ideally, the link opens automatically when the command is run. If not, open this link in your browser to load the LangGraph Studio dashboard.

Interact with the agent

In the Studio interface, enter a natural language prompt such as:

Show all PingOne tables available in my catalog

LangGraph displays a real-time visualization of the agent's reasoning flow, showing how it interprets the prompt, calls the appropriate MCP tools, and retrieves live data from PingOne.

Query and visualize the PingOne data Query and visualize the PingOne data (contd.)

Get CData Connect AI

To get live data access to hundreds of SaaS, Big Data, and NoSQL sources directly from your cloud applications, try CData Connect AI today!

Ready to get started?

Learn more about CData Connect AI or sign up for free trial access:

Free Trial