Skip to content

Commit 29db459

Browse files
Merge pull request #130 from scope3data/EmmaLouise2018/slim-sdk-overhaul
feat: replace McpAdapter with thin Scope3McpClient
2 parents 5d43cb7 + 9b89bfc commit 29db459

82 files changed

Lines changed: 8649 additions & 2142 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.npmignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jest.config.js
4343
openapi.yaml
4444
media-agent-openapi.yaml
4545
outcome-agent-openapi.yaml
46-
partner-api.yaml
46+
storefront-api.yaml
4747
platform-api.yaml
4848

4949
# Test files

‎README.md‎

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Scope3 SDK
22

3-
TypeScript client for the Scope3 Agentic Platform. Supports two personas (buyer, partner) with REST and MCP adapters.
3+
TypeScript client for the Scope3 Agentic Platform. Two entry points for two audiences:
4+
5+
- **REST consumers** (humans, CLI, programmatic) → `Scope3Client` with typed resource methods
6+
- **MCP consumers** (AI agents) → `Scope3McpClient` — thin connection helper with direct `callTool`/`readResource`
47

58
## Installation
69

@@ -24,11 +27,11 @@ Obtain your API key from the Scope3 dashboard:
2427

2528
## Quick Start
2629

27-
The SDK uses a unified `Scope3Client` with a `persona` parameter to determine available resources.
30+
### REST Client (Humans / CLI / Programmatic)
2831

29-
### Buyer Persona
32+
The `Scope3Client` provides typed resource methods and requires a `persona` parameter.
3033

31-
For programmatic advertising -- manage advertisers, bundles, campaigns, and signals.
34+
#### Buyer Persona
3235

3336
```typescript
3437
import { Scope3Client } from 'scope3';
@@ -66,41 +69,89 @@ const campaign = await client.campaigns.createDiscovery({
6669
await client.campaigns.execute(campaign.data.id);
6770
```
6871

69-
### Partner Persona
70-
71-
For partner and agent management.
72+
#### Storefront Persona
7273

7374
```typescript
74-
const partnerClient = new Scope3Client({
75+
const sfClient = new Scope3Client({
7576
apiKey: process.env.SCOPE3_API_KEY!,
76-
persona: 'partner',
77+
persona: 'storefront',
7778
});
7879

79-
// List partners
80-
const partners = await partnerClient.partners.list();
80+
// Get your storefront
81+
const sf = await sfClient.storefront.get();
8182

82-
// Register an agent
83-
const agent = await partnerClient.agents.register({
84-
name: 'My Agent',
83+
// Create an inventory source (registers an agent)
84+
const source = await sfClient.inventorySources.create({
85+
sourceId: 'my-sales-agent',
86+
name: 'My Sales Agent',
87+
executionType: 'agent',
8588
type: 'SALES',
86-
partnerId: 'partner-123',
89+
endpointUrl: 'https://my-agent.example.com/mcp',
90+
protocol: 'MCP',
91+
authenticationType: 'API_KEY',
92+
auth: { type: 'bearer', token: 'my-api-key' },
8793
});
94+
95+
// Check readiness
96+
const readiness = await sfClient.readiness.check();
97+
```
98+
99+
### MCP Client (AI Agents)
100+
101+
The `Scope3McpClient` is a thin connection helper for AI agents. It wires up auth and the MCP URL, then exposes `callTool()`, `readResource()`, and `listTools()` as direct passthroughs. The MCP server handles routing and validation — no typed resource wrappers needed.
102+
103+
```typescript
104+
import { Scope3McpClient } from 'scope3';
105+
106+
const mcp = new Scope3McpClient({
107+
apiKey: process.env.SCOPE3_API_KEY!,
108+
});
109+
await mcp.connect();
110+
111+
// Call tools directly — the v2 buyer surface exposes:
112+
// api_call, ask_about_capability, help, health
113+
const result = await mcp.callTool('api_call', {
114+
method: 'GET',
115+
path: '/api/v2/buyer/advertisers',
116+
});
117+
118+
// Ask what the API can do
119+
const capabilities = await mcp.callTool('ask_about_capability', {
120+
question: 'How do I create a campaign?',
121+
});
122+
123+
// List available tools
124+
const tools = await mcp.listTools();
125+
126+
await mcp.disconnect();
88127
```
89128

90129
## Configuration
91130

131+
### Scope3Client (REST)
132+
92133
```typescript
93134
const client = new Scope3Client({
94135
apiKey: 'your-api-key', // Required: Bearer token
95-
persona: 'buyer', // Required: 'buyer' | 'partner'
136+
persona: 'buyer', // Required: 'buyer' | 'storefront'
96137
environment: 'production', // Optional: 'production' (default) | 'staging'
97138
baseUrl: 'https://custom.com', // Optional: overrides environment
98-
adapter: 'rest', // Optional: 'rest' (default) | 'mcp'
99139
timeout: 30000, // Optional: request timeout in ms
100140
debug: false, // Optional: enable debug logging
101141
});
102142
```
103143

144+
### Scope3McpClient (MCP)
145+
146+
```typescript
147+
const mcp = new Scope3McpClient({
148+
apiKey: 'your-api-key', // Required: Bearer token
149+
environment: 'production', // Optional: 'production' (default) | 'staging'
150+
baseUrl: 'https://custom.com', // Optional: overrides environment
151+
debug: false, // Optional: enable debug logging
152+
});
153+
```
154+
104155
## CLI
105156

106157
```bash
@@ -115,7 +166,7 @@ scope3 campaigns list --format json
115166
scope3 bundles create --advertiser-id adv-123 --channels display,video
116167

117168
# Override persona per-command
118-
scope3 --persona partner partners list
169+
scope3 --persona storefront storefront get
119170

120171
# See all commands
121172
scope3 commands
@@ -125,17 +176,23 @@ scope3 commands
125176

126177
### Buyer Resources
127178

128-
- `client.advertisers` -- CRUD and sub-resources (conversionEvents, creativeSets, testCohorts)
129-
- `client.campaigns` -- list, get, createDiscovery, updateDiscovery, createPerformance, updatePerformance, createAudience, execute, pause
179+
- `client.advertisers` -- CRUD and sub-resources (conversionEvents, creativeSets, testCohorts, eventSources, measurementData, catalogs, audiences, syndication, propertyLists)
180+
- `client.campaigns` -- list, get, createDiscovery, updateDiscovery, createPerformance, updatePerformance, createAudience, execute, pause, creatives(campaignId)
130181
- `client.bundles` -- create, discoverProducts, browseProducts, products(bundleId)
131182
- `client.signals` -- Discover signals
132183
- `client.reporting` -- Get reporting metrics
133184
- `client.salesAgents` -- List sales agents, register accounts
185+
- `client.tasks` -- Get task status
186+
- `client.propertyListChecks` -- Run and retrieve property list check reports
134187

135-
### Partner Resources
188+
### Storefront Resources
136189

137-
- `client.partners` -- list, create, update, archive
138-
- `client.agents` -- list, get, register, update
190+
- `client.storefront` -- get, create, update, delete
191+
- `client.inventorySources` -- list, get, create, update, delete
192+
- `client.agents` -- list, get, update
193+
- `client.readiness` -- check
194+
- `client.billing` -- get, connect, status, transactions, payouts, onboardingUrl
195+
- `client.notifications` -- list, markAsRead, acknowledge, markAllAsRead
139196

140197
## skill.md Support
141198

@@ -176,29 +233,29 @@ The SDK is manually maintained. When the Agentic API changes, update these files
176233
1. Check the latest skill.md for your persona:
177234
```bash
178235
curl https://api.agentic.scope3.com/api/v2/buyer/skill.md
179-
curl https://api.agentic.scope3.com/api/v2/partner/skill.md
236+
curl https://api.agentic.scope3.com/api/v2/storefront/skill.md
180237
```
181238
2. Compare against `src/skill/bundled.ts` and update if needed
182239
3. Update types in `src/types/index.ts` to match any schema changes
183240
4. Update resource methods in `src/resources/` for endpoint changes
184241
5. Update CLI commands in `src/cli/commands/` if applicable
185242
6. Run `npm test` and `npm run build` to verify
186-
7. Run manual workflow tests: `npm run test:buyer`, `npm run test:partner`
243+
7. Run manual workflow tests: `npm run test:buyer`, `npm run test:storefront`
187244

188245
### Integration Tests
189246

190247
```bash
191248
export SCOPE3_API_KEY=your_key
192249
npm run test:buyer # Buyer workflow
193-
npm run test:partner # Partner workflow
250+
npm run test:storefront # Storefront workflow
194251
npm run test:all # All workflows
195252
```
196253

197254
## Documentation
198255

199256
- [Getting Started](docs/getting-started.md)
200257
- [Buyer Guide](docs/buyer-guide.md)
201-
- [Partner Guide](docs/partner-guide.md)
258+
- [Storefront Guide](docs/storefront-guide.md)
202259
- [CLI Reference](docs/cli-reference.md)
203260

204261
## Contributing

‎docs/TESTING.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Run the test suite:
88
npm test
99
```
1010

11-
This runs 211 unit tests covering:
11+
This runs 384+ unit tests covering:
1212
- Client initialization
1313
- REST and MCP adapters
1414
- All resource classes
@@ -28,8 +28,8 @@ export SCOPE3_API_KEY=your_api_key
2828
./dist/cli/index.js campaigns list
2929
./dist/cli/index.js bundles create --advertiser-id <id> --channels display
3030

31-
# Test partner persona
32-
./dist/cli/index.js --persona partner partners list
31+
# Test storefront persona
32+
./dist/cli/index.js --persona storefront storefront get
3333

3434
# Test config
3535
./dist/cli/index.js config set apiKey your_key
@@ -48,7 +48,7 @@ export SCOPE3_API_KEY=your_api_key
4848

4949
# CLI workflow tests
5050
npm run test:buyer # Buyer persona: advertisers, bundles, campaigns
51-
npm run test:partner # Partner persona: health check
51+
npm run test:storefront # Storefront persona: health check
5252

5353
# TypeScript SDK test
5454
npm run test:sdk
@@ -75,9 +75,10 @@ export SCOPE3_ENVIRONMENT=staging
7575
- Bundle creation and product discovery
7676
- Campaign creation and lifecycle
7777

78-
### Partner Workflow (`test-partner-workflow.sh`)
79-
- Partner listing
78+
### Storefront Workflow (`test-storefront-workflow.sh`)
79+
- Storefront get
8080
- Agent listing
81+
- Inventory source listing
8182
- Config management
8283
- Skill.md fetching
8384

‎docs/buyer-guide.md‎

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
The buyer persona enables AI-powered programmatic advertising with:
66

7-
- Advertiser management
7+
- Advertiser management with rich sub-resources (conversion events, creative sets, test cohorts, event sources, measurement data, catalogs, audiences, syndication, property lists)
88
- Bundle-based inventory discovery
9-
- 3 campaign types (discovery, performance, audience)
9+
- 3 campaign types (discovery, performance, audience) with creative management
1010
- Reporting and analytics
11-
- Reporting and sales agents
11+
- Sales agents
12+
- Async task tracking
13+
- Property list checks
1214

1315
## Setup
1416

@@ -130,6 +132,19 @@ Signal-based audience targeting (coming soon).
130132
await client.campaigns.createAudience({ ... });
131133
```
132134

135+
## Campaign Sub-Resources
136+
137+
### Creatives
138+
139+
```typescript
140+
const creatives = client.campaigns.creatives(campaignId);
141+
await creatives.list();
142+
await creatives.list({ quality: 'high', take: 5 });
143+
await creatives.get('creative-123');
144+
await creatives.update('creative-123', { /* updates */ });
145+
await creatives.delete('creative-123');
146+
```
147+
133148
## Advertiser Sub-Resources
134149

135150
Access sub-resources scoped to an advertiser.
@@ -158,6 +173,67 @@ await cohorts.list();
158173
await cohorts.create({ name: 'A/B Test', splitPercentage: 50 });
159174
```
160175

176+
### Event Sources
177+
178+
```typescript
179+
const eventSources = client.advertisers.eventSources(advId);
180+
await eventSources.sync({ /* event source config */ });
181+
await eventSources.list();
182+
await eventSources.create({ /* event source data */ });
183+
await eventSources.get('es-123');
184+
await eventSources.update('es-123', { /* updates */ });
185+
await eventSources.delete('es-123');
186+
```
187+
188+
### Measurement Data
189+
190+
```typescript
191+
const measurementData = client.advertisers.measurementData(advId);
192+
await measurementData.sync({ /* measurement data config */ });
193+
```
194+
195+
### Catalogs
196+
197+
```typescript
198+
const catalogs = client.advertisers.catalogs(advId);
199+
await catalogs.sync({ /* catalog data */ });
200+
await catalogs.list();
201+
await catalogs.list({ type: 'product', take: 10 });
202+
```
203+
204+
### Audiences
205+
206+
```typescript
207+
const audiences = client.advertisers.audiences(advId);
208+
await audiences.sync({ /* audience data */ });
209+
await audiences.list();
210+
```
211+
212+
### Syndication
213+
214+
```typescript
215+
const syndication = client.advertisers.syndication(advId);
216+
await syndication.syndicate({ /* syndication config */ });
217+
await syndication.status();
218+
await syndication.status({ resourceType: 'campaign' });
219+
```
220+
221+
### Property Lists
222+
223+
```typescript
224+
const propertyLists = client.advertisers.propertyLists(advId);
225+
await propertyLists.create({ /* property list data */ });
226+
await propertyLists.list();
227+
await propertyLists.list({ purpose: 'inclusion' });
228+
await propertyLists.get('pl-123');
229+
await propertyLists.update('pl-123', { /* updates */ });
230+
await propertyLists.delete('pl-123');
231+
232+
// Top-level property list checks (not advertiser-scoped)
233+
await client.propertyListChecks.check({ domains: ['example.com'] });
234+
await client.propertyListChecks.getReport('report-123');
235+
```
236+
161237
## Signals
162238

163239
```typescript
@@ -184,10 +260,19 @@ const agents = await client.salesAgents.list();
184260

185261
// Register an account for an agent
186262
await client.salesAgents.registerAccount('agent-123', {
187-
name: 'My Account',
263+
advertiserId: 'adv-123',
264+
accountIdentifier: 'my-account-id',
188265
});
189266
```
190267

268+
## Tasks
269+
270+
Check the status of async tasks.
271+
272+
```typescript
273+
const task = await client.tasks.get('task-123');
274+
```
275+
191276
## Pagination
192277

193278
All list methods support pagination:

0 commit comments

Comments
 (0)