Skip to main content

Connect an Astra DB MCP server to Langflow

Use the MCP server component to connect Langflow to a Datastax Astra DB MCP server.

  1. Install an LTS release of Node.js.
  2. Create an OpenAI API key.
  3. Create an Astra DB Serverless (Vector) database, if you don't already have one.
  4. Get your database's Astra DB API endpoint and an Astra DB application token with the Database Administrator role. For more information, see Generate an application token for a database.
  5. Create a Simple agent starter project.
  6. Remove the URL tool and replace it with an MCP server component. The flow should look like this: MCP stdio component
  7. In the MCP server component, in the MCP command field, add the following code. Replace the values for ASTRA_TOKEN and ASTRA_ENDPOINT with the values from your Astra database.

_10
env ASTRA_DB_APPLICATION_TOKEN=ASTRA_TOKEN ASTRA_DB_API_ENDPOINT=ASTRA_ENDPOINT npx -y @datastax/astra-db-mcpnpx -y @datastax/astra-db-mcp

important

Langflow passes environment variables from the .env file to MCP, but not global variables declared in the UI. To add the values for ASTRA_DB_APPLICATION_TOKEN and ASTRA_DB_API_ENDPOINT as global variables, add them to Langflow's .env file at startup. For more information, see global variables.

  1. In the Agent component, add your OpenAI API key.
  2. Open the Playground, and then ask the agent, What collections are available?

Since Langflow is connected to your Astra DB database through the MCP, the agent chooses the correct tool and connects to your database to retrieve the answer.


_10
The available collections in your database are:
_10
collection_002
_10
hardware_requirements
_10
load_collection
_10
nvidia_collection
_10
software_requirements

Search