@affset/mcp 0.1.0 → 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.
Files changed (66) hide show
  1. package/.env.example +5 -0
  2. package/README.md +158 -37
  3. package/dist/client.d.ts +43 -0
  4. package/dist/client.js +15 -2
  5. package/dist/config.d.ts +7 -0
  6. package/dist/config.js +15 -54
  7. package/dist/core.d.ts +18 -0
  8. package/dist/core.js +18 -0
  9. package/dist/docs.d.ts +39 -0
  10. package/dist/docs.js +105 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +0 -0
  13. package/dist/lib/format.d.ts +46 -0
  14. package/dist/lib/format.js +3 -0
  15. package/dist/lib/integrationUrls.d.ts +57 -0
  16. package/dist/lib/linkArgs.d.ts +27 -0
  17. package/dist/lib/patch.d.ts +10 -0
  18. package/dist/lib/payoutRules.d.ts +38 -0
  19. package/dist/lib/readBody.d.ts +17 -0
  20. package/dist/lib/readBody.js +69 -0
  21. package/dist/lib/targeting.d.ts +51 -0
  22. package/dist/lib/time.d.ts +38 -0
  23. package/dist/lib/toolResult.d.ts +7 -0
  24. package/dist/lib/urls.d.ts +2 -0
  25. package/dist/lib/zones.d.ts +24 -0
  26. package/dist/registerTools.d.ts +40 -0
  27. package/dist/registerTools.js +401 -0
  28. package/dist/runtimeConfig.d.ts +37 -0
  29. package/dist/runtimeConfig.js +93 -0
  30. package/dist/server.d.ts +4 -0
  31. package/dist/server.js +3 -306
  32. package/dist/tools/createCampaign.d.ts +25 -0
  33. package/dist/tools/createCampaign.js +3 -2
  34. package/dist/tools/createTeamMember.d.ts +26 -0
  35. package/dist/tools/createTeamMember.js +204 -0
  36. package/dist/tools/createZone.d.ts +22 -0
  37. package/dist/tools/cutZones.d.ts +29 -0
  38. package/dist/tools/deletePayoutRule.d.ts +16 -0
  39. package/dist/tools/getCampaign.d.ts +12 -0
  40. package/dist/tools/getCampaign.js +150 -0
  41. package/dist/tools/getStats.d.ts +40 -0
  42. package/dist/tools/getStats.js +37 -2
  43. package/dist/tools/getTrackingLink.d.ts +23 -0
  44. package/dist/tools/getZoneUrl.d.ts +21 -0
  45. package/dist/tools/listCampaigns.d.ts +23 -0
  46. package/dist/tools/listConversions.d.ts +29 -0
  47. package/dist/tools/listPayoutRules.d.ts +12 -0
  48. package/dist/tools/listSubLabels.d.ts +5 -0
  49. package/dist/tools/listTargetingRules.d.ts +12 -0
  50. package/dist/tools/listTargetingTypes.d.ts +5 -0
  51. package/dist/tools/listTeam.d.ts +14 -0
  52. package/dist/tools/listZones.d.ts +23 -0
  53. package/dist/tools/removeTargetingRule.d.ts +21 -0
  54. package/dist/tools/setCampaignStatus.d.ts +18 -0
  55. package/dist/tools/setPayoutGoal.d.ts +16 -0
  56. package/dist/tools/setPayoutRule.d.ts +18 -0
  57. package/dist/tools/setSubLabels.d.ts +22 -0
  58. package/dist/tools/setTargetingRule.d.ts +21 -0
  59. package/dist/tools/updateCampaign.d.ts +35 -0
  60. package/dist/tools/updateZone.d.ts +25 -0
  61. package/dist/tools/whoami.d.ts +6 -0
  62. package/dist/types.d.ts +210 -0
  63. package/dist/types.js +1 -0
  64. package/dist/version.d.ts +7 -0
  65. package/dist/version.js +8 -0
  66. package/package.json +16 -2
@@ -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"];
package/dist/types.js CHANGED
@@ -9,6 +9,7 @@ export const GROUP_BY_VALUES = [
9
9
  "country",
10
10
  "conversion_type",
11
11
  "publisher_email",
12
+ "advertiser_email",
12
13
  ...SUB_KEYS,
13
14
  ];
14
15
  export const CAMPAIGN_STATUSES = ["active", "paused", "archived"];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Package version, duplicated from package.json so the core stays importable
3
+ * on runtimes without Node's module APIs (Workers). createRequire-reading
4
+ * package.json here would break bundlers; a sync test guards the duplicate
5
+ * (see registerTools.test.ts).
6
+ */
7
+ export declare const VERSION = "0.2.0";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Package version, duplicated from package.json so the core stays importable
3
+ * on runtimes without Node's module APIs (Workers). createRequire-reading
4
+ * package.json here would break bundlers; a sync test guards the duplicate
5
+ * (see registerTools.test.ts).
6
+ */
7
+ export const VERSION = "0.2.0";
8
+ //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@affset/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
+ "mcpName": "io.github.affset/mcp",
4
5
  "description": "MCP server for the affset ad platform — stats, campaigns, zones, payouts, targeting, sub labels, and team from your chat client.",
5
6
  "type": "module",
6
7
  "license": "MIT",
@@ -19,6 +20,19 @@
19
20
  "bin": {
20
21
  "affset-mcp": "dist/index.js"
21
22
  },
23
+ "main": "./dist/core.js",
24
+ "types": "./dist/core.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/core.d.ts",
28
+ "default": "./dist/core.js"
29
+ },
30
+ "./core": {
31
+ "types": "./dist/core.d.ts",
32
+ "default": "./dist/core.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
22
36
  "files": [
23
37
  "dist",
24
38
  "!dist/**/*.test.*",
@@ -27,7 +41,7 @@
27
41
  ".env.example"
28
42
  ],
29
43
  "engines": {
30
- "node": ">=18"
44
+ "node": ">=22.13.0"
31
45
  },
32
46
  "scripts": {
33
47
  "build": "tsc",