Skip to Content
Account & CommunityHeadless Mode (BaaS)

Connect to Momen Backend (Using Momen BaaS)

Momen provides a fully managed backend infrastructure built on PostgreSQL. Through its Headless Mode, Momen exposes its underlying database, authentication system, business logic engine (Actionflows), and AI Agent orchestration directly via standard, clean GraphQL APIs.

This allows you to utilize Momen as a pure Backend-as-a-Service (BaaS), integrating seamlessly with any frontend framework such as React, Vue, Next.js, or mobile apps. Developers can build complex full-stack applications without writing or maintaining any backend routes or server environments. Furthermore, combined with Momen’s dedicated MCP and Development Skills, this architecture delivers an unparalleled Vibe Coding experience for AI assistants like Cursor.


Why Choose Momen BaaS?

Momen is more than just a simple database alternative; it is a production-ready, fully managed backend (BaaS). Whether you are using traditional development methods or AI coding assistants, Momen offers significant advantages:

  1. Out-of-the-box High-Performance Backend: Built on PostgreSQL, Momen comes with a comprehensive authentication system (Auth), complex business logic engine (Actionflows), and enterprise-grade data permission control (RLS). You gain a highly available and scalable backend infrastructure without the need to set up or maintain servers from scratch.
  2. Minimalist Frontend Integration: All the data models, business logic, and AI Agents you visually build in the Momen editor are automatically transformed into standardized, clean GraphQL APIs. The frontend doesn’t need to import bloated SDKs; simple GraphQL calls are all it takes to deliver complex business features.
  3. Perfect Synergy with AI Coding Assistants (Vibe Coding): When using AI assistants like Cursor, traditional development often suffers from “API hallucinations.” Momen provides dedicated MCP and Development Skills that allow the AI to accurately read the actual backend structure in real-time through “API introspection.” This determinism fundamentally eliminates API hallucinations, vastly improving the success rate during initial frontend-backend integration.

Obtain API Endpoints and Credentials

The first step to connect to the Momen backend is to obtain your project’s API endpoints. Momen provides unified GraphQL endpoints for each project (replace {projectExId} with your actual Project ID):

HTTP Endpoint (for standard Queries and Mutations):

https://villa.momen.app/zero/{projectExId}/api/graphql-v2

WebSocket Endpoint (for real-time Subscriptions):

wss://villa.momen.app/zero/{projectExId}/api/graphql-subscription

💡 Tip: For local development, you will also need a high-privilege Admin Token. You can copy this token from the Connect Backend modal at the top right of the Momen editor. The modal also includes a built-in GraphiQL panel to write and test GraphQL queries directly.

⚠️ Warning: The Admin Token has the highest privileges and should only be used for local development or in trusted server environments (e.g., Node.js backend). Never expose or hardcode it in pure frontend client code accessible to users.


Vibe Coding: AI Assistant Integration

If you use AI coding assistants like Cursor, Windsurf, or Claude Code, Momen provides a dedicated MCP Server and Development Skill. These tools help the AI accurately fetch your Momen backend structure and automatically generate the corresponding frontend integration code based on natural language instructions.

Momen MCP

The Momen MCP (Model Context Protocol) server allows AI assistants to securely connect to your Momen account.

Core Capabilities

  1. GraphQL Schema Introspection: The core capability. The AI can invoke the get_project_schema tool to read your complete, real-time backend Schema (including dataModel, actionFlows, apis, and zAiConfigs). This allows the AI to accurately fetch the backend structure, avoiding API hallucinations.
  2. Project Context Management: The AI can use the get_projects tool to search for projects in your account and automatically switch contexts using set_current_project.
  3. Intelligent Mock Data Generation: Includes the create_and_save_mock_data_recursively tool. When developing frontend lists or detail pages, you can ask the AI to generate mock data for specific tables. The tool automatically handles complex foreign key dependencies and type conversions, inserting the data directly into your Momen database to speed up UI debugging.
  4. Automated Authentication: If the token expires, the AI can seamlessly trigger the OAuth re-authentication flow via the reauth tool, keeping the development process uninterrupted.

How to Integrate

Method 1: JSON Configuration (for Cursor / Windsurf / Cline, etc.) Add the following JSON configuration to your editor’s MCP settings file (e.g., when using the Cline extension, configure mcpServers directly):

{ "mcpServers": { "momen": { "command": "npx", "args": ["-y", "momen-mcp"] } } }

Method 2: CLI Installation (for Claude Code / Codex, etc.) Run the following command in your terminal:

npx -y momen-mcp

Method 3: AI Prompt Mode Copy the following prompt and send it to your AI chat window:

Please help me install and configure an MCP server named momen. The npm URL is: https://www.npmjs.com/package/momen-mcp

Momen Development Skill

The Skill is an official collection of AI development guidelines (momen-baas-skill).

Core Capabilities

Once installed, the AI assistant will follow Momen’s specific backend rules and underlying protocol details:

  1. Data Operation Protocols (GraphQL Rules):
    • Strict Filtering Syntax: Standardizes the use of Momen’s unique “Operator-First” pattern to construct complex where queries (e.g., {"_eq": {"bigint_operand": {"left_operand": {"column": "id"}, "right_operand": {"literal": "1"}}}}).
    • Formulas & Functions: Defines how to utilize dozens of built-in Momen functions inside queries (e.g., CONCAT, EXTRACT_DATE, GEO_DISTANCE).
    • Aggregations & Sorting: Defines the usage of [table]_aggregate and multi-level relational sorting logic.
  2. Actionflow Protocol:
    • Synchronous Actionflows: Defines the invocation method to trigger mutations via fz_invoke_action_flow and fetch results immediately.
    • Asynchronous Actionflows: Defines the workflow for long-running tasks, requiring a call to fz_create_action_flow_task to get a taskId, followed by subscribing to fz_listen_action_flow_result via WebSocket to monitor status transitions (CREATED -> PROCESSING -> COMPLETED).
  3. AI Agent Protocol:
    • Streaming & Reasoning: Defines the standard for creating a conversation via fz_zai_create_conversation and subscribing to fz_zai_listen_conversation_result to handle state transitions (IN_PROGRESS -> STREAMING -> COMPLETED), as well as extracting reasoningContent.
    • Structured Output: Defines the standard for handling non-streaming structured responses constrained by JSONSchema.
    • Multi-turn Conversations: Defines the standard for continuing conversations using fz_zai_send_ai_message or halting generation via fz_zai_stop_responding.
  4. Binary Asset Upload Workflow:
    • Enforces the mandatory two-step upload process: First, calculate the file’s MD5 and call imagePresignedUrl to obtain the direct upload URL and file ID. Second, execute an HTTP PUT to upload the binary stream to OSS, and finally save the file ID into the business table.
  5. Third-Party API Integration:
    • Standardizes how to properly invoke imported external APIs and safely parse the field_200_json and responseCode.

How to Integrate

Method 1: Prompt Installation (for Cursor / Windsurf / Cline, etc.) Copy the following prompt and send it to your AI chat window:

Please carefully read and install the development skill from the following repository: https://github.com/momen-tech-org/momen-baas-skill

Method 2: CLI Installation (for Claude Code / Codex, etc.) Run the following command in your terminal to install globally:

npx skills add https://github.com/momen-tech-org/momen-baas-skill -g

Once connected, you can efficiently advance your project using this workflow:

  1. Visual Backend Setup: Visually configure your database tables, Actionflows, and AI Agents in the Momen web editor.
  2. Configure AI Assistant: Following the guide above, configure the Momen MCP and install the Momen Development Skill in your AI coding assistant (e.g., Cursor).
  3. AI Context Reading: In your AI coding assistant, provide your projectExId and ask the AI to read the latest backend GraphQL structure via MCP.
  4. Natural Language Development: Issue frontend development instructions directly. For example: “I have configured an AI Agent named ‘Image Analyzer’ in the backend. Please help me write a page that streams the AI Agent’s analysis results after the user uploads an image.” The AI will automatically generate the corresponding frontend integration code based on the fetched API structure.
🔄

Handling Backend Modifications During Development

After modifying the backend configuration in the Momen editor and clicking Sync Changes, simply tell the AI: "I have updated the backend to include [Feature/Field]. Please re-read the backend schema and update the frontend logic accordingly." The AI will automatically fetch the latest structure and apply the modifications.

Last updated on