Prerequisites
Before you can configure and use Node.js with Connect AI Embed, you must first do the following:- Generate an OAuth JWT bearer token. Copy this down, as it acts as your password during authentication.
- Install Node.js 18 or later (required for built-in
fetch). - If you plan to use the LangChain.js / LangGraph example below, obtain an OpenAI API key: https://platform.openai.com/.
Connect through LangChain.js and LangGraph
LangChain.js and LangGraph can call the Connect AI Embed MCP server through the@langchain/mcp-adapters package. The example below uses @langchain/langgraph to build a ReAct-style agent on top of the MCP tools — the agent discovers the MCP tools and uses them to answer prompts.
Create a file called
langchain.mjs and paste the following. Replace OAUTH_JWT_TOKEN with the token from the prerequisites and YOUR_OPENAI_API_KEY with your OpenAI API key:Connect Directly to the Connect AI Embed REST API
If you do not want to go through the MCP server, you can call the Connect AI Embed REST API directly from Node.js withfetch. The API accepts a JSON body with a query field and the JWT bearer token in the Authorization header. See REST API for the full response format.