VOOZH about

URL: https://www.cdata.com/kb/tech/domino-cloud-openai.rst

โ‡ฑ How to Connect to Live HCL Domino Data from OpenAI Python Applications (via CData Connect AI)


How to Connect to Live HCL Domino Data from OpenAI Python Applications (via CData Connect AI)

๐Ÿ‘ Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Leverage the CData Connect AI Remote MCP Server to enable OpenAI-powered Python applications to securely read and take actions on your HCL Domino data through natural language.

OpenAI's Python SDK provides powerful capabilities for building AI applications that can interact with various data sources. When combined with CData Connect AI Remote MCP, you can build intelligent chat applications that interact with your HCL Domino data in real-time through natural language queries. This article outlines the process of connecting to HCL Domino using Connect AI Remote MCP and configuring an OpenAI-powered Python application to interact with your HCL Domino data through conversational AI.

CData Connect AI offers a dedicated cloud-to-cloud interface for connecting to HCL Domino data. The CData Connect AI Remote MCP Server enables secure communication between OpenAI applications and HCL Domino. This allows your AI assistants to read from and take actions on your live HCL Domino data. With its inherent optimized data processing capabilities, CData Connect AI efficiently channels all supported SQL operations, including filters and JOINs, directly to HCL Domino. This leverages server-side processing to swiftly deliver the requested HCL Domino data.

In this article, we show how to configure an OpenAI-powered Python application to conversationally explore (or Vibe Query) your data using natural language. With Connect AI you can build AI assistants with access to live HCL Domino data, plus hundreds of other sources.

Step 1: Configure HCL Domino Connectivity for OpenAI Applications

Connectivity to HCL Domino from OpenAI applications is made possible through CData Connect AI Remote MCP. To interact with HCL Domino data from your OpenAI assistant, we start by creating and configuring a HCL Domino connection in CData Connect AI.

  1. Log into Connect AI, click Sources, and then click Add Connection
  2. ๐Ÿ‘ Adding a Connection
  3. Select "HCL Domino" from the Add Connection panel
  4. ๐Ÿ‘ Selecting a data source
  5. Enter the necessary authentication properties to connect to HCL Domino.

    Connecting to Domino

    To connect to Domino data, set the following properties:

    • URL: The host name or IP of the server hosting the Domino database. Include the port of the server hosting the Domino database. For example: http://sampleserver:1234/
    • DatabaseScope: The name of a scope in the Domino Web UI. The driver exposes forms and views for the schema governed by the specified scope. In the Domino Admin UI, select the Scopes menu in the sidebar. Set this property to the name of an existing scope.

    Authenticating with Domino

    Domino supports authenticating via login credentials or an Entra ID (formerly Azure AD) OAuth application:

    Login Credentials

    To authenticate with login credentials, set the following properties:

    • AuthScheme: Set this to "OAuthPassword"
    • User: The username of the authenticating Domino user
    • Password: The password associated with the authenticating Domino user

    The driver uses the login credentials to automatically perform an OAuth token exchange.

    EntraID (formerly AzureAD)

    This authentication method uses Entra ID (formerly Azure AD) as an IdP to obtain a JWT token. You need to create a custom OAuth application in Entra ID (formerly Azure AD) and configure it as an IdP. To do so, follow the instructions in the Help documentation. Then set the following properties:

    • AuthScheme: Set this to "EntraID (formerly AzureAD)"
    • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
    • OAuthClientId: The Client ID obtained when setting up the custom OAuth application.
    • OAuthClientSecret: The Client secret obtained when setting up the custom OAuth application.
    • CallbackURL: The redirect URI defined when you registered your app. For example: https://localhost:33333
    • AzureTenant: The Microsoft Online tenant being used to access data. Supply either a value in the form companyname.microsoft.com or the tenant ID.

      The tenant ID is the same as the directory ID shown in the Azure Portal's Entra ID (formerly Azure AD) > Properties page.

    ๐Ÿ‘ Configuring a connection (Salesforce is shown)
  6. Click Save & Test
  7. Navigate to the Permissions tab in the Add HCL Domino Connection page and update the User-based permissions. ๐Ÿ‘ Updating permissions

Add a Personal Access Token

A Personal Access Token (PAT) is used to authenticate the connection to Connect AI from your OpenAI application. It is best practice to create a separate PAT for each service to maintain granularity of access.

  1. Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create. ๐Ÿ‘ Creating a new PAT
  4. The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.

With the connection configured and a PAT generated, we are ready to connect to HCL Domino data from your OpenAI application.

Step 2: Configure Your OpenAI Python Application for CData Connect AI

Follow these steps to configure your OpenAI Python application to connect to CData Connect AI. You can use our pre-built client as a starting point, available at https://github.com/CDataSoftware/openai-mcp-client, or follow the instructions below to create your own.

  1. Ensure you have Python 3.8+ installed and install the required dependencies:
    pip install openai python-dotenv httpx
  2. Clone or download the OpenAI MCP client from GitHub:
    git clone https://github.com/CDataSoftware/openai-mcp-client.git
    cd openai-mcp-client
  3. Set up your environment variables. Create a .env file in your project root with the following variables:
    OPENAI_API_KEY=YOUR_OPENAI_API_KEY
    MCP_SERVER_URL=https://mcp.cloud.cdata.com/mcp
    MCP_USERNAME=YOUR_EMAIL
    MCP_PASSWORD=YOUR_PAT
    OPENAI_MODEL=gpt-4
     
    Replace YOUR_OPENAI_API_KEY with your OpenAI API key, YOUR_EMAIL with your Connect AI email address, and YOUR_PAT with the Personal Access Token created in Step 1.
  4. If creating your own application, here's the core implementation for connecting to CData Connect AI MCP Server:
    import os
    import asyncio
    import base64
    from dotenv import load_dotenv
    from mcp_client import MCPServerStreamableHttp, MCPAgent
    
    # Load environment variables
    load_dotenv()
    
    async def main():
     """Main chat loop for interacting with HCL Domino data."""
     # Get configuration
     api_key = os.getenv('OPENAI_API_KEY')
     mcp_url = os.getenv('MCP_SERVER_URL', 'https://mcp.cloud.cdata.com/mcp')
     username = os.getenv('MCP_USERNAME', '')
     password = os.getenv('MCP_PASSWORD', '')
     model = os.getenv('OPENAI_MODEL', 'gpt-4')
    
     # Create auth header for MCP server
     headers = {}
     if username and password:
     auth = base64.b64encode(f"{username}:{password}".encode()).decode()
     headers = {"Authorization": f"Basic {auth}"}
    
     # Connect to CData MCP Server
     async with MCPServerStreamableHttp(
     name="CData MCP Server",
     params={
     "url": mcp_url,
     "headers": headers,
     "timeout": 30,
     "verify_ssl": True
     }
     ) as mcp_server:
    
     # Create AI agent with access to HCL Domino data
     agent = MCPAgent(
     name="data_assistant",
     model=model,
     mcp_servers=[mcp_server],
     instructions="""You are a data query assistant with access to HCL Domino data through CData Connect AI.
    
     You can help users explore and query their HCL Domino data in real-time.
     Use the available MCP tools to:
     - List available databases and schemas
     - Explore table structures
     - Execute SQL queries
     - Provide insights about the data
    
     Always explain what you're doing and format results clearly.""",
     api_key=api_key
     )
    
     await agent.initialize()
     print(f"Connected! {len(agent._tools_cache)} tools available.")
     print("
    Chat with your HCL Domino data (type 'exit' to quit):
    ")
    
     # Interactive chat loop
     conversation = []
     while True:
     user_input = input("You: ")
     if user_input.lower() in ['exit', 'quit']:
     break
    
     conversation.append({"role": "user", "content": user_input})
    
     print("Assistant: ", end="", flush=True)
     response = await agent.run(conversation)
     print(response["content"])
    
     conversation.append({"role": "assistant", "content": response["content"]})
    
    if __name__ == "__main__":
     asyncio.run(main())
     
  5. Run your OpenAI application:
    python client.py
  6. Start interacting with your HCL Domino data through natural language queries. Your OpenAI assistant now has access to your HCL Domino data through the CData Connect AI MCP Server.

Step 3: Build Intelligent Applications with Live HCL Domino Data Access

With your OpenAI Python application configured and connected to CData Connect AI, you can now build sophisticated AI assistants that interact with your HCL Domino data using natural language. The MCP integration provides your applications with powerful data access capabilities through OpenAI's advanced language models.

Available MCP Tools for Your Assistant

Your OpenAI assistant has access to the following CData Connect AI MCP tools:

  • queryData: Execute SQL queries against connected data sources and retrieve results
  • getCatalogs: Retrieve a list of available connections from CData Connect AI
  • getSchemas: Retrieve database schemas for a specific catalog
  • getTables: Retrieve database tables for a specific catalog and schema
  • getColumns: Retrieve column metadata for a specific table
  • getProcedures: Retrieve stored procedures for a specific catalog and schema
  • getProcedureParameters: Retrieve parameter metadata for stored procedures
  • executeProcedure: Execute stored procedures with parameters

Example Use Cases

Here are some examples of what your OpenAI-powered applications can do with live HCL Domino data access:

  • Conversational Analytics: Build chat interfaces that answer complex business questions using natural language
  • Automated Reporting: Generate dynamic reports and summaries based on real-time data queries
  • Data Discovery Assistant: Help users explore and understand their data structure without SQL knowledge
  • Intelligent Data Monitor: Create AI assistants that proactively identify trends and anomalies
  • Custom Query Builder: Enable users to create complex queries through conversational interactions

Interacting with Your Assistant

Once running, you can interact with your OpenAI assistant through natural language. Example queries include:

  • "Show me all available databases"
  • "What tables are in the sales database?"
  • "List the top 10 customers by revenue"
  • "Find all orders from the last month"
  • "Analyze the trend in sales over the past quarter"
  • "What's the structure of the customer table?"

Your OpenAI assistant will automatically translate these natural language queries into appropriate SQL queries and execute them against your HCL Domino data through the CData Connect AI MCP Server, providing intelligent insights without requiring users to write complex SQL or understand the underlying data structure.

Advanced Features

The OpenAI MCP integration supports advanced capabilities:

  • Context Awareness: The assistant maintains conversation context for follow-up questions
  • Multi-turn Conversations: Build complex queries through iterative dialogue
  • Intelligent Error Handling: Get helpful suggestions when queries encounter issues
  • Data Insights: Leverage GPT's analytical capabilities to identify patterns and trends
  • Format Flexibility: Request results in various formats (tables, summaries, JSON, etc.)

Get CData Connect AI

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