bkend-mcp: MCP Tools & AI Integration Expert Skill
1. MCP Overview
The Model Context Protocol (MCP) is an open standard that enables AI models to interact with external tools and data sources through a unified interface. bkend.ai implements MCP to provide AI-powered development workflows.
Protocol Specification
| Property |
Value |
| Protocol |
MCP 2025-03-26 |
| Transport |
Streamable HTTP |
| Authentication |
OAuth 2.1 + PKCE |
| Server URL |
https://api.bkend.ai/mcp |
| Content Type |
application/json |
| Session Header |
Mcp-Session-Id |
How It Works
- The AI client (Gemini CLI, Claude Code, Cursor, etc.) connects to the MCP server
- The server advertises available tools and resources
- The AI model invokes tools on behalf of the user
- The server executes operations and returns structured results
- OAuth 2.1 + PKCE ensures secure, user-authorized access
2. MCP Tool Catalog (28 Tools)
bkend.ai exposes 28 MCP tools organized into 6 categories. Each tool follows the MCP tool schema with name, description, and inputSchema properties.
2.1 Fixed Tools (3)
These tools are always available regardless of project context.
| Tool Name |
Description |
Parameters |
get_context |
Returns current session context including org, project, environment, and user info |
None |
search_docs |
Searches bkend.ai documentation by topic or keyword |
query (string, required), category (string, optional) |
get_operation_schema |
Returns the OpenAPI schema for a specific REST API operation |
operationId (string, required) |
Usage Notes:
- Always call
get_context first to verify your session is properly authenticated
- Use
search_docs to find REST API documentation for Auth and Storage features (no MCP tools available for these)
- Use
get_operation_schema to get detailed request/response schemas for code generation
2.2 Project Management Tools (6)
Tools for managing organizations, projects, and environments.
| Tool Name |
Description |
Parameters |
backend_org_list |
Lists all organizations the user belongs to |
None |
backend_project_list |
Lists all projects in the current organization |
orgId (string, required) |
backend_project_create |
Creates a new project |
orgId (string, required), name (string, required), description (string, optional) |
backend_project_get |
Gets project details |
projectId (string, required) |
backend_env_list |
Lists environments for a project |
projectId (string, required) |
backend_env_create |
Creates a new environment (dev/staging/prod) |
projectId (string, required), name (string, required), type (enum: dev/staging/prod) |
Usage Notes:
- Start with
backend_org_list to get the orgId
- Then use
backend_project_list or backend_project_create to set up project context
- Each project can have multiple environments with isolated data
2.3 Table Management Tools (9)
Tools for defining and managing database table schemas.
| Tool Name |
Description |
Parameters |
backend_table_list |
Lists all tables in the environment |
envId (string, required) |
backend_table_create |
Creates a new table with fields |
envId (string, required), name (string, required), fields (array, required) |
backend_table_get |
Gets table schema details |
envId (string, required), tableId (string, required) |
backend_table_update |
Updates table settings |
envId (string, required), tableId (string, required), settings (object, required) |
backend_table_delete |
Deletes a table and all its data |
envId (string, required), tableId (string, required) |
backend_field_manage |
Adds, updates, or removes fields on a table |
envId (string, required), tableId (string, required), action (enum: add/update/remove), field (object, required) |
backend_index_manage |
Manages indexes on a table |
envId (string, required), tableId (string, required), action (enum: create/delete), index (object, required) |
backend_schema_version_list |
Lists schema versions (migration history) |
envId (string, required), tableId (string, required) |
backend_schema_version_get |
Gets a specific schema version |
envId (string, required), tableId (string, required), versionId (string, required) |
Field Types:
string, number, boolean, date, datetime
text (long text), richtext (HTML content)
email, url, phone
enum (with options array)
relation (with targetTable and relationType)
file (stored in bkend Storage)
json (arbitrary JSON object)
2.4 Data CRUD Tools (5)
Tools for creating, reading, updating, and deleting records in tables.
| Tool Name |
Description |
Parameters |
backend_data_list |
Lists records with filtering and paging |
envId (string, required), tableId (string, required), filter (object, optional), sort (object, optional), page (number, optional), limit (number, optional) |
backend_data_get |
Gets a single record by ID |
envId (string, required), tableId (string, required), recordId (string, required) |
backend_data_create |
Creates a new record |
envId (string, required), tableId (string, required), data (object, required) |
backend_data_update |
Updates an existing record |
envId (string, required), tableId (string, required), recordId (string, required), data (object, required) |
backend_data_delete |
Deletes a record |
envId (string, required), tableId (string, required), recordId (string, required) |
Filter Syntax:
{
"filter": {
"field": "status",
"operator": "eq",
"value": "active"
}
}
Supported Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, startsWith, endsWith, exists
Sort Syntax:
{
"sort": {
"field": "createdAt",
"order": "desc"
}
}
2.5 Environment Tools (3)
Included in Project Management above: backend_env_list, backend_env_create, plus:
| Tool Name |
Description |
Parameters |
backend_env_get |
Gets environment details and configuration |
envId (string, required) |
2.6 Schema Tools (2)
Included in Table Management above: backend_schema_version_list, backend_schema_version_get.
These tools provide migration history and rollback capabilities for table schemas.
3. MCP Resources (4)
MCP resources provide read-only contextual data that AI models can access without explicit tool calls.
| Resource URI |
Description |
MIME Type |
bkend://context |
Current session context (org, project, env) |
application/json |
bkend://tables |
List of all tables in the current environment |
application/json |
bkend://schema/{table} |
Full schema definition for a specific table |
application/json |
bkend://docs/{topic} |
Documentation content for a specific topic |
text/markdown |
Resource Usage:
- Resources are automatically available to AI models that support MCP resource reading
- Use
bkend://context to understand the current working environment
- Use
bkend://tables to discover available data structures
- Use
bkend://schema/{table} to get detailed field definitions before data operations
- Use
bkend://docs/{topic} to retrieve documentation (topics: auth, storage, rls, api-keys, webhooks)
4. Auth & Storage MCP Limitation
Important: bkend.ai does NOT provide MCP tools for Authentication or Storage operations. These features are accessible only through the REST API.
Why No MCP Tools?
- Authentication operations (signup, login, token management) involve sensitive credentials and security flows that are better handled through direct REST API calls with proper error handling
- Storage operations (file upload, download, signed URLs) require binary data transfer that is not well-suited for the MCP tool protocol
Recommended Workflow
- Use
search_docs to find the relevant REST API documentation:search_docs("authentication signup")
search_docs("storage file upload")
- Use
get_operation_schema to get the detailed OpenAPI schema:get_operation_schema("auth-signup")
get_operation_schema("storage-upload")
- Generate REST API client code based on the retrieved documentation and schemas
- Use the generated code in your application to call the REST API directly
Auth REST API Endpoints (Reference)
| Endpoint |
Method |
Description |
/auth/signup |
POST |
Register a new user |
/auth/login |
POST |
Login with credentials |
/auth/logout |
POST |
Invalidate session |
/auth/refresh |
POST |
Refresh access token |
/auth/me |
GET |
Get current user profile |
/auth/password/reset |
POST |
Request password reset |
/auth/password/change |
POST |
Change password |
Storage REST API Endpoints (Reference)
| Endpoint |
Method |
Description |
/storage/upload |
POST |
Upload a file |
/storage/download/{fileId} |
GET |
Download a file |
/storage/list |
GET |
List files in a bucket |
/storage/delete/{fileId} |
DELETE |
Delete a file |
/storage/signed-url |
POST |
Generate a signed URL |
5. AI Tool Setup
5.1 Gemini CLI
Create or edit .gemini/settings.json in your project root:
{
"mcpServers": {
"bkend": {
"httpUrl": "https://api.bkend.ai/mcp"
}
}
}
Verification:
gemini --mcp-list
The first time you invoke a bkend tool, Gemini CLI will open your browser for OAuth authentication.
5.2 Claude Code
Create or edit .mcp.json in your project root:
{
"mcpServers": {
"bkend": {
"type": "streamable-http",
"url": "https://api.bkend.ai/mcp"
}
}
}
Verification:
claude mcp list
Claude Code will automatically handle OAuth 2.1 + PKCE authentication when tools are first invoked.
5.3 Cursor
- Open Settings (Cmd/Ctrl + ,)
- Navigate to MCP section
- Click Add Server
- Configure:
- Name:
bkend
- Type: HTTP
- URL:
https://api.bkend.ai/mcp
- Click Save
Cursor will prompt for OAuth authentication when MCP tools are first used.
5.4 Windsurf
Create or edit .windsurfrules or use the MCP configuration in settings:
{
"mcpServers": {
"bkend": {
"serverUrl": "https://api.bkend.ai/mcp",
"transport": "streamable-http"
}
}
}
5.5 VS Code (GitHub Copilot)
Add to .vscode/settings.json:
{
"github.copilot.chat.mcpServers": {
"bkend": {
"type": "http",
"url": "https://api.bkend.ai/mcp"
}
}
}
5.6 Other Editors
Any MCP-compatible editor can connect to bkend.ai using:
- Transport: Streamable HTTP
- URL:
https://api.bkend.ai/mcp
- Auth: OAuth 2.1 + PKCE (handled automatically by most clients)
6. OAuth 2.1 + PKCE Authentication Flow
Flow Overview
AI Client bkend.ai Auth Server User Browser
| | |
|-- 1. Generate code_verifier -->| |
|-- 2. Compute code_challenge -->| |
| | |
|-- 3. GET /oauth/authorize ---->| |
| ?client_id=... | |
| &code_challenge=... | |
| &code_challenge_method=S256 |
| &redirect_uri=... | |
| &response_type=code | |
| &scope=mcp | |
| |-- 4. Show login page -------->|
| |<-- 5. User authenticates -----|
| | |
|<-- 6. Redirect with auth code -| |
| ?code=AUTH_CODE | |
| | |
|-- 7. POST /oauth/token ------->| |
| grant_type=authorization_code |
| code=AUTH_CODE | |
| code_verifier=... | |
| | |
|<-- 8. Access + Refresh tokens -| |
| | |
|-- 9. MCP requests with ------->| |
| Authorization: Bearer ... | |
Token Lifecycle
| Token |
Lifetime |
Storage |
Refresh Method |
| Access Token |
1 hour |
In-memory (client) |
Exchange refresh token |
| Refresh Token |
30 days |
Secure storage |
Re-authenticate |
Token Refresh
When the access token expires, the MCP client automatically:
- Sends a
POST /oauth/token request with grant_type=refresh_token
- Includes the refresh token in the request body
- Receives a new access token (and optionally a new refresh token)
- Retries the failed MCP request with the new access token
7. MCP Best Practices
7.1 Session Initialization
Always start by verifying your session context:
1. Call get_context -> verify org, project, and environment
2. Call backend_table_list -> understand available data structures
3. Proceed with specific operations
7.2 Schema-First Development
Create tables and define schemas via MCP before performing data operations:
1. backend_table_create -> define table with fields
2. backend_field_manage -> add/modify fields as needed
3. backend_index_manage -> create indexes for query performance
4. backend_data_create -> insert records
7.3 Documentation-Driven Code Generation
For Auth and Storage features (no MCP tools), use documentation tools:
1. search_docs("authentication login flow") -> get documentation
2. get_operation_schema("auth-login") -> get OpenAPI schema
3. Generate client code based on the schema
7.4 Environment Awareness
- Always confirm which environment (dev/staging/prod) you are working in before making changes
- Use
get_context to verify the active environment
- Create separate environments for development and production workflows
7.5 Batch Operations
- Use filtering and pagination with
backend_data_list for large datasets
- Set appropriate
limit values (default: 20, max: 100) to avoid excessive data transfer
- Use
sort to control the order of returned records
8. Common MCP Errors and Solutions
Connection Errors
| Error |
Cause |
Solution |
401 Unauthorized |
Expired or missing access token |
Re-authenticate via OAuth flow |
403 Forbidden |
Insufficient permissions or RLS |
Check API key type and RLS policies |
404 Not Found |
Invalid endpoint or resource ID |
Verify server URL and resource IDs |
429 Too Many Requests |
Rate limit exceeded |
Wait and retry with exponential backoff |
500 Internal Server Error |
Server-side issue |
Retry after a brief delay |
Tool Invocation Errors
| Error |
Cause |
Solution |
tool_not_found |
Tool name is incorrect |
Check tool catalog for exact names |
invalid_params |
Missing or invalid parameters |
Review tool parameter requirements |
env_not_set |
No environment selected |
Call get_context and set environment |
table_not_found |
Table does not exist |
Use backend_table_list to verify |
field_type_mismatch |
Data type does not match schema |
Check field types with backend_table_get |
Authentication Errors
| Error |
Cause |
Solution |
oauth_pkce_mismatch |
Code verifier does not match |
Regenerate code_verifier and retry |
oauth_code_expired |
Authorization code expired |
Restart OAuth flow from the beginning |
oauth_redirect_mismatch |
Redirect URI does not match |
Verify redirect_uri matches registered value |
refresh_token_expired |
Refresh token (30d) expired |
Full re-authentication required |
Quick Reference Card
Essential Tool Sequence
get_context # 1. Verify session
backend_org_list # 2. List organizations
backend_project_list(orgId) # 3. List projects
backend_table_list(envId) # 4. List tables
backend_data_list(envId, tableId) # 5. Query data
MCP Server Connection
URL: https://api.bkend.ai/mcp
Transport: Streamable HTTP
Auth: OAuth 2.1 + PKCE
Tool Count Summary
| Category |
Count |
Tools |
| Fixed |
3 |
get_context, search_docs, get_operation_schema |
| Project Management |
6 |
org_list, project_list/create/get, env_list/create |
| Table Management |
9 |
table CRUD (5), field_manage, index_manage, schema_version (2) |
| Data CRUD |
5 |
data_list/get/create/update/delete |
| Environment |
3 |
env_list/create/get |
| Schema |
2 |
schema_version_list/get |
| Total |
28 |
|
1---
2name: bkend-mcp
3classification: C
4description: |
5 bkend.ai MCP tools and AI integration expert skill.
6 Covers 28 MCP tools (Fixed 3 + Project 6 + Table 9 + Data CRUD 5 + Env 3 + Schema 2),
7 4 MCP resources, OAuth 2.1 + PKCE authentication, and AI tool setup
8 for Gemini CLI, Claude Code, and Cursor.
9
10 Triggers: mcp, ai tool, mcp setup, backend tool, bkend mcp,
11 MCP 설정, MCP 도구, AI 도구, MCP接続, MCP設定, AIツール,
12 MCP连接, MCP设置, AI工具,
13 herramientas MCP, configuracion MCP, outils MCP, configuration MCP,
14 MCP-Werkzeuge, MCP-Einrichtung, strumenti MCP, configurazione MCP
15
16 Do NOT use for: authentication implementation (use bkend-auth),
17 database queries (use bkend-data), file storage (use bkend-storage)
18
19user-invocable: true
20argument-hint: ""
21
22allowed-tools:
23 - read_file
24 - write_file
25 - replace
26 - glob
27 - grep_search
28 - run_shell_command
29 - web_fetch
30
31imports: []
32
33agents:
34 backend: bkend-expert
35
36context: session
37memory: project
38pdca-phase: all
39metadata:
40 source: https://skillmd.com/skills/aibot88/bkend-mcp
41---
42
43# bkend-mcp: MCP Tools & AI Integration Expert Skill
44
45## 1. MCP Overview
46
47The Model Context Protocol (MCP) is an open standard that enables AI models to interact with external tools and data sources through a unified interface. bkend.ai implements MCP to provide AI-powered development workflows.
48
49### Protocol Specification
50
51| Property | Value |
52|-----------------|--------------------------------------|
53| Protocol | MCP 2025-03-26 |
54| Transport | Streamable HTTP |
55| Authentication | OAuth 2.1 + PKCE |
56| Server URL | `https://api.bkend.ai/mcp` |
57| Content Type | `application/json` |
58| Session Header | `Mcp-Session-Id` |
59
60### How It Works
61
621. The AI client (Gemini CLI, Claude Code, Cursor, etc.) connects to the MCP server
632. The server advertises available tools and resources
643. The AI model invokes tools on behalf of the user
654. The server executes operations and returns structured results
665. OAuth 2.1 + PKCE ensures secure, user-authorized access
67
68---
69
70## 2. MCP Tool Catalog (28 Tools)
71
72bkend.ai exposes 28 MCP tools organized into 6 categories. Each tool follows the MCP tool schema with `name`, `description`, and `inputSchema` properties.
73
74### 2.1 Fixed Tools (3)
75
76These tools are always available regardless of project context.
77
78| Tool Name | Description | Parameters |
79|------------------------|---------------------------------------------------|--------------------------------|
80| `get_context` | Returns current session context including org, project, environment, and user info | None |
81| `search_docs` | Searches bkend.ai documentation by topic or keyword | `query` (string, required), `category` (string, optional) |
82| `get_operation_schema` | Returns the OpenAPI schema for a specific REST API operation | `operationId` (string, required) |
83
84**Usage Notes:**
85- Always call `get_context` first to verify your session is properly authenticated
86- Use `search_docs` to find REST API documentation for Auth and Storage features (no MCP tools available for these)
87- Use `get_operation_schema` to get detailed request/response schemas for code generation
88
89### 2.2 Project Management Tools (6)
90
91Tools for managing organizations, projects, and environments.
92
93| Tool Name | Description | Parameters |
94|--------------------------|------------------------------------------------|-----------------------------------------------------|
95| `backend_org_list` | Lists all organizations the user belongs to | None |
96| `backend_project_list` | Lists all projects in the current organization | `orgId` (string, required) |
97| `backend_project_create` | Creates a new project | `orgId` (string, required), `name` (string, required), `description` (string, optional) |
98| `backend_project_get` | Gets project details | `projectId` (string, required) |
99| `backend_env_list` | Lists environments for a project | `projectId` (string, required) |
100| `backend_env_create` | Creates a new environment (dev/staging/prod) | `projectId` (string, required), `name` (string, required), `type` (enum: dev/staging/prod) |
101
102**Usage Notes:**
103- Start with `backend_org_list` to get the `orgId`
104- Then use `backend_project_list` or `backend_project_create` to set up project context
105- Each project can have multiple environments with isolated data
106
107### 2.3 Table Management Tools (9)
108
109Tools for defining and managing database table schemas.
110
111| Tool Name | Description | Parameters |
112|--------------------------------|---------------------------------------------|---------------------------------------------------------|
113| `backend_table_list` | Lists all tables in the environment | `envId` (string, required) |
114| `backend_table_create` | Creates a new table with fields | `envId` (string, required), `name` (string, required), `fields` (array, required) |
115| `backend_table_get` | Gets table schema details | `envId` (string, required), `tableId` (string, required) |
116| `backend_table_update` | Updates table settings | `envId` (string, required), `tableId` (string, required), `settings` (object, required) |
117| `backend_table_delete` | Deletes a table and all its data | `envId` (string, required), `tableId` (string, required) |
118| `backend_field_manage` | Adds, updates, or removes fields on a table | `envId` (string, required), `tableId` (string, required), `action` (enum: add/update/remove), `field` (object, required) |
119| `backend_index_manage` | Manages indexes on a table | `envId` (string, required), `tableId` (string, required), `action` (enum: create/delete), `index` (object, required) |
120| `backend_schema_version_list` | Lists schema versions (migration history) | `envId` (string, required), `tableId` (string, required) |
121| `backend_schema_version_get` | Gets a specific schema version | `envId` (string, required), `tableId` (string, required), `versionId` (string, required) |
122
123**Field Types:**
124- `string`, `number`, `boolean`, `date`, `datetime`
125- `text` (long text), `richtext` (HTML content)
126- `email`, `url`, `phone`
127- `enum` (with `options` array)
128- `relation` (with `targetTable` and `relationType`)
129- `file` (stored in bkend Storage)
130- `json` (arbitrary JSON object)
131
132### 2.4 Data CRUD Tools (5)
133
134Tools for creating, reading, updating, and deleting records in tables.
135
136| Tool Name | Description | Parameters |
137|------------------------|------------------------------------------|-----------------------------------------------------------|
138| `backend_data_list` | Lists records with filtering and paging | `envId` (string, required), `tableId` (string, required), `filter` (object, optional), `sort` (object, optional), `page` (number, optional), `limit` (number, optional) |
139| `backend_data_get` | Gets a single record by ID | `envId` (string, required), `tableId` (string, required), `recordId` (string, required) |
140| `backend_data_create` | Creates a new record | `envId` (string, required), `tableId` (string, required), `data` (object, required) |
141| `backend_data_update` | Updates an existing record | `envId` (string, required), `tableId` (string, required), `recordId` (string, required), `data` (object, required) |
142| `backend_data_delete` | Deletes a record | `envId` (string, required), `tableId` (string, required), `recordId` (string, required) |
143
144**Filter Syntax:**
145```json
146{
147 "filter": {
148 "field": "status",
149 "operator": "eq",
150 "value": "active"
151 }
152}
153```
154
155**Supported Operators:** `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`, `contains`, `startsWith`, `endsWith`, `exists`
156
157**Sort Syntax:**
158```json
159{
160 "sort": {
161 "field": "createdAt",
162 "order": "desc"
163 }
164}
165```
166
167### 2.5 Environment Tools (3)
168
169Included in Project Management above: `backend_env_list`, `backend_env_create`, plus:
170
171| Tool Name | Description | Parameters |
172|----------------------|------------------------------------------------|-----------------------------------------------------|
173| `backend_env_get` | Gets environment details and configuration | `envId` (string, required) |
174
175### 2.6 Schema Tools (2)
176
177Included in Table Management above: `backend_schema_version_list`, `backend_schema_version_get`.
178
179These tools provide migration history and rollback capabilities for table schemas.
180
181---
182
183## 3. MCP Resources (4)
184
185MCP resources provide read-only contextual data that AI models can access without explicit tool calls.
186
187| Resource URI | Description | MIME Type |
188|-------------------------------|------------------------------------------------|--------------------|
189| `bkend://context` | Current session context (org, project, env) | `application/json` |
190| `bkend://tables` | List of all tables in the current environment | `application/json` |
191| `bkend://schema/{table}` | Full schema definition for a specific table | `application/json` |
192| `bkend://docs/{topic}` | Documentation content for a specific topic | `text/markdown` |
193
194**Resource Usage:**
195- Resources are automatically available to AI models that support MCP resource reading
196- Use `bkend://context` to understand the current working environment
197- Use `bkend://tables` to discover available data structures
198- Use `bkend://schema/{table}` to get detailed field definitions before data operations
199- Use `bkend://docs/{topic}` to retrieve documentation (topics: `auth`, `storage`, `rls`, `api-keys`, `webhooks`)
200
201---
202
203## 4. Auth & Storage MCP Limitation
204
205**Important:** bkend.ai does NOT provide MCP tools for Authentication or Storage operations. These features are accessible only through the REST API.
206
207### Why No MCP Tools?
208
209- **Authentication** operations (signup, login, token management) involve sensitive credentials and security flows that are better handled through direct REST API calls with proper error handling
210- **Storage** operations (file upload, download, signed URLs) require binary data transfer that is not well-suited for the MCP tool protocol
211
212### Recommended Workflow
213
2141. Use `search_docs` to find the relevant REST API documentation:
215 ```
216 search_docs("authentication signup")
217 search_docs("storage file upload")
218 ```
2192. Use `get_operation_schema` to get the detailed OpenAPI schema:
220 ```
221 get_operation_schema("auth-signup")
222 get_operation_schema("storage-upload")
223 ```
2243. Generate REST API client code based on the retrieved documentation and schemas
2254. Use the generated code in your application to call the REST API directly
226
227### Auth REST API Endpoints (Reference)
228
229| Endpoint | Method | Description |
230|------------------------------|--------|---------------------------|
231| `/auth/signup` | POST | Register a new user |
232| `/auth/login` | POST | Login with credentials |
233| `/auth/logout` | POST | Invalidate session |
234| `/auth/refresh` | POST | Refresh access token |
235| `/auth/me` | GET | Get current user profile |
236| `/auth/password/reset` | POST | Request password reset |
237| `/auth/password/change` | POST | Change password |
238
239### Storage REST API Endpoints (Reference)
240
241| Endpoint | Method | Description |
242|------------------------------|--------|---------------------------|
243| `/storage/upload` | POST | Upload a file |
244| `/storage/download/{fileId}` | GET | Download a file |
245| `/storage/list` | GET | List files in a bucket |
246| `/storage/delete/{fileId}` | DELETE | Delete a file |
247| `/storage/signed-url` | POST | Generate a signed URL |
248
249---
250
251## 5. AI Tool Setup
252
253### 5.1 Gemini CLI
254
255Create or edit `.gemini/settings.json` in your project root:
256
257```json
258{
259 "mcpServers": {
260 "bkend": {
261 "httpUrl": "https://api.bkend.ai/mcp"
262 }
263 }
264}
265```
266
267**Verification:**
268```bash
269gemini --mcp-list
270```
271
272The first time you invoke a bkend tool, Gemini CLI will open your browser for OAuth authentication.
273
274### 5.2 Claude Code
275
276Create or edit `.mcp.json` in your project root:
277
278```json
279{
280 "mcpServers": {
281 "bkend": {
282 "type": "streamable-http",
283 "url": "https://api.bkend.ai/mcp"
284 }
285 }
286}
287```
288
289**Verification:**
290```bash
291claude mcp list
292```
293
294Claude Code will automatically handle OAuth 2.1 + PKCE authentication when tools are first invoked.
295
296### 5.3 Cursor
297
2981. Open **Settings** (Cmd/Ctrl + ,)
2992. Navigate to **MCP** section
3003. Click **Add Server**
3014. Configure:
302 - **Name:** `bkend`
303 - **Type:** HTTP
304 - **URL:** `https://api.bkend.ai/mcp`
3055. Click **Save**
306
307Cursor will prompt for OAuth authentication when MCP tools are first used.
308
309### 5.4 Windsurf
310
311Create or edit `.windsurfrules` or use the MCP configuration in settings:
312
313```json
314{
315 "mcpServers": {
316 "bkend": {
317 "serverUrl": "https://api.bkend.ai/mcp",
318 "transport": "streamable-http"
319 }
320 }
321}
322```
323
324### 5.5 VS Code (GitHub Copilot)
325
326Add to `.vscode/settings.json`:
327
328```json
329{
330 "github.copilot.chat.mcpServers": {
331 "bkend": {
332 "type": "http",
333 "url": "https://api.bkend.ai/mcp"
334 }
335 }
336}
337```
338
339### 5.6 Other Editors
340
341Any MCP-compatible editor can connect to bkend.ai using:
342- **Transport:** Streamable HTTP
343- **URL:** `https://api.bkend.ai/mcp`
344- **Auth:** OAuth 2.1 + PKCE (handled automatically by most clients)
345
346---
347
348## 6. OAuth 2.1 + PKCE Authentication Flow
349
350### Flow Overview
351
352```
353AI Client bkend.ai Auth Server User Browser
354 | | |
355 |-- 1. Generate code_verifier -->| |
356 |-- 2. Compute code_challenge -->| |
357 | | |
358 |-- 3. GET /oauth/authorize ---->| |
359 | ?client_id=... | |
360 | &code_challenge=... | |
361 | &code_challenge_method=S256 |
362 | &redirect_uri=... | |
363 | &response_type=code | |
364 | &scope=mcp | |
365 | |-- 4. Show login page -------->|
366 | |<-- 5. User authenticates -----|
367 | | |
368 |<-- 6. Redirect with auth code -| |
369 | ?code=AUTH_CODE | |
370 | | |
371 |-- 7. POST /oauth/token ------->| |
372 | grant_type=authorization_code |
373 | code=AUTH_CODE | |
374 | code_verifier=... | |
375 | | |
376 |<-- 8. Access + Refresh tokens -| |
377 | | |
378 |-- 9. MCP requests with ------->| |
379 | Authorization: Bearer ... | |
380```
381
382### Token Lifecycle
383
384| Token | Lifetime | Storage | Refresh Method |
385|----------------|----------|---------------------|-------------------------|
386| Access Token | 1 hour | In-memory (client) | Exchange refresh token |
387| Refresh Token | 30 days | Secure storage | Re-authenticate |
388
389### Token Refresh
390
391When the access token expires, the MCP client automatically:
3921. Sends a `POST /oauth/token` request with `grant_type=refresh_token`
3932. Includes the refresh token in the request body
3943. Receives a new access token (and optionally a new refresh token)
3954. Retries the failed MCP request with the new access token
396
397---
398
399## 7. MCP Best Practices
400
401### 7.1 Session Initialization
402
403Always start by verifying your session context:
404
405```
4061. Call get_context -> verify org, project, and environment
4072. Call backend_table_list -> understand available data structures
4083. Proceed with specific operations
409```
410
411### 7.2 Schema-First Development
412
413Create tables and define schemas via MCP before performing data operations:
414
415```
4161. backend_table_create -> define table with fields
4172. backend_field_manage -> add/modify fields as needed
4183. backend_index_manage -> create indexes for query performance
4194. backend_data_create -> insert records
420```
421
422### 7.3 Documentation-Driven Code Generation
423
424For Auth and Storage features (no MCP tools), use documentation tools:
425
426```
4271. search_docs("authentication login flow") -> get documentation
4282. get_operation_schema("auth-login") -> get OpenAPI schema
4293. Generate client code based on the schema
430```
431
432### 7.4 Environment Awareness
433
434- Always confirm which environment (dev/staging/prod) you are working in before making changes
435- Use `get_context` to verify the active environment
436- Create separate environments for development and production workflows
437
438### 7.5 Batch Operations
439
440- Use filtering and pagination with `backend_data_list` for large datasets
441- Set appropriate `limit` values (default: 20, max: 100) to avoid excessive data transfer
442- Use `sort` to control the order of returned records
443
444---
445
446## 8. Common MCP Errors and Solutions
447
448### Connection Errors
449
450| Error | Cause | Solution |
451|---------------------------------|------------------------------------|-----------------------------------------|
452| `401 Unauthorized` | Expired or missing access token | Re-authenticate via OAuth flow |
453| `403 Forbidden` | Insufficient permissions or RLS | Check API key type and RLS policies |
454| `404 Not Found` | Invalid endpoint or resource ID | Verify server URL and resource IDs |
455| `429 Too Many Requests` | Rate limit exceeded | Wait and retry with exponential backoff |
456| `500 Internal Server Error` | Server-side issue | Retry after a brief delay |
457
458### Tool Invocation Errors
459
460| Error | Cause | Solution |
461|---------------------------------|------------------------------------|-----------------------------------------|
462| `tool_not_found` | Tool name is incorrect | Check tool catalog for exact names |
463| `invalid_params` | Missing or invalid parameters | Review tool parameter requirements |
464| `env_not_set` | No environment selected | Call `get_context` and set environment |
465| `table_not_found` | Table does not exist | Use `backend_table_list` to verify |
466| `field_type_mismatch` | Data type does not match schema | Check field types with `backend_table_get` |
467
468### Authentication Errors
469
470| Error | Cause | Solution |
471|---------------------------------|------------------------------------|-----------------------------------------|
472| `oauth_pkce_mismatch` | Code verifier does not match | Regenerate code_verifier and retry |
473| `oauth_code_expired` | Authorization code expired | Restart OAuth flow from the beginning |
474| `oauth_redirect_mismatch` | Redirect URI does not match | Verify redirect_uri matches registered value |
475| `refresh_token_expired` | Refresh token (30d) expired | Full re-authentication required |
476
477---
478
479## Quick Reference Card
480
481### Essential Tool Sequence
482
483```
484get_context # 1. Verify session
485backend_org_list # 2. List organizations
486backend_project_list(orgId) # 3. List projects
487backend_table_list(envId) # 4. List tables
488backend_data_list(envId, tableId) # 5. Query data
489```
490
491### MCP Server Connection
492
493```
494URL: https://api.bkend.ai/mcp
495Transport: Streamable HTTP
496Auth: OAuth 2.1 + PKCE
497```
498
499### Tool Count Summary
500
501| Category | Count | Tools |
502|--------------------|-------|-----------------------------------------------|
503| Fixed | 3 | get_context, search_docs, get_operation_schema |
504| Project Management | 6 | org_list, project_list/create/get, env_list/create |
505| Table Management | 9 | table CRUD (5), field_manage, index_manage, schema_version (2) |
506| Data CRUD | 5 | data_list/get/create/update/delete |
507| Environment | 3 | env_list/create/get |
508| Schema | 2 | schema_version_list/get |
509| **Total** | **28**| |