posterly-mcp-server 0.62.1 → 0.63.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 +15 -2
- package/dist/lib/api-client.d.ts +13 -0
- package/dist/lib/api-client.js +25 -0
- package/dist/lib/gbp-location-preview.d.ts +39 -3
- package/dist/lib/gbp-location-preview.js +418 -3
- package/dist/lib/tool-runtime.d.ts +3 -1
- package/dist/lib/tool-runtime.js +7 -2
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tools/list-google-business-locations.d.ts +32 -0
- package/dist/tools/list-google-business-locations.js +31 -21
- package/dist/tools/manage-google-business-location.d.ts +193 -4
- package/dist/tools/manage-google-business-location.js +278 -20
- package/package.json +1 -1
- package/server.json +2 -2
- package/tool-registry.json +114 -6
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ Add the same server definition to your Cursor MCP settings:
|
|
|
123
123
|
|
|
124
124
|
## Available tools
|
|
125
125
|
|
|
126
|
-
`posterly-mcp-server@0.
|
|
126
|
+
`posterly-mcp-server@0.63.0` exposes 75 tools covering 127 actions. The hosted HTTP endpoint exposes the same catalog minus the three signup tools: 72 tools covering 124 actions.
|
|
127
127
|
|
|
128
128
|
Many tools pick what to do with one parameter: `view` (reads), `action` (writes), or `type`. A few pick their mode from which parameters you pass (for example `update_post` with `status` changes the status instead of editing). Every tool description names all of its views and actions.
|
|
129
129
|
|
|
@@ -306,7 +306,7 @@ Google Business Profile reviews, media, and audits.
|
|
|
306
306
|
| --- | --- |
|
|
307
307
|
| `audit_google_business_profile` | Audit a Google profile |
|
|
308
308
|
| `list_google_business_media` | Google profile media |
|
|
309
|
-
| `list_google_business_locations` | Google location
|
|
309
|
+
| `list_google_business_locations` | Google location profile and categories |
|
|
310
310
|
|
|
311
311
|
**`list_google_business_reviews`**: Google reviews
|
|
312
312
|
|
|
@@ -339,12 +339,25 @@ Each review from `list_google_business_reviews` includes `review_name` (`account
|
|
|
339
339
|
| `areas` (default) | Service areas on a location |
|
|
340
340
|
| `places` | Search towns and postcodes |
|
|
341
341
|
|
|
342
|
+
**`list_google_business_locations`**: Google location profile and categories
|
|
343
|
+
|
|
344
|
+
| View | What it does |
|
|
345
|
+
| --- | --- |
|
|
346
|
+
| `profile` (default) | Location title, description, categories, services, phone numbers, website, hours, and attributes |
|
|
347
|
+
| `categories` | Search Google Business categories (`region_code`, `language_code`, `category_view`, `prefix`) |
|
|
348
|
+
|
|
342
349
|
**`manage_google_business_location`**: Manage a Google location
|
|
343
350
|
|
|
344
351
|
| Action | What it does |
|
|
345
352
|
| --- | --- |
|
|
346
353
|
| `update_hours` | Update regular hours (preview then confirm) |
|
|
347
354
|
| `update_attributes` | Update attributes (preview then confirm) |
|
|
355
|
+
| `update_description` | Update business description, up to 750 characters (preview then confirm) |
|
|
356
|
+
| `update_categories` | Update primary and additional categories (preview then confirm) |
|
|
357
|
+
| `update_services` | Replace structured and free-form services (preview then confirm) |
|
|
358
|
+
| `update_title` | Update business title (preview then confirm) |
|
|
359
|
+
| `update_phones` | Update primary and additional phone numbers (preview then confirm) |
|
|
360
|
+
| `update_website` | Update website URL (preview then confirm) |
|
|
348
361
|
|
|
349
362
|
**`manage_google_business_service_area`**: Update Google service areas
|
|
350
363
|
|
package/dist/lib/api-client.d.ts
CHANGED
|
@@ -2067,9 +2067,22 @@ export declare class PosterlyClient {
|
|
|
2067
2067
|
workspace_id?: string;
|
|
2068
2068
|
account_id?: number;
|
|
2069
2069
|
location_id?: string;
|
|
2070
|
+
include_google_updated?: boolean;
|
|
2071
|
+
}): Promise<Record<string, any>>;
|
|
2072
|
+
listGoogleBusinessCategories(params: {
|
|
2073
|
+
workspace_id?: string;
|
|
2074
|
+
account_id?: number;
|
|
2075
|
+
location_id?: string;
|
|
2076
|
+
region_code: string;
|
|
2077
|
+
language_code: string;
|
|
2078
|
+
category_view?: 'BASIC' | 'FULL';
|
|
2079
|
+
prefix?: string;
|
|
2080
|
+
page_size?: number;
|
|
2081
|
+
page_token?: string;
|
|
2070
2082
|
}): Promise<Record<string, any>>;
|
|
2071
2083
|
updateGoogleBusinessHours(data: Record<string, any>): Promise<Record<string, any>>;
|
|
2072
2084
|
updateGoogleBusinessAttributes(data: Record<string, any>): Promise<Record<string, any>>;
|
|
2085
|
+
updateGoogleBusinessLocation(data: Record<string, any>): Promise<Record<string, any>>;
|
|
2073
2086
|
listActivity(params?: {
|
|
2074
2087
|
workspace_id?: string;
|
|
2075
2088
|
post_id?: number;
|
package/dist/lib/api-client.js
CHANGED
|
@@ -719,15 +719,40 @@ export class PosterlyClient {
|
|
|
719
719
|
searchParams.set('account_id', String(params.account_id));
|
|
720
720
|
if (params?.location_id)
|
|
721
721
|
searchParams.set('location_id', params.location_id);
|
|
722
|
+
if (params?.include_google_updated)
|
|
723
|
+
searchParams.set('include_google_updated', 'true');
|
|
722
724
|
const qs = searchParams.toString();
|
|
723
725
|
return this.request('GET', `/google-business/location${qs ? `?${qs}` : ''}`);
|
|
724
726
|
}
|
|
727
|
+
async listGoogleBusinessCategories(params) {
|
|
728
|
+
const searchParams = new URLSearchParams();
|
|
729
|
+
if (params.workspace_id)
|
|
730
|
+
searchParams.set('workspace_id', params.workspace_id);
|
|
731
|
+
if (params.account_id)
|
|
732
|
+
searchParams.set('account_id', String(params.account_id));
|
|
733
|
+
if (params.location_id)
|
|
734
|
+
searchParams.set('location_id', params.location_id);
|
|
735
|
+
searchParams.set('region_code', params.region_code);
|
|
736
|
+
searchParams.set('language_code', params.language_code);
|
|
737
|
+
if (params.category_view)
|
|
738
|
+
searchParams.set('view', params.category_view);
|
|
739
|
+
if (params.prefix)
|
|
740
|
+
searchParams.set('prefix', params.prefix);
|
|
741
|
+
if (params.page_size !== undefined)
|
|
742
|
+
searchParams.set('page_size', String(params.page_size));
|
|
743
|
+
if (params.page_token)
|
|
744
|
+
searchParams.set('page_token', params.page_token);
|
|
745
|
+
return this.request('GET', `/google-business/categories?${searchParams.toString()}`);
|
|
746
|
+
}
|
|
725
747
|
async updateGoogleBusinessHours(data) {
|
|
726
748
|
return this.request('PATCH', '/google-business/location', { ...data, attributes: undefined, regular_hours: data.regular_hours });
|
|
727
749
|
}
|
|
728
750
|
async updateGoogleBusinessAttributes(data) {
|
|
729
751
|
return this.request('PATCH', '/google-business/location', { ...data, regular_hours: undefined, attributes: data.attributes });
|
|
730
752
|
}
|
|
753
|
+
async updateGoogleBusinessLocation(data) {
|
|
754
|
+
return this.request('PATCH', '/google-business/location', data);
|
|
755
|
+
}
|
|
731
756
|
async listActivity(params) {
|
|
732
757
|
const searchParams = new URLSearchParams();
|
|
733
758
|
if (params?.workspace_id)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Preview text for Google Business location edits,
|
|
3
|
-
* npm MCP servers.
|
|
4
|
-
* profile, so the preview
|
|
2
|
+
* Preview and output text for Google Business location reads and edits,
|
|
3
|
+
* shared by the hosted and npm MCP servers. Every write replaces a field
|
|
4
|
+
* group on the public profile, so the preview shows what is on the listing
|
|
5
|
+
* now next to what will be sent.
|
|
5
6
|
*/
|
|
6
7
|
export type GbpPreviewPeriod = {
|
|
7
8
|
open_day?: unknown;
|
|
@@ -15,7 +16,42 @@ export type GbpPreviewAttribute = {
|
|
|
15
16
|
values?: unknown;
|
|
16
17
|
};
|
|
17
18
|
export declare const GBP_CLOSED_DAYS_NOTE = "A day with no opening period shows as closed on Google.";
|
|
19
|
+
export declare const GBP_TITLE_SUSPENSION_WARNING = "Warning: Google may hold a business name change for review, and a wrong or keyword-stuffed name can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.";
|
|
20
|
+
export declare const GBP_PRIMARY_CATEGORY_SUSPENSION_WARNING = "Warning: Google may hold a primary category change for review, and a wrong primary category can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.";
|
|
21
|
+
export declare const GBP_CLEAR_SERVICES_WARNING = "Warning: Sending an empty service_items list clears all saved services from the public Google Business profile.";
|
|
22
|
+
export declare const GBP_LIVE_LISTING_CHANGED_ERROR = "The live Google Business listing changed since this preview was created (or the arguments do not match the preview), so nothing was changed. Call again without confirm to get a fresh preview.";
|
|
18
23
|
export declare function gbpPeriodLines(periods: GbpPreviewPeriod[] | null | undefined, empty: string): string;
|
|
19
24
|
export declare function gbpAttributeLines(attributes: GbpPreviewAttribute[] | null | undefined, empty: string): string;
|
|
20
25
|
/** The current values of only the attributes this edit names. */
|
|
21
26
|
export declare function gbpCurrentAttributesFor(current: GbpPreviewAttribute[] | null | undefined, requested: GbpPreviewAttribute[] | null | undefined): GbpPreviewAttribute[];
|
|
27
|
+
export declare function gbpTextValueLine(value: unknown, empty: string): string;
|
|
28
|
+
export declare function hasExplicitAdditionalCategories(requested: unknown): boolean;
|
|
29
|
+
export type ResolvedGbpCategoriesPreview = {
|
|
30
|
+
primary_category: string;
|
|
31
|
+
additional_categories: string[];
|
|
32
|
+
carried_over_additional_categories: boolean;
|
|
33
|
+
explicit_additional_categories: boolean;
|
|
34
|
+
removed_additional_categories: string[];
|
|
35
|
+
removed_additional_category_labels: string[];
|
|
36
|
+
/** Label of the current primary category when this write replaces it (it is not kept as an additional category). */
|
|
37
|
+
removed_primary_category_label: string | null;
|
|
38
|
+
};
|
|
39
|
+
export declare function resolveGbpCategoriesForWrite(requested: unknown, currentCategories: unknown): ResolvedGbpCategoriesPreview;
|
|
40
|
+
export declare function gbpCategoriesLines(categories: unknown, empty: string): string;
|
|
41
|
+
export declare function gbpProposedCategoriesLines(requested: unknown, currentCategories: unknown): string;
|
|
42
|
+
export declare function gbpPhoneNumbersLines(phones: unknown, empty: string): string;
|
|
43
|
+
export declare function hasExplicitAdditionalPhones(requested: unknown): boolean;
|
|
44
|
+
export type ResolvedGbpPhoneNumbersPreview = {
|
|
45
|
+
primary_phone: string;
|
|
46
|
+
additional_phones: string[];
|
|
47
|
+
carried_over_additional_phones: boolean;
|
|
48
|
+
explicit_additional_phones: boolean;
|
|
49
|
+
removed_additional_phones: string[];
|
|
50
|
+
};
|
|
51
|
+
export declare function resolveGbpPhoneNumbersForWrite(requested: unknown, currentPhones: unknown): ResolvedGbpPhoneNumbersPreview;
|
|
52
|
+
export declare function gbpProposedPhoneNumbersLines(requested: unknown, currentPhones: unknown): string;
|
|
53
|
+
export declare function gbpServiceItemLines(items: unknown, empty: string): string;
|
|
54
|
+
export declare function gbpProposedServiceItemLines(items: unknown, empty: string): string;
|
|
55
|
+
export declare function formatGbpLocationProfile(result: Record<string, any>): string;
|
|
56
|
+
export declare function formatGbpCategoryCatalog(result: Record<string, any>): string;
|
|
57
|
+
export declare function formatGbpLocationUpdateOutcome(fieldLabel: string, result: Record<string, any> | null | undefined): string;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Preview text for Google Business location edits,
|
|
3
|
-
* npm MCP servers.
|
|
4
|
-
* profile, so the preview
|
|
2
|
+
* Preview and output text for Google Business location reads and edits,
|
|
3
|
+
* shared by the hosted and npm MCP servers. Every write replaces a field
|
|
4
|
+
* group on the public profile, so the preview shows what is on the listing
|
|
5
|
+
* now next to what will be sent.
|
|
5
6
|
*/
|
|
6
7
|
export const GBP_CLOSED_DAYS_NOTE = 'A day with no opening period shows as closed on Google.';
|
|
8
|
+
export const GBP_TITLE_SUSPENSION_WARNING = 'Warning: Google may hold a business name change for review, and a wrong or keyword-stuffed name can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.';
|
|
9
|
+
export const GBP_PRIMARY_CATEGORY_SUSPENSION_WARNING = 'Warning: Google may hold a primary category change for review, and a wrong primary category can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.';
|
|
10
|
+
export const GBP_CLEAR_SERVICES_WARNING = 'Warning: Sending an empty service_items list clears all saved services from the public Google Business profile.';
|
|
11
|
+
export const GBP_LIVE_LISTING_CHANGED_ERROR = 'The live Google Business listing changed since this preview was created (or the arguments do not match the preview), so nothing was changed. Call again without confirm to get a fresh preview.';
|
|
12
|
+
const GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES = 9;
|
|
13
|
+
const GBP_PREVIEW_MAX_ADDITIONAL_PHONES = 2;
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
16
|
+
}
|
|
7
17
|
export function gbpPeriodLines(periods, empty) {
|
|
8
18
|
const rows = Array.isArray(periods) ? periods : [];
|
|
9
19
|
if (!rows.length)
|
|
@@ -25,3 +35,408 @@ export function gbpCurrentAttributesFor(current, requested) {
|
|
|
25
35
|
const names = new Set((Array.isArray(requested) ? requested : []).map((attribute) => String(attribute?.name ?? '')));
|
|
26
36
|
return (Array.isArray(current) ? current : []).filter((attribute) => names.has(String(attribute?.name ?? '')));
|
|
27
37
|
}
|
|
38
|
+
export function gbpTextValueLine(value, empty) {
|
|
39
|
+
if (typeof value === 'string' && value.trim())
|
|
40
|
+
return value.trim();
|
|
41
|
+
return empty;
|
|
42
|
+
}
|
|
43
|
+
function extractCategoryName(item) {
|
|
44
|
+
if (typeof item === 'string')
|
|
45
|
+
return item.trim();
|
|
46
|
+
if (isRecord(item) && typeof item.name === 'string')
|
|
47
|
+
return item.name.trim();
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
function formatCategoryItem(item) {
|
|
51
|
+
if (typeof item === 'string' && item.trim())
|
|
52
|
+
return item.trim();
|
|
53
|
+
if (isRecord(item)) {
|
|
54
|
+
const name = typeof item.name === 'string' ? item.name.trim() : '';
|
|
55
|
+
const display = typeof item.display_name === 'string' && item.display_name.trim()
|
|
56
|
+
? item.display_name.trim()
|
|
57
|
+
: typeof item.displayName === 'string' && item.displayName.trim()
|
|
58
|
+
? item.displayName.trim()
|
|
59
|
+
: '';
|
|
60
|
+
if (display && name)
|
|
61
|
+
return `${display} (${name})`;
|
|
62
|
+
if (name)
|
|
63
|
+
return name;
|
|
64
|
+
if (display)
|
|
65
|
+
return display;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
export function hasExplicitAdditionalCategories(requested) {
|
|
70
|
+
if (!isRecord(requested))
|
|
71
|
+
return false;
|
|
72
|
+
const root = isRecord(requested.categories) ? requested.categories : requested;
|
|
73
|
+
const hasKey = Object.prototype.hasOwnProperty.call(root, 'additional_categories') ||
|
|
74
|
+
Object.prototype.hasOwnProperty.call(root, 'additionalCategories');
|
|
75
|
+
const raw = root.additional_categories ?? root.additionalCategories;
|
|
76
|
+
return hasKey && raw !== undefined;
|
|
77
|
+
}
|
|
78
|
+
export function resolveGbpCategoriesForWrite(requested, currentCategories) {
|
|
79
|
+
const root = isRecord(requested)
|
|
80
|
+
? (isRecord(requested.categories) ? requested.categories : requested)
|
|
81
|
+
: {};
|
|
82
|
+
const primary = extractCategoryName(root.primary_category ?? root.primaryCategory);
|
|
83
|
+
const explicitProvided = hasExplicitAdditionalCategories(requested);
|
|
84
|
+
if (!primary) {
|
|
85
|
+
throw new Error('primary_category is required (a category resource name such as categories/gcid:coffee_shop). Nothing was changed.');
|
|
86
|
+
}
|
|
87
|
+
const currentRoot = isRecord(currentCategories)
|
|
88
|
+
? (isRecord(currentCategories.categories) ? currentCategories.categories : currentCategories)
|
|
89
|
+
: null;
|
|
90
|
+
const currentAdditionalRaw = currentRoot && Array.isArray(currentRoot.additional_categories ?? currentRoot.additionalCategories)
|
|
91
|
+
? (currentRoot.additional_categories ?? currentRoot.additionalCategories)
|
|
92
|
+
: [];
|
|
93
|
+
const currentPrimaryRaw = currentRoot ? (currentRoot.primary_category ?? currentRoot.primaryCategory) : null;
|
|
94
|
+
const currentPrimaryName = extractCategoryName(currentPrimaryRaw);
|
|
95
|
+
const currentPrimaryLabel = currentPrimaryName ? (formatCategoryItem(currentPrimaryRaw) || currentPrimaryName) : null;
|
|
96
|
+
const currentAdditionalEntries = currentAdditionalRaw
|
|
97
|
+
.map((item) => ({
|
|
98
|
+
name: extractCategoryName(item),
|
|
99
|
+
label: formatCategoryItem(item) || extractCategoryName(item),
|
|
100
|
+
}))
|
|
101
|
+
.filter((entry) => Boolean(entry.name));
|
|
102
|
+
if (explicitProvided && Array.isArray(root.additional_categories ?? root.additionalCategories)) {
|
|
103
|
+
const rawExplicit = (root.additional_categories ?? root.additionalCategories);
|
|
104
|
+
if (rawExplicit.length > GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES) {
|
|
105
|
+
throw new Error(`additional_categories can contain at most ${GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES} categories (got ${rawExplicit.length}). Nothing was changed.`);
|
|
106
|
+
}
|
|
107
|
+
const explicit = rawExplicit.map((item) => extractCategoryName(item));
|
|
108
|
+
if (explicit.some((name) => !name)) {
|
|
109
|
+
throw new Error('Each item in additional_categories must be a category resource name such as categories/gcid:coffee_shop. Nothing was changed.');
|
|
110
|
+
}
|
|
111
|
+
const kept = new Set([primary, ...explicit]);
|
|
112
|
+
const removedEntries = currentAdditionalEntries.filter((entry) => !kept.has(entry.name));
|
|
113
|
+
const primaryRemoved = Boolean(currentPrimaryName) && !kept.has(currentPrimaryName);
|
|
114
|
+
return {
|
|
115
|
+
primary_category: primary,
|
|
116
|
+
additional_categories: explicit,
|
|
117
|
+
carried_over_additional_categories: Boolean(root.carried_over_additional_categories === true ||
|
|
118
|
+
root.carriedOverAdditionalCategories === true),
|
|
119
|
+
explicit_additional_categories: true,
|
|
120
|
+
removed_additional_categories: removedEntries.map((entry) => entry.name),
|
|
121
|
+
removed_additional_category_labels: removedEntries.map((entry) => entry.label),
|
|
122
|
+
removed_primary_category_label: primaryRemoved ? currentPrimaryLabel : null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (explicitProvided) {
|
|
126
|
+
throw new Error('additional_categories must be a list of category resource names. Nothing was changed.');
|
|
127
|
+
}
|
|
128
|
+
const carried = currentAdditionalEntries
|
|
129
|
+
.map((entry) => entry.name)
|
|
130
|
+
.filter((name) => name !== primary)
|
|
131
|
+
.slice(0, GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES);
|
|
132
|
+
const primaryRemoved = Boolean(currentPrimaryName) && currentPrimaryName !== primary && !carried.includes(currentPrimaryName);
|
|
133
|
+
return {
|
|
134
|
+
primary_category: primary,
|
|
135
|
+
additional_categories: carried,
|
|
136
|
+
carried_over_additional_categories: carried.length > 0,
|
|
137
|
+
explicit_additional_categories: false,
|
|
138
|
+
removed_additional_categories: [],
|
|
139
|
+
removed_additional_category_labels: [],
|
|
140
|
+
removed_primary_category_label: primaryRemoved ? currentPrimaryLabel : null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function gbpCategoriesLines(categories, empty) {
|
|
144
|
+
if (!isRecord(categories))
|
|
145
|
+
return empty;
|
|
146
|
+
const root = isRecord(categories.categories) ? categories.categories : categories;
|
|
147
|
+
const primary = formatCategoryItem(root.primary_category ?? root.primaryCategory);
|
|
148
|
+
const additionalRaw = Array.isArray(root.additional_categories ?? root.additionalCategories)
|
|
149
|
+
? (root.additional_categories ?? root.additionalCategories)
|
|
150
|
+
: [];
|
|
151
|
+
const additional = additionalRaw
|
|
152
|
+
.map((item) => formatCategoryItem(item))
|
|
153
|
+
.filter((item) => Boolean(item));
|
|
154
|
+
if (!primary && additional.length === 0)
|
|
155
|
+
return empty;
|
|
156
|
+
return [
|
|
157
|
+
`- Primary category: ${primary || 'not set'}`,
|
|
158
|
+
`- Additional categories: ${additional.length > 0 ? additional.join(', ') : 'none'}`,
|
|
159
|
+
].join('\n');
|
|
160
|
+
}
|
|
161
|
+
export function gbpProposedCategoriesLines(requested, currentCategories) {
|
|
162
|
+
const resolved = resolveGbpCategoriesForWrite(requested, currentCategories);
|
|
163
|
+
const primary = resolved.primary_category || 'not set';
|
|
164
|
+
const additionalText = resolved.additional_categories.length > 0 ? resolved.additional_categories.join(', ') : 'none';
|
|
165
|
+
const lines = [
|
|
166
|
+
`- Primary category: ${primary}`,
|
|
167
|
+
resolved.explicit_additional_categories
|
|
168
|
+
? `- Additional categories: ${additionalText}`
|
|
169
|
+
: `- Additional categories: ${resolved.additional_categories.length > 0 ? `${additionalText} (carried over from current listing)` : 'none'}`,
|
|
170
|
+
];
|
|
171
|
+
const removed = [
|
|
172
|
+
...resolved.removed_additional_category_labels,
|
|
173
|
+
...(resolved.removed_primary_category_label ? [resolved.removed_primary_category_label] : []),
|
|
174
|
+
];
|
|
175
|
+
if (removed.length > 0) {
|
|
176
|
+
lines.push(`- Removed categories: ${removed.join(', ')}`);
|
|
177
|
+
}
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
180
|
+
export function gbpPhoneNumbersLines(phones, empty) {
|
|
181
|
+
if (!isRecord(phones))
|
|
182
|
+
return empty;
|
|
183
|
+
const root = isRecord(phones.phone_numbers ?? phones.phoneNumbers)
|
|
184
|
+
? (phones.phone_numbers ?? phones.phoneNumbers)
|
|
185
|
+
: phones;
|
|
186
|
+
const primary = typeof (root.primary_phone ?? root.primaryPhone) === 'string'
|
|
187
|
+
? String(root.primary_phone ?? root.primaryPhone).trim()
|
|
188
|
+
: '';
|
|
189
|
+
const additionalRaw = Array.isArray(root.additional_phones ?? root.additionalPhones)
|
|
190
|
+
? (root.additional_phones ?? root.additionalPhones)
|
|
191
|
+
: [];
|
|
192
|
+
const additional = additionalRaw
|
|
193
|
+
.filter((item) => typeof item === 'string' && item.trim().length > 0)
|
|
194
|
+
.map((item) => item.trim());
|
|
195
|
+
if (!primary && additional.length === 0)
|
|
196
|
+
return empty;
|
|
197
|
+
return [
|
|
198
|
+
`- Primary phone: ${primary || 'not set'}`,
|
|
199
|
+
`- Additional phones: ${additional.length > 0 ? additional.join(', ') : 'none'}`,
|
|
200
|
+
].join('\n');
|
|
201
|
+
}
|
|
202
|
+
export function hasExplicitAdditionalPhones(requested) {
|
|
203
|
+
if (!isRecord(requested))
|
|
204
|
+
return false;
|
|
205
|
+
const root = isRecord(requested.phone_numbers ?? requested.phoneNumbers)
|
|
206
|
+
? (requested.phone_numbers ?? requested.phoneNumbers)
|
|
207
|
+
: requested;
|
|
208
|
+
const hasKey = Object.prototype.hasOwnProperty.call(root, 'additional_phones') ||
|
|
209
|
+
Object.prototype.hasOwnProperty.call(root, 'additionalPhones');
|
|
210
|
+
const raw = root.additional_phones ?? root.additionalPhones;
|
|
211
|
+
return hasKey && raw !== undefined;
|
|
212
|
+
}
|
|
213
|
+
export function resolveGbpPhoneNumbersForWrite(requested, currentPhones) {
|
|
214
|
+
const root = isRecord(requested)
|
|
215
|
+
? (isRecord(requested.phone_numbers ?? requested.phoneNumbers)
|
|
216
|
+
? (requested.phone_numbers ?? requested.phoneNumbers)
|
|
217
|
+
: requested)
|
|
218
|
+
: {};
|
|
219
|
+
const primary = typeof (root.primary_phone ?? root.primaryPhone) === 'string'
|
|
220
|
+
? String(root.primary_phone ?? root.primaryPhone).trim()
|
|
221
|
+
: '';
|
|
222
|
+
const explicitProvided = hasExplicitAdditionalPhones(requested);
|
|
223
|
+
const currentRoot = isRecord(currentPhones)
|
|
224
|
+
? (isRecord(currentPhones.phone_numbers ?? currentPhones.phoneNumbers)
|
|
225
|
+
? (currentPhones.phone_numbers ?? currentPhones.phoneNumbers)
|
|
226
|
+
: currentPhones)
|
|
227
|
+
: null;
|
|
228
|
+
const currentAdditional = currentRoot && Array.isArray(currentRoot.additional_phones ?? currentRoot.additionalPhones)
|
|
229
|
+
? (currentRoot.additional_phones ?? currentRoot.additionalPhones)
|
|
230
|
+
.filter((item) => typeof item === 'string' && item.trim().length > 0)
|
|
231
|
+
.map((item) => item.trim())
|
|
232
|
+
: [];
|
|
233
|
+
if (explicitProvided && Array.isArray(root.additional_phones ?? root.additionalPhones)) {
|
|
234
|
+
const rawAdditional = (root.additional_phones ?? root.additionalPhones);
|
|
235
|
+
if (rawAdditional.length > GBP_PREVIEW_MAX_ADDITIONAL_PHONES) {
|
|
236
|
+
throw new Error(`additional_phones can contain at most ${GBP_PREVIEW_MAX_ADDITIONAL_PHONES} phone numbers (got ${rawAdditional.length}). Nothing was changed.`);
|
|
237
|
+
}
|
|
238
|
+
if (rawAdditional.some((item) => typeof item !== 'string' || !item.trim())) {
|
|
239
|
+
throw new Error('Each item in additional_phones must be a non-empty phone number string. Nothing was changed.');
|
|
240
|
+
}
|
|
241
|
+
const additional = rawAdditional.map((item) => item.trim());
|
|
242
|
+
const keptDigits = new Set([
|
|
243
|
+
primary.replace(/\D/g, ''),
|
|
244
|
+
...additional.map((phone) => phone.replace(/\D/g, '')),
|
|
245
|
+
]);
|
|
246
|
+
const removed = currentAdditional.filter((phone) => !keptDigits.has(phone.replace(/\D/g, '')));
|
|
247
|
+
return {
|
|
248
|
+
primary_phone: primary,
|
|
249
|
+
additional_phones: additional,
|
|
250
|
+
carried_over_additional_phones: Boolean(root.carried_over_additional_phones === true ||
|
|
251
|
+
root.carriedOverAdditionalPhones === true),
|
|
252
|
+
explicit_additional_phones: true,
|
|
253
|
+
removed_additional_phones: removed,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (explicitProvided) {
|
|
257
|
+
throw new Error('additional_phones must be a list of phone numbers. Nothing was changed.');
|
|
258
|
+
}
|
|
259
|
+
const primaryDigits = primary.replace(/\D/g, '');
|
|
260
|
+
const carried = currentAdditional
|
|
261
|
+
.filter((phone) => phone.replace(/\D/g, '') !== primaryDigits)
|
|
262
|
+
.slice(0, GBP_PREVIEW_MAX_ADDITIONAL_PHONES);
|
|
263
|
+
return {
|
|
264
|
+
primary_phone: primary,
|
|
265
|
+
additional_phones: carried,
|
|
266
|
+
carried_over_additional_phones: carried.length > 0,
|
|
267
|
+
explicit_additional_phones: false,
|
|
268
|
+
removed_additional_phones: [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
export function gbpProposedPhoneNumbersLines(requested, currentPhones) {
|
|
272
|
+
const resolved = resolveGbpPhoneNumbersForWrite(requested, currentPhones);
|
|
273
|
+
const primary = resolved.primary_phone || 'not set';
|
|
274
|
+
if (!resolved.explicit_additional_phones) {
|
|
275
|
+
return [
|
|
276
|
+
`- Primary phone: ${primary}`,
|
|
277
|
+
`- Additional phones: ${resolved.additional_phones.length > 0 ? `${resolved.additional_phones.join(', ')} (carried over from current listing)` : 'none'}`,
|
|
278
|
+
].join('\n');
|
|
279
|
+
}
|
|
280
|
+
const lines = [
|
|
281
|
+
`- Primary phone: ${primary}`,
|
|
282
|
+
`- Additional phones: ${resolved.additional_phones.length > 0 ? resolved.additional_phones.join(', ') : 'none'}`,
|
|
283
|
+
];
|
|
284
|
+
if (resolved.removed_additional_phones.length > 0) {
|
|
285
|
+
lines.push(`- Removed phones: ${resolved.removed_additional_phones.join(', ')}`);
|
|
286
|
+
}
|
|
287
|
+
return lines.join('\n');
|
|
288
|
+
}
|
|
289
|
+
function formatMoney(price) {
|
|
290
|
+
if (!isRecord(price))
|
|
291
|
+
return null;
|
|
292
|
+
const currency = typeof (price.currency_code ?? price.currencyCode) === 'string'
|
|
293
|
+
? String(price.currency_code ?? price.currencyCode).trim().toUpperCase()
|
|
294
|
+
: '';
|
|
295
|
+
if (!currency)
|
|
296
|
+
return null;
|
|
297
|
+
const units = price.units !== undefined && price.units !== null ? String(price.units) : '0';
|
|
298
|
+
const nanos = typeof price.nanos === 'number' && price.nanos > 0
|
|
299
|
+
? `.${String(Math.round(price.nanos / 10_000_000)).padStart(2, '0')}`
|
|
300
|
+
: '';
|
|
301
|
+
return `${currency} ${units}${nanos}`;
|
|
302
|
+
}
|
|
303
|
+
export function gbpServiceItemLines(items, empty) {
|
|
304
|
+
const list = Array.isArray(items)
|
|
305
|
+
? items
|
|
306
|
+
: isRecord(items) && Array.isArray(items.service_items ?? items.serviceItems)
|
|
307
|
+
? (items.service_items ?? items.serviceItems)
|
|
308
|
+
: [];
|
|
309
|
+
if (!list.length)
|
|
310
|
+
return empty;
|
|
311
|
+
return list
|
|
312
|
+
.map((raw) => {
|
|
313
|
+
if (!isRecord(raw))
|
|
314
|
+
return '- ?';
|
|
315
|
+
const priceText = formatMoney(raw.price);
|
|
316
|
+
const priceSuffix = priceText ? ` [${priceText}]` : '';
|
|
317
|
+
const structured = isRecord(raw.structured_service_item ?? raw.structuredServiceItem)
|
|
318
|
+
? (raw.structured_service_item ?? raw.structuredServiceItem)
|
|
319
|
+
: null;
|
|
320
|
+
if (structured) {
|
|
321
|
+
const id = String(structured.service_type_id ?? structured.serviceTypeId ?? '?');
|
|
322
|
+
const desc = typeof structured.description === 'string' && structured.description.trim()
|
|
323
|
+
? ` (${structured.description.trim()})`
|
|
324
|
+
: '';
|
|
325
|
+
return `- Structured: ${id}${desc}${priceSuffix}`;
|
|
326
|
+
}
|
|
327
|
+
const freeForm = isRecord(raw.free_form_service_item ?? raw.freeFormServiceItem)
|
|
328
|
+
? (raw.free_form_service_item ?? raw.freeFormServiceItem)
|
|
329
|
+
: null;
|
|
330
|
+
if (freeForm) {
|
|
331
|
+
const category = String(freeForm.category ?? '?');
|
|
332
|
+
const label = isRecord(freeForm.label) ? freeForm.label : freeForm;
|
|
333
|
+
const name = String(label.display_name ?? label.displayName ?? '?');
|
|
334
|
+
const desc = typeof label.description === 'string' && label.description.trim()
|
|
335
|
+
? ` - ${label.description.trim()}`
|
|
336
|
+
: '';
|
|
337
|
+
return `- Free-form: ${name} (${category})${desc}${priceSuffix}`;
|
|
338
|
+
}
|
|
339
|
+
return '- ?';
|
|
340
|
+
})
|
|
341
|
+
.join('\n');
|
|
342
|
+
}
|
|
343
|
+
export function gbpProposedServiceItemLines(items, empty) {
|
|
344
|
+
const list = Array.isArray(items)
|
|
345
|
+
? items
|
|
346
|
+
: isRecord(items) && Array.isArray(items.service_items ?? items.serviceItems)
|
|
347
|
+
? (items.service_items ?? items.serviceItems)
|
|
348
|
+
: null;
|
|
349
|
+
if (list && list.length === 0) {
|
|
350
|
+
return 'Empty list (clears all saved services from the listing).';
|
|
351
|
+
}
|
|
352
|
+
return gbpServiceItemLines(items, empty);
|
|
353
|
+
}
|
|
354
|
+
export function formatGbpLocationProfile(result) {
|
|
355
|
+
if (result?.enabled !== true) {
|
|
356
|
+
return 'Google Business location edits are switched off. Nothing was read from Google.';
|
|
357
|
+
}
|
|
358
|
+
const periods = Array.isArray(result.regular_hours?.periods) ? result.regular_hours.periods : [];
|
|
359
|
+
const attributes = Array.isArray(result.attributes) ? result.attributes : [];
|
|
360
|
+
const description = typeof result.profile?.description === 'string'
|
|
361
|
+
? result.profile.description
|
|
362
|
+
: typeof result.description === 'string'
|
|
363
|
+
? result.description
|
|
364
|
+
: '';
|
|
365
|
+
const pendingNote = result.has_pending_edits === true || result.review_status === 'pending Google review'
|
|
366
|
+
? 'pending Google review'
|
|
367
|
+
: 'none';
|
|
368
|
+
return [
|
|
369
|
+
'## Google Business location',
|
|
370
|
+
[
|
|
371
|
+
'### Location',
|
|
372
|
+
[
|
|
373
|
+
result.account_id != null ? `- **Account ID**: \`${result.account_id}\`` : '',
|
|
374
|
+
result.location ? `- **Location**: \`${String(result.location)}\`` : '',
|
|
375
|
+
result.title ? `- **Title**: ${String(result.title)}` : '- **Title**: Not set.',
|
|
376
|
+
result.website_uri ? `- **Website**: ${String(result.website_uri)}` : '- **Website**: Not set.',
|
|
377
|
+
`- **Pending edits**: ${pendingNote}`,
|
|
378
|
+
result.google_updated_check === 'failed'
|
|
379
|
+
? '- **Google-suggested updates**: could not be checked right now. The rest of this profile is current. Retry with include_google_updated to see the Google error.'
|
|
380
|
+
: '',
|
|
381
|
+
].filter(Boolean).join('\n'),
|
|
382
|
+
].join('\n'),
|
|
383
|
+
['### Description', description ? description : 'No description saved.'].join('\n'),
|
|
384
|
+
['### Categories', gbpCategoriesLines(result.categories, 'No categories saved.')].join('\n'),
|
|
385
|
+
['### Phone numbers', gbpPhoneNumbersLines(result.phone_numbers, 'No phone numbers saved.')].join('\n'),
|
|
386
|
+
['### Services', gbpServiceItemLines(result.service_items, 'No services saved.')].join('\n'),
|
|
387
|
+
[
|
|
388
|
+
'### Regular hours',
|
|
389
|
+
periods.length
|
|
390
|
+
? periods
|
|
391
|
+
.map((period) => `- ${period.open_day} ${period.open_time} to ${period.close_day} ${period.close_time}`)
|
|
392
|
+
.join('\n')
|
|
393
|
+
: 'No regular hours saved.',
|
|
394
|
+
].join('\n'),
|
|
395
|
+
[
|
|
396
|
+
'### Attributes',
|
|
397
|
+
attributes.length
|
|
398
|
+
? attributes
|
|
399
|
+
.map((attribute) => `- ${attribute.name} (${attribute.value_type}): ${(attribute.values || []).join(', ')}`)
|
|
400
|
+
.join('\n')
|
|
401
|
+
: 'No attributes saved.',
|
|
402
|
+
].join('\n'),
|
|
403
|
+
].join('\n\n');
|
|
404
|
+
}
|
|
405
|
+
export function formatGbpCategoryCatalog(result) {
|
|
406
|
+
if (result?.enabled !== true) {
|
|
407
|
+
return 'Google Business location edits are switched off. Nothing was read from Google.';
|
|
408
|
+
}
|
|
409
|
+
const categories = Array.isArray(result.categories) ? result.categories : [];
|
|
410
|
+
const metaLines = [
|
|
411
|
+
result.region_code ? `- **Region**: \`${result.region_code}\`` : '',
|
|
412
|
+
result.language_code ? `- **Language**: \`${result.language_code}\`` : '',
|
|
413
|
+
result.view ? `- **View**: \`${result.view}\`` : '',
|
|
414
|
+
result.prefix ? `- **Prefix**: \`${result.prefix}\`` : '',
|
|
415
|
+
result.total_size != null ? `- **Total**: ${result.total_size}` : '',
|
|
416
|
+
result.next_page_token ? `- **Next page token**: \`${result.next_page_token}\`` : '',
|
|
417
|
+
].filter(Boolean);
|
|
418
|
+
const listText = categories.length
|
|
419
|
+
? categories
|
|
420
|
+
.map((cat) => {
|
|
421
|
+
const display = cat.display_name || cat.displayName || cat.name;
|
|
422
|
+
const serviceCount = Array.isArray(cat.service_types) ? cat.service_types.length : 0;
|
|
423
|
+
const extra = serviceCount > 0 ? ` (${serviceCount} structured service types)` : '';
|
|
424
|
+
return `- **${display}** (\`${cat.name}\`)${extra}`;
|
|
425
|
+
})
|
|
426
|
+
.join('\n')
|
|
427
|
+
: 'No matching Google Business categories found.';
|
|
428
|
+
return [
|
|
429
|
+
'## Google Business categories',
|
|
430
|
+
['### Query', metaLines.join('\n')].join('\n'),
|
|
431
|
+
['### Categories', listText].join('\n'),
|
|
432
|
+
].join('\n\n');
|
|
433
|
+
}
|
|
434
|
+
export function formatGbpLocationUpdateOutcome(fieldLabel, result) {
|
|
435
|
+
if (!result?.success) {
|
|
436
|
+
return result?.error || `Google Business ${fieldLabel} was not updated.`;
|
|
437
|
+
}
|
|
438
|
+
const pending = result.has_pending_edits === true || result.review_status === 'pending Google review';
|
|
439
|
+
return pending
|
|
440
|
+
? `Google Business ${fieldLabel} updated (pending Google review).`
|
|
441
|
+
: `Google Business ${fieldLabel} updated.`;
|
|
442
|
+
}
|
|
@@ -45,8 +45,10 @@ export interface PreviewStep {
|
|
|
45
45
|
nonce: boolean;
|
|
46
46
|
/** The old tool's refusal when confirm is missing, for alias calls. */
|
|
47
47
|
legacyRefusal: string;
|
|
48
|
+
/** Optional custom refusal when verification fails with 'mismatch'. */
|
|
49
|
+
mismatchMessage?: string;
|
|
48
50
|
ctx: ToolContext;
|
|
49
|
-
/** What will change (may make one read request;
|
|
51
|
+
/** What will change (may make one read request; if it throws, no preview_id is issued). */
|
|
50
52
|
describe: () => Promise<string>;
|
|
51
53
|
run: () => Promise<string>;
|
|
52
54
|
}
|
package/dist/lib/tool-runtime.js
CHANGED
|
@@ -58,15 +58,20 @@ export async function previewThenConfirm(step) {
|
|
|
58
58
|
}
|
|
59
59
|
const binding = { userId: STDIO_PREVIEW_USER, tool: step.tool, action: step.action, args: canonicalArgs(args) };
|
|
60
60
|
if (args.confirm !== true) {
|
|
61
|
+
const body = await step.describe();
|
|
61
62
|
const previewId = ctx.previews.create(binding);
|
|
62
|
-
return formatPreview(
|
|
63
|
+
return formatPreview(body, previewId, step.tool);
|
|
63
64
|
}
|
|
64
65
|
const token = args.preview_id;
|
|
65
66
|
if (typeof token !== 'string' || !token)
|
|
66
67
|
throw new Error(previewFailureMessage('missing'));
|
|
67
68
|
const verified = ctx.previews.verify(token, binding);
|
|
68
|
-
if (!verified.ok)
|
|
69
|
+
if (!verified.ok) {
|
|
70
|
+
if (verified.reason === 'mismatch' && step.mismatchMessage) {
|
|
71
|
+
throw new Error(step.mismatchMessage);
|
|
72
|
+
}
|
|
69
73
|
throw new Error(previewFailureMessage(verified.reason));
|
|
74
|
+
}
|
|
70
75
|
if (step.nonce && !ctx.previews.claimOnce(token, verified.exp))
|
|
71
76
|
throw new Error(previewFailureMessage('used'));
|
|
72
77
|
return step.run();
|
package/dist/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const POSTERLY_MCP_VERSION = "0.
|
|
1
|
+
export declare const POSTERLY_MCP_VERSION = "0.63.0";
|
package/dist/lib/version.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
// tool set (minus the intentional pre-auth signup tools that only this stdio
|
|
6
6
|
// package exposes). `npm run check:mcp-parity` enforces both the version match
|
|
7
7
|
// and the tool-list match, and runs in the pre-commit hook.
|
|
8
|
-
export const POSTERLY_MCP_VERSION = '0.
|
|
8
|
+
export const POSTERLY_MCP_VERSION = '0.63.0';
|