JUHE API Marketplace

Step-by-Step Tutorial: Connecting Supabase to LLMs with MCP

4 min read
By Olivia Bennett

Introduction

Large Language Models (LLMs) become more powerful when connected to live data sources. Supabase, combined with the Model Context Protocol (MCP), allows LLMs to securely access and query your database in real time. This guide walks developers through setting up an MCP server for Supabase and then enhancing it with JuheAPI MCP-ready services for a richer toolset.

Prerequisites

  • Node.js v22+ installed (check with node -v). Download from nodejs.org if needed.
  • A Supabase account with access to your project's settings.
  • An MCP-compatible client (e.g., Cursor).
  • Basic familiarity with terminal commands and JSON configuration.

Step 1: Obtain Your Supabase Personal Access Token

  1. Navigate to your Supabase project dashboard.
  2. Open Settings > Access Tokens.
  3. Click New Token.
  4. Give it a descriptive name, like "Cursor MCP Server".
  5. Copy the token immediately — it will not be shown again.

Tip: Store this token securely. Never commit it to a public repository.

Step 2: Configure the MCP Client for Supabase

Most MCP clients store configuration in JSON. Here’s the format:

{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": [
        "-y",
        "@supabase/mcp-server-supabase@latest",
        "--read-only",
        "--project-ref=<project-ref>"
      ],
      "env": {
        "SUPABASE_ACCESS_TOKEN": "<personal-access-token>"
      }
    }
  }
}

Replace <personal-access-token> with your token from Step 1.

  • --read-only: Restricts the server to read-only queries.
  • --project-ref: Limits access to one project.

Security Tip: You can set the SUPABASE_ACCESS_TOKEN as a global environment variable to keep it out of version control.

On Windows, MCP clients often require command prefixes. If JSON config isn't supported, use:

npx -y @supabase/mcp-server-supabase@latest --read-only --project-ref=<project-ref>

Do not run directly unless required — MCP clients handle process execution.

Step 3: Run the Supabase MCP Server

  1. Ensure your config JSON is loaded by the MCP client.
  2. Start the client — it will launch the MCP server via npx automatically.
  3. MCP will download the latest server binary and connect to Supabase.

Verification: In your client logs, look for a message indicating successful connection.

Step 4: Testing the Connection with Your LLM

Once connected:

  1. Prompt your LLM with a specific data query (SELECT * FROM users LIMIT 5;).
  2. Watch for live results fetched from Supabase.

Example:

User: "Fetch the latest 5 orders from Supabase"
LLM: "Here are the latest 5 orders..."

If you receive errors, recheck project-ref and token configuration.

Step 5: Enhancing with JuheAPI MCP Services

JuheAPI offers ready-to-use MCP servers to integrate various APIs alongside Supabase. Link: JuheAPI MCP Servers - Supabase Community

Popular JuheAPI MCP Services:

  • Weather Service: Pull live weather data for location-aware features.
  • Finance Service: Access up-to-date market data.
  • News Service: Integrate real-time headlines for contextual responses.

Adding JuheAPI to Your MCP Config

Example JSON with both Supabase and JuheAPI weather:

{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": [
        "-y",
        "@supabase/mcp-server-supabase@latest",
        "--read-only",
        "--project-ref=<project-ref>"
      ],
      "env": {
        "SUPABASE_ACCESS_TOKEN": "<personal-access-token>"
      }
    },
    "juheapi-weather": {
      "command": "npx",
      "args": [
        "-y",
        "@juheapi/mcp-weather@latest"
      ]
    }
  }
}

Now your LLM can query both your database and external APIs.

Best Practices and Security Tips

  • Always use --read-only for production.
  • Limit access via --project-ref.
  • Keep PATs in environment variables.
  • Regularly update MCP server packages.
  • Monitor logs for unusual activity.

Troubleshooting

Issue: Token not recognized.

  • Check environment variable spelling.
  • Ensure MCP client reloads config after changes.

Issue: Server fails to start.

  • Verify Node.js v22+.
  • Ensure internet access to npm registry.

Issue: LLM queries are slow.

  • Optimize Supabase queries.
  • Consider caching frequent requests in MCP-enabled APIs.

Conclusion

By connecting Supabase to LLMs via MCP, you enable secure, real-time data interactions. Enhancing the setup with JuheAPI MCP services expands your LLM’s capabilities beyond database queries, bringing in live, contextual data from multiple domains. This modular approach keeps your tools scalable and your workflows efficient.

Step-by-Step Tutorial: Connecting Supabase to LLMs with MCP | JuheAPI