@affset/mcp 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +5 -0
- package/README.md +114 -37
- package/dist/client.d.ts +43 -0
- package/dist/client.js +15 -2
- package/dist/config.d.ts +7 -0
- package/dist/config.js +15 -54
- package/dist/core.d.ts +18 -0
- package/dist/core.js +18 -0
- package/dist/docs.d.ts +39 -0
- package/dist/docs.js +105 -0
- package/dist/index.d.ts +2 -0
- package/dist/lib/format.d.ts +46 -0
- package/dist/lib/format.js +3 -0
- package/dist/lib/integrationUrls.d.ts +57 -0
- package/dist/lib/linkArgs.d.ts +27 -0
- package/dist/lib/patch.d.ts +10 -0
- package/dist/lib/payoutRules.d.ts +38 -0
- package/dist/lib/readBody.d.ts +17 -0
- package/dist/lib/readBody.js +69 -0
- package/dist/lib/targeting.d.ts +51 -0
- package/dist/lib/time.d.ts +38 -0
- package/dist/lib/toolResult.d.ts +7 -0
- package/dist/lib/urls.d.ts +2 -0
- package/dist/lib/zones.d.ts +24 -0
- package/dist/registerTools.d.ts +40 -0
- package/dist/registerTools.js +401 -0
- package/dist/runtimeConfig.d.ts +37 -0
- package/dist/runtimeConfig.js +93 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +3 -318
- package/dist/tools/createCampaign.d.ts +25 -0
- package/dist/tools/createTeamMember.d.ts +26 -0
- package/dist/tools/createZone.d.ts +22 -0
- package/dist/tools/cutZones.d.ts +29 -0
- package/dist/tools/deletePayoutRule.d.ts +16 -0
- package/dist/tools/getCampaign.d.ts +12 -0
- package/dist/tools/getCampaign.js +150 -0
- package/dist/tools/getStats.d.ts +40 -0
- package/dist/tools/getStats.js +37 -2
- package/dist/tools/getTrackingLink.d.ts +23 -0
- package/dist/tools/getZoneUrl.d.ts +21 -0
- package/dist/tools/listCampaigns.d.ts +23 -0
- package/dist/tools/listConversions.d.ts +29 -0
- package/dist/tools/listPayoutRules.d.ts +12 -0
- package/dist/tools/listSubLabels.d.ts +5 -0
- package/dist/tools/listTargetingRules.d.ts +12 -0
- package/dist/tools/listTargetingTypes.d.ts +5 -0
- package/dist/tools/listTeam.d.ts +14 -0
- package/dist/tools/listZones.d.ts +23 -0
- package/dist/tools/removeTargetingRule.d.ts +21 -0
- package/dist/tools/setCampaignStatus.d.ts +18 -0
- package/dist/tools/setPayoutGoal.d.ts +16 -0
- package/dist/tools/setPayoutRule.d.ts +18 -0
- package/dist/tools/setSubLabels.d.ts +22 -0
- package/dist/tools/setTargetingRule.d.ts +21 -0
- package/dist/tools/updateCampaign.d.ts +35 -0
- package/dist/tools/updateZone.d.ts +25 -0
- package/dist/tools/whoami.d.ts +6 -0
- package/dist/types.d.ts +210 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +8 -0
- package/package.json +15 -2
package/dist/tools/getStats.js
CHANGED
|
@@ -6,10 +6,18 @@ import { GROUP_BY_VALUES, SUB_KEYS } from "../types.js";
|
|
|
6
6
|
export const GET_STATS_DESCRIPTION = "Pull affset traffic stats grouped by a single dimension. Returns impressions, clicks, " +
|
|
7
7
|
"conversions, CR, payout, media cost and ROI as a table. Drill down by calling " +
|
|
8
8
|
"repeatedly: first group_by=date or campaign_id, then narrow with filters " +
|
|
9
|
-
"(campaign_ids, zone_ids, sub1..sub5
|
|
9
|
+
"(campaign_ids, zone_ids, sub1..sub5, conversion_type, advertiser_email, publisher_email) " +
|
|
10
|
+
"and change group_by (zone_id, sub1, ...). " +
|
|
10
11
|
'Sub columns are titled with the tenant\'s configured labels (e.g. "Zone (sub1)") ' +
|
|
11
12
|
"when set; group_by/filters always take the raw subN key. " +
|
|
12
|
-
"
|
|
13
|
+
"conversion_type only matches conversion rows, so filtering by it zeroes impressions, clicks " +
|
|
14
|
+
"and media cost — it narrows to conversions of that type, not clicks that led to one. " +
|
|
15
|
+
"ROI is blank until traffic cost has been imported for the slice. " +
|
|
16
|
+
"group_by=advertiser_email / publisher_email break down by team member; the API limits them " +
|
|
17
|
+
"to owner/manager plus the matching side's manager role (403 otherwise). " +
|
|
18
|
+
"advertiser_email / publisher_email are also standalone filters — narrow every row to one " +
|
|
19
|
+
"advertiser's campaigns or one publisher's zones regardless of group_by, instead of breaking " +
|
|
20
|
+
"every user out into its own row. Same role limits as the matching group_by value.";
|
|
13
21
|
export const getStatsInputSchema = {
|
|
14
22
|
group_by: z
|
|
15
23
|
.enum(GROUP_BY_VALUES)
|
|
@@ -34,6 +42,25 @@ export const getStatsInputSchema = {
|
|
|
34
42
|
sub3: z.string().optional().describe("Filter by sub3 value(s)."),
|
|
35
43
|
sub4: z.string().optional().describe("Filter by sub4 value(s)."),
|
|
36
44
|
sub5: z.string().optional().describe("Filter by sub5 value(s)."),
|
|
45
|
+
conversion_type: z
|
|
46
|
+
.string()
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("Filter by conversion type value(s) (e.g. deposit, register), comma-separated for multiple. " +
|
|
49
|
+
'Pass "" to select conversions recorded without a type.'),
|
|
50
|
+
advertiser_email: z
|
|
51
|
+
.string()
|
|
52
|
+
.trim()
|
|
53
|
+
.email()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Narrow to one advertiser's campaigns, independent of group_by. Owner/manager: any advertiser. " +
|
|
56
|
+
"advertiser_manager: only one of their own assigned advertisers (else 403). Other roles: 403."),
|
|
57
|
+
publisher_email: z
|
|
58
|
+
.string()
|
|
59
|
+
.trim()
|
|
60
|
+
.email()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe("Narrow to one publisher's zones, independent of group_by. Owner/manager: any publisher. " +
|
|
63
|
+
"publisher_manager: only one of their own assigned publishers (else 403). Other roles: 403."),
|
|
37
64
|
};
|
|
38
65
|
export async function getStats(client, args) {
|
|
39
66
|
try {
|
|
@@ -53,6 +80,14 @@ export async function getStats(client, args) {
|
|
|
53
80
|
if (value !== undefined)
|
|
54
81
|
query[key] = value;
|
|
55
82
|
}
|
|
83
|
+
if (args.conversion_type !== undefined)
|
|
84
|
+
query.conversion_type = args.conversion_type;
|
|
85
|
+
if (args.advertiser_email !== undefined) {
|
|
86
|
+
query.advertiser_email = args.advertiser_email.trim();
|
|
87
|
+
}
|
|
88
|
+
if (args.publisher_email !== undefined) {
|
|
89
|
+
query.publisher_email = args.publisher_email.trim();
|
|
90
|
+
}
|
|
56
91
|
const data = await client.get("/api/stats", query);
|
|
57
92
|
const table = formatStatsTable(data.stats ?? [], args.group_by, data.sub_labels);
|
|
58
93
|
const heading = groupHeader(args.group_by, data.sub_labels);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
import type { Config } from "../runtimeConfig.js";
|
|
5
|
+
import { type LinkArgs } from "../lib/linkArgs.js";
|
|
6
|
+
export declare const GET_TRACKING_LINK_DESCRIPTION: string;
|
|
7
|
+
export declare const getTrackingLinkInputSchema: {
|
|
8
|
+
source_click_id: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
9
|
+
cost: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
10
|
+
sub1: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
|
+
sub2: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
12
|
+
sub3: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
13
|
+
sub4: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
14
|
+
sub5: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
15
|
+
campaign_id: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodNumber]>;
|
|
16
|
+
zone_id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
};
|
|
18
|
+
type GetTrackingLinkArgs = LinkArgs & {
|
|
19
|
+
campaign_id: string | number;
|
|
20
|
+
zone_id?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function getTrackingLink(client: AffsetClient, config: Config, args: GetTrackingLinkArgs): Promise<CallToolResult>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
import type { Config } from "../runtimeConfig.js";
|
|
5
|
+
import { type LinkArgs } from "../lib/linkArgs.js";
|
|
6
|
+
export declare const GET_ZONE_URL_DESCRIPTION: string;
|
|
7
|
+
export declare const getZoneUrlInputSchema: {
|
|
8
|
+
source_click_id: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
9
|
+
cost: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
10
|
+
sub1: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
|
+
sub2: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
12
|
+
sub3: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
13
|
+
sub4: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
14
|
+
sub5: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
15
|
+
zone_id: z.ZodOptional<z.ZodString>;
|
|
16
|
+
};
|
|
17
|
+
type GetZoneUrlArgs = LinkArgs & {
|
|
18
|
+
zone_id?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function getZoneUrl(client: AffsetClient, config: Config, args: GetZoneUrlArgs): Promise<CallToolResult>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
import { CAMPAIGN_STATUSES } from "../types.js";
|
|
5
|
+
export declare const LIST_CAMPAIGNS_DESCRIPTION: string;
|
|
6
|
+
export declare const listCampaignsInputSchema: {
|
|
7
|
+
status: z.ZodOptional<z.ZodEnum<["active", "paused", "archived"]>>;
|
|
8
|
+
name_contains: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
sort: z.ZodDefault<z.ZodEnum<["name", "created_at", "start_date"]>>;
|
|
12
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
13
|
+
};
|
|
14
|
+
type ListCampaignsArgs = {
|
|
15
|
+
status?: (typeof CAMPAIGN_STATUSES)[number];
|
|
16
|
+
name_contains?: string;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
sort: "name" | "created_at" | "start_date";
|
|
20
|
+
order: "asc" | "desc";
|
|
21
|
+
};
|
|
22
|
+
export declare function listCampaigns(client: AffsetClient, args: ListCampaignsArgs): Promise<CallToolResult>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
declare const SORT_FIELDS: readonly ["created_at", "ad_event_id", "click_id"];
|
|
5
|
+
export declare const LIST_CONVERSIONS_DESCRIPTION: string;
|
|
6
|
+
export declare const listConversionsInputSchema: {
|
|
7
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
sort: z.ZodDefault<z.ZodEnum<["created_at", "ad_event_id", "click_id"]>>;
|
|
10
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
11
|
+
click_id: z.ZodOptional<z.ZodString>;
|
|
12
|
+
source_click_id: z.ZodOptional<z.ZodString>;
|
|
13
|
+
type: z.ZodOptional<z.ZodString>;
|
|
14
|
+
payload_contains: z.ZodOptional<z.ZodString>;
|
|
15
|
+
zero_payout: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
};
|
|
17
|
+
type ListConversionsArgs = {
|
|
18
|
+
limit: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
sort: (typeof SORT_FIELDS)[number];
|
|
21
|
+
order: "asc" | "desc";
|
|
22
|
+
click_id?: string;
|
|
23
|
+
source_click_id?: string;
|
|
24
|
+
type?: string;
|
|
25
|
+
payload_contains?: string;
|
|
26
|
+
zero_payout?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function listConversions(client: AffsetClient, args: ListConversionsArgs): Promise<CallToolResult>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
export declare const LIST_PAYOUT_RULES_DESCRIPTION: string;
|
|
5
|
+
export declare const listPayoutRulesInputSchema: {
|
|
6
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
|
+
};
|
|
8
|
+
type ListPayoutRulesArgs = {
|
|
9
|
+
campaign_id: string | number;
|
|
10
|
+
};
|
|
11
|
+
export declare function listPayoutRules(client: AffsetClient, args: ListPayoutRulesArgs): Promise<CallToolResult>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { AffsetClient } from "../client.js";
|
|
3
|
+
export declare const LIST_SUB_LABELS_DESCRIPTION: string;
|
|
4
|
+
export declare const listSubLabelsInputSchema: {};
|
|
5
|
+
export declare function listSubLabels(client: AffsetClient): Promise<CallToolResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
export declare const LIST_TARGETING_RULES_DESCRIPTION: string;
|
|
5
|
+
export declare const listTargetingRulesInputSchema: {
|
|
6
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
|
+
};
|
|
8
|
+
type ListTargetingRulesArgs = {
|
|
9
|
+
campaign_id: string | number;
|
|
10
|
+
};
|
|
11
|
+
export declare function listTargetingRules(client: AffsetClient, args: ListTargetingRulesArgs): Promise<CallToolResult>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { AffsetClient } from "../client.js";
|
|
3
|
+
export declare const LIST_TARGETING_TYPES_DESCRIPTION: string;
|
|
4
|
+
export declare const listTargetingTypesInputSchema: {};
|
|
5
|
+
export declare function listTargetingTypes(client: AffsetClient): Promise<CallToolResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
export declare const LIST_TEAM_DESCRIPTION: string;
|
|
5
|
+
export declare const listTeamInputSchema: {
|
|
6
|
+
role: z.ZodOptional<z.ZodString>;
|
|
7
|
+
include_expired: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
};
|
|
9
|
+
type ListTeamArgs = {
|
|
10
|
+
role?: string;
|
|
11
|
+
include_expired: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function listTeam(client: AffsetClient, args: ListTeamArgs): Promise<CallToolResult>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
import { ZONE_STATUSES } from "../types.js";
|
|
5
|
+
export declare const LIST_ZONES_DESCRIPTION: string;
|
|
6
|
+
export declare const listZonesInputSchema: {
|
|
7
|
+
status: z.ZodOptional<z.ZodEnum<["active", "inactive"]>>;
|
|
8
|
+
name_contains: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
sort: z.ZodDefault<z.ZodEnum<["name", "created_at", "site_url"]>>;
|
|
12
|
+
order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
13
|
+
};
|
|
14
|
+
type ListZonesArgs = {
|
|
15
|
+
status?: (typeof ZONE_STATUSES)[number];
|
|
16
|
+
name_contains?: string;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
sort: "name" | "created_at" | "site_url";
|
|
20
|
+
order: "asc" | "desc";
|
|
21
|
+
};
|
|
22
|
+
export declare function listZones(client: AffsetClient, args: ListZonesArgs): Promise<CallToolResult>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
import { type TargetingMethod } from "../lib/targeting.js";
|
|
5
|
+
export declare const REMOVE_TARGETING_RULE_DESCRIPTION: string;
|
|
6
|
+
export declare const removeTargetingRuleInputSchema: {
|
|
7
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
8
|
+
rule_id: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
type: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
10
|
+
method: z.ZodOptional<z.ZodEnum<["whitelist", "blacklist"]>>;
|
|
11
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
};
|
|
13
|
+
type RemoveTargetingRuleArgs = {
|
|
14
|
+
campaign_id: string | number;
|
|
15
|
+
rule_id?: number;
|
|
16
|
+
type?: string | number;
|
|
17
|
+
method?: TargetingMethod;
|
|
18
|
+
confirm: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function removeTargetingRule(client: AffsetClient, args: RemoveTargetingRuleArgs): Promise<CallToolResult>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
/** Media-buyer verbs → API status. */
|
|
5
|
+
export declare const CAMPAIGN_ACTIONS: readonly ["run", "pause"];
|
|
6
|
+
export declare const SET_CAMPAIGN_STATUS_DESCRIPTION: string;
|
|
7
|
+
export declare const setCampaignStatusInputSchema: {
|
|
8
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
9
|
+
action: z.ZodEnum<["run", "pause"]>;
|
|
10
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
};
|
|
12
|
+
type SetCampaignStatusArgs = {
|
|
13
|
+
campaign_id: string | number;
|
|
14
|
+
action: (typeof CAMPAIGN_ACTIONS)[number];
|
|
15
|
+
confirm: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function setCampaignStatus(client: AffsetClient, args: SetCampaignStatusArgs): Promise<CallToolResult>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
export declare const SET_PAYOUT_GOAL_DESCRIPTION: string;
|
|
5
|
+
export declare const setPayoutGoalInputSchema: {
|
|
6
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
|
+
goal_type: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
8
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
};
|
|
10
|
+
type SetPayoutGoalArgs = {
|
|
11
|
+
campaign_id: string | number;
|
|
12
|
+
goal_type: string | null;
|
|
13
|
+
confirm: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function setPayoutGoal(client: AffsetClient, args: SetPayoutGoalArgs): Promise<CallToolResult>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
export declare const SET_PAYOUT_RULE_DESCRIPTION: string;
|
|
5
|
+
export declare const setPayoutRuleInputSchema: {
|
|
6
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
|
+
payout: z.ZodNumber;
|
|
8
|
+
zone_id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
};
|
|
11
|
+
type SetPayoutRuleArgs = {
|
|
12
|
+
campaign_id: string | number;
|
|
13
|
+
payout: number;
|
|
14
|
+
zone_id?: string;
|
|
15
|
+
confirm: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function setPayoutRule(client: AffsetClient, args: SetPayoutRuleArgs): Promise<CallToolResult>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { AffsetClient } from "../client.js";
|
|
4
|
+
export declare const SET_SUB_LABELS_DESCRIPTION: string;
|
|
5
|
+
export declare const setSubLabelsInputSchema: {
|
|
6
|
+
sub1: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
7
|
+
sub2: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
8
|
+
sub3: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
9
|
+
sub4: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
10
|
+
sub5: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
11
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
};
|
|
13
|
+
type SetSubLabelsArgs = {
|
|
14
|
+
sub1?: string | null;
|
|
15
|
+
sub2?: string | null;
|
|
16
|
+
sub3?: string | null;
|
|
17
|
+
sub4?: string | null;
|
|
18
|
+
sub5?: string | null;
|
|
19
|
+
confirm: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function setSubLabels(client: AffsetClient, args: SetSubLabelsArgs): Promise<CallToolResult>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
import { type TargetingMethod } from "../lib/targeting.js";
|
|
5
|
+
export declare const SET_TARGETING_RULE_DESCRIPTION: string;
|
|
6
|
+
export declare const setTargetingRuleInputSchema: {
|
|
7
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
8
|
+
type: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
9
|
+
method: z.ZodEnum<["whitelist", "blacklist"]>;
|
|
10
|
+
rule: z.ZodString;
|
|
11
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
};
|
|
13
|
+
type SetTargetingRuleArgs = {
|
|
14
|
+
campaign_id: string | number;
|
|
15
|
+
type: string | number;
|
|
16
|
+
method: TargetingMethod;
|
|
17
|
+
rule: string;
|
|
18
|
+
confirm: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function setTargetingRule(client: AffsetClient, args: SetTargetingRuleArgs): Promise<CallToolResult>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
import { CAMPAIGN_STATUSES, PACING_VALUES, PAYMENT_MODELS } from "../types.js";
|
|
5
|
+
export declare const UPDATE_CAMPAIGN_DESCRIPTION: string;
|
|
6
|
+
export declare const updateCampaignInputSchema: {
|
|
7
|
+
campaign_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
8
|
+
name: z.ZodOptional<z.ZodString>;
|
|
9
|
+
redirect_url: z.ZodOptional<z.ZodString>;
|
|
10
|
+
status: z.ZodOptional<z.ZodEnum<["active", "paused", "archived"]>>;
|
|
11
|
+
payment_model: z.ZodOptional<z.ZodEnum<["cpa", "cpm"]>>;
|
|
12
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
start_date: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
14
|
+
end_date: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
15
|
+
daily_budget: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodNull]>>;
|
|
16
|
+
total_budget: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodNull]>>;
|
|
17
|
+
pacing: z.ZodOptional<z.ZodEnum<["asap", "even"]>>;
|
|
18
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
};
|
|
20
|
+
type UpdateCampaignArgs = {
|
|
21
|
+
campaign_id: string | number;
|
|
22
|
+
name?: string;
|
|
23
|
+
redirect_url?: string;
|
|
24
|
+
status?: (typeof CAMPAIGN_STATUSES)[number];
|
|
25
|
+
payment_model?: (typeof PAYMENT_MODELS)[number];
|
|
26
|
+
rate?: number;
|
|
27
|
+
start_date?: string | number | null;
|
|
28
|
+
end_date?: string | number | null;
|
|
29
|
+
daily_budget?: number | null;
|
|
30
|
+
total_budget?: number | null;
|
|
31
|
+
pacing?: (typeof PACING_VALUES)[number];
|
|
32
|
+
confirm: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare function updateCampaign(client: AffsetClient, args: UpdateCampaignArgs): Promise<CallToolResult>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type AffsetClient } from "../client.js";
|
|
4
|
+
import { ZONE_STATUSES } from "../types.js";
|
|
5
|
+
export declare const UPDATE_ZONE_DESCRIPTION: string;
|
|
6
|
+
export declare const updateZoneInputSchema: {
|
|
7
|
+
zone_id: z.ZodString;
|
|
8
|
+
name: z.ZodOptional<z.ZodString>;
|
|
9
|
+
status: z.ZodOptional<z.ZodEnum<["active", "inactive"]>>;
|
|
10
|
+
postback_url: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
11
|
+
site_url: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
12
|
+
traffic_back_url: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
13
|
+
confirm: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
};
|
|
15
|
+
type UpdateZoneArgs = {
|
|
16
|
+
zone_id: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
status?: (typeof ZONE_STATUSES)[number];
|
|
19
|
+
postback_url?: string | null;
|
|
20
|
+
site_url?: string | null;
|
|
21
|
+
traffic_back_url?: string | null;
|
|
22
|
+
confirm: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function updateZone(client: AffsetClient, args: UpdateZoneArgs): Promise<CallToolResult>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { AffsetClient } from "../client.js";
|
|
3
|
+
import type { Config } from "../runtimeConfig.js";
|
|
4
|
+
export declare const WHOAMI_DESCRIPTION: string;
|
|
5
|
+
export declare const whoamiInputSchema: {};
|
|
6
|
+
export declare function whoami(client: AffsetClient, config: Config): Promise<CallToolResult>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/** Shapes of the affset tenant API responses this server consumes. */
|
|
2
|
+
/** A single grouped row from `GET /api/stats`. */
|
|
3
|
+
export interface StatRow {
|
|
4
|
+
date?: string;
|
|
5
|
+
campaign_id?: string;
|
|
6
|
+
campaign_name?: string | null;
|
|
7
|
+
zone_id?: string;
|
|
8
|
+
zone_name?: string | null;
|
|
9
|
+
country?: string | null;
|
|
10
|
+
conversion_type?: string | null;
|
|
11
|
+
publisher_email?: string | null;
|
|
12
|
+
advertiser_email?: string | null;
|
|
13
|
+
sub1?: string | null;
|
|
14
|
+
sub2?: string | null;
|
|
15
|
+
sub3?: string | null;
|
|
16
|
+
sub4?: string | null;
|
|
17
|
+
sub5?: string | null;
|
|
18
|
+
impressions: number;
|
|
19
|
+
fallbacks: number;
|
|
20
|
+
unsold: number;
|
|
21
|
+
clicks: number;
|
|
22
|
+
conversions: number;
|
|
23
|
+
spend?: number;
|
|
24
|
+
payout?: number;
|
|
25
|
+
media_cost?: number;
|
|
26
|
+
/** (payout - media_cost) / media_cost; null when the slice carries no cost. */
|
|
27
|
+
roi?: number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface StatsResponse {
|
|
30
|
+
stats: StatRow[];
|
|
31
|
+
period: {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
};
|
|
35
|
+
/** Tenant display names for sub1..sub5 (e.g. sub1 -> "Zone"); {} when none set. */
|
|
36
|
+
sub_labels?: SubLabels;
|
|
37
|
+
}
|
|
38
|
+
export interface Pagination {
|
|
39
|
+
total: number;
|
|
40
|
+
limit: number;
|
|
41
|
+
offset: number;
|
|
42
|
+
has_more: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One conversion from GET /api/conversions.
|
|
46
|
+
*
|
|
47
|
+
* spend/payout are absent (key missing) when the caller's role may not see them —
|
|
48
|
+
* publisher-side roles lose `spend`, advertiser-side roles lose `payout`. `null`
|
|
49
|
+
* is different: the column is visible and simply has no amount recorded. Consumers
|
|
50
|
+
* that treat "no payout" as a signal have to tell the two apart.
|
|
51
|
+
*/
|
|
52
|
+
export interface Conversion {
|
|
53
|
+
ad_event_id: string;
|
|
54
|
+
namespace?: string;
|
|
55
|
+
click_id: string | null;
|
|
56
|
+
payload: string | null;
|
|
57
|
+
spend?: number | null;
|
|
58
|
+
payout?: number | null;
|
|
59
|
+
source_click_id?: string | null;
|
|
60
|
+
sub1?: string | null;
|
|
61
|
+
sub2?: string | null;
|
|
62
|
+
sub3?: string | null;
|
|
63
|
+
sub4?: string | null;
|
|
64
|
+
sub5?: string | null;
|
|
65
|
+
/** Unix ms when the conversion was recorded. */
|
|
66
|
+
created_at: number;
|
|
67
|
+
}
|
|
68
|
+
export interface ConversionsResponse {
|
|
69
|
+
conversions: Conversion[];
|
|
70
|
+
pagination: Pagination;
|
|
71
|
+
}
|
|
72
|
+
/** Campaign row from list/get. */
|
|
73
|
+
export interface Campaign {
|
|
74
|
+
id: number;
|
|
75
|
+
name: string;
|
|
76
|
+
status: string;
|
|
77
|
+
redirect_url?: string | null;
|
|
78
|
+
payment_model?: string;
|
|
79
|
+
rate?: number;
|
|
80
|
+
start_date?: number | null;
|
|
81
|
+
end_date?: number | null;
|
|
82
|
+
user_email?: string | null;
|
|
83
|
+
daily_budget?: number | null;
|
|
84
|
+
total_budget?: number | null;
|
|
85
|
+
pacing?: string;
|
|
86
|
+
budget_paused?: number;
|
|
87
|
+
budget_pause_reason?: string | null;
|
|
88
|
+
silent?: number;
|
|
89
|
+
payout_goal_type?: string | null;
|
|
90
|
+
created_at?: number;
|
|
91
|
+
updated_at?: number;
|
|
92
|
+
targeting_rules?: TargetingRule[];
|
|
93
|
+
}
|
|
94
|
+
/** Response of POST /api/campaigns. */
|
|
95
|
+
export interface CreateCampaignResponse {
|
|
96
|
+
id: number;
|
|
97
|
+
name: string;
|
|
98
|
+
status: string;
|
|
99
|
+
created_at: number;
|
|
100
|
+
}
|
|
101
|
+
export interface CampaignsResponse {
|
|
102
|
+
campaigns: Campaign[];
|
|
103
|
+
pagination: Pagination;
|
|
104
|
+
}
|
|
105
|
+
export interface Zone {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
status: string;
|
|
109
|
+
site_url?: string | null;
|
|
110
|
+
traffic_back_url?: string | null;
|
|
111
|
+
postback_url?: string | null;
|
|
112
|
+
user_email?: string | null;
|
|
113
|
+
manager_email?: string | null;
|
|
114
|
+
created_at?: number;
|
|
115
|
+
updated_at?: number;
|
|
116
|
+
}
|
|
117
|
+
export interface ZonesResponse {
|
|
118
|
+
zones: Zone[];
|
|
119
|
+
pagination: Pagination;
|
|
120
|
+
}
|
|
121
|
+
export interface CreateZoneResponse {
|
|
122
|
+
id: string;
|
|
123
|
+
status: string;
|
|
124
|
+
created_at: number;
|
|
125
|
+
}
|
|
126
|
+
export interface UpdateZoneResponse {
|
|
127
|
+
id: string;
|
|
128
|
+
updated_at: number;
|
|
129
|
+
}
|
|
130
|
+
export interface UpdateCampaignResponse {
|
|
131
|
+
id: number;
|
|
132
|
+
updated_at: number;
|
|
133
|
+
}
|
|
134
|
+
/** Subset of GET /api/tenant this server reads. */
|
|
135
|
+
export interface TenantSettingsResponse {
|
|
136
|
+
company?: string;
|
|
137
|
+
/** IANA name; every date the tools render or resolve is in this zone. */
|
|
138
|
+
timezone?: string;
|
|
139
|
+
sub_labels?: SubLabels;
|
|
140
|
+
/** Tenant's own API domain; "" when unset. Integration URLs must use it. */
|
|
141
|
+
custom_api_domain?: string;
|
|
142
|
+
}
|
|
143
|
+
/** One payout rule from GET/POST /api/campaigns/{id}/payout_rules. */
|
|
144
|
+
export interface PayoutRule {
|
|
145
|
+
id: number;
|
|
146
|
+
campaign_id: number;
|
|
147
|
+
zone_id: string | null;
|
|
148
|
+
payout: number;
|
|
149
|
+
created_at?: number;
|
|
150
|
+
}
|
|
151
|
+
export interface PayoutRulesResponse {
|
|
152
|
+
payout_rules: PayoutRule[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One team member from GET /api/api-keys?type=user, or the response of
|
|
156
|
+
* POST /api/api-keys?type=user (create).
|
|
157
|
+
*
|
|
158
|
+
* `token` is present in both. It is not a one-time secret — affset returns it
|
|
159
|
+
* on every list call to a permitted role, same as the dashboard's "Copy token"
|
|
160
|
+
* button — but `list_team` deliberately never echoes it anyway, since a
|
|
161
|
+
* browsing-style "show my team" query is a bad place for live credentials to
|
|
162
|
+
* repeatedly pass through model context. `create_team_member` is the
|
|
163
|
+
* considered exception: it echoes the token exactly once, on the one call
|
|
164
|
+
* that just minted it for the operator to hand to that person.
|
|
165
|
+
*/
|
|
166
|
+
export interface TeamMember {
|
|
167
|
+
token?: string;
|
|
168
|
+
namespace?: string;
|
|
169
|
+
user_id?: string;
|
|
170
|
+
email: string | null;
|
|
171
|
+
role: string;
|
|
172
|
+
created_at: number;
|
|
173
|
+
expires_at?: number;
|
|
174
|
+
permissions?: string[];
|
|
175
|
+
manager_email?: string;
|
|
176
|
+
}
|
|
177
|
+
/** Response of POST /api/api-keys?type=user — same shape as TeamMember, token always present. */
|
|
178
|
+
export type CreateTeamMemberResponse = TeamMember & {
|
|
179
|
+
token: string;
|
|
180
|
+
};
|
|
181
|
+
export interface TargetingRule {
|
|
182
|
+
id?: number;
|
|
183
|
+
campaign_id?: string | number;
|
|
184
|
+
targeting_rule_type_id: number;
|
|
185
|
+
targeting_method: "whitelist" | "blacklist";
|
|
186
|
+
rule: string;
|
|
187
|
+
}
|
|
188
|
+
export interface TargetingRulesResponse {
|
|
189
|
+
targeting_rules: TargetingRule[];
|
|
190
|
+
}
|
|
191
|
+
export interface TargetingRuleType {
|
|
192
|
+
id: number;
|
|
193
|
+
name: string;
|
|
194
|
+
description?: string | null;
|
|
195
|
+
}
|
|
196
|
+
export interface TargetingRuleTypesResponse {
|
|
197
|
+
targeting_rule_types: TargetingRuleType[];
|
|
198
|
+
}
|
|
199
|
+
/** The five traffic-source breakdown keys. */
|
|
200
|
+
export declare const SUB_KEYS: readonly ["sub1", "sub2", "sub3", "sub4", "sub5"];
|
|
201
|
+
export type SubKey = (typeof SUB_KEYS)[number];
|
|
202
|
+
/** Tenant display names for sub slots; only labeled slots are present. */
|
|
203
|
+
export type SubLabels = Partial<Record<SubKey, string>>;
|
|
204
|
+
/** Valid `group_by` dimensions accepted by `GET /api/stats`. */
|
|
205
|
+
export declare const GROUP_BY_VALUES: readonly ["date", "campaign_id", "zone_id", "country", "conversion_type", "publisher_email", "advertiser_email", "sub1", "sub2", "sub3", "sub4", "sub5"];
|
|
206
|
+
export type GroupBy = (typeof GROUP_BY_VALUES)[number];
|
|
207
|
+
export declare const CAMPAIGN_STATUSES: readonly ["active", "paused", "archived"];
|
|
208
|
+
export declare const ZONE_STATUSES: readonly ["active", "inactive"];
|
|
209
|
+
export declare const PAYMENT_MODELS: readonly ["cpa", "cpm"];
|
|
210
|
+
export declare const PACING_VALUES: readonly ["asap", "even"];
|