Skip to content

Latest commit

 

History

History
141 lines (107 loc) · 3.48 KB

File metadata and controls

141 lines (107 loc) · 3.48 KB

Connecting Your Database

The initial setup includes a demo database. To connect your own database:

Quick Method (via Admin UI)

  1. Access DreamFactory Admin:

    open http://localhost:8080

    Login with the email/password from your .env file

  2. Navigate to Services:

    • Click "Services" in the sidebar
    • Click "Create" button
  3. Select Database Type:

    • Choose your database (PostgreSQL, MySQL, MongoDB, etc.)
    • Note: Oracle, SQL Server, Snowflake require DreamFactory Commercial
  4. Enter Connection Details:

    • Service Name: my_database (used in API URLs)
    • Host: Your database hostname (e.g., localhost, db.example.com)
    • Port: Database port (e.g., 5432 for PostgreSQL)
    • Database Name: Your database name
    • Username: Database user
    • Password: Database password
  5. Test & Save:

    • Click "Test Connection"
    • If successful, click "Save"
  6. Access Your API:

    # List tables
    curl http://localhost:8080/api/v2/my_database/_table
    
    # Query data
    curl http://localhost:8080/api/v2/my_database/_table/users

Advanced: Docker Compose Configuration

To add a database to your Docker Compose setup:

Example: External PostgreSQL

Edit docker-compose.yml, add to web service environment:

environment:
  # ... existing vars ...
  EXTERNAL_DB_DRIVER: pgsql
  EXTERNAL_DB_HOST: db.yourcompany.com
  EXTERNAL_DB_PORT: 5432
  EXTERNAL_DB_DATABASE: production_db
  EXTERNAL_DB_USERNAME: readonly_user
  EXTERNAL_DB_PASSWORD: "your_secure_password"

Then configure the service via Admin UI (see Quick Method above).


Update MCP Configuration

After adding your database:

  1. Update MCP config to point to your new service:

    Claude Desktop (~/.config/Claude/claude_desktop_config.json):

    {
      "mcpServers": {
        "my-database": {
          "url": "http://localhost:8080/api/v2/mcp/my_database",
          "headers": {
            "X-DreamFactory-API-Key": "YOUR_API_KEY"
          }
        }
      }
    }

    Claude Code (.mcp.json in your project):

    {
      "mcpServers": {
        "my-database": {
          "command": "node",
          "args": ["./mcp-proxy/proxy.js"],
          "env": {
            "DF_BASE_URL": "http://localhost:8080",
            "DF_INTERNAL_URL": "http://localhost",
            "DF_ADMIN_EMAIL": "admin@example.com",
            "DF_ADMIN_PASSWORD": "your_password",
            "DF_MCP_SERVICE": "mcp_my_database",
            "DF_OAUTH_CLIENT_ID": "your_client_id",
            "DF_OAUTH_CLIENT_SECRET": "your_client_secret"
          }
        }
      }
    }
  2. Restart Claude Desktop or restart MCP servers


Connection Wizard (Coming in v0.2.0)

Simplified database connection with one command:

npx @dreamfactory/connect
# Interactive wizard for database setup

See ROADMAP.md for details.


Troubleshooting

Connection failed:

  • Verify database is accessible from Docker container
  • Check firewall rules
  • For localhost databases, use host.docker.internal (Mac/Windows) or 172.17.0.1 (Linux)

API key not working:

  • Generate new API key in Admin UI → Apps → Create
  • Update MCP configuration with new key

Can't see tables:

  • Check database user permissions
  • Verify schema/database name is correct
  • Review DreamFactory logs: docker compose logs web

More help: Troubleshooting Guide