Integrate Model Context Protocol clients with Astra DB Serverless
Model Context Protocol (MCP) extends the capabilities of Large Language Models (LLMs) by allowing them to interact with external systems as agents.
MCP is a standardized protocol designed for sharing context between language models and tools. MCP clients can access tools and data from MCP servers based on natural language queries, enabling language models to execute functions agentically on your behalf. You don’t need to write any code because the MCP client manages those interactions for you.
This guide demonstrates how you can use Astra DB MCP servers and an MCP client to create and manage Astra DB Serverless (Vector) databases without writing any code.
Prerequisites
-
An active Astra account.
-
Your database’s API endpoint and an application token with the Database Administrator role. For more information about both of these values, see Generate an application token for a database.
-
An MCP client, such as Cursor or Claude for Desktop.
-
An LTS release of Node.js
Add an astra-db-mcp server to your MCP client
Use an Astra DB MCP server to interact with Astra DB through an MCP client.
The following examples demonstrate how to add an astra-db-mcp
server to Claude for Desktop and Cursor, but there are other MCP clients available.
-
Claude for Desktop
-
Cursor
In Claude for Desktop, you can configure an astra-db-mcp
server in the same way as other MCP servers.
For more information about this process and the claude_desktop_config.json
file, see the MCP Claude for Desktop quickstart.
-
Open Claude for Desktop, and then go to the program settings. For example, on the MacOS menu bar, click Claude, and then select Settings.
-
In the Settings dialog, click Developer, and then click Edit Config. This creates a
claude_desktop_config.json
file if you don’t already have one. -
Open the
claude_desktop_config.json
file in a text editor, and then add theastra-db-mcp
server configuration:{ "mcpServers": { "astra-db-mcp": { "command": "npx", "args": ["-y", "@datastax/astra-db-mcp"], "env": { "ASTRA_DB_APPLICATION_TOKEN": "APPLICATION_TOKEN", "ASTRA_DB_API_ENDPOINT": "API_ENDPOINT" } } } }
Replace
APPLICATION_TOKEN
andAPI_ENDPOINT
with your database’s API endpoint and a valid application token. For more information, see Prerequisites. -
Restart Claude for Desktop.
-
In the input box, click MCP tools to view the tools included with the
astra-db-mcp
server.If MCP tools is missing or the
astra-db-mcp
server tools aren’t listed, see MCP Claude for Desktop troubleshooting.For more information about the available tools, see the Astra DB MCP server repository.
-
To test the server and use the
astra-db-mcp
tools, use natural language queries to interact with Claude in Claude for Desktop.Based on your queries, Claude determines when to call
astra-db-mcp
tools, asks you for additional input, and asks permission before running tools. If necessary, Claude asks permission before running a tool. This can range from simple, single-tool queries to more complex queries that require multiple tools and leverage other LLM functionality. For examples, see the Astra DB MCP demo video. -
To verify changes to your database, open the Astra Portal, select your database, and then click Data Explorer.
For example, if you ask Claude to create a collection, you can confirm that the collection is listed in the Astra Portal.
-
To connect to other databases, change the application token and API endpoint in your
astra-db-mcp
server configuration.
In Cursor, you can configure an astra-db-mcp
server in the same way as other MCP servers.
For more information, see the Cursor MCP documentation.
-
Open Cursor, and then go to Cursor Settings.
-
Click MCP, and then click Add New MCP Server.
-
For Name, enter a human-readable name for the server, such as
astra-db
. -
For Type, select command to use the
stdio
library. -
For Command, enter the following shell script that will run the
astra-db-mcp
server and use the specified environment variables to connect to your database:env ASTRA_DB_APPLICATION_TOKEN=APPLICATION_TOKEN ASTRA_DB_API_ENDPOINT=API_ENDPOINT npx -y @datastax/astra-db-mcp
Replace
APPLICATION_TOKEN
andAPI_ENDPOINT
with your database’s API endpoint and a valid application token. For more information, see Prerequisites. -
Click Add.
-
In the MCP Servers list, hover over the available tools to get information about the
astra-db-mcp
tools.If your server doesn’t automatically appear in the MCP Servers list, restart Cursor.
If the Tools list doesn’t automatically populate, click refresh Refresh.
For more information about the available tools, see the Astra DB MCP server repository.
-
To test the server and use the
astra-db-mcp
tools, open the Composer chat window, select Agent, and then use natural language queries to interact with Composer Agent.Based on your queries, Agent determines when to call
astra-db-mcp
tools, asks you for additional input, and asks permission before running tools. This can range from simple, single-tool queries to more complex queries that require multiple tools and leverage other LLM functionality. For examples, see the Astra DB MCP demo video. -
To verify changes to your database, open the Astra Portal, select your database, and then click Data Explorer.
For example, if you ask Agent to create a collection, you can confirm that the new collection is listed in the Astra Portal.
-
To connect to other databases, change the application token and API endpoint in your
astra-db-mcp
server configuration.