Skip to content

Commit 12fe4b5

Browse files
APIbaseclaude
andcommitted
Add UC-023 Sabre use case, UC-022 Amadeus, and onboard-provider skill
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 7260d29 commit 12fe4b5

File tree

4 files changed

+908
-0
lines changed

4 files changed

+908
-0
lines changed
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
---
2+
name: onboard-provider
3+
description: "Full workflow for onboarding a new API provider into APIbase. Creates adapter, schemas, registers tools, seeds DB, builds, deploys, and verifies. Give this skill the provider name and credentials to get a fully integrated provider on apibase.pro."
4+
user-invocable: true
5+
argument-hint: "<provider-name>"
6+
allowed-tools: Read, Write, Edit, Grep, Glob, Bash, Agent
7+
---
8+
9+
# APIbase — Provider Onboarding Workflow
10+
11+
Complete step-by-step workflow for integrating a new API provider into APIbase.
12+
When invoked, follow ALL steps in order. Do NOT skip steps.
13+
14+
## Prerequisites
15+
16+
Before starting, you MUST have from the user:
17+
1. **Provider name** and website
18+
2. **API credentials** (API key, OAuth2 client ID/secret, etc.)
19+
3. **API endpoints** that are verified working
20+
4. **Tool list** — which tools to create (tool_id, description, price, cache_ttl)
21+
22+
If any of these are missing, ask the user before proceeding.
23+
24+
## Production URLs
25+
26+
| Service | URL |
27+
|---------|-----|
28+
| MCP Endpoint | `https://apibase.pro/mcp` |
29+
| Tool Catalog | `https://apibase.pro/api/v1/tools` |
30+
| Health | `https://apibase.pro/health/ready` |
31+
| Discovery | `https://apibase.pro/.well-known/mcp.json` |
32+
33+
---
34+
35+
## Step 1: Read Existing Patterns
36+
37+
Before writing any code, read these files to understand the patterns:
38+
39+
```
40+
src/adapters/base.adapter.ts — Base adapter class (timeout, retry, size limit)
41+
src/adapters/registry.ts — Adapter registry (tool_id → adapter mapping)
42+
src/types/provider.ts — ProviderRequest, ProviderRawResponse types
43+
src/schemas/index.ts — Schema registry
44+
src/mcp/tool-adapter.ts — MCP tool definitions
45+
config/tool_provider_config.yaml — Tool config (prices, TTLs)
46+
src/config/env.ts — Environment variable schema
47+
.env — Environment variables
48+
```
49+
50+
Also read one existing adapter as reference (e.g. `src/adapters/openweathermap/` or `src/adapters/sabre/`).
51+
52+
---
53+
54+
## Step 2: Create Adapter Files (3 files)
55+
56+
Create `src/adapters/{provider}/` directory with:
57+
58+
### 2a. `types.ts` — Raw API Response Types
59+
60+
TypeScript interfaces for each API endpoint's response structure.
61+
Follow the pattern from `src/adapters/openweathermap/types.ts` or `src/adapters/sabre/types.ts`.
62+
63+
### 2b. `auth.ts` (if needed) — Auth Manager
64+
65+
Only needed for OAuth2 or token-based auth that requires refresh.
66+
If using simple API key in query/header, skip this file.
67+
68+
Pattern: `src/adapters/sabre/auth.ts` (OAuth2 with token caching).
69+
70+
### 2c. `index.ts` — Main Adapter Class
71+
72+
Extends `BaseAdapter`. Must implement:
73+
- `buildRequest(req: ProviderRequest)` — returns `{ url, method, headers, body? }`
74+
- `parseResponse(raw: ProviderRawResponse, req: ProviderRequest)` — validates and returns parsed response
75+
76+
Constructor takes credentials. Switch on `req.toolId` in buildRequest/parseResponse.
77+
78+
If auth is async (OAuth2), override `call()` to fetch token before calling `super.call()`:
79+
```typescript
80+
async call(req: ProviderRequest): Promise<ProviderRawResponse> {
81+
this.currentToken = await this.auth.getToken();
82+
return super.call(req);
83+
}
84+
```
85+
86+
---
87+
88+
## Step 3: Create Zod Schemas (1 file)
89+
90+
Create `src/schemas/{provider}.schema.ts`.
91+
92+
One Zod schema per tool. Export as `Record<string, ZodSchema>`:
93+
```typescript
94+
export const {provider}Schemas: Record<string, ZodSchema> = {
95+
'{provider}.{tool_name}': schema,
96+
};
97+
```
98+
99+
Use `.strip()` on all schemas.
100+
101+
---
102+
103+
## Step 4: Modify Existing Files (6 files)
104+
105+
### 4a. `.env` — Add credentials
106+
```
107+
PROVIDER_KEY_{NAME}=value
108+
# or for OAuth2:
109+
{PROVIDER}_CLIENT_ID=value
110+
{PROVIDER}_CLIENT_SECRET=value
111+
```
112+
113+
### 4b. `src/config/env.ts` — Add to appEnvSchema
114+
```typescript
115+
PROVIDER_KEY_{NAME}: z.string().optional().default(''),
116+
```
117+
118+
### 4c. `src/adapters/registry.ts` — Add import + case
119+
```typescript
120+
import { {Provider}Adapter } from './{provider}';
121+
// In resolveAdapter switch:
122+
case '{provider}':
123+
// instantiate and return adapter
124+
```
125+
126+
### 4d. `src/schemas/index.ts` — Import and spread schemas
127+
```typescript
128+
import { {provider}Schemas } from './{provider}.schema';
129+
// In toolSchemas:
130+
...{provider}Schemas,
131+
```
132+
133+
### 4e. `src/mcp/tool-adapter.ts` — Add tool definitions
134+
```typescript
135+
// {Provider} ({N})
136+
{ toolId: '{provider}.{tool}', description: '...' },
137+
```
138+
Update the tool count comment at the top.
139+
140+
### 4f. `config/tool_provider_config.yaml` — Add tool entries
141+
```yaml
142+
# --- UC-{NNN}: {Provider} ---
143+
- tool_id: {provider}.{tool}
144+
name: {Tool Name}
145+
provider: {provider}
146+
price_usd: "{price}"
147+
cache_ttl: {ttl}
148+
```
149+
150+
---
151+
152+
## Step 5: Verify TypeScript Compilation
153+
154+
```bash
155+
npx tsc --noEmit 2>&1 | grep "src/" || echo "No errors in project source"
156+
```
157+
158+
Must have zero errors in `src/` files.
159+
160+
---
161+
162+
## Step 6: Seed Database
163+
164+
```bash
165+
# Get PostgreSQL container IP
166+
PG_IP=$(sudo docker inspect apibase-postgres-1 2>/dev/null | python3 -c "import sys,json; c=json.load(sys.stdin)[0]; nets=c['NetworkSettings']['Networks']; print(list(nets.values())[0]['IPAddress'])")
167+
168+
DATABASE_URL="postgresql://apibase:0f36a390724b6d8b14ec5ab41bcdc9abb76ef16a86af27e73c2f1553175a6124@${PG_IP}:5432/apibase?schema=public" npx tsx scripts/seed.ts
169+
```
170+
171+
Verify: output should show "Upserted N tools" where N includes the new tools.
172+
173+
---
174+
175+
## Step 7: Build & Deploy
176+
177+
```bash
178+
sudo docker compose -f docker-compose.yml -f docker-compose.prod.yml build api
179+
sudo docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d api
180+
```
181+
182+
Wait 5 seconds for startup.
183+
184+
---
185+
186+
## Step 8: Verify in Production
187+
188+
```bash
189+
# Health check
190+
curl -s https://apibase.pro/health/ready
191+
192+
# Verify new tools appear in catalog
193+
curl -s https://apibase.pro/api/v1/tools | python3 -m json.tool | grep -i "{provider}"
194+
195+
# Check tool detail
196+
curl -s https://apibase.pro/api/v1/tools/{provider}.{first_tool} | python3 -m json.tool
197+
198+
# Count total tools
199+
curl -s https://apibase.pro/api/v1/tools | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'Total tools: {len(d[\"data\"])}')"
200+
```
201+
202+
All new tools MUST appear in catalog with correct pricing.
203+
204+
---
205+
206+
## Step 9: Create UC File
207+
208+
Create `.claude/skills/user-usecases/usecases/UC-{NNN}-{provider}.md`.
209+
210+
Follow the template from `UC-023-sabre.md` or `_TEMPLATE.md`. Must include:
211+
- Meta table (ID, provider, category, date, status)
212+
- Client input data & credentials
213+
- Provider API analysis
214+
- Tool mapping table
215+
- Input schemas
216+
- Implementation files list
217+
- Pricing rationale
218+
219+
Update the index in `.claude/skills/user-usecases/SKILL.md`.
220+
221+
---
222+
223+
## Step 10: Create Smoke Test Script
224+
225+
Create `scripts/test-{provider}.sh`. Must test:
226+
1. Health check
227+
2. Provider tools in catalog (count)
228+
3. Tool detail endpoints (200)
229+
4. Live API calls (with TEST_API_KEY if available)
230+
231+
Make executable: `chmod +x scripts/test-{provider}.sh`
232+
233+
---
234+
235+
## Step 11: Update README.md
236+
237+
Add provider section at the TOP of "Available Tools" in `README.md`.
238+
New providers go first, older providers move down.
239+
240+
---
241+
242+
## Step 12: Update Memory
243+
244+
Update `/home/apibase/.claude/projects/-home-apibase-apibase/memory/MEMORY.md`:
245+
- Add provider to "Connected Providers" list
246+
- Update tool count in "Production Status"
247+
248+
---
249+
250+
## Step 13: Commit & Push
251+
252+
```bash
253+
git add [all new and modified files]
254+
git commit -m "Add {Provider} adapter — {N} tools (UC-{NNN})"
255+
git push origin main
256+
```
257+
258+
---
259+
260+
## Checklist
261+
262+
- [ ] Adapter files created (types.ts, auth.ts if needed, index.ts)
263+
- [ ] Zod schemas created
264+
- [ ] .env updated with credentials
265+
- [ ] env.ts updated with schema
266+
- [ ] registry.ts updated with case
267+
- [ ] schemas/index.ts updated with import
268+
- [ ] tool-adapter.ts updated with definitions
269+
- [ ] tool_provider_config.yaml updated with entries
270+
- [ ] TypeScript compiles with zero errors
271+
- [ ] Database seeded
272+
- [ ] API container built and deployed
273+
- [ ] Tools visible at https://apibase.pro/api/v1/tools
274+
- [ ] UC file created
275+
- [ ] Smoke test script created
276+
- [ ] README.md updated
277+
- [ ] Memory updated
278+
- [ ] Committed and pushed to GitHub

.claude/skills/user-usecases/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Use these examples as reference patterns when:
4343
| UC-019 | Shippo + Geocodio + USITC HTS + GeoNames + UN Comtrade | Logistics / Shipping / Tracking / Delivery Intelligence | Reference | Shippo (Platform Partner, $0.05/label) + Geocodio (free-$200/mo) + USITC HTS (US Gov, free) + GeoNames (CC-BY 4.0, free) + UN Comtrade (Premium Pro, ~$50/mo) | `usecases/UC-019-logistics.md` |
4444
| UC-020 | AsterDex (Aster) | DeFi / Decentralized Trading / Perpetual Futures | Reference | Aster Code Builder Program (100 ASTER deposit) + Referral (tlRYkq, 5-10%) + API Key (HMAC SHA256) | `usecases/UC-020-asterdex.md` |
4545
| UC-021 | Hyperliquid (#1 DEX) | DeFi / Decentralized Trading / Perpetual Futures | Reference | Builder Codes (100 USDC, permissionless) + Referral (CRYPTOREFERENCE, 10%) + API Wallet (0xc98d...eAbB) | `usecases/UC-021-hyperliquid.md` |
46+
| UC-022 | Amadeus | Travel / Flights / Hotels / Airports | Draft | API Key + Secret (OAuth2, Self-Service) | `usecases/UC-022-amadeus.md` |
47+
| UC-023 | Sabre GDS | Travel / Flights / Airlines / Destinations | Live | Client ID + Secret (OAuth2 double base64, cert env) | `usecases/UC-023-sabre.md` |
4648

4749
## How to Use
4850

0 commit comments

Comments
 (0)