Skip to content

AI Integration (MCP)

SchemaStack supports the Model Context Protocol (MCP) — an open standard that lets AI assistants like Claude interact directly with your workspace data. Instead of copy-pasting data or writing API calls, your AI assistant can browse schemas, query data, and even create records through a natural conversation.

What Can AI Do With Your Workspace?

Once connected, an AI assistant can:

  • Browse your schema — list workspaces, views (tables), and columns
  • Query data — search and retrieve records with pagination
  • Create and edit records — insert new rows or update existing values
  • Manage schema — create views, add columns, set up validation constraints
  • Understand your data model — read form schemas to understand column types and constraints

Access Levels

Each workspace has its own MCP access level, giving you fine-grained control over what AI clients can do:

LevelRead SchemaQuery DataCreate/Edit RecordsModify Schema
Disabled (default)NoNoNoNo
Read-OnlyYesYesNoNo
Data-OnlyYesYesYesNo
FullYesYesYesYes

TIP

Start with Read-Only to let AI assistants explore and query your data safely. Upgrade to Data-Only or Full when you need AI-assisted data entry or schema management.

Setting Up MCP Access

1. Enable MCP for Your Workspace

In the Admin app, navigate to your workspace settings and set the MCP access level:

http
PUT /api/workspaces/{workspaceUuid}/mcp-config
Authorization: Bearer <your-token>
Content-Type: application/json

{
  "accessMode": "READ_ONLY"
}

Only workspace administrators (OWNER or ADMIN role) can change MCP settings.

2. Connect Claude Desktop

Add SchemaStack as an MCP server in your Claude Desktop configuration file:

json
{
  "mcpServers": {
    "schemastack": {
      "url": "https://your-schemastack-instance.com/mcp",
      "headers": {
        "Authorization": "Bearer <your-jwt-token>"
      }
    }
  }
}
json
{
  "mcpServers": {
    "schemastack": {
      "url": "https://your-schemastack-instance.com/mcp",
      "headers": {
        "Authorization": "Bearer <your-jwt-token>"
      }
    }
  }
}

3. Connect Claude Code

Add SchemaStack as an MCP server in your project's .mcp.json file:

json
{
  "mcpServers": {
    "schemastack": {
      "type": "url",
      "url": "https://your-schemastack-instance.com/mcp",
      "headers": {
        "Authorization": "Bearer <your-jwt-token>"
      }
    }
  }
}

4. Start Using It

Once connected, you can ask your AI assistant things like:

  • "What workspaces do I have?"
  • "Show me the columns in the Customers view"
  • "Query the first 10 orders"
  • "Add a new column called 'priority' to the Tasks view"
  • "Create a new customer record with name 'Acme Corp' and email '[email protected]'"

Available Tools

Your AI assistant has access to 18 tools organized by category:

Workspace Tools

ToolDescription
get_workspaceGet workspace details including its views

View Tools

ToolDescription
list_viewsList all views (tables) in a workspace
get_viewGet view details with column definitions
create_viewCreate a new view (database table)
update_viewUpdate a view's name or slug
delete_viewDelete a view and its data

Column Tools

ToolDescription
list_columnsList all columns in a view
add_columnAdd a new column with a display name and widget type (STRING, EMAIL, NUMBER, etc.)
update_columnUpdate column display name, widget type, or settings
delete_columnRemove a column

Data Tools

ToolDescription
get_form_schemaGet the full schema for a view (types, constraints, widgets)
query_dataQuery records with pagination
get_recordGet a single record by ID
create_recordCreate a new data record
update_recordUpdate a cell value in a record

Constraint Tools

ToolDescription
list_constraintsList validation constraints on a column
add_constraintAdd a validation constraint (NOT_BLANK, MAX_LENGTH, EMAIL, etc.)
delete_constraintRemove a validation constraint

Transport Protocol

SchemaStack uses the Streamable HTTP MCP transport (not SSE). This is the newer, stateless-friendly transport from the MCP specification (2025-03-26).

How It Works

All communication happens via POST requests to a single /mcp endpoint. The server uses sessions to track state:

  1. Initialize — your first request must be an initialize call. The server returns an Mcp-Session-Id header in the response.
  2. Include the session ID — all subsequent requests must include the Mcp-Session-Id header from step 1.

Most MCP clients (Claude Desktop, Claude Code, Cursor) handle this handshake automatically. If you're building a custom integration, here's the flow:

bash
# Step 1: Initialize and capture the session ID
curl -D- -X POST https://your-instance.com/mcp \
  -H "Authorization: Bearer <your-mcp-api-key>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0", "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-03-26",
      "capabilities": {},
      "clientInfo": {"name": "my-app", "version": "1.0"}
    }
  }'
# → Response includes: Mcp-Session-Id: abc123...

# Step 2: Call tools with the session ID
curl -X POST https://your-instance.com/mcp \
  -H "Authorization: Bearer <your-mcp-api-key>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: abc123..." \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/call",
       "params": {"name": "get_workspace", "arguments": {}}}'

TIP

If you see the error Mcp-Session-Id header not found, your client is skipping the initialize handshake. Make sure it sends an initialize request first and includes the returned session ID on all follow-up requests.

Schema Migrations

When an admin changes a column's type or adds constraints, a schema migration runs on the database. During this time, the affected table may be temporarily unavailable.

If your AI assistant tries to read or write data on a table that's being migrated, it will receive an error like:

Table 'customers' is currently being migrated (operation: abc-123, impact: BLOCKING). Please retry in ~15 seconds.

The AI assistant can inform you and retry after the migration completes. Most migrations take seconds — only large tables with type changes take longer.

What's blocked depends on the migration type:

MigrationReads blocked?Writes blocked?
Column type change (PostgreSQL)YesYes
Column type change (MySQL)NoYes
Add NOT NULL (PostgreSQL)YesYes
Add NOT NULL (MySQL)NoNo
Add unique constraintNoYes

TIP

If your AI workflow needs uninterrupted access, coordinate schema changes with your team to avoid running migrations during active AI sessions.

Security

MCP access uses the same authentication and authorization as the REST API:

  • Authentication: JWT Bearer token — the same token you use for the REST API
  • Authorization: Your existing RBAC roles (Owner, Admin, Member, Viewer) still apply. MCP access levels are an additional gate on top of role-based permissions.
  • Organisation isolation: AI assistants can only access workspaces within the organisation your token is scoped to

WARNING

Your JWT token grants the AI assistant the same permissions you have. Only share tokens with AI clients you trust, and use the most restrictive MCP access level that meets your needs.

Checking MCP Status

To check the current MCP configuration for a workspace:

http
GET /api/workspaces/{workspaceUuid}/mcp-config
Authorization: Bearer <your-token>

Response:

json
{
  "accessMode": "READ_ONLY"
}

SchemaStack Documentation