npm package: @linabase/mcp-server
Description: MCP server for Linabase with 28 tools for schema, data, RLS, storage, and auth management
Latest version: 0.1.1

# @linabase/mcp-server

[Model Context Protocol](https://modelcontextprotocol.io) (MCP) server for [Linabase](https://linabase.com), providing 28 tools for AI-assisted database management.

## Install

```bash
npm install @linabase/mcp-server
```

## Quick Start (stdio mode)

Connect your AI client (Claude Desktop, Cursor, etc.) to your Linabase project:

```bash
LINABASE_DB_URL="postgresql://tenant_{projectId}:{password}@localhost:3105/linabase" \
npx @linabase/mcp-server
```

### Claude Desktop config

```json
{
  "mcpServers": {
    "linabase": {
      "command": "npx",
      "args": ["@linabase/mcp-server"],
      "env": {
        "LINABASE_DB_URL": "postgresql://tenant_{projectId}:{password}@host:3105/linabase",
        "LINABASE_API_URL": "http://localhost:3107",
        "LINABASE_API_KEY": "lb_your_service_role_key"
      }
    }
  }
}
```

## Tools (28)

### Schema
- `list_tables` - List all tables with row counts and RLS status
- `describe_table` - Get column definitions, types, constraints
- `list_views` - List all views
- `list_functions` - List Postgres functions
- `list_triggers` - List triggers
- `list_indexes` - List indexes
- `list_enums` - List custom enum types

### Data
- `query` - Run read-only SQL queries
- `insert_row` - Insert a row into a table
- `update_row` - Update rows matching a filter
- `delete_row` - Delete rows matching a filter
- `execute_sql` - Run DDL/DML (CREATE, ALTER, DROP, INSERT, UPDATE, DELETE)

### RLS
- `list_rls_policies` - List all RLS policies
- `manage_rls_policy` - Create, alter, or drop RLS policies

### Storage
- `list_buckets` - List storage buckets
- `create_bucket` - Create a new bucket
- `update_bucket` - Update bucket settings (public, size limit, MIME types)
- `delete_bucket` - Delete a bucket
- `list_files` - List files in a bucket
- `get_storage_stats` - Get storage usage statistics

### Auth
- `list_auth_users` - List project auth users
- `get_auth_user` - Get user details by ID
- `create_auth_user` - Create a new auth user
- `update_auth_user` - Update user metadata or role
- `delete_auth_user` - Delete an auth user

### Settings
- `get_project_settings` - Get project configuration

### Utilities
- `generate_types` - Generate TypeScript types from schema
- `get_schema_advice` - Get AI-powered schema optimization suggestions

## Environment Variables

| Variable | Required | Description |
|---|---|---|
| `LINABASE_DB_URL` | Yes (stdio) | PostgreSQL connection string for your project |
| `LINABASE_API_URL` | No | REST API URL (enables auth user management tools) |
| `LINABASE_API_KEY` | No | Service role API key (for auth admin endpoints) |
| `SENTRY_DSN` | No | Sentry DSN for error reporting |

## HTTP + OAuth Mode (hosted)

For the hosted Linabase SaaS, the MCP server runs in HTTP mode with OAuth 2.1 authentication:

```bash
DIRECT_DATABASE_URL="postgres://admin:pass@host:5432/linabase" \
MCP_BASE_URL="https://mcp.linabase.com" \
npx @linabase/mcp-server
```

Users authenticate via browser-based OAuth and select their project. The server manages per-session database connections.

## Links

- [Documentation](https://linabase.com/docs)
- [GitHub](https://github.com/linabase/linabase)
- [JavaScript SDK](https://www.npmjs.com/package/@linabase/js)

## License

MIT