How do I connect Claude Code to a database?
Recipe verified on
Ran on the public demo (read-only)
Tested: the command's address and key header, with an MCP client
Short answer
Run claude mcp add with the database's MCP address and your key as a header. For mcpdata: claude mcp add --transport http mcpdata https://[you].mcpdata.org/mcp --header "Authorization: Bearer $KEY". Then ask Claude Code about your tables.
Steps
- Connect your assistant to the public demo. It's a read-only instance with 10 million synthetic orders,
so you can try this before you have your own. In Claude Code:
claude mcp add --transport http mcpdata-demo https://demo.mcpdata.org/mcp --header "Authorization: Bearer cdb_live_PkVoldus8qcE-hqffjajNZzQwiA7rTHMoR4RLSAxsCE"
The key is public on purpose: it can only read the demo's sample data. For Claude Desktop, Cursor and other apps, see Connect your AI.
- Ask your question. Give your AI this prompt:
Using mcpdata, describe Demo.Orders: its columns and how many rows it has.
What your AI does: the tool call it makes for this prompt, and what came back
describe_table(table_name="Demo.Orders") → 15 columns, 10,005,000 rows
The assistant needs mcpdata connected (step 1) to run the query.
Why this works
Claude Code talks to remote MCP servers over HTTP directly, so no bridge is needed. /mcp inside Claude Code lists the servers and whether each is connected. Add --scope user to have it in every project.