@hasna/microservices 0.0.16 → 0.0.18
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 +143 -23
- package/bin/index.js +784 -13987
- package/bin/mcp.js +298 -10973
- package/dist/index.js +251 -10056
- package/package.json +36 -26
- package/microservices/microservice-ads/package.json +0 -28
- package/microservices/microservice-ads/src/cli/index.ts +0 -605
- package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
- package/microservices/microservice-ads/src/db/database.ts +0 -91
- package/microservices/microservice-ads/src/db/migrations.ts +0 -60
- package/microservices/microservice-ads/src/index.ts +0 -39
- package/microservices/microservice-ads/src/mcp/index.ts +0 -480
- package/microservices/microservice-analytics/package.json +0 -28
- package/microservices/microservice-analytics/src/cli/index.ts +0 -373
- package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
- package/microservices/microservice-analytics/src/db/database.ts +0 -91
- package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
- package/microservices/microservice-analytics/src/index.ts +0 -37
- package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
- package/microservices/microservice-assets/package.json +0 -28
- package/microservices/microservice-assets/src/cli/index.ts +0 -375
- package/microservices/microservice-assets/src/db/assets.ts +0 -370
- package/microservices/microservice-assets/src/db/database.ts +0 -91
- package/microservices/microservice-assets/src/db/migrations.ts +0 -51
- package/microservices/microservice-assets/src/index.ts +0 -32
- package/microservices/microservice-assets/src/mcp/index.ts +0 -346
- package/microservices/microservice-bookkeeping/package.json +0 -28
- package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
- package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
- package/microservices/microservice-bookkeeping/src/db/database.ts +0 -91
- package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
- package/microservices/microservice-bookkeeping/src/index.ts +0 -32
- package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
- package/microservices/microservice-calendar/package.json +0 -28
- package/microservices/microservice-calendar/src/cli/index.ts +0 -287
- package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
- package/microservices/microservice-calendar/src/db/database.ts +0 -91
- package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
- package/microservices/microservice-calendar/src/index.ts +0 -24
- package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
- package/microservices/microservice-company/package.json +0 -28
- package/microservices/microservice-company/src/cli/index.ts +0 -1126
- package/microservices/microservice-company/src/db/company.ts +0 -854
- package/microservices/microservice-company/src/db/database.ts +0 -91
- package/microservices/microservice-company/src/db/migrations.ts +0 -214
- package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
- package/microservices/microservice-company/src/index.ts +0 -60
- package/microservices/microservice-company/src/lib/audit.ts +0 -168
- package/microservices/microservice-company/src/lib/finance.ts +0 -299
- package/microservices/microservice-company/src/lib/settings.ts +0 -85
- package/microservices/microservice-company/src/lib/workflows.ts +0 -698
- package/microservices/microservice-company/src/mcp/index.ts +0 -991
- package/microservices/microservice-compliance/package.json +0 -28
- package/microservices/microservice-compliance/src/cli/index.ts +0 -467
- package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
- package/microservices/microservice-compliance/src/db/database.ts +0 -91
- package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
- package/microservices/microservice-compliance/src/index.ts +0 -46
- package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
- package/microservices/microservice-contacts/package.json +0 -28
- package/microservices/microservice-contacts/src/cli/index.ts +0 -393
- package/microservices/microservice-contacts/src/db/companies.ts +0 -167
- package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
- package/microservices/microservice-contacts/src/db/database.ts +0 -91
- package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
- package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
- package/microservices/microservice-contacts/src/index.ts +0 -42
- package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
- package/microservices/microservice-contracts/package.json +0 -28
- package/microservices/microservice-contracts/src/cli/index.ts +0 -770
- package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
- package/microservices/microservice-contracts/src/db/database.ts +0 -91
- package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
- package/microservices/microservice-contracts/src/index.ts +0 -43
- package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
- package/microservices/microservice-crm/package.json +0 -28
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -91
- package/microservices/microservice-crm/src/db/migrations.ts +0 -66
- package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
- package/microservices/microservice-crm/src/index.ts +0 -34
- package/microservices/microservice-crm/src/mcp/index.ts +0 -294
- package/microservices/microservice-documents/package.json +0 -28
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -91
- package/microservices/microservice-documents/src/db/documents.ts +0 -316
- package/microservices/microservice-documents/src/db/migrations.ts +0 -49
- package/microservices/microservice-documents/src/index.ts +0 -24
- package/microservices/microservice-documents/src/mcp/index.ts +0 -202
- package/microservices/microservice-domains/package.json +0 -28
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -91
- package/microservices/microservice-domains/src/db/domains.ts +0 -1164
- package/microservices/microservice-domains/src/db/migrations.ts +0 -60
- package/microservices/microservice-domains/src/index.ts +0 -65
- package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
- package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
- package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
- package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
- package/microservices/microservice-domains/src/mcp/index.ts +0 -781
- package/microservices/microservice-expenses/package.json +0 -28
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -91
- package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
- package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
- package/microservices/microservice-expenses/src/index.ts +0 -25
- package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
- package/microservices/microservice-habits/package.json +0 -28
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -91
- package/microservices/microservice-habits/src/db/habits.ts +0 -451
- package/microservices/microservice-habits/src/db/migrations.ts +0 -46
- package/microservices/microservice-habits/src/index.ts +0 -31
- package/microservices/microservice-habits/src/mcp/index.ts +0 -313
- package/microservices/microservice-health/package.json +0 -28
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -91
- package/microservices/microservice-health/src/db/health.ts +0 -708
- package/microservices/microservice-health/src/db/migrations.ts +0 -70
- package/microservices/microservice-health/src/index.ts +0 -63
- package/microservices/microservice-health/src/mcp/index.ts +0 -437
- package/microservices/microservice-hiring/package.json +0 -28
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -91
- package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
- package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
- package/microservices/microservice-hiring/src/index.ts +0 -80
- package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
- package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
- package/microservices/microservice-inventory/package.json +0 -28
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -91
- package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
- package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
- package/microservices/microservice-inventory/src/index.ts +0 -28
- package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
- package/microservices/microservice-invoices/dashboard/index.html +0 -12
- package/microservices/microservice-invoices/dashboard/package.json +0 -29
- package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
- package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
- package/microservices/microservice-invoices/package.json +0 -31
- package/microservices/microservice-invoices/src/cli/index.ts +0 -308
- package/microservices/microservice-invoices/src/db/business.ts +0 -241
- package/microservices/microservice-invoices/src/db/clients.ts +0 -127
- package/microservices/microservice-invoices/src/db/database.ts +0 -91
- package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
- package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
- package/microservices/microservice-invoices/src/index.ts +0 -56
- package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
- package/microservices/microservice-invoices/src/server/index.ts +0 -162
- package/microservices/microservice-leads/package.json +0 -28
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -91
- package/microservices/microservice-leads/src/db/leads.ts +0 -520
- package/microservices/microservice-leads/src/db/lists.ts +0 -151
- package/microservices/microservice-leads/src/db/migrations.ts +0 -93
- package/microservices/microservice-leads/src/index.ts +0 -65
- package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
- package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
- package/microservices/microservice-leads/src/mcp/index.ts +0 -533
- package/microservices/microservice-notes/package.json +0 -28
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -91
- package/microservices/microservice-notes/src/db/migrations.ts +0 -40
- package/microservices/microservice-notes/src/db/notes.ts +0 -114
- package/microservices/microservice-notes/src/index.ts +0 -2
- package/microservices/microservice-notes/src/mcp/index.ts +0 -37
- package/microservices/microservice-notifications/package.json +0 -28
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -91
- package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
- package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
- package/microservices/microservice-notifications/src/index.ts +0 -41
- package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
- package/microservices/microservice-payments/package.json +0 -28
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -91
- package/microservices/microservice-payments/src/db/migrations.ts +0 -81
- package/microservices/microservice-payments/src/db/payments.ts +0 -1204
- package/microservices/microservice-payments/src/index.ts +0 -51
- package/microservices/microservice-payments/src/mcp/index.ts +0 -683
- package/microservices/microservice-payroll/package.json +0 -28
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -91
- package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
- package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
- package/microservices/microservice-payroll/src/index.ts +0 -48
- package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
- package/microservices/microservice-products/package.json +0 -28
- package/microservices/microservice-products/src/cli/index.ts +0 -416
- package/microservices/microservice-products/src/db/categories.ts +0 -154
- package/microservices/microservice-products/src/db/database.ts +0 -91
- package/microservices/microservice-products/src/db/migrations.ts +0 -58
- package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
- package/microservices/microservice-products/src/db/products.ts +0 -452
- package/microservices/microservice-products/src/index.ts +0 -53
- package/microservices/microservice-products/src/mcp/index.ts +0 -453
- package/microservices/microservice-projects/package.json +0 -28
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -91
- package/microservices/microservice-projects/src/db/migrations.ts +0 -65
- package/microservices/microservice-projects/src/db/projects.ts +0 -715
- package/microservices/microservice-projects/src/index.ts +0 -57
- package/microservices/microservice-projects/src/mcp/index.ts +0 -501
- package/microservices/microservice-proposals/package.json +0 -28
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -91
- package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
- package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
- package/microservices/microservice-proposals/src/index.ts +0 -37
- package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
- package/microservices/microservice-reading/package.json +0 -28
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -91
- package/microservices/microservice-reading/src/db/migrations.ts +0 -59
- package/microservices/microservice-reading/src/db/reading.ts +0 -524
- package/microservices/microservice-reading/src/index.ts +0 -51
- package/microservices/microservice-reading/src/mcp/index.ts +0 -368
- package/microservices/microservice-shipping/package.json +0 -28
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -91
- package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
- package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
- package/microservices/microservice-shipping/src/index.ts +0 -53
- package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
- package/microservices/microservice-social/package.json +0 -29
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -91
- package/microservices/microservice-social/src/db/migrations.ts +0 -160
- package/microservices/microservice-social/src/db/social.ts +0 -1076
- package/microservices/microservice-social/src/index.ts +0 -46
- package/microservices/microservice-social/src/lib/audience.ts +0 -353
- package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
- package/microservices/microservice-social/src/lib/media.ts +0 -311
- package/microservices/microservice-social/src/lib/mentions.ts +0 -434
- package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
- package/microservices/microservice-social/src/lib/publisher.ts +0 -377
- package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
- package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
- package/microservices/microservice-social/src/lib/threads.ts +0 -291
- package/microservices/microservice-social/src/mcp/index.ts +0 -1425
- package/microservices/microservice-social/src/server/index.ts +0 -441
- package/microservices/microservice-subscriptions/package.json +0 -28
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -91
- package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
- package/microservices/microservice-subscriptions/src/index.ts +0 -41
- package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
- package/microservices/microservice-timesheets/package.json +0 -28
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -91
- package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
- package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
- package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
- package/microservices/microservice-timesheets/src/index.ts +0 -44
- package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
- package/microservices/microservice-transcriber/package.json +0 -29
- package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
- package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
- package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
- package/microservices/microservice-transcriber/src/db/database.ts +0 -91
- package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
- package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
- package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
- package/microservices/microservice-transcriber/src/index.ts +0 -43
- package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
- package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
- package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
- package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
- package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
- package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
- package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
- package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
- package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
- package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
- package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
- package/microservices/microservice-transcriber/src/server/index.ts +0 -199
- package/microservices/microservice-travel/package.json +0 -28
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -91
- package/microservices/microservice-travel/src/db/migrations.ts +0 -77
- package/microservices/microservice-travel/src/db/travel.ts +0 -802
- package/microservices/microservice-travel/src/index.ts +0 -60
- package/microservices/microservice-travel/src/mcp/index.ts +0 -495
- package/microservices/microservice-wiki/package.json +0 -28
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -91
- package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
- package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
- package/microservices/microservice-wiki/src/index.ts +0 -32
- package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
|
@@ -1,1425 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import {
|
|
7
|
-
createAccount,
|
|
8
|
-
getAccount,
|
|
9
|
-
listAccounts,
|
|
10
|
-
updateAccount,
|
|
11
|
-
deleteAccount,
|
|
12
|
-
createPost,
|
|
13
|
-
getPost,
|
|
14
|
-
listPosts,
|
|
15
|
-
updatePost,
|
|
16
|
-
deletePost,
|
|
17
|
-
schedulePost,
|
|
18
|
-
publishPost,
|
|
19
|
-
createTemplate,
|
|
20
|
-
getTemplate,
|
|
21
|
-
listTemplates,
|
|
22
|
-
deleteTemplate,
|
|
23
|
-
useTemplate,
|
|
24
|
-
getEngagementStats,
|
|
25
|
-
getStatsByPlatform,
|
|
26
|
-
getCalendar,
|
|
27
|
-
getOverallStats,
|
|
28
|
-
batchSchedule,
|
|
29
|
-
crossPost,
|
|
30
|
-
getBestTimeToPost,
|
|
31
|
-
reschedulePost,
|
|
32
|
-
submitPostForReview,
|
|
33
|
-
approvePost,
|
|
34
|
-
createRecurringPost,
|
|
35
|
-
getHashtagStats,
|
|
36
|
-
PLATFORM_LIMITS,
|
|
37
|
-
} from "../db/social.js";
|
|
38
|
-
import {
|
|
39
|
-
startScheduler,
|
|
40
|
-
stopScheduler,
|
|
41
|
-
getSchedulerStatus,
|
|
42
|
-
runOnce as runSchedulerOnce,
|
|
43
|
-
} from "../lib/scheduler.js";
|
|
44
|
-
import {
|
|
45
|
-
validateMedia,
|
|
46
|
-
getSupportedFormats,
|
|
47
|
-
uploadMedia,
|
|
48
|
-
} from "../lib/media.js";
|
|
49
|
-
|
|
50
|
-
const PlatformEnum = z.enum(["x", "linkedin", "instagram", "threads", "bluesky"]);
|
|
51
|
-
const PostStatusEnum = z.enum(["draft", "scheduled", "published", "failed", "pending_review"]);
|
|
52
|
-
const RecurrenceEnum = z.enum(["daily", "weekly", "biweekly", "monthly"]);
|
|
53
|
-
|
|
54
|
-
const server = new McpServer({
|
|
55
|
-
name: "microservice-social",
|
|
56
|
-
version: "0.0.1",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// --- Accounts ---
|
|
60
|
-
|
|
61
|
-
server.registerTool(
|
|
62
|
-
"create_account",
|
|
63
|
-
{
|
|
64
|
-
title: "Create Social Account",
|
|
65
|
-
description: "Add a social media account.",
|
|
66
|
-
inputSchema: {
|
|
67
|
-
platform: PlatformEnum,
|
|
68
|
-
handle: z.string(),
|
|
69
|
-
display_name: z.string().optional(),
|
|
70
|
-
connected: z.boolean().optional(),
|
|
71
|
-
access_token_env: z.string().optional(),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
async (params) => {
|
|
75
|
-
const account = createAccount(params);
|
|
76
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
server.registerTool(
|
|
81
|
-
"get_account",
|
|
82
|
-
{
|
|
83
|
-
title: "Get Social Account",
|
|
84
|
-
description: "Get a social media account by ID.",
|
|
85
|
-
inputSchema: { id: z.string() },
|
|
86
|
-
},
|
|
87
|
-
async ({ id }) => {
|
|
88
|
-
const account = getAccount(id);
|
|
89
|
-
if (!account) {
|
|
90
|
-
return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
|
|
91
|
-
}
|
|
92
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
server.registerTool(
|
|
97
|
-
"list_accounts",
|
|
98
|
-
{
|
|
99
|
-
title: "List Social Accounts",
|
|
100
|
-
description: "List social media accounts with optional filters.",
|
|
101
|
-
inputSchema: {
|
|
102
|
-
platform: PlatformEnum.optional(),
|
|
103
|
-
connected: z.boolean().optional(),
|
|
104
|
-
limit: z.number().optional(),
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
async (params) => {
|
|
108
|
-
const accounts = listAccounts(params);
|
|
109
|
-
return {
|
|
110
|
-
content: [
|
|
111
|
-
{ type: "text", text: JSON.stringify({ accounts, count: accounts.length }, null, 2) },
|
|
112
|
-
],
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
server.registerTool(
|
|
118
|
-
"update_account",
|
|
119
|
-
{
|
|
120
|
-
title: "Update Social Account",
|
|
121
|
-
description: "Update a social media account.",
|
|
122
|
-
inputSchema: {
|
|
123
|
-
id: z.string(),
|
|
124
|
-
platform: PlatformEnum.optional(),
|
|
125
|
-
handle: z.string().optional(),
|
|
126
|
-
display_name: z.string().optional(),
|
|
127
|
-
connected: z.boolean().optional(),
|
|
128
|
-
access_token_env: z.string().optional(),
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
async ({ id, ...input }) => {
|
|
132
|
-
const account = updateAccount(id, input);
|
|
133
|
-
if (!account) {
|
|
134
|
-
return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
|
|
135
|
-
}
|
|
136
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
server.registerTool(
|
|
141
|
-
"delete_account",
|
|
142
|
-
{
|
|
143
|
-
title: "Delete Social Account",
|
|
144
|
-
description: "Delete a social media account by ID.",
|
|
145
|
-
inputSchema: { id: z.string() },
|
|
146
|
-
},
|
|
147
|
-
async ({ id }) => {
|
|
148
|
-
const deleted = deleteAccount(id);
|
|
149
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// --- Posts ---
|
|
154
|
-
|
|
155
|
-
server.registerTool(
|
|
156
|
-
"create_post",
|
|
157
|
-
{
|
|
158
|
-
title: "Create Post",
|
|
159
|
-
description: "Create a new social media post.",
|
|
160
|
-
inputSchema: {
|
|
161
|
-
account_id: z.string(),
|
|
162
|
-
content: z.string(),
|
|
163
|
-
media_urls: z.array(z.string()).optional(),
|
|
164
|
-
status: PostStatusEnum.optional(),
|
|
165
|
-
scheduled_at: z.string().optional(),
|
|
166
|
-
tags: z.array(z.string()).optional(),
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
async (params) => {
|
|
170
|
-
const post = createPost(params);
|
|
171
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
server.registerTool(
|
|
176
|
-
"get_post",
|
|
177
|
-
{
|
|
178
|
-
title: "Get Post",
|
|
179
|
-
description: "Get a post by ID.",
|
|
180
|
-
inputSchema: { id: z.string() },
|
|
181
|
-
},
|
|
182
|
-
async ({ id }) => {
|
|
183
|
-
const post = getPost(id);
|
|
184
|
-
if (!post) {
|
|
185
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
186
|
-
}
|
|
187
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
server.registerTool(
|
|
192
|
-
"list_posts",
|
|
193
|
-
{
|
|
194
|
-
title: "List Posts",
|
|
195
|
-
description: "List posts with optional filters.",
|
|
196
|
-
inputSchema: {
|
|
197
|
-
account_id: z.string().optional(),
|
|
198
|
-
status: PostStatusEnum.optional(),
|
|
199
|
-
tag: z.string().optional(),
|
|
200
|
-
search: z.string().optional(),
|
|
201
|
-
limit: z.number().optional(),
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
async (params) => {
|
|
205
|
-
const posts = listPosts(params);
|
|
206
|
-
return {
|
|
207
|
-
content: [
|
|
208
|
-
{ type: "text", text: JSON.stringify({ posts, count: posts.length }, null, 2) },
|
|
209
|
-
],
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
server.registerTool(
|
|
215
|
-
"update_post",
|
|
216
|
-
{
|
|
217
|
-
title: "Update Post",
|
|
218
|
-
description: "Update an existing post.",
|
|
219
|
-
inputSchema: {
|
|
220
|
-
id: z.string(),
|
|
221
|
-
content: z.string().optional(),
|
|
222
|
-
media_urls: z.array(z.string()).optional(),
|
|
223
|
-
status: PostStatusEnum.optional(),
|
|
224
|
-
scheduled_at: z.string().optional(),
|
|
225
|
-
published_at: z.string().optional(),
|
|
226
|
-
platform_post_id: z.string().optional(),
|
|
227
|
-
engagement: z.object({
|
|
228
|
-
likes: z.number().optional(),
|
|
229
|
-
shares: z.number().optional(),
|
|
230
|
-
comments: z.number().optional(),
|
|
231
|
-
impressions: z.number().optional(),
|
|
232
|
-
clicks: z.number().optional(),
|
|
233
|
-
}).optional(),
|
|
234
|
-
tags: z.array(z.string()).optional(),
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
async ({ id, ...input }) => {
|
|
238
|
-
const post = updatePost(id, input);
|
|
239
|
-
if (!post) {
|
|
240
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
241
|
-
}
|
|
242
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
server.registerTool(
|
|
247
|
-
"delete_post",
|
|
248
|
-
{
|
|
249
|
-
title: "Delete Post",
|
|
250
|
-
description: "Delete a post by ID.",
|
|
251
|
-
inputSchema: { id: z.string() },
|
|
252
|
-
},
|
|
253
|
-
async ({ id }) => {
|
|
254
|
-
const deleted = deletePost(id);
|
|
255
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
server.registerTool(
|
|
260
|
-
"schedule_post",
|
|
261
|
-
{
|
|
262
|
-
title: "Schedule Post",
|
|
263
|
-
description: "Schedule a post for a specific date/time.",
|
|
264
|
-
inputSchema: {
|
|
265
|
-
id: z.string(),
|
|
266
|
-
scheduled_at: z.string(),
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
async ({ id, scheduled_at }) => {
|
|
270
|
-
const post = schedulePost(id, scheduled_at);
|
|
271
|
-
if (!post) {
|
|
272
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
273
|
-
}
|
|
274
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
server.registerTool(
|
|
279
|
-
"publish_post",
|
|
280
|
-
{
|
|
281
|
-
title: "Publish Post",
|
|
282
|
-
description: "Publish a post. Set live=true to send via platform API (X, Meta), otherwise marks as published locally.",
|
|
283
|
-
inputSchema: {
|
|
284
|
-
id: z.string(),
|
|
285
|
-
platform_post_id: z.string().optional(),
|
|
286
|
-
live: z.boolean().optional().describe("If true, publish via the platform API instead of just marking locally"),
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
async ({ id, platform_post_id, live }) => {
|
|
290
|
-
try {
|
|
291
|
-
let post;
|
|
292
|
-
if (live) {
|
|
293
|
-
const { publishToApi } = await import("../lib/publisher.js");
|
|
294
|
-
post = await publishToApi(id);
|
|
295
|
-
} else {
|
|
296
|
-
post = publishPost(id, platform_post_id);
|
|
297
|
-
}
|
|
298
|
-
if (!post) {
|
|
299
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
300
|
-
}
|
|
301
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
302
|
-
} catch (error) {
|
|
303
|
-
return {
|
|
304
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
305
|
-
isError: true,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
// --- Threads ---
|
|
312
|
-
|
|
313
|
-
server.registerTool(
|
|
314
|
-
"create_thread",
|
|
315
|
-
{
|
|
316
|
-
title: "Create Thread",
|
|
317
|
-
description: "Create a thread of multiple posts linked by thread_id, ordered sequentially.",
|
|
318
|
-
inputSchema: {
|
|
319
|
-
contents: z.array(z.string()).describe("Content for each post in the thread"),
|
|
320
|
-
account_id: z.string(),
|
|
321
|
-
scheduled_at: z.string().optional(),
|
|
322
|
-
tags: z.array(z.string()).optional(),
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
async ({ contents, account_id, scheduled_at, tags }) => {
|
|
326
|
-
try {
|
|
327
|
-
const { createThread } = await import("../lib/threads.js");
|
|
328
|
-
const result = createThread(contents, account_id, { scheduledAt: scheduled_at, tags });
|
|
329
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
330
|
-
} catch (error) {
|
|
331
|
-
return {
|
|
332
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
333
|
-
isError: true,
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
server.registerTool(
|
|
340
|
-
"get_thread",
|
|
341
|
-
{
|
|
342
|
-
title: "Get Thread",
|
|
343
|
-
description: "Get all posts in a thread ordered by position.",
|
|
344
|
-
inputSchema: {
|
|
345
|
-
thread_id: z.string(),
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
async ({ thread_id }) => {
|
|
349
|
-
try {
|
|
350
|
-
const { getThread } = await import("../lib/threads.js");
|
|
351
|
-
const posts = getThread(thread_id);
|
|
352
|
-
return {
|
|
353
|
-
content: [
|
|
354
|
-
{ type: "text", text: JSON.stringify({ thread_id, posts, count: posts.length }, null, 2) },
|
|
355
|
-
],
|
|
356
|
-
};
|
|
357
|
-
} catch (error) {
|
|
358
|
-
return {
|
|
359
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
360
|
-
isError: true,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
);
|
|
365
|
-
|
|
366
|
-
server.registerTool(
|
|
367
|
-
"publish_thread",
|
|
368
|
-
{
|
|
369
|
-
title: "Publish Thread",
|
|
370
|
-
description: "Publish a thread sequentially via platform APIs. X chains tweets as replies; Meta posts first then comments.",
|
|
371
|
-
inputSchema: {
|
|
372
|
-
thread_id: z.string(),
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
async ({ thread_id }) => {
|
|
376
|
-
try {
|
|
377
|
-
const { publishThread } = await import("../lib/threads.js");
|
|
378
|
-
const result = await publishThread(thread_id);
|
|
379
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
380
|
-
} catch (error) {
|
|
381
|
-
return {
|
|
382
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
383
|
-
isError: true,
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
server.registerTool(
|
|
390
|
-
"create_carousel",
|
|
391
|
-
{
|
|
392
|
-
title: "Create Carousel",
|
|
393
|
-
description: "Create a carousel post with multiple images (Instagram/LinkedIn format).",
|
|
394
|
-
inputSchema: {
|
|
395
|
-
images: z.array(z.string()).describe("Image URLs for the carousel"),
|
|
396
|
-
captions: z.array(z.string()).optional().describe("Captions for the images"),
|
|
397
|
-
account_id: z.string(),
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
async ({ images, captions, account_id }) => {
|
|
401
|
-
try {
|
|
402
|
-
const { createCarousel } = await import("../lib/threads.js");
|
|
403
|
-
const post = createCarousel(images, captions || [], account_id);
|
|
404
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
405
|
-
} catch (error) {
|
|
406
|
-
return {
|
|
407
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
408
|
-
isError: true,
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
// --- Templates ---
|
|
415
|
-
|
|
416
|
-
server.registerTool(
|
|
417
|
-
"create_template",
|
|
418
|
-
{
|
|
419
|
-
title: "Create Template",
|
|
420
|
-
description: "Create a post template with variables.",
|
|
421
|
-
inputSchema: {
|
|
422
|
-
name: z.string(),
|
|
423
|
-
content: z.string(),
|
|
424
|
-
variables: z.array(z.string()).optional(),
|
|
425
|
-
},
|
|
426
|
-
},
|
|
427
|
-
async (params) => {
|
|
428
|
-
const template = createTemplate(params);
|
|
429
|
-
return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] };
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
|
-
|
|
433
|
-
server.registerTool(
|
|
434
|
-
"list_templates",
|
|
435
|
-
{
|
|
436
|
-
title: "List Templates",
|
|
437
|
-
description: "List all post templates.",
|
|
438
|
-
inputSchema: {},
|
|
439
|
-
},
|
|
440
|
-
async () => {
|
|
441
|
-
const templates = listTemplates();
|
|
442
|
-
return {
|
|
443
|
-
content: [
|
|
444
|
-
{ type: "text", text: JSON.stringify({ templates, count: templates.length }, null, 2) },
|
|
445
|
-
],
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
server.registerTool(
|
|
451
|
-
"get_template",
|
|
452
|
-
{
|
|
453
|
-
title: "Get Template",
|
|
454
|
-
description: "Get a template by ID.",
|
|
455
|
-
inputSchema: { id: z.string() },
|
|
456
|
-
},
|
|
457
|
-
async ({ id }) => {
|
|
458
|
-
const template = getTemplate(id);
|
|
459
|
-
if (!template) {
|
|
460
|
-
return { content: [{ type: "text", text: `Template '${id}' not found.` }], isError: true };
|
|
461
|
-
}
|
|
462
|
-
return { content: [{ type: "text", text: JSON.stringify(template, null, 2) }] };
|
|
463
|
-
}
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
server.registerTool(
|
|
467
|
-
"delete_template",
|
|
468
|
-
{
|
|
469
|
-
title: "Delete Template",
|
|
470
|
-
description: "Delete a template by ID.",
|
|
471
|
-
inputSchema: { id: z.string() },
|
|
472
|
-
},
|
|
473
|
-
async ({ id }) => {
|
|
474
|
-
const deleted = deleteTemplate(id);
|
|
475
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
server.registerTool(
|
|
480
|
-
"use_template",
|
|
481
|
-
{
|
|
482
|
-
title: "Use Template",
|
|
483
|
-
description: "Create a post from a template by replacing variables.",
|
|
484
|
-
inputSchema: {
|
|
485
|
-
template_id: z.string(),
|
|
486
|
-
account_id: z.string(),
|
|
487
|
-
values: z.record(z.string()).optional(),
|
|
488
|
-
tags: z.array(z.string()).optional(),
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
async ({ template_id, account_id, values, tags }) => {
|
|
492
|
-
try {
|
|
493
|
-
const post = useTemplate(template_id, account_id, values || {}, tags);
|
|
494
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
495
|
-
} catch (error) {
|
|
496
|
-
return {
|
|
497
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
498
|
-
isError: true,
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
// --- Analytics ---
|
|
505
|
-
|
|
506
|
-
server.registerTool(
|
|
507
|
-
"get_engagement_stats",
|
|
508
|
-
{
|
|
509
|
-
title: "Get Engagement Stats",
|
|
510
|
-
description: "Get engagement analytics for published posts.",
|
|
511
|
-
inputSchema: {
|
|
512
|
-
account_id: z.string().optional(),
|
|
513
|
-
},
|
|
514
|
-
},
|
|
515
|
-
async ({ account_id }) => {
|
|
516
|
-
const stats = getEngagementStats(account_id);
|
|
517
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
518
|
-
}
|
|
519
|
-
);
|
|
520
|
-
|
|
521
|
-
server.registerTool(
|
|
522
|
-
"get_stats_by_platform",
|
|
523
|
-
{
|
|
524
|
-
title: "Get Stats By Platform",
|
|
525
|
-
description: "Get analytics grouped by social media platform.",
|
|
526
|
-
inputSchema: {},
|
|
527
|
-
},
|
|
528
|
-
async () => {
|
|
529
|
-
const stats = getStatsByPlatform();
|
|
530
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
531
|
-
}
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
server.registerTool(
|
|
535
|
-
"get_calendar",
|
|
536
|
-
{
|
|
537
|
-
title: "Get Calendar",
|
|
538
|
-
description: "View scheduled posts grouped by date.",
|
|
539
|
-
inputSchema: {
|
|
540
|
-
start_date: z.string().optional(),
|
|
541
|
-
end_date: z.string().optional(),
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
async ({ start_date, end_date }) => {
|
|
545
|
-
const calendar = getCalendar(start_date, end_date);
|
|
546
|
-
return { content: [{ type: "text", text: JSON.stringify(calendar, null, 2) }] };
|
|
547
|
-
}
|
|
548
|
-
);
|
|
549
|
-
|
|
550
|
-
server.registerTool(
|
|
551
|
-
"get_overall_stats",
|
|
552
|
-
{
|
|
553
|
-
title: "Get Overall Stats",
|
|
554
|
-
description: "Get overall social media management statistics.",
|
|
555
|
-
inputSchema: {},
|
|
556
|
-
},
|
|
557
|
-
async () => {
|
|
558
|
-
const stats = getOverallStats();
|
|
559
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
560
|
-
}
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
// --- Batch Schedule ---
|
|
564
|
-
|
|
565
|
-
server.registerTool(
|
|
566
|
-
"batch_schedule_posts",
|
|
567
|
-
{
|
|
568
|
-
title: "Batch Schedule Posts",
|
|
569
|
-
description: "Schedule multiple posts at once from an array of post definitions.",
|
|
570
|
-
inputSchema: {
|
|
571
|
-
posts: z.array(z.object({
|
|
572
|
-
account_id: z.string(),
|
|
573
|
-
content: z.string(),
|
|
574
|
-
scheduled_at: z.string(),
|
|
575
|
-
media_urls: z.array(z.string()).optional(),
|
|
576
|
-
tags: z.array(z.string()).optional(),
|
|
577
|
-
recurrence: RecurrenceEnum.optional(),
|
|
578
|
-
})),
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
async ({ posts }) => {
|
|
582
|
-
const result = batchSchedule(posts);
|
|
583
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
584
|
-
}
|
|
585
|
-
);
|
|
586
|
-
|
|
587
|
-
// --- Cross-Post ---
|
|
588
|
-
|
|
589
|
-
server.registerTool(
|
|
590
|
-
"crosspost",
|
|
591
|
-
{
|
|
592
|
-
title: "Cross-Post",
|
|
593
|
-
description: "Create identical post on multiple platform accounts.",
|
|
594
|
-
inputSchema: {
|
|
595
|
-
content: z.string(),
|
|
596
|
-
platforms: z.array(PlatformEnum),
|
|
597
|
-
media_urls: z.array(z.string()).optional(),
|
|
598
|
-
tags: z.array(z.string()).optional(),
|
|
599
|
-
scheduled_at: z.string().optional(),
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
async ({ content, platforms, ...options }) => {
|
|
603
|
-
try {
|
|
604
|
-
const result = crossPost(content, platforms, options);
|
|
605
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
606
|
-
} catch (error) {
|
|
607
|
-
return {
|
|
608
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
609
|
-
isError: true,
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
// --- Best Time to Post ---
|
|
616
|
-
|
|
617
|
-
server.registerTool(
|
|
618
|
-
"best_time_to_post",
|
|
619
|
-
{
|
|
620
|
-
title: "Best Time to Post",
|
|
621
|
-
description: "Analyze historical engagement to find the best hours and days to post.",
|
|
622
|
-
inputSchema: {
|
|
623
|
-
account_id: z.string(),
|
|
624
|
-
},
|
|
625
|
-
},
|
|
626
|
-
async ({ account_id }) => {
|
|
627
|
-
const result = getBestTimeToPost(account_id);
|
|
628
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
629
|
-
}
|
|
630
|
-
);
|
|
631
|
-
|
|
632
|
-
// --- Reschedule Post ---
|
|
633
|
-
|
|
634
|
-
server.registerTool(
|
|
635
|
-
"reschedule_post",
|
|
636
|
-
{
|
|
637
|
-
title: "Reschedule Post",
|
|
638
|
-
description: "Update the scheduled date/time of a post without delete/recreate.",
|
|
639
|
-
inputSchema: {
|
|
640
|
-
id: z.string(),
|
|
641
|
-
new_date: z.string(),
|
|
642
|
-
},
|
|
643
|
-
},
|
|
644
|
-
async ({ id, new_date }) => {
|
|
645
|
-
try {
|
|
646
|
-
const post = reschedulePost(id, new_date);
|
|
647
|
-
if (!post) {
|
|
648
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
649
|
-
}
|
|
650
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
651
|
-
} catch (error) {
|
|
652
|
-
return {
|
|
653
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
654
|
-
isError: true,
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
);
|
|
659
|
-
|
|
660
|
-
// --- Approval Workflow ---
|
|
661
|
-
|
|
662
|
-
server.registerTool(
|
|
663
|
-
"submit_post_for_review",
|
|
664
|
-
{
|
|
665
|
-
title: "Submit Post for Review",
|
|
666
|
-
description: "Submit a draft post for review (draft → pending_review).",
|
|
667
|
-
inputSchema: {
|
|
668
|
-
id: z.string(),
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
async ({ id }) => {
|
|
672
|
-
try {
|
|
673
|
-
const post = submitPostForReview(id);
|
|
674
|
-
if (!post) {
|
|
675
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
676
|
-
}
|
|
677
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
678
|
-
} catch (error) {
|
|
679
|
-
return {
|
|
680
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
681
|
-
isError: true,
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
);
|
|
686
|
-
|
|
687
|
-
server.registerTool(
|
|
688
|
-
"approve_post",
|
|
689
|
-
{
|
|
690
|
-
title: "Approve Post",
|
|
691
|
-
description: "Approve a post pending review (pending_review → scheduled).",
|
|
692
|
-
inputSchema: {
|
|
693
|
-
id: z.string(),
|
|
694
|
-
scheduled_at: z.string().optional(),
|
|
695
|
-
},
|
|
696
|
-
},
|
|
697
|
-
async ({ id, scheduled_at }) => {
|
|
698
|
-
try {
|
|
699
|
-
const post = approvePost(id, scheduled_at);
|
|
700
|
-
if (!post) {
|
|
701
|
-
return { content: [{ type: "text", text: `Post '${id}' not found.` }], isError: true };
|
|
702
|
-
}
|
|
703
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
704
|
-
} catch (error) {
|
|
705
|
-
return {
|
|
706
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
707
|
-
isError: true,
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
);
|
|
712
|
-
|
|
713
|
-
// --- Platform Limits ---
|
|
714
|
-
|
|
715
|
-
server.registerTool(
|
|
716
|
-
"get_platform_limits",
|
|
717
|
-
{
|
|
718
|
-
title: "Get Platform Limits",
|
|
719
|
-
description: "Get character limits for all supported platforms.",
|
|
720
|
-
inputSchema: {},
|
|
721
|
-
},
|
|
722
|
-
async () => {
|
|
723
|
-
return { content: [{ type: "text", text: JSON.stringify(PLATFORM_LIMITS, null, 2) }] };
|
|
724
|
-
}
|
|
725
|
-
);
|
|
726
|
-
|
|
727
|
-
// --- Recurring Posts ---
|
|
728
|
-
|
|
729
|
-
server.registerTool(
|
|
730
|
-
"create_recurring_post",
|
|
731
|
-
{
|
|
732
|
-
title: "Create Recurring Post",
|
|
733
|
-
description: "Create a post that recurs on a schedule (daily, weekly, biweekly, monthly).",
|
|
734
|
-
inputSchema: {
|
|
735
|
-
account_id: z.string(),
|
|
736
|
-
content: z.string(),
|
|
737
|
-
scheduled_at: z.string(),
|
|
738
|
-
recurrence: RecurrenceEnum,
|
|
739
|
-
media_urls: z.array(z.string()).optional(),
|
|
740
|
-
tags: z.array(z.string()).optional(),
|
|
741
|
-
},
|
|
742
|
-
},
|
|
743
|
-
async (params) => {
|
|
744
|
-
try {
|
|
745
|
-
const post = createRecurringPost(params);
|
|
746
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
747
|
-
} catch (error) {
|
|
748
|
-
return {
|
|
749
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
750
|
-
isError: true,
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
|
|
756
|
-
// --- Hashtag Analytics ---
|
|
757
|
-
|
|
758
|
-
server.registerTool(
|
|
759
|
-
"hashtag_analytics",
|
|
760
|
-
{
|
|
761
|
-
title: "Hashtag Analytics",
|
|
762
|
-
description: "Extract hashtags from published posts and correlate with engagement metrics.",
|
|
763
|
-
inputSchema: {
|
|
764
|
-
account_id: z.string(),
|
|
765
|
-
},
|
|
766
|
-
},
|
|
767
|
-
async ({ account_id }) => {
|
|
768
|
-
const stats = getHashtagStats(account_id);
|
|
769
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
770
|
-
}
|
|
771
|
-
);
|
|
772
|
-
|
|
773
|
-
// --- Publisher Bridge ---
|
|
774
|
-
|
|
775
|
-
server.registerTool(
|
|
776
|
-
"check_providers",
|
|
777
|
-
{
|
|
778
|
-
title: "Check Providers",
|
|
779
|
-
description: "Check which platform API providers have env vars configured (X, Meta).",
|
|
780
|
-
inputSchema: {},
|
|
781
|
-
},
|
|
782
|
-
async () => {
|
|
783
|
-
const { checkProviders } = await import("../lib/publisher.js");
|
|
784
|
-
const providers = checkProviders();
|
|
785
|
-
return { content: [{ type: "text", text: JSON.stringify(providers, null, 2) }] };
|
|
786
|
-
}
|
|
787
|
-
);
|
|
788
|
-
|
|
789
|
-
server.registerTool(
|
|
790
|
-
"sync_post_metrics",
|
|
791
|
-
{
|
|
792
|
-
title: "Sync Post Metrics",
|
|
793
|
-
description: "Fetch engagement metrics from the platform API and update the post in DB.",
|
|
794
|
-
inputSchema: { id: z.string() },
|
|
795
|
-
},
|
|
796
|
-
async ({ id }) => {
|
|
797
|
-
try {
|
|
798
|
-
const { syncPostMetrics } = await import("../lib/publisher.js");
|
|
799
|
-
const post = await syncPostMetrics(id);
|
|
800
|
-
return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] };
|
|
801
|
-
} catch (error) {
|
|
802
|
-
return {
|
|
803
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
804
|
-
isError: true,
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
);
|
|
809
|
-
|
|
810
|
-
// --- Scheduler ---
|
|
811
|
-
|
|
812
|
-
server.registerTool(
|
|
813
|
-
"start_scheduler",
|
|
814
|
-
{
|
|
815
|
-
title: "Start Scheduler",
|
|
816
|
-
description: "Start the auto-publish scheduler that checks for due posts at a regular interval.",
|
|
817
|
-
inputSchema: {
|
|
818
|
-
interval_ms: z.number().optional(),
|
|
819
|
-
},
|
|
820
|
-
},
|
|
821
|
-
async ({ interval_ms }) => {
|
|
822
|
-
try {
|
|
823
|
-
startScheduler(interval_ms || 60000);
|
|
824
|
-
const status = getSchedulerStatus();
|
|
825
|
-
return { content: [{ type: "text", text: JSON.stringify({ message: "Scheduler started", ...status }, null, 2) }] };
|
|
826
|
-
} catch (error) {
|
|
827
|
-
return {
|
|
828
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
829
|
-
isError: true,
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
server.registerTool(
|
|
836
|
-
"stop_scheduler",
|
|
837
|
-
{
|
|
838
|
-
title: "Stop Scheduler",
|
|
839
|
-
description: "Stop the auto-publish scheduler.",
|
|
840
|
-
inputSchema: {},
|
|
841
|
-
},
|
|
842
|
-
async () => {
|
|
843
|
-
stopScheduler();
|
|
844
|
-
const status = getSchedulerStatus();
|
|
845
|
-
return { content: [{ type: "text", text: JSON.stringify({ message: "Scheduler stopped", ...status }, null, 2) }] };
|
|
846
|
-
}
|
|
847
|
-
);
|
|
848
|
-
|
|
849
|
-
server.registerTool(
|
|
850
|
-
"scheduler_status",
|
|
851
|
-
{
|
|
852
|
-
title: "Scheduler Status",
|
|
853
|
-
description: "Get the current status of the auto-publish scheduler.",
|
|
854
|
-
inputSchema: {},
|
|
855
|
-
},
|
|
856
|
-
async () => {
|
|
857
|
-
const status = getSchedulerStatus();
|
|
858
|
-
return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }] };
|
|
859
|
-
}
|
|
860
|
-
);
|
|
861
|
-
|
|
862
|
-
// --- Media ---
|
|
863
|
-
|
|
864
|
-
server.registerTool(
|
|
865
|
-
"upload_media",
|
|
866
|
-
{
|
|
867
|
-
title: "Upload Media",
|
|
868
|
-
description: "Upload a media file to a social media platform.",
|
|
869
|
-
inputSchema: {
|
|
870
|
-
file_path: z.string(),
|
|
871
|
-
platform: PlatformEnum,
|
|
872
|
-
page_id: z.string().optional(),
|
|
873
|
-
},
|
|
874
|
-
},
|
|
875
|
-
async ({ file_path, platform, page_id }) => {
|
|
876
|
-
try {
|
|
877
|
-
const validation = validateMedia(file_path, platform);
|
|
878
|
-
if (!validation.valid) {
|
|
879
|
-
return {
|
|
880
|
-
content: [{ type: "text", text: JSON.stringify({ valid: false, errors: validation.errors }, null, 2) }],
|
|
881
|
-
isError: true,
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
const result = await uploadMedia(file_path, platform, page_id);
|
|
886
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
887
|
-
} catch (error) {
|
|
888
|
-
return {
|
|
889
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
890
|
-
isError: true,
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
);
|
|
895
|
-
|
|
896
|
-
server.registerTool(
|
|
897
|
-
"validate_media",
|
|
898
|
-
{
|
|
899
|
-
title: "Validate Media",
|
|
900
|
-
description: "Validate a media file for a specific platform without uploading.",
|
|
901
|
-
inputSchema: {
|
|
902
|
-
file_path: z.string(),
|
|
903
|
-
platform: PlatformEnum,
|
|
904
|
-
},
|
|
905
|
-
},
|
|
906
|
-
async ({ file_path, platform }) => {
|
|
907
|
-
const result = validateMedia(file_path, platform);
|
|
908
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
909
|
-
}
|
|
910
|
-
);
|
|
911
|
-
|
|
912
|
-
server.registerTool(
|
|
913
|
-
"get_supported_formats",
|
|
914
|
-
{
|
|
915
|
-
title: "Get Supported Formats",
|
|
916
|
-
description: "Get supported media formats for a platform.",
|
|
917
|
-
inputSchema: {
|
|
918
|
-
platform: PlatformEnum,
|
|
919
|
-
},
|
|
920
|
-
},
|
|
921
|
-
async ({ platform }) => {
|
|
922
|
-
const formats = getSupportedFormats(platform);
|
|
923
|
-
return { content: [{ type: "text", text: JSON.stringify({ platform, formats }, null, 2) }] };
|
|
924
|
-
}
|
|
925
|
-
);
|
|
926
|
-
|
|
927
|
-
// --- Metrics Sync ---
|
|
928
|
-
|
|
929
|
-
server.registerTool(
|
|
930
|
-
"sync_all_metrics",
|
|
931
|
-
{
|
|
932
|
-
title: "Sync All Metrics",
|
|
933
|
-
description: "Sync engagement metrics for all published posts from the last 7 days via platform APIs.",
|
|
934
|
-
inputSchema: {},
|
|
935
|
-
},
|
|
936
|
-
async () => {
|
|
937
|
-
try {
|
|
938
|
-
const { syncAllMetrics } = await import("../lib/metrics-sync.js");
|
|
939
|
-
const report = await syncAllMetrics();
|
|
940
|
-
return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
|
|
941
|
-
} catch (error) {
|
|
942
|
-
return {
|
|
943
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
944
|
-
isError: true,
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
);
|
|
949
|
-
|
|
950
|
-
server.registerTool(
|
|
951
|
-
"sync_account_metrics",
|
|
952
|
-
{
|
|
953
|
-
title: "Sync Account Metrics",
|
|
954
|
-
description: "Pull follower count and profile data from platform API for a specific account.",
|
|
955
|
-
inputSchema: {
|
|
956
|
-
account_id: z.string(),
|
|
957
|
-
},
|
|
958
|
-
},
|
|
959
|
-
async ({ account_id }) => {
|
|
960
|
-
try {
|
|
961
|
-
const { syncAccountMetrics } = await import("../lib/metrics-sync.js");
|
|
962
|
-
const account = await syncAccountMetrics(account_id);
|
|
963
|
-
if (!account) {
|
|
964
|
-
return { content: [{ type: "text", text: `Account '${account_id}' not found.` }], isError: true };
|
|
965
|
-
}
|
|
966
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
967
|
-
} catch (error) {
|
|
968
|
-
return {
|
|
969
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
970
|
-
isError: true,
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
);
|
|
975
|
-
|
|
976
|
-
server.registerTool(
|
|
977
|
-
"metrics_sync_status",
|
|
978
|
-
{
|
|
979
|
-
title: "Metrics Sync Status",
|
|
980
|
-
description: "Get the current status of the metrics sync worker, including sync report.",
|
|
981
|
-
inputSchema: {},
|
|
982
|
-
},
|
|
983
|
-
async () => {
|
|
984
|
-
const { getMetricsSyncStatus, getSyncReport } = await import("../lib/metrics-sync.js");
|
|
985
|
-
const status = getMetricsSyncStatus();
|
|
986
|
-
const report = getSyncReport();
|
|
987
|
-
return { content: [{ type: "text", text: JSON.stringify({ status, report }, null, 2) }] };
|
|
988
|
-
}
|
|
989
|
-
);
|
|
990
|
-
|
|
991
|
-
// --- Mentions ---
|
|
992
|
-
|
|
993
|
-
const MentionTypeEnum = z.enum(["mention", "reply", "quote", "dm"]);
|
|
994
|
-
|
|
995
|
-
server.registerTool(
|
|
996
|
-
"list_mentions",
|
|
997
|
-
{
|
|
998
|
-
title: "List Mentions",
|
|
999
|
-
description: "List mentions for an account with optional filters (unread, type, platform).",
|
|
1000
|
-
inputSchema: {
|
|
1001
|
-
account_id: z.string().optional(),
|
|
1002
|
-
unread: z.boolean().optional(),
|
|
1003
|
-
type: MentionTypeEnum.optional(),
|
|
1004
|
-
platform: z.string().optional(),
|
|
1005
|
-
limit: z.number().optional(),
|
|
1006
|
-
},
|
|
1007
|
-
},
|
|
1008
|
-
async ({ account_id, ...filters }) => {
|
|
1009
|
-
const { listMentions } = await import("../lib/mentions.js");
|
|
1010
|
-
const mentions = listMentions(account_id, filters);
|
|
1011
|
-
return {
|
|
1012
|
-
content: [
|
|
1013
|
-
{ type: "text", text: JSON.stringify({ mentions, count: mentions.length }, null, 2) },
|
|
1014
|
-
],
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
);
|
|
1018
|
-
|
|
1019
|
-
server.registerTool(
|
|
1020
|
-
"reply_to_mention",
|
|
1021
|
-
{
|
|
1022
|
-
title: "Reply to Mention",
|
|
1023
|
-
description: "Reply to a mention via the platform API (X or Meta).",
|
|
1024
|
-
inputSchema: {
|
|
1025
|
-
mention_id: z.string(),
|
|
1026
|
-
content: z.string(),
|
|
1027
|
-
},
|
|
1028
|
-
},
|
|
1029
|
-
async ({ mention_id, content }) => {
|
|
1030
|
-
try {
|
|
1031
|
-
const { replyToMention } = await import("../lib/mentions.js");
|
|
1032
|
-
const result = await replyToMention(mention_id, content);
|
|
1033
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1034
|
-
} catch (error) {
|
|
1035
|
-
return {
|
|
1036
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1037
|
-
isError: true,
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
);
|
|
1042
|
-
|
|
1043
|
-
server.registerTool(
|
|
1044
|
-
"mark_mention_read",
|
|
1045
|
-
{
|
|
1046
|
-
title: "Mark Mention Read",
|
|
1047
|
-
description: "Mark a single mention as read, or all mentions for an account.",
|
|
1048
|
-
inputSchema: {
|
|
1049
|
-
mention_id: z.string().optional(),
|
|
1050
|
-
account_id: z.string().optional(),
|
|
1051
|
-
},
|
|
1052
|
-
},
|
|
1053
|
-
async ({ mention_id, account_id }) => {
|
|
1054
|
-
const { markRead, markAllRead } = await import("../lib/mentions.js");
|
|
1055
|
-
if (account_id) {
|
|
1056
|
-
const count = markAllRead(account_id);
|
|
1057
|
-
return { content: [{ type: "text", text: JSON.stringify({ account_id, marked_read: count }, null, 2) }] };
|
|
1058
|
-
}
|
|
1059
|
-
if (mention_id) {
|
|
1060
|
-
const mention = markRead(mention_id);
|
|
1061
|
-
if (!mention) {
|
|
1062
|
-
return { content: [{ type: "text", text: `Mention '${mention_id}' not found.` }], isError: true };
|
|
1063
|
-
}
|
|
1064
|
-
return { content: [{ type: "text", text: JSON.stringify(mention, null, 2) }] };
|
|
1065
|
-
}
|
|
1066
|
-
return { content: [{ type: "text", text: "Provide either mention_id or account_id." }], isError: true };
|
|
1067
|
-
}
|
|
1068
|
-
);
|
|
1069
|
-
|
|
1070
|
-
server.registerTool(
|
|
1071
|
-
"poll_mentions",
|
|
1072
|
-
{
|
|
1073
|
-
title: "Poll Mentions",
|
|
1074
|
-
description: "Start or stop the background mention poller.",
|
|
1075
|
-
inputSchema: {
|
|
1076
|
-
action: z.enum(["start", "stop", "status"]),
|
|
1077
|
-
interval_ms: z.number().optional(),
|
|
1078
|
-
},
|
|
1079
|
-
},
|
|
1080
|
-
async ({ action, interval_ms }) => {
|
|
1081
|
-
const { pollMentions, stopPolling, isPolling } = await import("../lib/mentions.js");
|
|
1082
|
-
try {
|
|
1083
|
-
if (action === "start") {
|
|
1084
|
-
pollMentions(interval_ms || 120000);
|
|
1085
|
-
return { content: [{ type: "text", text: JSON.stringify({ status: "started", interval_ms: interval_ms || 120000 }, null, 2) }] };
|
|
1086
|
-
} else if (action === "stop") {
|
|
1087
|
-
stopPolling();
|
|
1088
|
-
return { content: [{ type: "text", text: JSON.stringify({ status: "stopped" }, null, 2) }] };
|
|
1089
|
-
} else {
|
|
1090
|
-
return { content: [{ type: "text", text: JSON.stringify({ running: isPolling() }, null, 2) }] };
|
|
1091
|
-
}
|
|
1092
|
-
} catch (error) {
|
|
1093
|
-
return {
|
|
1094
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1095
|
-
isError: true,
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
);
|
|
1100
|
-
|
|
1101
|
-
server.registerTool(
|
|
1102
|
-
"mention_stats",
|
|
1103
|
-
{
|
|
1104
|
-
title: "Mention Stats",
|
|
1105
|
-
description: "Get mention statistics for an account (total, unread, by type, by sentiment).",
|
|
1106
|
-
inputSchema: {
|
|
1107
|
-
account_id: z.string(),
|
|
1108
|
-
},
|
|
1109
|
-
},
|
|
1110
|
-
async ({ account_id }) => {
|
|
1111
|
-
const { getMentionStats } = await import("../lib/mentions.js");
|
|
1112
|
-
const stats = getMentionStats(account_id);
|
|
1113
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
1114
|
-
}
|
|
1115
|
-
);
|
|
1116
|
-
|
|
1117
|
-
// --- AI Content Generation ---
|
|
1118
|
-
|
|
1119
|
-
const ToneEnum = z.enum(["professional", "casual", "witty"]);
|
|
1120
|
-
|
|
1121
|
-
server.registerTool(
|
|
1122
|
-
"generate_post",
|
|
1123
|
-
{
|
|
1124
|
-
title: "Generate Post with AI",
|
|
1125
|
-
description: "Generate a social media post using AI. Provide a topic and platform; get back content, hashtags, and a suggested media prompt.",
|
|
1126
|
-
inputSchema: {
|
|
1127
|
-
topic: z.string(),
|
|
1128
|
-
platform: PlatformEnum,
|
|
1129
|
-
tone: ToneEnum.optional(),
|
|
1130
|
-
includeHashtags: z.boolean().optional(),
|
|
1131
|
-
includeEmoji: z.boolean().optional(),
|
|
1132
|
-
language: z.string().optional(),
|
|
1133
|
-
},
|
|
1134
|
-
},
|
|
1135
|
-
async ({ topic, platform, ...options }) => {
|
|
1136
|
-
try {
|
|
1137
|
-
const { generatePost } = await import("../lib/content-ai.js");
|
|
1138
|
-
const result = await generatePost(topic, platform, options);
|
|
1139
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1140
|
-
} catch (error) {
|
|
1141
|
-
return {
|
|
1142
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1143
|
-
isError: true,
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
);
|
|
1148
|
-
|
|
1149
|
-
server.registerTool(
|
|
1150
|
-
"suggest_hashtags",
|
|
1151
|
-
{
|
|
1152
|
-
title: "Suggest Hashtags",
|
|
1153
|
-
description: "Analyze post content and suggest relevant hashtags using AI.",
|
|
1154
|
-
inputSchema: {
|
|
1155
|
-
content: z.string(),
|
|
1156
|
-
platform: PlatformEnum,
|
|
1157
|
-
count: z.number().optional(),
|
|
1158
|
-
},
|
|
1159
|
-
},
|
|
1160
|
-
async ({ content, platform, count }) => {
|
|
1161
|
-
try {
|
|
1162
|
-
const { suggestHashtags } = await import("../lib/content-ai.js");
|
|
1163
|
-
const hashtags = await suggestHashtags(content, platform, count || 5);
|
|
1164
|
-
return { content: [{ type: "text", text: JSON.stringify({ hashtags }, null, 2) }] };
|
|
1165
|
-
} catch (error) {
|
|
1166
|
-
return {
|
|
1167
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1168
|
-
isError: true,
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
);
|
|
1173
|
-
|
|
1174
|
-
server.registerTool(
|
|
1175
|
-
"optimize_post",
|
|
1176
|
-
{
|
|
1177
|
-
title: "Optimize Post",
|
|
1178
|
-
description: "Rewrite a post for better engagement using AI. Returns optimized content and a list of improvements.",
|
|
1179
|
-
inputSchema: {
|
|
1180
|
-
content: z.string(),
|
|
1181
|
-
platform: PlatformEnum,
|
|
1182
|
-
},
|
|
1183
|
-
},
|
|
1184
|
-
async ({ content, platform }) => {
|
|
1185
|
-
try {
|
|
1186
|
-
const { optimizePost } = await import("../lib/content-ai.js");
|
|
1187
|
-
const result = await optimizePost(content, platform);
|
|
1188
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1189
|
-
} catch (error) {
|
|
1190
|
-
return {
|
|
1191
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1192
|
-
isError: true,
|
|
1193
|
-
};
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
);
|
|
1197
|
-
|
|
1198
|
-
server.registerTool(
|
|
1199
|
-
"generate_thread",
|
|
1200
|
-
{
|
|
1201
|
-
title: "Generate Thread",
|
|
1202
|
-
description: "Generate a multi-tweet thread using AI. Each tweet stays within 280 chars.",
|
|
1203
|
-
inputSchema: {
|
|
1204
|
-
topic: z.string(),
|
|
1205
|
-
tweet_count: z.number().optional(),
|
|
1206
|
-
},
|
|
1207
|
-
},
|
|
1208
|
-
async ({ topic, tweet_count }) => {
|
|
1209
|
-
try {
|
|
1210
|
-
const { generateThread } = await import("../lib/content-ai.js");
|
|
1211
|
-
const tweets = await generateThread(topic, tweet_count || 5);
|
|
1212
|
-
return { content: [{ type: "text", text: JSON.stringify({ tweets, count: tweets.length }, null, 2) }] };
|
|
1213
|
-
} catch (error) {
|
|
1214
|
-
return {
|
|
1215
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1216
|
-
isError: true,
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
);
|
|
1221
|
-
|
|
1222
|
-
server.registerTool(
|
|
1223
|
-
"repurpose_post",
|
|
1224
|
-
{
|
|
1225
|
-
title: "Repurpose Post",
|
|
1226
|
-
description: "Adapt a post from one platform's style to another using AI (e.g., X to LinkedIn).",
|
|
1227
|
-
inputSchema: {
|
|
1228
|
-
content: z.string(),
|
|
1229
|
-
source_platform: PlatformEnum,
|
|
1230
|
-
target_platform: PlatformEnum,
|
|
1231
|
-
},
|
|
1232
|
-
},
|
|
1233
|
-
async ({ content, source_platform, target_platform }) => {
|
|
1234
|
-
try {
|
|
1235
|
-
const { repurposePost } = await import("../lib/content-ai.js");
|
|
1236
|
-
const result = await repurposePost(content, source_platform, target_platform);
|
|
1237
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1238
|
-
} catch (error) {
|
|
1239
|
-
return {
|
|
1240
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1241
|
-
isError: true,
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
);
|
|
1246
|
-
|
|
1247
|
-
// --- Audience ---
|
|
1248
|
-
|
|
1249
|
-
server.registerTool(
|
|
1250
|
-
"sync_followers",
|
|
1251
|
-
{
|
|
1252
|
-
title: "Sync Followers",
|
|
1253
|
-
description: "Sync followers from the platform API for an account. Returns sync results including new and unfollowed counts.",
|
|
1254
|
-
inputSchema: {
|
|
1255
|
-
account_id: z.string(),
|
|
1256
|
-
},
|
|
1257
|
-
},
|
|
1258
|
-
async ({ account_id }) => {
|
|
1259
|
-
try {
|
|
1260
|
-
const { syncFollowers } = await import("../lib/audience.js");
|
|
1261
|
-
const result = syncFollowers(account_id);
|
|
1262
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1263
|
-
} catch (error) {
|
|
1264
|
-
return {
|
|
1265
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1266
|
-
isError: true,
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
);
|
|
1271
|
-
|
|
1272
|
-
server.registerTool(
|
|
1273
|
-
"audience_insights",
|
|
1274
|
-
{
|
|
1275
|
-
title: "Audience Insights",
|
|
1276
|
-
description: "Get audience insights for an account: total followers, growth rates, new/lost followers, and top followers.",
|
|
1277
|
-
inputSchema: {
|
|
1278
|
-
account_id: z.string(),
|
|
1279
|
-
},
|
|
1280
|
-
},
|
|
1281
|
-
async ({ account_id }) => {
|
|
1282
|
-
try {
|
|
1283
|
-
const { getAudienceInsights } = await import("../lib/audience.js");
|
|
1284
|
-
const insights = getAudienceInsights(account_id);
|
|
1285
|
-
return { content: [{ type: "text", text: JSON.stringify(insights, null, 2) }] };
|
|
1286
|
-
} catch (error) {
|
|
1287
|
-
return {
|
|
1288
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1289
|
-
isError: true,
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
);
|
|
1294
|
-
|
|
1295
|
-
server.registerTool(
|
|
1296
|
-
"follower_growth",
|
|
1297
|
-
{
|
|
1298
|
-
title: "Follower Growth Chart",
|
|
1299
|
-
description: "Get follower growth data points over a number of days for charting.",
|
|
1300
|
-
inputSchema: {
|
|
1301
|
-
account_id: z.string(),
|
|
1302
|
-
days: z.number().optional(),
|
|
1303
|
-
},
|
|
1304
|
-
},
|
|
1305
|
-
async ({ account_id, days }) => {
|
|
1306
|
-
try {
|
|
1307
|
-
const { getFollowerGrowthChart } = await import("../lib/audience.js");
|
|
1308
|
-
const chart = getFollowerGrowthChart(account_id, days || 30);
|
|
1309
|
-
return { content: [{ type: "text", text: JSON.stringify(chart, null, 2) }] };
|
|
1310
|
-
} catch (error) {
|
|
1311
|
-
return {
|
|
1312
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1313
|
-
isError: true,
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
);
|
|
1318
|
-
|
|
1319
|
-
server.registerTool(
|
|
1320
|
-
"top_followers",
|
|
1321
|
-
{
|
|
1322
|
-
title: "Top Followers",
|
|
1323
|
-
description: "Get top followers for an account, sorted by their follower count (most influential first).",
|
|
1324
|
-
inputSchema: {
|
|
1325
|
-
account_id: z.string(),
|
|
1326
|
-
limit: z.number().optional(),
|
|
1327
|
-
},
|
|
1328
|
-
},
|
|
1329
|
-
async ({ account_id, limit }) => {
|
|
1330
|
-
try {
|
|
1331
|
-
const { getTopFollowers } = await import("../lib/audience.js");
|
|
1332
|
-
const followers = getTopFollowers(account_id, limit || 10);
|
|
1333
|
-
return { content: [{ type: "text", text: JSON.stringify({ followers, count: followers.length }, null, 2) }] };
|
|
1334
|
-
} catch (error) {
|
|
1335
|
-
return {
|
|
1336
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1337
|
-
isError: true,
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
);
|
|
1342
|
-
|
|
1343
|
-
// --- Sentiment Analysis ---
|
|
1344
|
-
|
|
1345
|
-
server.registerTool(
|
|
1346
|
-
"analyze_sentiment",
|
|
1347
|
-
{
|
|
1348
|
-
title: "Analyze Sentiment",
|
|
1349
|
-
description: "Analyze the sentiment of a text using AI. Returns sentiment label (positive/neutral/negative), score (0-1), and emotional keywords.",
|
|
1350
|
-
inputSchema: {
|
|
1351
|
-
text: z.string().describe("The text to analyze for sentiment"),
|
|
1352
|
-
},
|
|
1353
|
-
},
|
|
1354
|
-
async ({ text }) => {
|
|
1355
|
-
try {
|
|
1356
|
-
const { analyzeSentiment } = await import("../lib/sentiment.js");
|
|
1357
|
-
const result = await analyzeSentiment(text);
|
|
1358
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1359
|
-
} catch (error) {
|
|
1360
|
-
return {
|
|
1361
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1362
|
-
isError: true,
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
);
|
|
1367
|
-
|
|
1368
|
-
server.registerTool(
|
|
1369
|
-
"sentiment_report",
|
|
1370
|
-
{
|
|
1371
|
-
title: "Sentiment Report",
|
|
1372
|
-
description: "Get an aggregated sentiment report for an account's mentions. Shows positive/neutral/negative percentages, trending keywords, and most positive/negative mentions.",
|
|
1373
|
-
inputSchema: {
|
|
1374
|
-
account_id: z.string(),
|
|
1375
|
-
days: z.number().optional().describe("Number of days to look back (default: all time)"),
|
|
1376
|
-
},
|
|
1377
|
-
},
|
|
1378
|
-
async ({ account_id, days }) => {
|
|
1379
|
-
try {
|
|
1380
|
-
const { getSentimentReport } = await import("../lib/sentiment.js");
|
|
1381
|
-
const report = getSentimentReport(account_id, days);
|
|
1382
|
-
return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
|
|
1383
|
-
} catch (error) {
|
|
1384
|
-
return {
|
|
1385
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1386
|
-
isError: true,
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
);
|
|
1391
|
-
|
|
1392
|
-
server.registerTool(
|
|
1393
|
-
"auto_analyze_mention",
|
|
1394
|
-
{
|
|
1395
|
-
title: "Auto-Analyze Mention Sentiment",
|
|
1396
|
-
description: "Analyze a mention's content for sentiment and store the result in the mention record. Returns the sentiment analysis result.",
|
|
1397
|
-
inputSchema: {
|
|
1398
|
-
mention_id: z.string(),
|
|
1399
|
-
},
|
|
1400
|
-
},
|
|
1401
|
-
async ({ mention_id }) => {
|
|
1402
|
-
try {
|
|
1403
|
-
const { autoAnalyzeMention } = await import("../lib/sentiment.js");
|
|
1404
|
-
const result = await autoAnalyzeMention(mention_id);
|
|
1405
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
1406
|
-
} catch (error) {
|
|
1407
|
-
return {
|
|
1408
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
1409
|
-
isError: true,
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
);
|
|
1414
|
-
|
|
1415
|
-
// --- Start ---
|
|
1416
|
-
async function main() {
|
|
1417
|
-
const transport = new StdioServerTransport();
|
|
1418
|
-
await server.connect(transport);
|
|
1419
|
-
console.error("microservice-social MCP server running on stdio");
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
main().catch((error) => {
|
|
1423
|
-
console.error("Fatal error:", error);
|
|
1424
|
-
process.exit(1);
|
|
1425
|
-
});
|