Skip to content

MCP Server ​

AYB exposes a Model Context Protocol (MCP) server so AI assistants can safely interact with your database through structured tools, resources, and prompts.

With MCP, an assistant can:

  • Inspect schema and functions
  • Query and mutate records
  • Call RPC functions
  • Run SQL (admin token required)
  • Use spatial tools for PostGIS-aware queries

Start the server ​

bash
ayb mcp

Optional flags:

  • --url: AYB server URL
  • --admin-token: privileged token (or AYB_ADMIN_TOKEN)
  • --token: user JWT for RLS-filtered access (or AYB_TOKEN)

Claude Code setup ​

Register AYB as a local stdio MCP server from Claude Code:

bash
claude mcp add ayb -- ayb mcp --url http://127.0.0.1:8090 --token "$AYB_TOKEN"

Use --admin-token instead of --token only when you need privileged tools like run_sql.

Claude Desktop setup ​

ayb mcp also works with Claude Desktop over stdio.

Example claude_desktop_config.json:

json
{
  "mcpServers": {
    "ayb": {
      "command": "ayb",
      "args": ["mcp", "--url", "http://127.0.0.1:8090", "--token", "YOUR_USER_JWT"]
    }
  }
}

Keep your default Desktop config on --token for least-privilege, RLS-scoped access. Create a separate, temporary --admin-token profile only when you explicitly need privileged tools like run_sql.

Cursor setup ​

In Cursor MCP settings, add a stdio MCP server:

  • Command: ayb
  • Args: mcp --url http://127.0.0.1:8090 --token YOUR_USER_JWT

Switch to --admin-token only when SQL execution is required.

Generic MCP-compatible clients ​

Any MCP client that supports stdio transport can launch:

bash
ayb mcp --url http://127.0.0.1:8090 --token "$AYB_TOKEN"

Tools (13 total) ​

Data & schema tools (10) ​

ToolPurpose
list_tablesList database tables and schema metadata
describe_tableDescribe columns, PKs, FKs, indexes for one table
list_functionsList callable RPC/Postgres functions
query_recordsFilter/sort/paginate table records
get_recordFetch one record by ID
create_recordInsert one record
update_recordPartially update one record
delete_recordDelete one record
run_sqlExecute SQL (requires admin token)
call_functionCall RPC/Postgres function with named args

Admin tool (1) ​

ToolPurpose
get_statusFetch AYB health/status and admin metadata

Spatial tools (2) ​

ToolPurpose
spatial_infoShow PostGIS and spatial column/index info
spatial_queryQuery with near, within, intersects, bbox filters

Resources ​

  • ayb://schema: complete schema cache
  • ayb://health: server health payload

Prompts ​

  • explore-table: guides schema + sample-row exploration for one table
  • write-migration: guides safe SQL migration drafting
  • generate-types: guides TypeScript type generation from schema

Security model ​

  • User token (--token / AYB_TOKEN): RLS-filtered data access; preferred default.
  • Admin token (--admin-token / AYB_ADMIN_TOKEN): privileged access for tools that require admin APIs, especially run_sql.

Recommended practice:

  1. Default to user token for normal assistant usage.
  2. Use admin token only for tasks that require privileged APIs (especially run_sql).

Released under the MIT License.