![]() |
VOOZH | about |
LangChain is a framework used by developers, data engineers, and AI practitioners for building AI-powered applications and workflows by combining reasoning models (LLMs), tools, APIs, and data connectors. By integrating LangChain with CData Connect AI through the built-in MCP Server, workflows can effortlessly access and interact with live Paylocity data in real time.
CData Connect AI offers a secure, low-code environment to connect Paylocity and other data sources, removing the need for complex ETL and enabling seamless automation across business applications with live data.
This article outlines how to configure Paylocity connectivity in CData Connect AI, register the MCP server with LangChain, and build a workflow that queries Paylocity data in real time.
Before LangChain can access Paylocity, a Paylocity connection must be created in CData Connect AI. This connection is then exposed to LangChain through the remote MCP server.
Set the following to establish a connection to Paylocity:
This property is required for executing Insert and Update statements, and it is not required if the feature is disabled.
Paylocity will decrypt the AES key using RSA decryption.
It is an optional property if the IV value not provided, The driver will generate a key internally.
You must use OAuth to authenticate with Paylocity. OAuth requires the authenticating user to interact with Paylocity using the browser. For more information, refer to the OAuth section in the Help documentation.
The Pay Entry API is completely separate from the rest of the Paylocity API. It uses a separate Client ID and Secret, and must be explicitly requested from Paylocity for access to be granted for an account. The Pay Entry API allows you to automatically submit payroll information for individual employees, and little else. Due to the extremely limited nature of what is offered by the Pay Entry API, we have elected not to give it a separate schema, but it may be enabled via the UsePayEntryAPI connection property.
Please be aware that when setting UsePayEntryAPI to true, you may only use the CreatePayEntryImportBatch & MergePayEntryImportBatchgtable stored procedures, the
InputTimeEntry table, and the OAuth stored procedures. Attempts to use other features of the product will result in an error. You must also store your OAuthAccessToken
separately, which often means setting a different OAuthSettingsLocation when using this connection property.
π Configuring a connection (Salesforce is shown)
LangChain authenticates to Connect AI using an account email and a Personal Access Token (PAT). Creating separate PATs for each integration is recommended to maintain access control granularity.
With the Paylocity connection configured and a PAT generated, LangChain is prepared to connect to Paylocity data through the CData MCP server.
Note: You can also generate a PAT from LangChain in the Integrations section of Connect AI. Simply click Connect --> Create PAT to generate it.
π Navigate to the LangChain integration tool and click on Connect.To connect LangChain with CData Connect AI Remote MCP Server and use OpenAI (ChatGPT) for reasoning, you need to configure your MCP server endpoint and authentication values in a config.py file. These values allow LangChain to call the MCP server tools, while OpenAI handles the natural language reasoning.
class Config: MCP_BASE_URL = "https://mcp.cloud.cdata.com/mcp" #MCP Server URL MCP_AUTH = "base64encoded(EMAIL:PAT)" #Base64 encoded Connect AI Email:PAT
Note: You can create the base64 encoded version of MCP_AUTH using any Base64 encoding tool.
"""
Integrates a LangChain ReAct agent with CData Connect AI MCP server.
The script demonstrates fetching, filtering, and using tools with an LLM for agent-based reasoning.
"""
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from config import Config
async def main():
# Initialize MCP client with one or more server URLs
mcp_client = MultiServerMCPClient(
connections={
"default": { # you can name this anything
"transport": "streamable_http",
"url": Config.MCP_BASE_URL,
"headers": {"Authorization": f"Basic {Config.MCP_AUTH}"},
}
}
)
# Load remote MCP tools exposed by the server
all_mcp_tools = await mcp_client.get_tools()
print("Discovered MCP tools:", [tool.name for tool in all_mcp_tools])
# Create and run the ReAct style agent
llm = ChatOpenAI(
model="gpt-4o",
temperature=0.2,
api_key="YOUR_OPEN_API_KEY" #Use your OpenAI API Key here, this can be found here: https://platform.openai.com/
)
agent = create_react_agent(llm, all_mcp_tools)
user_prompt = "How many tables are available in Paylocity1?" #Change prompts as per need
print(f"
User prompt: {user_prompt}")
# Send a prompt asking the agent to use the MCP tools
response = await agent.ainvoke(
{ "messages": [{ "role": "user", "content": (user_prompt),}]}
)
# Print out the agent's final response
final_msg = response["messages"][-1].content
print("Agent final response:", final_msg)
if __name__ == "__main__":
asyncio.run(main())
Since this workflow uses LangChain together with CData Connect AI MCP and integrates OpenAI for reasoning, you need to install the required Python packages.
Run the following command in your project terminal:
pip install langchain-mcp-adapters langchain-openai langgraph
To get live data access to hundreds of SaaS, Big Data, and NoSQL sources directly from your cloud applications, try CData Connect AI today!
Learn more about CData Connect AI or sign up for free trial access:
Free Trial