@sketric/favstash-mcp 0.3.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/README.md +102 -0
- package/bin/favstash-mcp.js +563 -0
- package/bin/local-media-upload.js +575 -0
- package/bin/schema-registration.js +28 -0
- package/bin/social-post-schema.js +501 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# FavStash MCP stdio bridge
|
|
2
|
+
|
|
3
|
+
Stdio MCP bridge for FavStash. It lets local AI agents that expect a command-based MCP server talk to the hosted FavStash MCP endpoint.
|
|
4
|
+
|
|
5
|
+
Use this package when a client requires a local stdio command **or when a
|
|
6
|
+
filesystem-capable agent needs to publish a local image, video, or LinkedIn PDF
|
|
7
|
+
document**. Remote
|
|
8
|
+
Streamable HTTP clients that use only existing HTTPS media should connect
|
|
9
|
+
directly to `https://mcp.favstash.app/mcp` and use OAuth.
|
|
10
|
+
|
|
11
|
+
## Connection requirements
|
|
12
|
+
|
|
13
|
+
Hosted HTTPS-media workflows can connect directly without this package.
|
|
14
|
+
The bridge uses a locally stored FavStash API key; it does not reuse a host's
|
|
15
|
+
remote OAuth connection.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
FAVSTASH_API_KEY=favstash_pk_... \
|
|
21
|
+
FAVSTASH_MCP_URL=https://mcp.favstash.app/mcp \
|
|
22
|
+
npx -y @sketric/favstash-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
An older stdio-only host can configure the bridge as:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"favstash": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "@sketric/favstash-mcp"],
|
|
33
|
+
"env": {
|
|
34
|
+
"FAVSTASH_API_KEY": "favstash_pk_...",
|
|
35
|
+
"FAVSTASH_MCP_URL": "https://mcp.favstash.app/mcp"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`FAVSTASH_MCP_URL` is optional when the hosted default endpoint is correct.
|
|
43
|
+
The bridge derives the matching REST base used for its private upload
|
|
44
|
+
orchestration. A developer sandbox may set `FAVSTASH_API_URL` explicitly when
|
|
45
|
+
its MCP URL does not share that base.
|
|
46
|
+
|
|
47
|
+
The bridge registers the same 19 FavStash MCP v2 tool names as the hosted
|
|
48
|
+
endpoint, with local-file input added to the publishing tools.
|
|
49
|
+
Use `list_connected_social_accounts` before account-dependent work,
|
|
50
|
+
`get_social_account_analytics` for aggregate trends, and
|
|
51
|
+
`analyze_social_content_performance` for individual posts or rankings.
|
|
52
|
+
Agents can create a date-only calendar plan by calling `create_social_post`
|
|
53
|
+
with `draft=true` and `plannedDate="YYYY-MM-DD"`. A planned draft never
|
|
54
|
+
publishes automatically; scheduling it later still requires `publishAt`.
|
|
55
|
+
Instagram, YouTube, TikTok, and LinkedIn personal accounts are publishing
|
|
56
|
+
destinations. LinkedIn personal accounts are publishing-only: the self-serve
|
|
57
|
+
API does not expose their analytics or owned-post history.
|
|
58
|
+
|
|
59
|
+
For ordinary publishing, pass an absolute `media[].localPath` and optional
|
|
60
|
+
`media[].thumbnailPath` directly to `create_social_post` or
|
|
61
|
+
`update_social_post`. Root content/media are shared defaults; a target may carry
|
|
62
|
+
its own `content` and `media` when a channel needs a different caption or asset.
|
|
63
|
+
The bridge resolves local paths in both locations, validates regular-file
|
|
64
|
+
status, extension, magic bytes, and size, and validates the complete typed
|
|
65
|
+
platform, publishing-mode, and statically known media-compatibility contract
|
|
66
|
+
before reading or uploading a file. This includes each destination's effective
|
|
67
|
+
caption limit and rejects LinkedIn MOV video before transfer. It then hides presign, streaming PUT,
|
|
68
|
+
multipart retries, ETags, completion, and CDN substitution inside the same tool
|
|
69
|
+
call. It hashes files while preparing them so
|
|
70
|
+
an exact retry resolves to the same content-addressed CDN URL; conditional
|
|
71
|
+
storage writes make that object immutable, and backend completion streams and
|
|
72
|
+
verifies every uploaded byte against the digest in the key. A conflicting or
|
|
73
|
+
truncated first write is deleted instead of being accepted, so a retry cannot
|
|
74
|
+
silently reference different media. This remains compatible with
|
|
75
|
+
`clientRequestId`-based post idempotency. Images may be up to 8 MB, PDF
|
|
76
|
+
documents up to 100 MB, video up to 200 MB, and JPEG/PNG thumbnails up to 2 MB.
|
|
77
|
+
A PDF is valid only as the sole media item on a LinkedIn target; its filename
|
|
78
|
+
becomes the document title unless `title` is provided.
|
|
79
|
+
For a planned YouTube or TikTok draft, a non-empty provider
|
|
80
|
+
`target.settings.title` also counts as meaningful draft content, matching the
|
|
81
|
+
hosted contract.
|
|
82
|
+
|
|
83
|
+
`create_social_post` requires a 16–128 character `clientRequestId` beginning
|
|
84
|
+
with a letter or number; reuse it only for an exact retry of the same request.
|
|
85
|
+
The hosted backend uses that key to prevent a lost response from creating
|
|
86
|
+
another post.
|
|
87
|
+
|
|
88
|
+
`update_social_post` requires `expectedUpdatedAt` from `get_social_post` or
|
|
89
|
+
`list_social_posts`. FavStash rejects the update if a newer web, mobile, or
|
|
90
|
+
agent edit has already changed that version.
|
|
91
|
+
|
|
92
|
+
Use `import_post_media` only for explicit staging or reuse. It accepts one HTTPS
|
|
93
|
+
`url`, one local `path`, or up to ten ordered local `files[]` entries. A
|
|
94
|
+
singular URL or path also accepts a 1–200 character PDF `title`. Agents
|
|
95
|
+
must not reuse the configured bearer credential outside the bridge, call the
|
|
96
|
+
FavStash upload routes themselves, or expose signed upload details.
|
|
97
|
+
|
|
98
|
+
For local development from the repository root:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
FAVSTASH_API_KEY=favstash_pk_... node packages/favstash-mcp/bin/favstash-mcp.js
|
|
102
|
+
```
|
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import {
|
|
6
|
+
createLocalMediaUploadClient,
|
|
7
|
+
deriveApiBaseUrl,
|
|
8
|
+
normalizeLocalPostArguments,
|
|
9
|
+
} from "./local-media-upload.js";
|
|
10
|
+
import { registrationShape } from "./schema-registration.js";
|
|
11
|
+
import {
|
|
12
|
+
draftPostTarget,
|
|
13
|
+
hasMeaningfulPostContent,
|
|
14
|
+
mediaItemSchema,
|
|
15
|
+
postClientRequestId,
|
|
16
|
+
updateTarget,
|
|
17
|
+
validatePublishTargetsBeforeUpload,
|
|
18
|
+
} from "./social-post-schema.js";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_MCP_URL = "https://mcp.favstash.app/mcp";
|
|
21
|
+
const apiKey = process.env.FAVSTASH_API_KEY;
|
|
22
|
+
const mcpUrl = process.env.FAVSTASH_MCP_URL ?? DEFAULT_MCP_URL;
|
|
23
|
+
|
|
24
|
+
if (!apiKey) {
|
|
25
|
+
console.error(
|
|
26
|
+
"FAVSTASH_API_KEY is required. Create one in FavStash Dashboard > API keys.",
|
|
27
|
+
);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const apiBaseUrl = deriveApiBaseUrl(mcpUrl, process.env.FAVSTASH_API_URL);
|
|
32
|
+
const mediaUploadClient = createLocalMediaUploadClient({
|
|
33
|
+
apiKey,
|
|
34
|
+
apiBaseUrl,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const server = new McpServer(
|
|
38
|
+
{ name: "favstash", version: "2.0.0" },
|
|
39
|
+
{
|
|
40
|
+
instructions:
|
|
41
|
+
"Use FavStash to search saved creator inspiration, inspect connected-account analytics, compare owned social content, and review or publish posts. Discover connection IDs before account-dependent calls and follow structured nextActions when a result points to a narrower tool.",
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
let rpcId = 1;
|
|
46
|
+
|
|
47
|
+
async function callHostedTool(name, args) {
|
|
48
|
+
const response = await fetch(mcpUrl, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: {
|
|
51
|
+
Authorization: `Bearer ${apiKey}`,
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
Accept: "application/json",
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify({
|
|
56
|
+
jsonrpc: "2.0",
|
|
57
|
+
id: rpcId++,
|
|
58
|
+
method: "tools/call",
|
|
59
|
+
params: { name, arguments: args },
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
const text = await response.text();
|
|
63
|
+
let json;
|
|
64
|
+
try {
|
|
65
|
+
json = text ? JSON.parse(text) : null;
|
|
66
|
+
} catch {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`FavStash returned non-JSON response (${response.status}): ${text}`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
json?.message ?? json?.error ?? `FavStash HTTP ${response.status}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (json?.error) {
|
|
77
|
+
throw new Error(json.error.message ?? "FavStash tool call failed");
|
|
78
|
+
}
|
|
79
|
+
const result = json?.result ?? json;
|
|
80
|
+
if (result?.isError) {
|
|
81
|
+
const message = Array.isArray(result.content)
|
|
82
|
+
? result.content.find((item) => item?.type === "text")?.text
|
|
83
|
+
: undefined;
|
|
84
|
+
throw new Error(message ?? "FavStash tool call failed");
|
|
85
|
+
}
|
|
86
|
+
return result?.structuredContent ?? result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function asToolResult(result) {
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
92
|
+
structuredContent: result,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function registerHostedTool(
|
|
97
|
+
name,
|
|
98
|
+
title,
|
|
99
|
+
description,
|
|
100
|
+
schema,
|
|
101
|
+
annotations,
|
|
102
|
+
handler = (args) => callHostedTool(name, args),
|
|
103
|
+
) {
|
|
104
|
+
server.registerTool(
|
|
105
|
+
name,
|
|
106
|
+
{
|
|
107
|
+
title,
|
|
108
|
+
description,
|
|
109
|
+
// The SDK serializes raw object shapes correctly, but ZodEffects
|
|
110
|
+
// (created by superRefine) has no `.shape` and otherwise advertises an
|
|
111
|
+
// empty schema. Keep the full schema below for execution validation.
|
|
112
|
+
inputSchema: registrationShape(schema),
|
|
113
|
+
annotations,
|
|
114
|
+
},
|
|
115
|
+
async (args) => asToolResult(await handler(schema.parse(args))),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const readOnly = {
|
|
120
|
+
readOnlyHint: true,
|
|
121
|
+
destructiveHint: false,
|
|
122
|
+
idempotentHint: true,
|
|
123
|
+
openWorldHint: false,
|
|
124
|
+
};
|
|
125
|
+
const openWorldRead = { ...readOnly, openWorldHint: true };
|
|
126
|
+
const write = {
|
|
127
|
+
readOnlyHint: false,
|
|
128
|
+
destructiveHint: false,
|
|
129
|
+
idempotentHint: false,
|
|
130
|
+
openWorldHint: true,
|
|
131
|
+
};
|
|
132
|
+
const destructiveWrite = { ...write, destructiveHint: true };
|
|
133
|
+
const localDestructiveWrite = {
|
|
134
|
+
...destructiveWrite,
|
|
135
|
+
openWorldHint: false,
|
|
136
|
+
};
|
|
137
|
+
const empty = z.object({}).strict();
|
|
138
|
+
const iso = z.string().datetime();
|
|
139
|
+
const calendarDate = z.string().date();
|
|
140
|
+
const httpsUrl = z
|
|
141
|
+
.string()
|
|
142
|
+
.url()
|
|
143
|
+
.regex(/^https:\/\//);
|
|
144
|
+
const platform = z.enum([
|
|
145
|
+
"instagram",
|
|
146
|
+
"tiktok",
|
|
147
|
+
"youtube",
|
|
148
|
+
"twitter",
|
|
149
|
+
"linkedin",
|
|
150
|
+
"reddit",
|
|
151
|
+
"threads",
|
|
152
|
+
"web",
|
|
153
|
+
]);
|
|
154
|
+
const localPath = z
|
|
155
|
+
.string()
|
|
156
|
+
.min(1)
|
|
157
|
+
.describe("Absolute path to a local JPEG, PNG, WebP, MP4, MOV, or PDF file.");
|
|
158
|
+
const importFile = z
|
|
159
|
+
.object({
|
|
160
|
+
path: localPath,
|
|
161
|
+
role: z.enum(["media", "thumbnail"]).optional(),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
|
|
165
|
+
registerHostedTool(
|
|
166
|
+
"list_connected_social_accounts",
|
|
167
|
+
"List connected social accounts",
|
|
168
|
+
"Use first when a request depends on Instagram, YouTube, TikTok, or LinkedIn. Returns owner-scoped connection IDs, account identity, safe health state, available capabilities, and plan locks. Sensitive token, scope, provider-metadata, and internal media fields are omitted. LinkedIn personal accounts support publishing but not analytics or post history; pass a returned connectionId to the relevant tool.",
|
|
169
|
+
empty,
|
|
170
|
+
readOnly,
|
|
171
|
+
);
|
|
172
|
+
registerHostedTool(
|
|
173
|
+
"get_account_plan_and_usage",
|
|
174
|
+
"Get account plan and usage",
|
|
175
|
+
"Use before bulk saves or publishing when plan capacity matters. Returns the current plan, live save/channel/post usage, analytics-history allowance, and upgrade URL. Do not call for ordinary single-item reads.",
|
|
176
|
+
empty,
|
|
177
|
+
readOnly,
|
|
178
|
+
);
|
|
179
|
+
registerHostedTool(
|
|
180
|
+
"save_content_url",
|
|
181
|
+
"Save content URL",
|
|
182
|
+
"Save one public Instagram, TikTok, YouTube, or LinkedIn URL to the user's FavStash. Metadata/enrichment may continue asynchronously; use get_saved_content with the returned item id to check status. This changes the user's stash and requires confirmation unless the user already asked to save that exact URL.",
|
|
183
|
+
z
|
|
184
|
+
.object({
|
|
185
|
+
url: z.string().url(),
|
|
186
|
+
clientRequestId: z
|
|
187
|
+
.string()
|
|
188
|
+
.min(16)
|
|
189
|
+
.max(128)
|
|
190
|
+
.regex(/^[A-Za-z0-9:_-]+$/)
|
|
191
|
+
.describe(
|
|
192
|
+
"Stable request key for this save. Reuse the exact same value only when retrying the same URL, collection, and note; use a new UUID-like value for a different save.",
|
|
193
|
+
),
|
|
194
|
+
collectionId: z.string().optional(),
|
|
195
|
+
userNote: z.string().optional(),
|
|
196
|
+
})
|
|
197
|
+
.strict(),
|
|
198
|
+
write,
|
|
199
|
+
);
|
|
200
|
+
registerHostedTool(
|
|
201
|
+
"search_saved_content",
|
|
202
|
+
"Search saved content",
|
|
203
|
+
"Semantic search across saved captions, transcripts, on-screen text, visual summaries, creators, notes, and topics. Use when the request describes meaning or content; use list_recently_saved_content for a purely chronological request. Returns ranked owner-scoped matches and applied search metadata.",
|
|
204
|
+
z
|
|
205
|
+
.object({
|
|
206
|
+
query: z.string(),
|
|
207
|
+
collectionId: z.string().optional(),
|
|
208
|
+
sourcePlatform: platform.optional(),
|
|
209
|
+
dateFrom: iso.optional(),
|
|
210
|
+
dateTo: iso.optional(),
|
|
211
|
+
tagIds: z.array(z.string()).optional(),
|
|
212
|
+
limit: z.number().int().min(1).max(10).optional(),
|
|
213
|
+
})
|
|
214
|
+
.strict(),
|
|
215
|
+
readOnly,
|
|
216
|
+
);
|
|
217
|
+
registerHostedTool(
|
|
218
|
+
"list_recently_saved_content",
|
|
219
|
+
"List recently saved content",
|
|
220
|
+
"List saved content newest-first without semantic search. Use for requests such as 'what did I save this week?' and optional date/collection filters. Use search_saved_content when the request is about meaning, hooks, creators, or topics.",
|
|
221
|
+
z
|
|
222
|
+
.object({
|
|
223
|
+
since: iso.optional(),
|
|
224
|
+
until: iso.optional(),
|
|
225
|
+
collectionId: z.string().optional(),
|
|
226
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
227
|
+
})
|
|
228
|
+
.strict(),
|
|
229
|
+
readOnly,
|
|
230
|
+
);
|
|
231
|
+
registerHostedTool(
|
|
232
|
+
"get_saved_content",
|
|
233
|
+
"Get saved content",
|
|
234
|
+
"Fetch one known saved-content item by FavStash item id. Returns bounded long text by default and null when missing or not owned by the caller. Request full text only when the user needs the transcript/caption rather than a preview.",
|
|
235
|
+
z
|
|
236
|
+
.object({
|
|
237
|
+
id: z.string(),
|
|
238
|
+
includeFullText: z.boolean().optional(),
|
|
239
|
+
textLimit: z.number().int().min(500).max(50_000).optional(),
|
|
240
|
+
})
|
|
241
|
+
.strict(),
|
|
242
|
+
readOnly,
|
|
243
|
+
);
|
|
244
|
+
registerHostedTool(
|
|
245
|
+
"get_stash_summary",
|
|
246
|
+
"Get stash summary",
|
|
247
|
+
"Return counts for the user's stash, grouped by platform, source type, enrichment status, and collection. Use for inventory/count questions without retrieving item text.",
|
|
248
|
+
z
|
|
249
|
+
.object({
|
|
250
|
+
since: iso.optional(),
|
|
251
|
+
until: iso.optional(),
|
|
252
|
+
collectionId: z.string().optional(),
|
|
253
|
+
maxItemsToScan: z.number().int().min(1).max(2_000).optional(),
|
|
254
|
+
})
|
|
255
|
+
.strict(),
|
|
256
|
+
readOnly,
|
|
257
|
+
);
|
|
258
|
+
registerHostedTool(
|
|
259
|
+
"list_stash_collections",
|
|
260
|
+
"List stash collections",
|
|
261
|
+
"List owner-scoped FavStash collections with IDs and descriptive metadata. Use before applying a user-named collection filter.",
|
|
262
|
+
z.object({ limit: z.number().int().min(1).max(200).optional() }).strict(),
|
|
263
|
+
readOnly,
|
|
264
|
+
);
|
|
265
|
+
registerHostedTool(
|
|
266
|
+
"list_stash_tags",
|
|
267
|
+
"List stash tags",
|
|
268
|
+
"List owner-scoped user-created tags with IDs. Use before passing tagIds to search_saved_content when the user names a tag.",
|
|
269
|
+
z.object({ limit: z.number().int().min(1).max(500).optional() }).strict(),
|
|
270
|
+
readOnly,
|
|
271
|
+
);
|
|
272
|
+
registerHostedTool(
|
|
273
|
+
"get_social_account_analytics",
|
|
274
|
+
"Get social account analytics",
|
|
275
|
+
"Return aggregate analytics for one connected social account over a plan-capped 1–90 day window. Use for account trends and totals only. Do not use to identify, rank, or inspect individual posts; use analyze_social_content_performance for that.",
|
|
276
|
+
z
|
|
277
|
+
.object({
|
|
278
|
+
connectionId: z.string(),
|
|
279
|
+
days: z.number().int().min(1).max(90).optional(),
|
|
280
|
+
})
|
|
281
|
+
.strict(),
|
|
282
|
+
openWorldRead,
|
|
283
|
+
);
|
|
284
|
+
registerHostedTool(
|
|
285
|
+
"analyze_social_content_performance",
|
|
286
|
+
"Analyze social content performance",
|
|
287
|
+
"Inspect or rank owned Instagram, YouTube, or TikTok content, including posts not published through FavStash. Use exactly one mode: (1) connectionId alone lists/ranks recent owned content; (2) connectionId plus providerContentId inspects one native post; (3) favstashPostId resolves one FavStash-published post internally. Identity, metadata, URL, and metrics stay together in each content row. Provider limitations are returned explicitly.",
|
|
288
|
+
z
|
|
289
|
+
.object({
|
|
290
|
+
connectionId: z.string().optional(),
|
|
291
|
+
providerContentId: z.string().optional(),
|
|
292
|
+
favstashPostId: z.string().optional(),
|
|
293
|
+
days: z.number().int().min(1).max(90).optional(),
|
|
294
|
+
limit: z.number().int().min(1).max(25).optional(),
|
|
295
|
+
sortBy: z
|
|
296
|
+
.enum([
|
|
297
|
+
"views",
|
|
298
|
+
"reach",
|
|
299
|
+
"likes",
|
|
300
|
+
"comments",
|
|
301
|
+
"shares",
|
|
302
|
+
"saves",
|
|
303
|
+
"watch_time",
|
|
304
|
+
"average_view_duration",
|
|
305
|
+
"average_view_percentage",
|
|
306
|
+
"subscribers_gained",
|
|
307
|
+
])
|
|
308
|
+
.optional(),
|
|
309
|
+
order: z.enum(["asc", "desc"]).optional(),
|
|
310
|
+
})
|
|
311
|
+
.strict()
|
|
312
|
+
.superRefine((value, context) => {
|
|
313
|
+
const favstashMode = Boolean(value.favstashPostId);
|
|
314
|
+
const connectionMode = Boolean(value.connectionId);
|
|
315
|
+
if (
|
|
316
|
+
favstashMode === connectionMode ||
|
|
317
|
+
(value.providerContentId && !value.connectionId)
|
|
318
|
+
) {
|
|
319
|
+
context.addIssue({
|
|
320
|
+
code: z.ZodIssueCode.custom,
|
|
321
|
+
message:
|
|
322
|
+
"Use connectionId with optional providerContentId, or favstashPostId alone.",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}),
|
|
326
|
+
openWorldRead,
|
|
327
|
+
);
|
|
328
|
+
registerHostedTool(
|
|
329
|
+
"create_social_post",
|
|
330
|
+
"Create social post",
|
|
331
|
+
"Create one multi-channel publishing group as a planned draft, future schedule, or immediate publish. Top-level content/media are shared defaults; target.content and target.media can provide platform-specific variants. Local clients may use localPath for images, video, or a LinkedIn PDF; FavStash validates, uploads, and publishes it inside this one tool call. Provide a stable clientRequestId and exactly one of draft=true, publishAt, or postNow=true. Use typed targets from list_connected_social_accounts and call get_social_publishing_options before provider-sensitive publishing. This can publish externally, so confirm the exact channels, media, timing, and declarations unless the user explicitly authorized them.",
|
|
332
|
+
z
|
|
333
|
+
.object({
|
|
334
|
+
targets: z.array(draftPostTarget).min(1).max(5),
|
|
335
|
+
clientRequestId: postClientRequestId,
|
|
336
|
+
content: z.string().max(5_000).optional(),
|
|
337
|
+
media: z.array(mediaItemSchema()).max(20).optional(),
|
|
338
|
+
publishAt: iso.optional(),
|
|
339
|
+
plannedDate: calendarDate.optional(),
|
|
340
|
+
postNow: z.boolean().optional(),
|
|
341
|
+
draft: z.boolean().optional(),
|
|
342
|
+
})
|
|
343
|
+
.strict()
|
|
344
|
+
.superRefine((value, context) => {
|
|
345
|
+
const selected = [
|
|
346
|
+
Boolean(value.publishAt),
|
|
347
|
+
value.postNow === true,
|
|
348
|
+
value.draft === true,
|
|
349
|
+
].filter(Boolean).length;
|
|
350
|
+
if (selected !== 1) {
|
|
351
|
+
context.addIssue({
|
|
352
|
+
code: z.ZodIssueCode.custom,
|
|
353
|
+
message:
|
|
354
|
+
"Provide exactly one of publishAt, postNow=true, or draft=true.",
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
if (value.plannedDate && value.draft !== true) {
|
|
358
|
+
context.addIssue({
|
|
359
|
+
code: z.ZodIssueCode.custom,
|
|
360
|
+
path: ["plannedDate"],
|
|
361
|
+
message: "plannedDate is only valid when draft=true.",
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
if (!hasMeaningfulPostContent(value)) {
|
|
365
|
+
context.addIssue({
|
|
366
|
+
code: z.ZodIssueCode.custom,
|
|
367
|
+
message: "Provide a caption, title, media, or a combination.",
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
validatePublishTargetsBeforeUpload(value, context);
|
|
371
|
+
}),
|
|
372
|
+
destructiveWrite,
|
|
373
|
+
async (args) =>
|
|
374
|
+
callHostedTool(
|
|
375
|
+
"create_social_post",
|
|
376
|
+
await normalizeLocalPostArguments(args, mediaUploadClient),
|
|
377
|
+
),
|
|
378
|
+
);
|
|
379
|
+
registerHostedTool(
|
|
380
|
+
"get_social_post",
|
|
381
|
+
"Get social post",
|
|
382
|
+
"Fetch one FavStash social post by id, including state, release URL, warnings, and errors. Poll after immediate publishing or while a scheduled post is processing.",
|
|
383
|
+
z.object({ id: z.string() }).strict(),
|
|
384
|
+
readOnly,
|
|
385
|
+
);
|
|
386
|
+
registerHostedTool(
|
|
387
|
+
"list_social_posts",
|
|
388
|
+
"List social posts",
|
|
389
|
+
"List the user's planned drafts, queued, processing, paused, published, failed, or cancelled social posts in a calendar range. Planned drafts are matched by plannedDate; other posts are matched by publishAt. Optionally filter by state or connected account.",
|
|
390
|
+
z
|
|
391
|
+
.object({
|
|
392
|
+
from: iso.optional(),
|
|
393
|
+
to: iso.optional(),
|
|
394
|
+
state: z
|
|
395
|
+
.enum([
|
|
396
|
+
"DRAFT",
|
|
397
|
+
"QUEUE",
|
|
398
|
+
"PROCESSING",
|
|
399
|
+
"PAUSED",
|
|
400
|
+
"PUBLISHED",
|
|
401
|
+
"ERROR",
|
|
402
|
+
"CANCELLED",
|
|
403
|
+
])
|
|
404
|
+
.optional(),
|
|
405
|
+
connectionId: z.string().optional(),
|
|
406
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
407
|
+
})
|
|
408
|
+
.strict(),
|
|
409
|
+
readOnly,
|
|
410
|
+
);
|
|
411
|
+
registerHostedTool(
|
|
412
|
+
"update_social_post",
|
|
413
|
+
"Update social post",
|
|
414
|
+
"Update a FavStash DRAFT, QUEUE, or PAUSED post's content, media, typed target settings, planned date, or publish time. Local clients may provide media[].localPath and media[].thumbnailPath; FavStash validates and uploads them inside this one tool call. Pass expectedUpdatedAt so a retry cannot overwrite a newer edit. plannedDate only moves a DRAFT on the calendar and never schedules it; publishAt retains the existing scheduling behavior. Queued posts become read-only inside the publishing window. Confirm the exact change unless the user already requested it.",
|
|
415
|
+
z
|
|
416
|
+
.object({
|
|
417
|
+
id: z.string().min(1),
|
|
418
|
+
expectedUpdatedAt: iso,
|
|
419
|
+
publishAt: iso.optional(),
|
|
420
|
+
plannedDate: calendarDate.optional(),
|
|
421
|
+
content: z.string().max(5_000).optional(),
|
|
422
|
+
media: z.array(mediaItemSchema()).max(20).optional(),
|
|
423
|
+
target: updateTarget.optional(),
|
|
424
|
+
})
|
|
425
|
+
.strict()
|
|
426
|
+
.superRefine((value, context) => {
|
|
427
|
+
if (value.publishAt && value.plannedDate) {
|
|
428
|
+
context.addIssue({
|
|
429
|
+
code: z.ZodIssueCode.custom,
|
|
430
|
+
path: ["plannedDate"],
|
|
431
|
+
message: "Provide plannedDate or publishAt, not both.",
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
if (
|
|
435
|
+
!value.publishAt &&
|
|
436
|
+
!value.plannedDate &&
|
|
437
|
+
value.content === undefined &&
|
|
438
|
+
value.media === undefined &&
|
|
439
|
+
value.target === undefined
|
|
440
|
+
) {
|
|
441
|
+
context.addIssue({
|
|
442
|
+
code: z.ZodIssueCode.custom,
|
|
443
|
+
message: "Provide at least one post field to update.",
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}),
|
|
447
|
+
destructiveWrite,
|
|
448
|
+
async (args) =>
|
|
449
|
+
callHostedTool(
|
|
450
|
+
"update_social_post",
|
|
451
|
+
await normalizeLocalPostArguments(args, mediaUploadClient),
|
|
452
|
+
),
|
|
453
|
+
);
|
|
454
|
+
registerHostedTool(
|
|
455
|
+
"cancel_social_post",
|
|
456
|
+
"Cancel social post",
|
|
457
|
+
"Cancel one FavStash DRAFT, QUEUE, or PAUSED post. Published posts cannot be cancelled. This is destructive and requires confirmation unless the user explicitly asked to cancel that exact post.",
|
|
458
|
+
z.object({ id: z.string() }).strict(),
|
|
459
|
+
localDestructiveWrite,
|
|
460
|
+
);
|
|
461
|
+
registerHostedTool(
|
|
462
|
+
"import_post_media",
|
|
463
|
+
"Import post media",
|
|
464
|
+
"Stage media without creating a post. Provide url for one server-fetchable HTTPS source, path for one local file, or files for an ordered local batch; title optionally names a singular PDF document. Ordinary local publishing should pass localPath directly to create_social_post or update_social_post instead. FavStash hides upload URLs and multipart details. JPEG, PNG, WebP, MP4, MOV, or PDF; images up to 8 MB, thumbnails up to 2 MB, videos up to 200 MB, PDFs up to 100 MB.",
|
|
465
|
+
z
|
|
466
|
+
.object({
|
|
467
|
+
url: httpsUrl.optional(),
|
|
468
|
+
path: localPath.optional(),
|
|
469
|
+
role: z.enum(["media", "thumbnail"]).optional(),
|
|
470
|
+
title: z.string().min(1).max(200).optional(),
|
|
471
|
+
files: z.array(importFile).min(1).max(10).optional(),
|
|
472
|
+
})
|
|
473
|
+
.strict()
|
|
474
|
+
.superRefine((value, context) => {
|
|
475
|
+
const selected = [value.url, value.path, value.files].filter(
|
|
476
|
+
Boolean,
|
|
477
|
+
).length;
|
|
478
|
+
if (selected !== 1) {
|
|
479
|
+
context.addIssue({
|
|
480
|
+
code: z.ZodIssueCode.custom,
|
|
481
|
+
message: "Provide exactly one of url, path, or files.",
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (value.role && !value.path) {
|
|
485
|
+
context.addIssue({
|
|
486
|
+
code: z.ZodIssueCode.custom,
|
|
487
|
+
message: "role is valid only with path.",
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
if (value.title && value.files) {
|
|
491
|
+
context.addIssue({
|
|
492
|
+
code: z.ZodIssueCode.custom,
|
|
493
|
+
message: "title is valid only with singular url or path input.",
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
}),
|
|
497
|
+
write,
|
|
498
|
+
async (args) => {
|
|
499
|
+
if (args.url) {
|
|
500
|
+
return callHostedTool("import_post_media", {
|
|
501
|
+
url: args.url,
|
|
502
|
+
...(args.title ? { title: args.title } : {}),
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
const files = args.path
|
|
506
|
+
? [{ path: args.path, role: args.role ?? "media" }]
|
|
507
|
+
: args.files.map((file) => ({
|
|
508
|
+
path: file.path,
|
|
509
|
+
role: file.role ?? "media",
|
|
510
|
+
}));
|
|
511
|
+
const prepared = [];
|
|
512
|
+
for (const file of files) {
|
|
513
|
+
prepared.push({
|
|
514
|
+
role: file.role,
|
|
515
|
+
file: {
|
|
516
|
+
...(await mediaUploadClient.prepareFile(file.path, file.role)),
|
|
517
|
+
role: file.role,
|
|
518
|
+
},
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
const imports = [];
|
|
522
|
+
for (const entry of prepared) {
|
|
523
|
+
imports.push({
|
|
524
|
+
role: entry.role,
|
|
525
|
+
...(await mediaUploadClient.uploadPreparedFile(entry.file)),
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
if (!args.path) return { imports, count: imports.length };
|
|
529
|
+
return args.title && imports[0].type === "document"
|
|
530
|
+
? { ...imports[0], title: args.title }
|
|
531
|
+
: imports[0];
|
|
532
|
+
},
|
|
533
|
+
);
|
|
534
|
+
registerHostedTool(
|
|
535
|
+
"get_social_publishing_options",
|
|
536
|
+
"Get social publishing options",
|
|
537
|
+
"Fetch live publishing constraints for one connected social account before composing or confirming a post. Returns provider content types, privacy/interactions, declarations, media requirements, quota/limits, and current limitations. Required before TikTok Direct Post and recommended whenever provider-specific settings matter.",
|
|
538
|
+
z
|
|
539
|
+
.object({
|
|
540
|
+
connectionId: z.string(),
|
|
541
|
+
mediaType: z.enum(["image", "video", "carousel", "document"]).optional(),
|
|
542
|
+
durationSeconds: z.number().positive().optional(),
|
|
543
|
+
})
|
|
544
|
+
.strict(),
|
|
545
|
+
openWorldRead,
|
|
546
|
+
);
|
|
547
|
+
registerHostedTool(
|
|
548
|
+
"search_instagram_audio",
|
|
549
|
+
"Search Instagram audio",
|
|
550
|
+
"Search music or original sound for an Instagram-via-Facebook connection. Use the returned audio id in provider settings for a single-video Reel; this does not search a user's FavStash.",
|
|
551
|
+
z
|
|
552
|
+
.object({
|
|
553
|
+
connectionId: z.string(),
|
|
554
|
+
q: z.string().optional(),
|
|
555
|
+
type: z.enum(["music", "original_sound"]).optional(),
|
|
556
|
+
})
|
|
557
|
+
.strict(),
|
|
558
|
+
openWorldRead,
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
const transport = new StdioServerTransport();
|
|
562
|
+
await server.connect(transport);
|
|
563
|
+
console.error(`FavStash MCP v2 bridge connected to ${mcpUrl}`);
|