npm package: @lubes/mcp-server
Description: MCP Server for Lubes.dev - enables AI agents to interact with the platform
Author: Lubes
Latest version: 0.1.4

# Lubes MCP Server

Model Context Protocol (MCP) server for Lubes.dev, enabling AI agents to interact with the platform programmatically.

## Installation

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

Or install globally:

```bash
npm install -g @lubes/mcp-server
```

## Configuration

The MCP server requires configuration to connect to your Lubes project. Configuration can be provided via:

### Environment Variables

```bash
export LUBES_API_URL=https://api.lubes.dev
export LUBES_API_KEY=your-api-key
export LUBES_ORG=your-org-slug
export LUBES_PROJECT=your-project-slug
export LUBES_READ_ONLY=false  # Optional: restrict to read-only operations
```

### Config File

Create `.lubesrc` or `lubes.json` in your working directory:

```json
{
  "apiUrl": "https://api.lubes.dev",
  "apiKey": "your-api-key",
  "org": "your-org-slug",
  "project": "your-project-slug"
}
```

### Project Link

If you've linked a project using the Lubes CLI, the MCP server will automatically read from `.lubes/config.yaml`.

## Usage with Claude Desktop

Add the MCP server to your Claude Desktop configuration:

**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "lubes": {
      "command": "npx",
      "args": ["@lubes/mcp-server"],
      "env": {
        "LUBES_API_URL": "https://api.lubes.dev",
        "LUBES_API_KEY": "your-api-key",
        "LUBES_ORG": "your-org-slug",
        "LUBES_PROJECT": "your-project-slug"
      }
    }
  }
}
```

## Available Tools

### Database Tools

| Tool | Description |
|------|-------------|
| `db_list_tables` | List all tables in the project database |
| `db_get_schema` | Get detailed schema for a specific table |
| `db_query` | Execute SQL queries (SELECT, INSERT, UPDATE, DELETE) |
| `db_branches_list` | List database branches |
| `db_branch_create` | Create a new database branch |
| `db_branch_delete` | Delete a database branch |

### Database Configuration Tools

| Tool | Description |
|------|-------------|
| `db_config_get` | Get the current database configuration |
| `db_config_update` | Update database connection settings |
| `db_config_test` | Test the database connection |
| `db_config_provision` | Provision a new managed database |
| `db_config_reveal_password` | Reveal the current database password |
| `db_config_reset_password` | Reset database password to a new value |
| `db_table_rows` | Get paginated rows from a table |
| `db_table_count` | Get total row count for a table |

### Function Tools

| Tool | Description |
|------|-------------|
| `fn_list` | List all serverless functions |
| `fn_get` | Get details about a specific function |
| `fn_invoke` | Invoke a function with optional payload |
| `fn_logs` | Get recent function execution logs |

### Deployment Tools

| Tool | Description |
|------|-------------|
| `deploy_list` | List all deployments |
| `deploy_create` | Create a new deployment |
| `deploy_status` | Get deployment status |
| `deploy_rollback` | Rollback to a previous deployment |
| `deploy_logs` | Get deployment logs |

### Environment Variable Tools

| Tool | Description |
|------|-------------|
| `env_list` | List environment variables (secrets masked) |
| `env_get` | Get an environment variable value |
| `env_set` | Create or update an environment variable |
| `env_delete` | Delete an environment variable |

### Storage Tools

| Tool | Description |
|------|-------------|
| `storage_buckets_list` | List storage buckets |
| `storage_bucket_create` | Create a new bucket |
| `storage_bucket_delete` | Delete a bucket |
| `storage_objects_list` | List objects in a bucket |
| `storage_object_delete` | Delete an object |
| `storage_signed_url` | Generate a signed URL for an object |

### Project Tools

| Tool | Description |
|------|-------------|
| `project_info` | Get project information |
| `logs_get` | Get project logs |
| `activity_get` | Get recent project activity |

## Resources

The MCP server exposes the following resources:

- `lubes://schema` - Complete database schema
- `lubes://schema/{table_name}` - Schema for a specific table
- `lubes://project` - Current project information

## Prompts

The MCP server provides the following prompt templates:

- `generate_sql` - Generate SQL from natural language
- `design_schema` - Design database schema from requirements
- `explain_schema` - Get an explanation of the current schema

## Read-Only Mode

Set `LUBES_READ_ONLY=true` to restrict the MCP server to read-only operations. In this mode:

- Only `SELECT` queries are allowed
- Bucket/object creation/deletion is disabled
- Environment variable modifications are disabled
- Deployment creation/rollback is disabled
- Function invocation is disabled
- Database configuration changes are disabled
- Database provisioning/password reset is disabled

## Development

```bash
# Install dependencies
npm install

# Build
npm run build

# Run locally
npm start
```

## Testing with MCP Inspector

```bash
npx @modelcontextprotocol/inspector ./bin/lubes-mcp.js
```

## License

MIT