posterly-mcp-server 0.19.4 → 0.19.6
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/README.md +38 -18
- package/dist/index.js +52 -9
- package/dist/lib/api-client.d.ts +87 -0
- package/dist/lib/api-client.js +36 -1
- package/dist/tools/create-connect-session.d.ts +24 -0
- package/dist/tools/create-connect-session.js +38 -0
- package/dist/tools/create-webhook.d.ts +2 -2
- package/dist/tools/generate-image.d.ts +2 -2
- package/dist/tools/get-account-analytics.d.ts +7 -0
- package/dist/tools/get-account-analytics.js +121 -56
- package/dist/tools/get-agent-signup-info.d.ts +8 -0
- package/dist/tools/get-agent-signup-info.js +32 -0
- package/dist/tools/get-connect-session.d.ts +16 -0
- package/dist/tools/get-connect-session.js +26 -0
- package/dist/tools/get-post-analytics.d.ts +7 -0
- package/dist/tools/get-post-analytics.js +133 -54
- package/dist/tools/get-signup-session.d.ts +16 -0
- package/dist/tools/get-signup-session.js +65 -0
- package/dist/tools/get-video-job.d.ts +2 -2
- package/dist/tools/list-posts.d.ts +2 -2
- package/dist/tools/start-signup.d.ts +40 -0
- package/dist/tools/start-signup.js +83 -0
- package/dist/tools/update-webhook.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +77 -9
- package/src/lib/api-client.ts +142 -2
- package/src/tools/create-connect-session.ts +46 -0
- package/src/tools/get-account-analytics.ts +127 -64
- package/src/tools/get-agent-signup-info.ts +37 -0
- package/src/tools/get-connect-session.ts +34 -0
- package/src/tools/get-post-analytics.ts +139 -57
- package/src/tools/get-signup-session.ts +74 -0
- package/src/tools/start-signup.ts +104 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PosterlyClient, PublicSignupResponse, PublicSignupTier } from '../lib/api-client.js';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_RETURN_PATH = '/dashboard/api?api_signup=success';
|
|
5
|
+
|
|
6
|
+
export const startSignupTool = {
|
|
7
|
+
name: 'start_signup',
|
|
8
|
+
description:
|
|
9
|
+
'Start the public Posterly paid signup flow for a user before Posterly API access exists. Returns a Posterly checkout handoff URL and signup poll URL. The user must handle payment and password setup in the browser.',
|
|
10
|
+
inputSchema: z.object({
|
|
11
|
+
email: z
|
|
12
|
+
.string()
|
|
13
|
+
.email()
|
|
14
|
+
.describe('User email address to sign up. Confirm this with the user before calling.'),
|
|
15
|
+
name: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Optional user or workspace name to pass into Posterly signup.'),
|
|
19
|
+
tier: z
|
|
20
|
+
.enum(['starter', 'pro', 'power_user', 'agency'])
|
|
21
|
+
.default('starter')
|
|
22
|
+
.describe('Posterly plan to start. Use starter unless the user explicitly chooses another plan.'),
|
|
23
|
+
interval: z
|
|
24
|
+
.enum(['month'])
|
|
25
|
+
.default('month')
|
|
26
|
+
.describe('Billing interval. Public agent signup currently supports monthly billing.'),
|
|
27
|
+
api_addon: z
|
|
28
|
+
.boolean()
|
|
29
|
+
.default(true)
|
|
30
|
+
.describe('Always true for AI agent setup because MCP/API access requires the API add-on.'),
|
|
31
|
+
return_path: z
|
|
32
|
+
.string()
|
|
33
|
+
.default(DEFAULT_RETURN_PATH)
|
|
34
|
+
.describe('Where Posterly should continue after checkout and password setup.'),
|
|
35
|
+
source: z
|
|
36
|
+
.string()
|
|
37
|
+
.default('posterly_mcp_pre_auth_signup')
|
|
38
|
+
.describe('Source label for analytics and support diagnostics.'),
|
|
39
|
+
}),
|
|
40
|
+
|
|
41
|
+
async execute(
|
|
42
|
+
client: PosterlyClient,
|
|
43
|
+
input: {
|
|
44
|
+
email: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
tier?: PublicSignupTier;
|
|
47
|
+
interval?: 'month';
|
|
48
|
+
api_addon?: boolean;
|
|
49
|
+
return_path?: string;
|
|
50
|
+
source?: string;
|
|
51
|
+
},
|
|
52
|
+
) {
|
|
53
|
+
const response = await client.startSignup({
|
|
54
|
+
email: input.email,
|
|
55
|
+
name: input.name,
|
|
56
|
+
tier: input.tier ?? 'starter',
|
|
57
|
+
interval: input.interval ?? 'month',
|
|
58
|
+
api_addon: input.api_addon ?? true,
|
|
59
|
+
return_path: input.return_path ?? DEFAULT_RETURN_PATH,
|
|
60
|
+
source: input.source ?? 'posterly_mcp_pre_auth_signup',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return formatSignupStart(response);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function valueFromLinks(response: PublicSignupResponse, key: string): string | null {
|
|
68
|
+
const links = response.signup_session?.links ?? response.links;
|
|
69
|
+
const value = links?.[key];
|
|
70
|
+
return typeof value === 'string' ? value : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function formatSignupStart(response: PublicSignupResponse): string {
|
|
74
|
+
const session = response.signup_session;
|
|
75
|
+
const sessionId = session?.id || response.checkout_session_id;
|
|
76
|
+
const checkoutUrl = response.checkout_url || valueFromLinks(response, 'checkout_url');
|
|
77
|
+
const checkoutRedirectUrl = response.checkout_redirect_url || session?.checkout_redirect_url || valueFromLinks(response, 'checkout_redirect_url');
|
|
78
|
+
const pollUrl = response.poll_url || valueFromLinks(response, 'poll_url');
|
|
79
|
+
const completeUrl = response.complete_url || valueFromLinks(response, 'complete_url');
|
|
80
|
+
const status = session?.status || response.status || 'checkout_pending';
|
|
81
|
+
const message = session?.status_message || response.status_message;
|
|
82
|
+
|
|
83
|
+
const lines = [
|
|
84
|
+
'Posterly signup started.',
|
|
85
|
+
sessionId ? `Signup session: ${sessionId}` : '',
|
|
86
|
+
`Status: ${status}`,
|
|
87
|
+
message ? `Message: ${message}` : '',
|
|
88
|
+
checkoutRedirectUrl ? `Checkout handoff URL: ${checkoutRedirectUrl}` : '',
|
|
89
|
+
checkoutUrl ? `Checkout URL: ${checkoutUrl}` : '',
|
|
90
|
+
pollUrl ? `Poll URL: ${pollUrl}` : '',
|
|
91
|
+
completeUrl ? `Completion URL: ${completeUrl}` : '',
|
|
92
|
+
'',
|
|
93
|
+
'Next steps for the AI agent:',
|
|
94
|
+
'1. Send the Checkout handoff URL to the user so they can pay securely in their browser. Use the raw Stripe checkout URL only if you preserve the full URL including any fragment.',
|
|
95
|
+
'2. Call get_signup_session with the signup session ID until the status changes.',
|
|
96
|
+
'3. Tell the user when Posterly sends the password setup email.',
|
|
97
|
+
'4. If status becomes agent_access_required, ask the user to install or paste the Posterly MCP/API setup instructions into this trusted AI chat.',
|
|
98
|
+
'5. Do not ask for card details, the Posterly password, social passwords, or OAuth codes.',
|
|
99
|
+
'',
|
|
100
|
+
`Raw signup response:\n${JSON.stringify(response, null, 2)}`,
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
return lines.filter(Boolean).join('\n');
|
|
104
|
+
}
|