Fix inconsistent line endings across all project files for cross-environment consistency. Add complete unit test suite covering core utilities, API routes, and server services. Add Playwright E2E test setup with smoke, auth, and agent API tests. Update all project configuration files to match standardized formatting. Fix MCP API error handling to properly propagate HTTP status codes and use correct JSON-RPC error codes. Add VSCode workspace configuration, extensions, and example MCP config files. Update .gitignore to exclude new test and build artifacts.
54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
# API + MCP Layer
|
|
|
|
## Environment
|
|
Add to `.env.local`:
|
|
|
|
```bash
|
|
NEXT_PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090
|
|
PB_ADMIN_EMAIL=your_admin_email
|
|
PB_ADMIN_PASSWORD=your_admin_password
|
|
AGENT_API_KEY=replace_with_secure_token
|
|
ORDER_ITEMS_COLLECTION=order_items
|
|
```
|
|
|
|
## REST Endpoints
|
|
- `GET /api/v1/health`
|
|
- `GET /api/v1/orders?page=1&perPage=50&status=new`
|
|
- `POST /api/v1/orders/from-quote`
|
|
- `GET /api/v1/collection-pool?page=1&perPage=50&status=queued`
|
|
- `PATCH /api/v1/order-items/{id}/status`
|
|
|
|
Auth for agent routes:
|
|
- Header: `Authorization: Bearer <AGENT_API_KEY>`
|
|
|
|
`POST /orders/from-quote` body:
|
|
```json
|
|
{ "quote_id": "QUOTE_RECORD_ID" }
|
|
```
|
|
|
|
`PATCH /order-items/{id}/status` body supports:
|
|
```json
|
|
{
|
|
"item_status": "processed",
|
|
"drv_status": "assigned",
|
|
"notes": "Assigned to route 2"
|
|
}
|
|
```
|
|
|
|
## MCP Endpoint
|
|
- `POST /api/mcp`
|
|
|
|
Supported methods:
|
|
- `tools/list`
|
|
- `tools/call`
|
|
|
|
Available tools:
|
|
- `orders.list`
|
|
- `orders.create_from_quote`
|
|
- `collection_pool.list`
|
|
- `order_items.update_status`
|
|
|
|
## Notes
|
|
- `ORDER_ITEMS_COLLECTION` controls where order-item writes/updates go.
|
|
- Set `ORDER_ITEMS_COLLECTION=order_items` once new collection is created/imported.
|
|
- Status endpoint accepts `driver_status` input and normalizes to `drv_status`.
|