Skip to main content
The Tenants API manages multi-tenant organization and the MCP (Model Context Protocol) endpoints enable AI agent integration with the Fataplus backend.

List Tenants

curl -X GET "https://bknd.fata.plus/api/tenants" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json"
Retrieves all tenants (admin access required). Endpoint: GET /api/tenants

Response

data
array
Array of tenant objects with isolation and access configuration
{
  "data": [
    {
      "id": "tenant_main",
      "name": "Fataplus Main",
      "subdomain": "main",
      "clients": ["client_xyz789", "client_abc456"],
      "created_at": "2026-01-01T00:00:00Z"
    }
  ]
}

Create Tenant

curl -X POST "https://bknd.fata.plus/api/tenants" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Rice Cooperative Platform",
    "subdomain": "rice-coop"
  }'
Creates a new tenant organization with isolated data access. Endpoint: POST /api/tenants

Request Body

name
string
required
Tenant organization name
subdomain
string
required
Unique subdomain for tenant access (e.g., rice-coop.fata.plus)

Response

data
object
The created tenant object

MCP Protocol Endpoints

The Model Context Protocol (MCP) enables AI agents to interact with the Fataplus backend. These endpoints implement the MCP JSON-RPC 2.0 specification.

MCP Initialization

curl -X POST "https://bknd.fata.plus/api/system/mcp" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-06-18",
      "capabilities": {},
      "clientInfo": {
        "name": "client",
        "version": "1.0.0"
      }
    }
  }'
Initializes an MCP session with the backend. Endpoint: POST /api/system/mcp

Request Body

jsonrpc
string
required
JSON-RPC version: "2.0"
id
number
required
Request identifier
method
string
required
MCP method: "initialize"
params
object
required
Initialization parameters

Response

jsonrpc
string
JSON-RPC version: "2.0"
id
number
Matching request ID
result
object
Initialization result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-06-18",
    "capabilities": {
      "tools": {},
      "resources": {},
      "logging": {},
      "completions": {}
    },
    "serverInfo": {
      "name": "bknd",
      "version": "0.19.0"
    }
  }
}

List MCP Tools

curl -X POST "https://bknd.fata.plus/api/system/mcp" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/list",
    "params": {}
  }'
Retrieves available MCP tools for AI agent interaction. Endpoint: POST /api/system/mcp

Request Body

jsonrpc
string
required
JSON-RPC version: "2.0"
id
number
required
Request identifier
method
string
required
MCP method: "tools/list"
params
object
Empty object or tool filters

Response

result
object
Tools list result
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "system_info",
        "description": "Get system information",
        "inputSchema": {
          "type": "object"
        }
      },
      {
        "name": "data_entity_read_many",
        "description": "Read multiple entities from database",
        "inputSchema": {
          "type": "object",
          "properties": {
            "entity": {
              "type": "string"
            },
            "filter": {
              "type": "object"
            }
          },
          "required": ["entity"]
        }
      }
    ]
  }
}

MCP Implementation Details

The MCP endpoints are implemented in /src/index.ts:28-121 with the following features:
  • Protocol Version: 2025-06-18
  • JSON-RPC 2.0: Compliant with JSON-RPC specification
  • CORS Enabled: Cross-origin requests allowed for AI agent access
  • Available Tools:
    • system_info: Get backend system information
    • data_entity_read_many: Query database entities (projects, clients, etc.)

Multi-Tenant Data Isolation

Fataplus ensures strict data isolation:
  • Each tenant has isolated database access
  • Subdomain routing: [tenant].fata.plus
  • Client data is scoped to their tenant
  • Admin users can access cross-tenant for management
  • Session-based authentication with D1 database storage

Error Handling

MCP endpoints return JSON-RPC 2.0 error responses:
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32700,
    "message": "Parse error"
  }
}

Error Codes

  • -32700: Parse error (invalid JSON)
  • -32600: Invalid request
  • -32601: Method not found
  • -32602: Invalid params
  • -32603: Internal error