MCP Server: Connecting AI Coding Assistants to Your Databases
Your AI coding assistant can write SQL, generate migrations, and debug queries. But when you need a database to run that code against, you leave the conversation, open a dashboard, click through a provisioning wizard, copy credentials back into your editor, and resume. That context switch breaks flow.
FoundryDB's MCP server removes it. Your AI assistant provisions databases, retrieves connection strings, checks metrics, and triggers backups without you ever leaving the conversation.
What Is MCP?
The Model Context Protocol (MCP) is an open standard that lets AI assistants call external tools. Instead of the assistant generating code for you to copy and run, MCP lets it execute actions directly: create a database, fetch logs, list backups. The assistant sends a structured tool call, the MCP server executes it against the FoundryDB API, and the result comes back into the conversation.
MCP is supported by Claude (Anthropic), Cursor, Windsurf, and a growing list of AI coding tools. If your assistant supports MCP, it can use the FoundryDB server.
What the FoundryDB MCP Server Provides
The server exposes 13 tools across four categories. Every tool maps to a real FoundryDB API operation. Here is the full list, pulled directly from the implementation.
Service Management (7 tools)
| Tool | Description |
|---|---|
list_organizations | List all organizations the authenticated user belongs to |
list_services | List all managed database services with status, type, zone, and plan |
get_service | Get full details of a service by UUID or name |
create_service | Provision a new database (PostgreSQL, MySQL, MongoDB, Valkey, Kafka, OpenSearch, or SQL Server) |
delete_service | Permanently delete a service and all its data |
get_service_nodes | List all nodes (primary and replicas) with roles, status, and VM details |
list_presets | List available AI agent presets for one-call provisioning |
Database Users (3 tools)
| Tool | Description |
|---|---|
list_users | List all database users for a service |
reveal_password | Reveal the password for a specific database user |
get_connection_string | Get a ready-to-use connection string in multiple formats: url, env, psql, mysql, mongosh, or redis-cli |
Backups (2 tools)
| Tool | Description |
|---|---|
list_backups | List all backups for a service, including scheduled and on-demand |
trigger_backup | Trigger an immediate on-demand backup (full, incremental, or PITR) |
Monitoring (2 tools)
| Tool | Description |
|---|---|
get_metrics | Get current CPU, memory, storage, and connection metrics |
get_logs | Retrieve recent database logs (up to 1,000 lines) |
Installation
The MCP server is distributed as a Go binary. Configure it in your assistant's MCP settings with three environment variables.
For Claude Desktop, add this to your claude_desktop_config.json:
{
"mcpServers": {
"foundrydb": {
"command": "foundrydb-mcp",
"env": {
"FOUNDRYDB_API_URL": "https://api.foundrydb.com",
"FOUNDRYDB_USERNAME": "your-username",
"FOUNDRYDB_PASSWORD": "your-password"
}
}
}
}
For Cursor, add the same configuration to your .cursor/mcp.json.
The server communicates over stdio, which is the standard MCP transport. No ports to open, no daemons to manage.
Example Conversations
Here is what working with the MCP server looks like in practice.
Provisioning a database for a new project
You: I need a PostgreSQL 17 database for the new recommendation service. Use tier-2 in Stockholm with 50 GB storage.
Assistant calls
create_servicewithname: "recommendation-svc",database_type: "postgresql",version: "17",plan_name: "tier-2",zone: "se-sto1",storage_size_gb: 50.Assistant: Created service
recommendation-svc(ID:a1b2c3d4-...). It will be ready in about 5 minutes. Want me to check the status?
Getting connection credentials
You: The recommendation service should be ready now. Get me the psql connection string.
Assistant calls
get_servicewithname: "recommendation-svc", thenlist_usersandget_connection_stringwithformat: "psql".Assistant: Here is your connection command:
psql "postgres://app_user:abc123@rec-svc.db.foundrydb.com:5432/defaultdb?sslmode=verify-full"
Checking health during an incident
You: The app is slow. Check the database metrics and recent logs.
Assistant calls
get_metricsandget_logswithlines: 200.Assistant: CPU is at 89%, connections are at 147/200. The logs show several slow queries on the
embeddingstable. The longest took 12 seconds. Want me to pull the specific queries?
Creating ephemeral databases for AI agents
The create_service tool supports AI-specific parameters that make it useful for agent orchestration, not just human conversations.
create_service({
name: "langchain-rag-run-482",
preset: "agent-postgresql-rag",
ttl_hours: 24,
is_ephemeral: true,
agent_framework: "langchain",
agent_purpose: "rag"
})
This creates a PostgreSQL instance with pgvector pre-configured, labels it with the agent framework and purpose, and auto-deletes it after 24 hours. The list_presets tool shows all available presets, including agent-mongodb-conversation, agent-valkey-session, and agent-kafka-events.
Security Model
The MCP server authenticates to the FoundryDB API using username/password credentials set via environment variables. Both FOUNDRYDB_USERNAME and FOUNDRYDB_PASSWORD are required. The server refuses to start if either is missing, which prevents accidental runs with default credentials.
All tool calls go through the same authentication, authorization, and audit logging as direct API calls. The MCP server is a thin client that wraps the Go SDK. It does not bypass any access controls.
A few things to keep in mind:
- Destructive operations require confirmation. Tools like
delete_serviceandtrigger_backupmodify state. Your AI assistant will typically ask for confirmation before calling them, since the tool descriptions clearly indicate irreversible actions (e.g., "Permanently delete a managed database service and all its data. This action cannot be undone."). - Credentials stay local. The MCP server runs on your machine, communicating with your assistant over stdio. Your FoundryDB credentials are never sent to the AI model itself.
- Organization scoping. The
create_servicetool accepts anorganization_idparameter. When provided, the server creates an org-scoped API client, ensuring the service is provisioned in the correct organization.
How It Works Under the Hood
The MCP server is built with the mcp-go library and the FoundryDB Go SDK. Each tool is a function that validates inputs, calls the SDK, and returns formatted JSON. The server runs as a stdio process that the AI assistant manages.
For endpoints not yet covered by the SDK (like metrics and logs), the server makes direct authenticated HTTP calls to the API. Log retrieval is async: the server triggers the fetch, then polls for results with a 60-second timeout, so the assistant gets the logs without the user needing to wait and retry.
Get Started
- Install the MCP server from github.com/foundrydb/foundrydb-mcp
- Configure your assistant with your FoundryDB credentials
- Ask your assistant to
list_servicesand see what comes back
If you do not have a FoundryDB account yet, sign up at foundrydb.com and you will have a database running in under five minutes. Check the documentation for full API reference and guides.