@yoryoboy/bi-mcp 1.6.0 → 1.8.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 +87 -87
- package/bin/bi-mcp.js +9 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +2 -2
- package/dist/mcp-use.json +2 -2
- package/dist/public/icon.svg +6 -6
- package/dist/scripts/_helpers.js.map +1 -1
- package/dist/scripts/admin-profile-delete.js.map +1 -1
- package/dist/scripts/admin-profile-list.js.map +1 -1
- package/dist/scripts/admin-profile-upsert.js.map +1 -1
- package/dist/scripts/admin-vtex-list.js.map +1 -1
- package/dist/scripts/admin-vtex-upsert.js.map +1 -1
- package/dist/scripts/admin-vtex-validate.js.map +1 -1
- package/dist/scripts/run-migrations.js.map +1 -1
- package/dist/scripts/test-db-connection.js.map +1 -1
- package/dist/src/analytics/ga4-channel-groups.js.map +1 -1
- package/dist/src/analytics/ga4-report-utils.js.map +1 -1
- package/dist/src/config/benchmarks.js.map +1 -1
- package/dist/src/config/google-store.js.map +1 -1
- package/dist/src/config/google.js.map +1 -1
- package/dist/src/config/mercadolibre-profile-store.js.map +1 -1
- package/dist/src/config/mercadolibre.js.map +1 -1
- package/dist/src/config/meta.js.map +1 -1
- package/dist/src/config/profile-store.js.map +1 -1
- package/dist/src/config/vtex-crypto.js.map +1 -1
- package/dist/src/config/vtex-profile-store.js.map +1 -1
- package/dist/src/config/vtex.js.map +1 -1
- package/dist/src/db/client.js.map +1 -1
- package/dist/src/google-ads/report-utils.js +78 -0
- package/dist/src/google-ads/report-utils.js.map +7 -0
- package/dist/src/meta/meta-utils.js.map +1 -1
- package/dist/src/prompts/reporte-ventas.js.map +1 -1
- package/dist/src/search-console/search-console-utils.js +275 -0
- package/dist/src/search-console/search-console-utils.js.map +7 -0
- package/dist/src/services/analytics/ga4-client.js.map +1 -1
- package/dist/src/services/analytics/oauth.js.map +1 -1
- package/dist/src/services/google-ads/google-ads-client.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-api.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-items.js +29 -2
- package/dist/src/services/mercadolibre/mercadolibre-items.js.map +2 -2
- package/dist/src/services/mercadolibre/mercadolibre-orders.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-questions.js.map +1 -1
- package/dist/src/services/meta/meta-ads.js.map +1 -1
- package/dist/src/services/meta/meta-api.js.map +1 -1
- package/dist/src/services/search-console/search-console-client.js.map +1 -1
- package/dist/src/services/search-console/search-console-utils.js.map +1 -1
- package/dist/src/services/vtex/vtex-api.js.map +1 -1
- package/dist/src/services/vtex/vtex-catalog-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-catalog.js.map +1 -1
- package/dist/src/services/vtex/vtex-logistics.js.map +1 -1
- package/dist/src/services/vtex/vtex-orders-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-orders.js.map +1 -1
- package/dist/src/services/vtex/vtex-pricing-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-pricing.js.map +1 -1
- package/dist/src/services/vtex/vtex-write.js.map +1 -1
- package/dist/src/tools/analytics/attribution-gaps.js.map +1 -1
- package/dist/src/tools/analytics/channel-mix.js.map +1 -1
- package/dist/src/tools/analytics/ecommerce-tracking-health.js.map +1 -1
- package/dist/src/tools/analytics/engagement-overview.js.map +1 -1
- package/dist/src/tools/analytics/index.js.map +1 -1
- package/dist/src/tools/analytics/list-accessible-properties.js.map +1 -1
- package/dist/src/tools/analytics/property-info.js.map +1 -1
- package/dist/src/tools/analytics/revenue-by-channel.js.map +1 -1
- package/dist/src/tools/analytics/revenue-overview.js.map +1 -1
- package/dist/src/tools/analytics/revenue-trend.js.map +1 -1
- package/dist/src/tools/analytics/source-medium-breakdown.js.map +1 -1
- package/dist/src/tools/analytics/top-landing-pages.js.map +1 -1
- package/dist/src/tools/config/check-database-connection.js.map +1 -1
- package/dist/src/tools/config/index.js.map +1 -1
- package/dist/src/tools/config/list-profiles.js.map +1 -1
- package/dist/src/tools/google-ads/account-overview.js.map +1 -1
- package/dist/src/tools/google-ads/account-risks.js.map +1 -1
- package/dist/src/tools/google-ads/break-even-analysis.js.map +1 -1
- package/dist/src/tools/google-ads/campaign-performance.js.map +1 -1
- package/dist/src/tools/google-ads/channel-mix.js.map +1 -1
- package/dist/src/tools/google-ads/compare-accounts.js.map +1 -1
- package/dist/src/tools/google-ads/customer-clients.js.map +1 -1
- package/dist/src/tools/google-ads/customer-info.js.map +1 -1
- package/dist/src/tools/google-ads/index.js.map +1 -1
- package/dist/src/tools/google-ads/scaling-health.js.map +1 -1
- package/dist/src/tools/google-ads/search-terms-summary.js.map +1 -1
- package/dist/src/tools/google-ads/time-series.js.map +1 -1
- package/dist/src/tools/index.js.map +1 -1
- package/dist/src/tools/mercadolibre/answer-question.js.map +1 -1
- package/dist/src/tools/mercadolibre/create-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/estimate-listing-fee.js +4 -17
- package/dist/src/tools/mercadolibre/estimate-listing-fee.js.map +2 -2
- package/dist/src/tools/mercadolibre/get-account-context.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-category-requirements.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-item-details.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-item-visits.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-listing-quality.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-order-details.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-orders-summary.js +366 -28
- package/dist/src/tools/mercadolibre/get-orders-summary.js.map +2 -2
- package/dist/src/tools/mercadolibre/get-sales-by-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-sales-trend.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-shipping-summary.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-site-categories-and-listing-types.js +50 -0
- package/dist/src/tools/mercadolibre/get-site-categories-and-listing-types.js.map +7 -0
- package/dist/src/tools/mercadolibre/get-store-performance.js.map +1 -1
- package/dist/src/tools/mercadolibre/helpers.js.map +1 -1
- package/dist/src/tools/mercadolibre/index.js +1 -0
- package/dist/src/tools/mercadolibre/index.js.map +2 -2
- package/dist/src/tools/mercadolibre/pause-or-reactivate-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/predict-category.js.map +1 -1
- package/dist/src/tools/mercadolibre/profile-resolution.js.map +1 -1
- package/dist/src/tools/mercadolibre/search-items.js +207 -52
- package/dist/src/tools/mercadolibre/search-items.js.map +2 -2
- package/dist/src/tools/mercadolibre/search-questions.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-basic-fields.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-description.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-pictures.js.map +1 -1
- package/dist/src/tools/mercadolibre/validate-connection.js.map +1 -1
- package/dist/src/tools/mercadolibre/write-helpers.js.map +1 -1
- package/dist/src/tools/meta/account-overview.js.map +1 -1
- package/dist/src/tools/meta/ad-account-info.js.map +1 -1
- package/dist/src/tools/meta/ads-performance.js.map +1 -1
- package/dist/src/tools/meta/campaign-performance.js.map +1 -1
- package/dist/src/tools/meta/index.js.map +1 -1
- package/dist/src/tools/meta/list-accessible-ad-accounts.js.map +1 -1
- package/dist/src/tools/meta/list-accessible-businesses.js.map +1 -1
- package/dist/src/tools/meta/placement-mix.js.map +1 -1
- package/dist/src/tools/meta/time-series.js.map +1 -1
- package/dist/src/tools/search-console/country-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/device-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/high-impression-low-click-queries.js.map +1 -1
- package/dist/src/tools/search-console/index.js.map +1 -1
- package/dist/src/tools/search-console/list-accessible-sites.js.map +1 -1
- package/dist/src/tools/search-console/low-ctr-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/page-performance.js.map +1 -1
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js.map +1 -1
- package/dist/src/tools/search-console/query-page-matrix.js.map +1 -1
- package/dist/src/tools/search-console/query-performance.js.map +1 -1
- package/dist/src/tools/search-console/quick-win-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/rising-non-brand-queries.js.map +1 -1
- package/dist/src/tools/search-console/search-performance.js.map +1 -1
- package/dist/src/tools/search-console/site-context.js.map +1 -1
- package/dist/src/tools/search-console/visibility-declines.js.map +1 -1
- package/dist/src/tools/vtex/activate-sku.js.map +1 -1
- package/dist/src/tools/vtex/add-order-tracking.js.map +1 -1
- package/dist/src/tools/vtex/associate-specification.js.map +1 -1
- package/dist/src/tools/vtex/attach-catalog-image.js.map +1 -1
- package/dist/src/tools/vtex/cancel-order.js.map +1 -1
- package/dist/src/tools/vtex/computed-price.js.map +1 -1
- package/dist/src/tools/vtex/create-brand.js.map +1 -1
- package/dist/src/tools/vtex/create-category.js.map +1 -1
- package/dist/src/tools/vtex/create-product-with-sku.js.map +1 -1
- package/dist/src/tools/vtex/create-product.js.map +1 -1
- package/dist/src/tools/vtex/create-sku.js.map +1 -1
- package/dist/src/tools/vtex/create-specification-value.js.map +1 -1
- package/dist/src/tools/vtex/create-specification.js.map +1 -1
- package/dist/src/tools/vtex/deactivate-sku.js.map +1 -1
- package/dist/src/tools/vtex/delete-fixed-price.js.map +1 -1
- package/dist/src/tools/vtex/index.js.map +1 -1
- package/dist/src/tools/vtex/inventory-check.js.map +1 -1
- package/dist/src/tools/vtex/invoice-order.js.map +1 -1
- package/dist/src/tools/vtex/order-details.js.map +1 -1
- package/dist/src/tools/vtex/orders-summary.js.map +1 -1
- package/dist/src/tools/vtex/product-offers.js.map +1 -1
- package/dist/src/tools/vtex/profile-resolution.js.map +1 -1
- package/dist/src/tools/vtex/sku-offers.js.map +1 -1
- package/dist/src/tools/vtex/sku-price.js.map +1 -1
- package/dist/src/tools/vtex/toggle-unlimited-quantity.js.map +1 -1
- package/dist/src/tools/vtex/update-inventory.js.map +1 -1
- package/dist/src/tools/vtex/update-lead-time.js.map +1 -1
- package/dist/src/tools/vtex/update-product-basic-fields.js.map +1 -1
- package/dist/src/tools/vtex/update-sku-basic-fields.js.map +1 -1
- package/dist/src/tools/vtex/update-sku-price.js.map +1 -1
- package/dist/src/tools/vtex/upsert-fixed-price.js.map +1 -1
- package/dist/src/tools/vtex/warehouse-inventory.js.map +1 -1
- package/dist/src/tools/vtex/write-helpers.js.map +1 -1
- package/dist/src/utils/case-conversion.js.map +1 -1
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/format-order-details.js.map +1 -1
- package/dist/src/utils/google-ads.js.map +1 -1
- package/dist/src/utils/money.js.map +1 -1
- package/dist/src/utils/order-status.js.map +1 -1
- package/dist/src/utils/pagination.js.map +1 -1
- package/dist/src/utils/strip-payload.js.map +1 -1
- package/dist/src/utils/type-guards.js.map +1 -1
- package/package.json +1 -1
- package/public/icon.svg +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./get-account-context.js\";\
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from \"./get-account-context.js\";\nexport * from \"./validate-connection.js\";\nexport * from \"./get-orders-summary.js\";\nexport * from \"./get-order-details.js\";\nexport * from \"./get-sales-by-item.js\";\nexport * from \"./get-sales-trend.js\";\nexport * from \"./get-shipping-summary.js\";\nexport * from \"./get-item-visits.js\";\nexport * from \"./get-store-performance.js\";\nexport * from \"./search-items.js\";\nexport * from \"./get-item-details.js\";\nexport * from \"./get-listing-quality.js\";\nexport * from \"./predict-category.js\";\nexport * from \"./get-category-requirements.js\";\nexport * from \"./estimate-listing-fee.js\";\nexport * from \"./create-item.js\";\nexport * from \"./update-item-basic-fields.js\";\nexport * from \"./update-item-description.js\";\nexport * from \"./update-item-pictures.js\";\nexport * from \"./pause-or-reactivate-item.js\";\nexport * from \"./search-questions.js\";\nexport * from \"./answer-question.js\";\nexport * from \"./profile-resolution.js\";\nexport * from \"./get-site-categories-and-listing-types.js\";\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/pause-or-reactivate-item.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getMercadoLibreItem,\n updateMercadoLibreItem,\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport {\n buildMercadoLibreWriteSuccessResponse,\n handleMercadoLibreWriteError,\n mercadolibreProfileIdSchemaField,\n resolveMercadoLibreWriteProfile,\n} from \"./write-helpers.js\";\n\nexport const meliPauseOrReactivateItemSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n itemId: z.string().trim().min(1).describe(\"MercadoLibre item id.\"),\n status: z.enum([\"active\", \"paused\"]).describe(\"Target status for the item.\"),\n});\n\nexport async function meliPauseOrReactivateItemHandler(\n params: z.infer<typeof meliPauseOrReactivateItemSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreWriteProfile(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const before = await getMercadoLibreItem(profileId, params.itemId);\n const after = await updateMercadoLibreItem(profileId, params.itemId, {\n status: params.status,\n });\n\n return buildMercadoLibreWriteSuccessResponse({\n profileId,\n operation: \"pause_or_reactivate_item\",\n resourceId: params.itemId,\n message: `MercadoLibre item status changed to ${params.status}.`,\n before,\n after,\n });\n } catch (err) {\n return handleMercadoLibreWriteError(err, `Failed to change status for ${params.itemId}`);\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,kCAAkC,EAAE,OAAO;AAAA,EACtD,WAAW;AAAA,EACX,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EACjE,QAAQ,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAS,6BAA6B;AAC7E,CAAC;AAED,eAAsB,iCACpB,QACA;AACA,MAAI;AACF,UAAM,oBAAoB,MAAM,gCAAgC,OAAO,SAAS;AAChF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,oBAAoB,WAAW,OAAO,MAAM;AACjE,UAAM,QAAQ,MAAM,uBAAuB,WAAW,OAAO,QAAQ;AAAA,MACnE,QAAQ,OAAO;AAAA,IACjB,CAAC;AAED,WAAO,sCAAsC;AAAA,MAC3C;AAAA,MACA,WAAW;AAAA,MACX,YAAY,OAAO;AAAA,MACnB,SAAS,uCAAuC,OAAO,MAAM;AAAA,MAC7D;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,6BAA6B,KAAK,+BAA+B,OAAO,MAAM,EAAE;AAAA,EACzF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/predict-category.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatMercadoLibreError } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { searchMercadoLibreDomainDiscovery } from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { asArray, normalizeString, toNumber } from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nexport const meliPredictCategorySchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n query: z.string().trim().min(2).describe(\"Search phrase describing the product to categorize.\"),\n siteId: z.string().trim().min(3).optional().describe(\"MercadoLibre site id. Defaults to MLA.\"),\n limit: z.number().int().min(1).max(8).optional().describe(\"Maximum candidate categories to return. Defaults to 5.\"),\n});\n\nexport async function meliPredictCategoryHandler(params: z.infer<typeof meliPredictCategorySchema>) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const candidates = await searchMercadoLibreDomainDiscovery(\n profileResolution.value.profileId,\n params.query,\n params.limit ?? 5,\n params.siteId ?? \"MLA\"\n );\n\n return object(\n stripNulls({\n profile_id: profileResolution.value.profileId,\n query: params.query,\n site_id: params.siteId ?? \"MLA\",\n candidates: asArray<Record<string, unknown>>(candidates).map((candidate) => ({\n category_id: normalizeString(candidate.category_id),\n category_name: normalizeString(candidate.category_name),\n domain_id: normalizeString(candidate.domain_id),\n domain_name: normalizeString(candidate.domain_name),\n attributes_matched: toNumber(candidate.attributes_matched),\n })),\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to predict MercadoLibre category\"));\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,+BAA+B;AACxC,SAAS,yCAAyC;AAClD,SAAS,kBAAkB;AAC3B,SAAS,SAAS,iBAAiB,gBAAgB;AACnD,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAE1C,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,qDAAqD;AAAA,EAC9F,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,wCAAwC;AAAA,EAC7F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,wDAAwD;AACpH,CAAC;AAED,eAAsB,2BAA2B,QAAmD;AAClG,MAAI;AACF,UAAM,oBAAoB,MAAM,sCAAsC,OAAO,SAAS;AACtF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,aAAa,MAAM;AAAA,MACvB,kBAAkB,MAAM;AAAA,MACxB,OAAO;AAAA,MACP,OAAO,SAAS;AAAA,MAChB,OAAO,UAAU;AAAA,IACnB;AAEA,WAAO;AAAA,MACL,WAAW;AAAA,QACT,YAAY,kBAAkB,MAAM;AAAA,QACpC,OAAO,OAAO;AAAA,QACd,SAAS,OAAO,UAAU;AAAA,QAC1B,YAAY,QAAiC,UAAU,EAAE,IAAI,CAAC,eAAe;AAAA,UAC3E,aAAa,gBAAgB,UAAU,WAAW;AAAA,UAClD,eAAe,gBAAgB,UAAU,aAAa;AAAA,UACtD,WAAW,gBAAgB,UAAU,SAAS;AAAA,UAC9C,aAAa,gBAAgB,UAAU,WAAW;AAAA,UAClD,oBAAoB,SAAS,UAAU,kBAAkB;AAAA,QAC3D,EAAE;AAAA,MACJ,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,wBAAwB,KAAK,yCAAyC,CAAC;AAAA,EACtF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/profile-resolution.ts"],
|
|
4
|
-
"sourcesContent": ["import { object } from \"mcp-use/server\";\
|
|
4
|
+
"sourcesContent": ["import { object } from \"mcp-use/server\";\n\nimport { getProfile, listProfiles } from \"../../config/profile-store.js\";\n\nexport type MercadoLibreProfileSelectionReason =\n | \"missing_profile\"\n | \"profile_not_found\"\n | \"profile_inactive\";\n\nexport interface ResolvedMercadoLibreProfile {\n profileId: string;\n}\n\nfunction buildSelectionMessage(\n reason: MercadoLibreProfileSelectionReason,\n profileId?: string\n): string {\n switch (reason) {\n case \"missing_profile\":\n return \"MercadoLibre requiere seleccion explicita de profileId. Reenviar la misma tool con uno de los perfiles activos disponibles.\";\n case \"profile_not_found\":\n return `El profileId \"${profileId}\" no existe. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\n case \"profile_inactive\":\n return `El profileId \"${profileId}\" esta inactivo. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\n }\n}\n\nasync function buildSelectionResponse(\n reason: MercadoLibreProfileSelectionReason,\n profileId?: string\n) {\n const profiles = await listProfiles({ activeOnly: true });\n return object({\n selection_required: true,\n reason,\n message: buildSelectionMessage(reason, profileId),\n available_profiles: profiles.map((profile) => ({\n profile_id: profile.id,\n name: profile.name,\n })),\n });\n}\n\nexport async function resolveMercadoLibreProfileOrSelection(\n profileId?: string\n): Promise<\n | { ok: true; value: ResolvedMercadoLibreProfile }\n | { ok: false; response: ReturnType<typeof object<Record<string, unknown>>> }\n> {\n const requestedProfileId = profileId?.trim();\n\n if (!requestedProfileId) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"missing_profile\"),\n };\n }\n\n const profile = await getProfile(requestedProfileId);\n if (!profile) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"profile_not_found\", requestedProfileId),\n };\n }\n\n if (!profile.isActive) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"profile_inactive\", requestedProfileId),\n };\n }\n\n return {\n ok: true,\n value: {\n profileId: profile.id,\n },\n };\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,YAAY,oBAAoB;AAWzC,SAAS,sBACP,QACA,WACQ;AACR,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,iBAAiB,SAAS;AAAA,IACnC,KAAK;AACH,aAAO,iBAAiB,SAAS;AAAA,EACrC;AACF;AAEA,eAAe,uBACb,QACA,WACA;AACA,QAAM,WAAW,MAAM,aAAa,EAAE,YAAY,KAAK,CAAC;AACxD,SAAO,OAAO;AAAA,IACZ,oBAAoB;AAAA,IACpB;AAAA,IACA,SAAS,sBAAsB,QAAQ,SAAS;AAAA,IAChD,oBAAoB,SAAS,IAAI,CAAC,aAAa;AAAA,MAC7C,YAAY,QAAQ;AAAA,MACpB,MAAM,QAAQ;AAAA,IAChB,EAAE;AAAA,EACJ,CAAC;AACH;AAEA,eAAsB,sCACpB,WAIA;AACA,QAAM,qBAAqB,WAAW,KAAK;AAE3C,MAAI,CAAC,oBAAoB;AACvB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,iBAAiB;AAAA,IAC1D;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,WAAW,kBAAkB;AACnD,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,qBAAqB,kBAAkB;AAAA,IAChF;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,UAAU;AACrB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,oBAAoB,kBAAkB;AAAA,IAC/E;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,MACL,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,48 +1,167 @@
|
|
|
1
1
|
import { error, object } from "mcp-use/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getMercadoLibreAccessForProfile } from "../../config/mercadolibre.js";
|
|
4
|
-
import {
|
|
5
|
-
buildMercadoLibrePaginationMetadata,
|
|
6
|
-
formatMercadoLibreError,
|
|
7
|
-
normalizeMercadoLibrePaging
|
|
8
|
-
} from "../../services/mercadolibre/mercadolibre-api.js";
|
|
4
|
+
import { formatMercadoLibreError, normalizeMercadoLibrePaging } from "../../services/mercadolibre/mercadolibre-api.js";
|
|
9
5
|
import {
|
|
10
6
|
getMercadoLibreItemDetailsBatch,
|
|
11
|
-
|
|
7
|
+
getMercadoLibreItemDetailsWithFallbackBatch,
|
|
8
|
+
searchMercadoLibreItems,
|
|
9
|
+
searchMercadoLibreItemsBatch
|
|
12
10
|
} from "../../services/mercadolibre/mercadolibre-items.js";
|
|
13
11
|
import { stripNulls } from "../../utils/strip-payload.js";
|
|
14
|
-
import { asArray, normalizeString, toNumber } from "./helpers.js";
|
|
12
|
+
import { asArray, asRecord, normalizeString, toNumber } from "./helpers.js";
|
|
15
13
|
import { resolveMercadoLibreProfileOrSelection } from "./profile-resolution.js";
|
|
16
14
|
import { mercadolibreProfileIdSchemaField } from "./write-helpers.js";
|
|
15
|
+
const DEFAULT_STATUS = "active";
|
|
16
|
+
const SEARCH_PAGE_LIMIT = 50;
|
|
17
|
+
const DETAIL_BATCH_SIZE = 20;
|
|
18
|
+
const PAGE_FETCH_CONCURRENCY = 15;
|
|
19
|
+
const PAGE_FETCH_MAX_RETRIES = 2;
|
|
20
|
+
const AVAILABLE_STATUS_FILTERS = [
|
|
21
|
+
"active",
|
|
22
|
+
"paused",
|
|
23
|
+
"closed",
|
|
24
|
+
"under_review",
|
|
25
|
+
"inactive",
|
|
26
|
+
"not_yet_active",
|
|
27
|
+
"payment_required",
|
|
28
|
+
"deleted"
|
|
29
|
+
];
|
|
30
|
+
const itemsSchema = [
|
|
31
|
+
"item_id",
|
|
32
|
+
"title",
|
|
33
|
+
"status",
|
|
34
|
+
"price",
|
|
35
|
+
"currency_id",
|
|
36
|
+
"available_quantity",
|
|
37
|
+
"sold_quantity",
|
|
38
|
+
"listing_type_id",
|
|
39
|
+
"category_id"
|
|
40
|
+
];
|
|
17
41
|
const meliSearchItemsSchema = z.object({
|
|
18
42
|
profileId: mercadolibreProfileIdSchemaField,
|
|
19
|
-
status: z.string().trim().min(1).optional().describe("Optional item status filter."),
|
|
43
|
+
status: z.string().trim().min(1).optional().describe("Optional item status filter. Defaults to active when omitted."),
|
|
44
|
+
title: z.string().trim().min(1).optional().describe("Optional item title or text query. Maps to MercadoLibre q search."),
|
|
20
45
|
category: z.string().trim().min(1).optional().describe("Optional category id filter."),
|
|
21
46
|
listingTypeId: z.string().trim().min(1).optional().describe("Optional listing type filter."),
|
|
22
47
|
orders: z.string().trim().min(1).optional().describe("Optional MercadoLibre sort expression for items search."),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
offset: z.number().int().min(0).max(5e3).optional().describe("Pagination offset.")
|
|
48
|
+
limit: z.number().int().min(1).max(50).optional().describe("Optional maximum detailed items to return. If omitted, returns the full matching universe from offset onward."),
|
|
49
|
+
offset: z.number().int().min(0).max(5e3).optional().describe("Pagination offset over the matching MercadoLibre items universe.")
|
|
26
50
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
function formatCompactItem(item) {
|
|
52
|
+
return [
|
|
53
|
+
normalizeString(item.id),
|
|
54
|
+
normalizeString(item.title),
|
|
55
|
+
normalizeString(item.status),
|
|
56
|
+
toNumber(item.price),
|
|
57
|
+
normalizeString(item.currency_id, "UNKNOWN"),
|
|
58
|
+
toNumber(item.available_quantity),
|
|
59
|
+
toNumber(item.sold_quantity),
|
|
60
|
+
normalizeString(item.listing_type_id),
|
|
61
|
+
normalizeString(item.category_id)
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function buildItemsMetadata(params) {
|
|
65
|
+
const nextOffset = params.offset + params.returned;
|
|
66
|
+
const hasMore = nextOffset < params.total;
|
|
67
|
+
let continuation = "No more pages for this query.";
|
|
68
|
+
if (params.pagesFailed > 0 || params.detailFailures > 0) {
|
|
69
|
+
continuation = hasMore ? `Se recuper\xF3 cobertura parcial. Reintentar la misma tool con offset=${params.offset} y limit=${params.limitWasExplicit ? params.effectiveLimit : 50}. Luego continuar con offset=${nextOffset} si hace falta.` : "Se recuper\xF3 cobertura parcial. Reintentar la misma tool con los mismos filtros si hace falta completar la cobertura.";
|
|
70
|
+
} else if (params.limitWasExplicit && hasMore) {
|
|
71
|
+
continuation = `Para continuar trayendo items, volver a invocar meli_search_items con los mismos filtros, offset=${nextOffset} y limit=${params.effectiveLimit}. Repetir hasta has_more=false.`;
|
|
72
|
+
}
|
|
73
|
+
return stripNulls({
|
|
74
|
+
total: params.total,
|
|
75
|
+
limit: params.effectiveLimit,
|
|
76
|
+
offset: params.offset,
|
|
77
|
+
returned: params.returned,
|
|
78
|
+
has_more: params.limitWasExplicit ? hasMore || params.pagesFailed > 0 || params.detailFailures > 0 : params.pagesFailed > 0 || params.detailFailures > 0,
|
|
79
|
+
next_offset: params.limitWasExplicit && hasMore ? nextOffset : void 0,
|
|
80
|
+
continuation,
|
|
81
|
+
applied_status: params.appliedStatus,
|
|
82
|
+
default_status_notice: params.usedDefaultStatus ? "Solo se devolvieron publicaciones active por default. Tambi\xE9n se puede pedir status expl\xEDcito como paused, closed, under_review, inactive, not_yet_active, payment_required o deleted." : void 0,
|
|
83
|
+
available_status_filters: AVAILABLE_STATUS_FILTERS,
|
|
84
|
+
detail_coverage: {
|
|
85
|
+
detail_failures: params.detailFailures,
|
|
86
|
+
details_complete: params.detailFailures === 0
|
|
87
|
+
},
|
|
88
|
+
pages_requested: params.pagesRequested,
|
|
89
|
+
pages_succeeded: params.pagesSucceeded,
|
|
90
|
+
pages_failed: params.pagesFailed,
|
|
91
|
+
universe_fully_fetched: params.universeFullyFetched
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async function fetchAllMatchingItemIds(profileId, sellerId, params) {
|
|
95
|
+
const appliedStatus = params.status ?? DEFAULT_STATUS;
|
|
96
|
+
const firstResponse = await searchMercadoLibreItems(profileId, {
|
|
97
|
+
sellerId,
|
|
98
|
+
status: appliedStatus,
|
|
99
|
+
q: params.title,
|
|
100
|
+
category: params.category,
|
|
101
|
+
listingTypeId: params.listingTypeId,
|
|
102
|
+
orders: params.orders,
|
|
103
|
+
limit: SEARCH_PAGE_LIMIT,
|
|
104
|
+
offset: 0
|
|
105
|
+
});
|
|
106
|
+
const firstPaging = normalizeMercadoLibrePaging(asRecord(firstResponse.paging));
|
|
107
|
+
const total = firstPaging.total;
|
|
108
|
+
const effectiveLimit = firstPaging.limit || SEARCH_PAGE_LIMIT;
|
|
109
|
+
const ids = asArray(firstResponse.results).map((value) => normalizeString(value)).filter(Boolean);
|
|
110
|
+
const failedOffsets = [];
|
|
111
|
+
let pagesRequested = 1;
|
|
112
|
+
let pagesSucceeded = 1;
|
|
113
|
+
if (effectiveLimit > 0 && total > ids.length) {
|
|
114
|
+
const nextOffsets = [];
|
|
115
|
+
for (let nextOffset = effectiveLimit; nextOffset < total; nextOffset += effectiveLimit) {
|
|
116
|
+
nextOffsets.push(nextOffset);
|
|
32
117
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
118
|
+
pagesRequested += nextOffsets.length;
|
|
119
|
+
if (nextOffsets.length > 0) {
|
|
120
|
+
const batch = await searchMercadoLibreItemsBatch(
|
|
121
|
+
profileId,
|
|
122
|
+
{
|
|
123
|
+
sellerId,
|
|
124
|
+
status: appliedStatus,
|
|
125
|
+
q: params.title,
|
|
126
|
+
category: params.category,
|
|
127
|
+
listingTypeId: params.listingTypeId,
|
|
128
|
+
orders: params.orders,
|
|
129
|
+
limit: effectiveLimit
|
|
130
|
+
},
|
|
131
|
+
nextOffsets,
|
|
132
|
+
{
|
|
133
|
+
maxConcurrency: PAGE_FETCH_CONCURRENCY,
|
|
134
|
+
maxRetries: PAGE_FETCH_MAX_RETRIES
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
pagesSucceeded += batch.successful.length;
|
|
138
|
+
batch.successful.forEach((entry) => {
|
|
139
|
+
ids.push(...asArray(entry.document.results).map((value) => normalizeString(value)).filter(Boolean));
|
|
140
|
+
});
|
|
141
|
+
batch.failed.forEach((failure) => {
|
|
142
|
+
failedOffsets.push(Number(failure.id));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
ids,
|
|
148
|
+
total,
|
|
149
|
+
appliedStatus,
|
|
150
|
+
pagesRequested,
|
|
151
|
+
pagesSucceeded,
|
|
152
|
+
pagesFailed: failedOffsets.length,
|
|
153
|
+
universeFullyFetched: failedOffsets.length === 0 && ids.length >= total
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function fetchDetailedItems(profileId, itemIds) {
|
|
157
|
+
const details = {};
|
|
158
|
+
let detailFailures = 0;
|
|
159
|
+
for (let index = 0; index < itemIds.length; index += DETAIL_BATCH_SIZE) {
|
|
160
|
+
const chunk = itemIds.slice(index, index + DETAIL_BATCH_SIZE);
|
|
161
|
+
if (chunk.length === 0) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const batch = await getMercadoLibreItemDetailsBatch(profileId, chunk, [
|
|
46
165
|
"id",
|
|
47
166
|
"title",
|
|
48
167
|
"status",
|
|
@@ -51,33 +170,69 @@ async function meliSearchItemsHandler(params) {
|
|
|
51
170
|
"available_quantity",
|
|
52
171
|
"sold_quantity",
|
|
53
172
|
"listing_type_id",
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
173
|
+
"category_id"
|
|
174
|
+
]);
|
|
175
|
+
const foundIds = /* @__PURE__ */ new Set();
|
|
176
|
+
for (const item of batch) {
|
|
177
|
+
const itemId = normalizeString(item.id);
|
|
178
|
+
if (!itemId) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
foundIds.add(itemId);
|
|
182
|
+
details[itemId] = item;
|
|
183
|
+
}
|
|
184
|
+
const missingIds = chunk.filter((itemId) => !foundIds.has(itemId));
|
|
185
|
+
if (missingIds.length > 0) {
|
|
186
|
+
const fallback = await getMercadoLibreItemDetailsWithFallbackBatch(profileId, missingIds, {
|
|
187
|
+
maxConcurrency: 10,
|
|
188
|
+
maxRetries: 1
|
|
189
|
+
});
|
|
190
|
+
fallback.successful.forEach((entry) => {
|
|
191
|
+
details[entry.id] = entry.document;
|
|
192
|
+
});
|
|
193
|
+
detailFailures += fallback.failed.length;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
orderedItems: itemIds.map((itemId) => details[itemId]).filter(Boolean),
|
|
198
|
+
detailFailures
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async function meliSearchItemsHandler(params) {
|
|
202
|
+
try {
|
|
203
|
+
const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);
|
|
204
|
+
if (!profileResolution.ok) {
|
|
205
|
+
return profileResolution.response;
|
|
206
|
+
}
|
|
207
|
+
const profileId = profileResolution.value.profileId;
|
|
208
|
+
const access = await getMercadoLibreAccessForProfile(profileId);
|
|
209
|
+
const requestedOffset = params.offset ?? 0;
|
|
210
|
+
const limitWasExplicit = typeof params.limit === "number";
|
|
211
|
+
const usedDefaultStatus = !params.status;
|
|
212
|
+
const { ids, total, appliedStatus, pagesRequested, pagesSucceeded, pagesFailed, universeFullyFetched } = await fetchAllMatchingItemIds(profileId, access.sellerId, params);
|
|
213
|
+
const pageIds = limitWasExplicit ? ids.slice(requestedOffset, requestedOffset + (params.limit ?? 0)) : ids.slice(requestedOffset);
|
|
214
|
+
const effectiveLimit = limitWasExplicit ? params.limit ?? pageIds.length : Math.max(pageIds.length, 0);
|
|
215
|
+
const { orderedItems, detailFailures } = await fetchDetailedItems(profileId, pageIds);
|
|
216
|
+
const compactItems = orderedItems.map((item) => formatCompactItem(item));
|
|
58
217
|
return object(
|
|
59
218
|
stripNulls({
|
|
60
219
|
profile_id: profileId,
|
|
61
|
-
metadata:
|
|
62
|
-
total
|
|
63
|
-
|
|
64
|
-
offset:
|
|
65
|
-
returned:
|
|
66
|
-
|
|
220
|
+
metadata: buildItemsMetadata({
|
|
221
|
+
total,
|
|
222
|
+
effectiveLimit,
|
|
223
|
+
offset: requestedOffset,
|
|
224
|
+
returned: compactItems.length,
|
|
225
|
+
appliedStatus,
|
|
226
|
+
usedDefaultStatus,
|
|
227
|
+
detailFailures,
|
|
228
|
+
pagesRequested,
|
|
229
|
+
pagesSucceeded,
|
|
230
|
+
pagesFailed,
|
|
231
|
+
universeFullyFetched,
|
|
232
|
+
limitWasExplicit
|
|
67
233
|
}),
|
|
68
|
-
|
|
69
|
-
items: compactItems
|
|
70
|
-
item_id: normalizeString(item.id),
|
|
71
|
-
title: normalizeString(item.title),
|
|
72
|
-
status: normalizeString(item.status),
|
|
73
|
-
price: toNumber(item.price),
|
|
74
|
-
currency_id: normalizeString(item.currency_id, "UNKNOWN"),
|
|
75
|
-
available_quantity: toNumber(item.available_quantity),
|
|
76
|
-
sold_quantity: toNumber(item.sold_quantity),
|
|
77
|
-
listing_type_id: normalizeString(item.listing_type_id),
|
|
78
|
-
permalink: normalizeString(item.permalink),
|
|
79
|
-
thumbnail: normalizeString(item.thumbnail)
|
|
80
|
-
}))
|
|
234
|
+
items_schema: itemsSchema,
|
|
235
|
+
items: compactItems
|
|
81
236
|
})
|
|
82
237
|
);
|
|
83
238
|
} catch (err) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/search-items.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { getMercadoLibreAccessForProfile } from \"../../config/mercadolibre.js\";\r\nimport {\r\n buildMercadoLibrePaginationMetadata,\r\n formatMercadoLibreError,\r\n normalizeMercadoLibrePaging,\r\n} from \"../../services/mercadolibre/mercadolibre-api.js\";\r\nimport {\r\n getMercadoLibreItemDetailsBatch,\r\n searchMercadoLibreItems,\r\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { asArray, normalizeString, toNumber } from \"./helpers.js\";\r\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\r\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\r\n\r\nexport const meliSearchItemsSchema = z.object({\r\n profileId: mercadolibreProfileIdSchemaField,\r\n status: z.string().trim().min(1).optional().describe(\"Optional item status filter.\"),\r\n category: z.string().trim().min(1).optional().describe(\"Optional category id filter.\"),\r\n listingTypeId: z.string().trim().min(1).optional().describe(\"Optional listing type filter.\"),\r\n orders: z.string().trim().min(1).optional().describe(\"Optional MercadoLibre sort expression for items search.\"),\r\n includeDetails: z.boolean().optional().describe(\"Whether to multiget compact item details for returned item ids.\"),\r\n limit: z.number().int().min(1).max(50).optional().describe(\"Results per page (1-50).\"),\r\n offset: z.number().int().min(0).max(5000).optional().describe(\"Pagination offset.\"),\r\n});\r\n\r\nexport async function meliSearchItemsHandler(params: z.infer<typeof meliSearchItemsSchema>) {\r\n try {\r\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const profileId = profileResolution.value.profileId;\r\n const access = await getMercadoLibreAccessForProfile(profileId);\r\n const searchResponse = await searchMercadoLibreItems(profileId, {\r\n sellerId: access.sellerId,\r\n status: params.status,\r\n category: params.category,\r\n listingTypeId: params.listingTypeId,\r\n orders: params.orders,\r\n limit: params.limit ?? 20,\r\n offset: params.offset ?? 0,\r\n });\r\n\r\n const itemIds = asArray<string>(searchResponse.results).map((value) => normalizeString(value)).filter(Boolean);\r\n const compactItems = params.includeDetails\r\n ? await getMercadoLibreItemDetailsBatch(profileId, itemIds.slice(0, 20), [\r\n \"id\",\r\n \"title\",\r\n \"status\",\r\n \"price\",\r\n \"currency_id\",\r\n \"available_quantity\",\r\n \"sold_quantity\",\r\n \"listing_type_id\",\r\n \"permalink\",\r\n \"thumbnail\",\r\n ])\r\n : [];\r\n\r\n const paging = normalizeMercadoLibrePaging(searchResponse.paging as Record<string, unknown>);\r\n\r\n return object(\r\n stripNulls({\r\n profile_id: profileId,\r\n metadata: buildMercadoLibrePaginationMetadata({\r\n total: paging.total,\r\n limit: paging.limit || params.limit || itemIds.length,\r\n offset: paging.offset || params.offset || 0,\r\n returned: itemIds.length,\r\n nextField: \"offset\",\r\n }),\r\n item_ids: itemIds,\r\n items: compactItems.map((item) => ({\r\n item_id: normalizeString(item.id),\r\n title: normalizeString(item.title),\r\n status: normalizeString(item.status),\r\n price: toNumber(item.price),\r\n currency_id: normalizeString(item.currency_id, \"UNKNOWN\"),\r\n available_quantity: toNumber(item.available_quantity),\r\n sold_quantity: toNumber(item.sold_quantity),\r\n listing_type_id: normalizeString(item.listing_type_id),\r\n permalink: normalizeString(item.permalink),\r\n thumbnail: normalizeString(item.thumbnail),\r\n })),\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatMercadoLibreError(err, \"Failed to search MercadoLibre items\"));\r\n }\r\n}\r\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uCAAuC;AAChD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { getMercadoLibreAccessForProfile } from \"../../config/mercadolibre.js\";\nimport { formatMercadoLibreError, normalizeMercadoLibrePaging } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport {\n getMercadoLibreItemDetailsBatch,\n getMercadoLibreItemDetailsWithFallbackBatch,\n searchMercadoLibreItems,\n searchMercadoLibreItemsBatch,\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { asArray, asRecord, normalizeString, toNumber } from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nconst DEFAULT_STATUS = \"active\";\nconst SEARCH_PAGE_LIMIT = 50;\nconst DETAIL_BATCH_SIZE = 20;\nconst PAGE_FETCH_CONCURRENCY = 15;\nconst PAGE_FETCH_MAX_RETRIES = 2;\nconst AVAILABLE_STATUS_FILTERS = [\n \"active\",\n \"paused\",\n \"closed\",\n \"under_review\",\n \"inactive\",\n \"not_yet_active\",\n \"payment_required\",\n \"deleted\",\n];\n\nconst itemsSchema = [\n \"item_id\",\n \"title\",\n \"status\",\n \"price\",\n \"currency_id\",\n \"available_quantity\",\n \"sold_quantity\",\n \"listing_type_id\",\n \"category_id\",\n] as const;\n\nexport const meliSearchItemsSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n status: z.string().trim().min(1).optional().describe(\"Optional item status filter. Defaults to active when omitted.\"),\n title: z.string().trim().min(1).optional().describe(\"Optional item title or text query. Maps to MercadoLibre q search.\"),\n category: z.string().trim().min(1).optional().describe(\"Optional category id filter.\"),\n listingTypeId: z.string().trim().min(1).optional().describe(\"Optional listing type filter.\"),\n orders: z.string().trim().min(1).optional().describe(\"Optional MercadoLibre sort expression for items search.\"),\n limit: z.number().int().min(1).max(50).optional().describe(\"Optional maximum detailed items to return. If omitted, returns the full matching universe from offset onward.\"),\n offset: z.number().int().min(0).max(5000).optional().describe(\"Pagination offset over the matching MercadoLibre items universe.\"),\n});\n\nfunction formatCompactItem(item: Record<string, unknown>) {\n return [\n normalizeString(item.id),\n normalizeString(item.title),\n normalizeString(item.status),\n toNumber(item.price),\n normalizeString(item.currency_id, \"UNKNOWN\"),\n toNumber(item.available_quantity),\n toNumber(item.sold_quantity),\n normalizeString(item.listing_type_id),\n normalizeString(item.category_id),\n ];\n}\n\nfunction buildItemsMetadata(params: {\n total: number;\n effectiveLimit: number;\n offset: number;\n returned: number;\n appliedStatus: string;\n usedDefaultStatus: boolean;\n detailFailures: number;\n pagesRequested: number;\n pagesSucceeded: number;\n pagesFailed: number;\n universeFullyFetched: boolean;\n limitWasExplicit: boolean;\n}) {\n const nextOffset = params.offset + params.returned;\n const hasMore = nextOffset < params.total;\n\n let continuation = \"No more pages for this query.\";\n if (params.pagesFailed > 0 || params.detailFailures > 0) {\n continuation = hasMore\n ? `Se recuper\u00F3 cobertura parcial. Reintentar la misma tool con offset=${params.offset} y limit=${params.limitWasExplicit ? params.effectiveLimit : 50}. Luego continuar con offset=${nextOffset} si hace falta.`\n : \"Se recuper\u00F3 cobertura parcial. Reintentar la misma tool con los mismos filtros si hace falta completar la cobertura.\";\n } else if (params.limitWasExplicit && hasMore) {\n continuation = `Para continuar trayendo items, volver a invocar meli_search_items con los mismos filtros, offset=${nextOffset} y limit=${params.effectiveLimit}. Repetir hasta has_more=false.`;\n }\n\n return stripNulls({\n total: params.total,\n limit: params.effectiveLimit,\n offset: params.offset,\n returned: params.returned,\n has_more: params.limitWasExplicit ? hasMore || params.pagesFailed > 0 || params.detailFailures > 0 : params.pagesFailed > 0 || params.detailFailures > 0,\n next_offset: params.limitWasExplicit && hasMore ? nextOffset : undefined,\n continuation,\n applied_status: params.appliedStatus,\n default_status_notice: params.usedDefaultStatus\n ? 'Solo se devolvieron publicaciones active por default. Tambi\u00E9n se puede pedir status expl\u00EDcito como paused, closed, under_review, inactive, not_yet_active, payment_required o deleted.'\n : undefined,\n available_status_filters: AVAILABLE_STATUS_FILTERS,\n detail_coverage: {\n detail_failures: params.detailFailures,\n details_complete: params.detailFailures === 0,\n },\n pages_requested: params.pagesRequested,\n pages_succeeded: params.pagesSucceeded,\n pages_failed: params.pagesFailed,\n universe_fully_fetched: params.universeFullyFetched,\n });\n}\n\nasync function fetchAllMatchingItemIds(profileId: string, sellerId: string, params: z.infer<typeof meliSearchItemsSchema>) {\n const appliedStatus = params.status ?? DEFAULT_STATUS;\n const firstResponse = await searchMercadoLibreItems(profileId, {\n sellerId,\n status: appliedStatus,\n q: params.title,\n category: params.category,\n listingTypeId: params.listingTypeId,\n orders: params.orders,\n limit: SEARCH_PAGE_LIMIT,\n offset: 0,\n });\n\n const firstPaging = normalizeMercadoLibrePaging(asRecord(firstResponse.paging));\n const total = firstPaging.total;\n const effectiveLimit = firstPaging.limit || SEARCH_PAGE_LIMIT;\n const ids = asArray<string>(firstResponse.results).map((value) => normalizeString(value)).filter(Boolean);\n const failedOffsets: number[] = [];\n let pagesRequested = 1;\n let pagesSucceeded = 1;\n\n if (effectiveLimit > 0 && total > ids.length) {\n const nextOffsets: number[] = [];\n for (let nextOffset = effectiveLimit; nextOffset < total; nextOffset += effectiveLimit) {\n nextOffsets.push(nextOffset);\n }\n\n pagesRequested += nextOffsets.length;\n\n if (nextOffsets.length > 0) {\n const batch = await searchMercadoLibreItemsBatch(\n profileId,\n {\n sellerId,\n status: appliedStatus,\n q: params.title,\n category: params.category,\n listingTypeId: params.listingTypeId,\n orders: params.orders,\n limit: effectiveLimit,\n },\n nextOffsets,\n {\n maxConcurrency: PAGE_FETCH_CONCURRENCY,\n maxRetries: PAGE_FETCH_MAX_RETRIES,\n }\n );\n\n pagesSucceeded += batch.successful.length;\n batch.successful.forEach((entry) => {\n ids.push(...asArray<string>(entry.document.results).map((value) => normalizeString(value)).filter(Boolean));\n });\n batch.failed.forEach((failure) => {\n failedOffsets.push(Number(failure.id));\n });\n }\n }\n\n return {\n ids,\n total,\n appliedStatus,\n pagesRequested,\n pagesSucceeded,\n pagesFailed: failedOffsets.length,\n universeFullyFetched: failedOffsets.length === 0 && ids.length >= total,\n };\n}\n\nasync function fetchDetailedItems(profileId: string, itemIds: string[]) {\n const details: Record<string, Record<string, unknown>> = {};\n let detailFailures = 0;\n\n for (let index = 0; index < itemIds.length; index += DETAIL_BATCH_SIZE) {\n const chunk = itemIds.slice(index, index + DETAIL_BATCH_SIZE);\n if (chunk.length === 0) {\n continue;\n }\n\n const batch = await getMercadoLibreItemDetailsBatch(profileId, chunk, [\n \"id\",\n \"title\",\n \"status\",\n \"price\",\n \"currency_id\",\n \"available_quantity\",\n \"sold_quantity\",\n \"listing_type_id\",\n \"category_id\",\n ]);\n\n const foundIds = new Set<string>();\n for (const item of batch) {\n const itemId = normalizeString(item.id);\n if (!itemId) {\n continue;\n }\n foundIds.add(itemId);\n details[itemId] = item;\n }\n\n const missingIds = chunk.filter((itemId) => !foundIds.has(itemId));\n if (missingIds.length > 0) {\n const fallback = await getMercadoLibreItemDetailsWithFallbackBatch(profileId, missingIds, {\n maxConcurrency: 10,\n maxRetries: 1,\n });\n fallback.successful.forEach((entry) => {\n details[entry.id] = entry.document;\n });\n detailFailures += fallback.failed.length;\n }\n }\n\n return {\n orderedItems: itemIds.map((itemId) => details[itemId]).filter(Boolean),\n detailFailures,\n };\n}\n\nexport async function meliSearchItemsHandler(params: z.infer<typeof meliSearchItemsSchema>) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const access = await getMercadoLibreAccessForProfile(profileId);\n const requestedOffset = params.offset ?? 0;\n const limitWasExplicit = typeof params.limit === \"number\";\n const usedDefaultStatus = !params.status;\n\n const { ids, total, appliedStatus, pagesRequested, pagesSucceeded, pagesFailed, universeFullyFetched } = await fetchAllMatchingItemIds(profileId, access.sellerId, params);\n\n const pageIds = limitWasExplicit\n ? ids.slice(requestedOffset, requestedOffset + (params.limit ?? 0))\n : ids.slice(requestedOffset);\n const effectiveLimit = limitWasExplicit ? params.limit ?? pageIds.length : Math.max(pageIds.length, 0);\n\n const { orderedItems, detailFailures } = await fetchDetailedItems(profileId, pageIds);\n const compactItems = orderedItems.map((item) => formatCompactItem(item));\n\n return object(\n stripNulls({\n profile_id: profileId,\n metadata: buildItemsMetadata({\n total,\n effectiveLimit,\n offset: requestedOffset,\n returned: compactItems.length,\n appliedStatus,\n usedDefaultStatus,\n detailFailures,\n pagesRequested,\n pagesSucceeded,\n pagesFailed,\n universeFullyFetched,\n limitWasExplicit,\n }),\n items_schema: itemsSchema,\n items: compactItems,\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to search MercadoLibre items\"));\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uCAAuC;AAChD,SAAS,yBAAyB,mCAAmC;AACrE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,SAAS,UAAU,iBAAiB,gBAAgB;AAC7D,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAEjD,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;AAC/B,MAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,cAAc;AA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A,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,gCAAgC,SAAS;AAC9D,UAAM,kBAAkB,OAAO,UAAU;AACzC,UAAM,mBAAmB,OAAO,OAAO,UAAU;AACjD,UAAM,oBAAoB,CAAC,OAAO;AAElC,UAAM,EAAE,KAAK,OAAO,eAAe,gBAAgB,gBAAgB,aAAa,qBAAqB,IAAI,MAAM,wBAAwB,WAAW,OAAO,UAAU,MAAM;AAEzK,UAAM,UAAU,mBACZ,IAAI,MAAM,iBAAiB,mBAAmB,OAAO,SAAS,EAAE,IAChE,IAAI,MAAM,eAAe;AAC7B,UAAM,iBAAiB,mBAAmB,OAAO,SAAS,QAAQ,SAAS,KAAK,IAAI,QAAQ,QAAQ,CAAC;AAErG,UAAM,EAAE,cAAc,eAAe,IAAI,MAAM,mBAAmB,WAAW,OAAO;AACpF,UAAM,eAAe,aAAa,IAAI,CAAC,SAAS,kBAAkB,IAAI,CAAC;AAEvE,WAAO;AAAA,MACL,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,UAAU,mBAAmB;AAAA,UAC3B;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR,UAAU,aAAa;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD,cAAc;AAAA,QACd,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,wBAAwB,KAAK,qCAAqC,CAAC;AAAA,EAClF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/search-questions.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { getMercadoLibreAccessForProfile } from \"../../config/mercadolibre.js\";\nimport {\n buildMercadoLibrePaginationMetadata,\n formatMercadoLibreError,\n normalizeMercadoLibrePaging,\n} from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { searchMercadoLibreQuestions } from \"../../services/mercadolibre/mercadolibre-questions.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { asArray, asRecord, compactDateTime, normalizeString } from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nexport const meliSearchQuestionsSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n itemId: z.string().trim().min(1).optional().describe(\"Optional MercadoLibre item id filter.\"),\n status: z.string().trim().min(1).optional().describe(\"Optional question status filter.\"),\n limit: z.number().int().min(1).max(50).optional().describe(\"Results per page (1-50).\"),\n offset: z.number().int().min(0).max(5000).optional().describe(\"Pagination offset.\"),\n});\n\nexport async function meliSearchQuestionsHandler(\n params: z.infer<typeof meliSearchQuestionsSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const access = await getMercadoLibreAccessForProfile(profileId);\n const response = await searchMercadoLibreQuestions(profileId, {\n sellerId: access.sellerId,\n itemId: params.itemId,\n status: params.status,\n limit: params.limit ?? 20,\n offset: params.offset ?? 0,\n });\n\n const questions = asArray<Record<string, unknown>>(response.questions ?? response.results);\n const paging = normalizeMercadoLibrePaging(asRecord(response.paging));\n\n return object(\n stripNulls({\n profile_id: profileId,\n metadata: buildMercadoLibrePaginationMetadata({\n total: paging.total || questions.length,\n limit: paging.limit || params.limit || questions.length,\n offset: paging.offset || params.offset || 0,\n returned: questions.length,\n nextField: \"offset\",\n }),\n questions: questions.map((question) => ({\n question_id: question.id,\n item_id: normalizeString(question.item_id),\n item_title: normalizeString(asRecord(question.item).title),\n status: normalizeString(question.status),\n text: normalizeString(question.text),\n date_created: compactDateTime(question.date_created),\n from: stripNulls({\n id: normalizeString(asRecord(question.from).id),\n nickname: normalizeString(asRecord(question.from).nickname),\n }),\n answer_status: normalizeString(asRecord(question.answer).status),\n })),\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to search MercadoLibre questions\"));\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uCAAuC;AAChD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mCAAmC;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,SAAS,UAAU,iBAAiB,uBAAuB;AACpE,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAE1C,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EAC5F,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,kCAAkC;AAAA,EACvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,0BAA0B;AAAA,EACrF,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAI,EAAE,SAAS,EAAE,SAAS,oBAAoB;AACpF,CAAC;AAED,eAAsB,2BACpB,QACA;AACA,MAAI;AACF,UAAM,oBAAoB,MAAM,sCAAsC,OAAO,SAAS;AACtF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,gCAAgC,SAAS;AAC9D,UAAM,WAAW,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{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/update-item-basic-fields.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getMercadoLibreItem,\n updateMercadoLibreItem,\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport {\n buildMercadoLibreWriteSuccessResponse,\n handleMercadoLibreWriteError,\n mercadolibreProfileIdSchemaField,\n resolveMercadoLibreWriteProfile,\n} from \"./write-helpers.js\";\n\nconst attributeSchema = z.object({\n id: z.string().trim().min(1).describe(\"MercadoLibre attribute id.\"),\n value_name: z.string().trim().min(1).optional().describe(\"Human-readable attribute value.\"),\n value_id: z.string().trim().min(1).optional().describe(\"MercadoLibre attribute value id when known.\"),\n});\n\nexport const meliUpdateItemBasicFieldsSchema = z\n .object({\n profileId: mercadolibreProfileIdSchemaField,\n itemId: z.string().trim().min(1).describe(\"MercadoLibre item id.\"),\n title: z.string().trim().min(3).optional().describe(\"New listing title.\"),\n price: z.number().positive().optional().describe(\"New listing price.\"),\n availableQuantity: z.number().int().min(0).optional().describe(\"New available quantity.\"),\n attributes: z.array(attributeSchema).optional().describe(\"Updated attributes array.\"),\n saleTerms: z.array(z.record(z.string(), z.unknown())).optional().describe(\"Updated sale terms array.\"),\n shipping: z.record(z.string(), z.unknown()).optional().describe(\"Updated shipping payload.\"),\n status: z.enum([\"active\", \"paused\", \"closed\", \"under_review\"]).optional().describe(\"New listing status.\"),\n listingTypeId: z.string().trim().min(1).optional().describe(\"Optional new listing type id if supported by MercadoLibre for the item.\"),\n channels: z.array(z.string().trim().min(1)).optional().describe(\"Optional replacement channels array if supported.\"),\n })\n .refine(\n (value) =>\n value.title !== undefined ||\n value.price !== undefined ||\n value.availableQuantity !== undefined ||\n value.attributes !== undefined ||\n value.saleTerms !== undefined ||\n value.shipping !== undefined ||\n value.status !== undefined ||\n value.listingTypeId !== undefined ||\n value.channels !== undefined,\n {\n message: \"At least one item field must be provided.\",\n path: [\"title\"],\n }\n );\n\nexport async function meliUpdateItemBasicFieldsHandler(\n params: z.infer<typeof meliUpdateItemBasicFieldsSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreWriteProfile(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const before = await getMercadoLibreItem(profileId, params.itemId);\n const after = await updateMercadoLibreItem(profileId, params.itemId, {\n title: params.title,\n price: params.price,\n available_quantity: params.availableQuantity,\n attributes: params.attributes,\n sale_terms: params.saleTerms,\n shipping: params.shipping,\n status: params.status,\n listing_type_id: params.listingTypeId,\n channels: params.channels,\n });\n\n return buildMercadoLibreWriteSuccessResponse({\n profileId,\n operation: \"update_item_basic_fields\",\n resourceId: params.itemId,\n message: \"MercadoLibre item updated successfully.\",\n before,\n after,\n });\n } catch (err) {\n return handleMercadoLibreWriteError(err, `Failed to update MercadoLibre item ${params.itemId}`);\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,4BAA4B;AAAA,EAClE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,iCAAiC;AAAA,EAC1F,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,6CAA6C;AACtG,CAAC;AAEM,MAAM,kCAAkC,EAC5C,OAAO;AAAA,EACN,WAAW;AAAA,EACX,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EACjE,OAAO,EAAE,OAAO,E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AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,oBAAoB,WAAW,OAAO,MAAM;AACjE,UAAM,QAAQ,MAAM,uBAAuB,WAAW,OAAO,QAAQ;AAAA,MACnE,OAAO,OAAO;AAAA,MACd,OAAO,OAAO;AAAA,MACd,oBAAoB,OAAO;AAAA,MAC3B,YAAY,OAAO;AAAA,MACnB,YAAY,OAAO;AAAA,MACnB,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,MACf,iBAAiB,OAAO;AAAA,MACxB,UAAU,OAAO;AAAA,IACnB,CAAC;AAED,WAAO,sCAAsC;AAAA,MAC3C;AAAA,MACA,WAAW;AAAA,MACX,YAAY,OAAO;AAAA,MACnB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,6BAA6B,KAAK,sCAAsC,OAAO,MAAM,EAAE;AAAA,EAChG;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/update-item-description.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n createMercadoLibreItemDescription,\n getMercadoLibreItemDescription,\n replaceMercadoLibreItemDescription,\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport {\n buildMercadoLibreWriteSuccessResponse,\n handleMercadoLibreWriteError,\n mercadolibreProfileIdSchemaField,\n resolveMercadoLibreWriteProfile,\n} from \"./write-helpers.js\";\n\nexport const meliUpdateItemDescriptionSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n itemId: z.string().trim().min(1).describe(\"MercadoLibre item id.\"),\n plainText: z.string().trim().min(1).describe(\"Plain-text description to publish.\"),\n});\n\nexport async function meliUpdateItemDescriptionHandler(\n params: z.infer<typeof meliUpdateItemDescriptionSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreWriteProfile(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n let before: Record<string, unknown> | null = null;\n let after: Record<string, unknown>;\n\n try {\n before = await getMercadoLibreItemDescription(profileId, params.itemId);\n after = await replaceMercadoLibreItemDescription(profileId, params.itemId, params.plainText);\n } catch {\n after = await createMercadoLibreItemDescription(profileId, params.itemId, params.plainText);\n }\n\n return buildMercadoLibreWriteSuccessResponse({\n profileId,\n operation: \"update_item_description\",\n resourceId: params.itemId,\n message: \"MercadoLibre item description updated successfully.\",\n before,\n after,\n });\n } catch (err) {\n return handleMercadoLibreWriteError(err, `Failed to update description for ${params.itemId}`);\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,kCAAkC,EAAE,OAAO;AAAA,EACtD,WAAW;AAAA,EACX,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EACjE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,oCAAoC;AACnF,CAAC;AAED,eAAsB,iCACpB,QACA;AACA,MAAI;AACF,UAAM,oBAAoB,MAAM,gCAAgC,OAAO,SAAS;AAChF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,QAAI,SAAyC;AAC7C,QAAI;AAEJ,QAAI;AACF,eAAS,MAAM,+BAA+B,WAAW,OAAO,MAAM;AACtE,cAAQ,MAAM,mCAAmC,WAAW,OAAO,QAAQ,OAAO,SAAS;AAAA,IAC7F,QAAQ;AACN,cAAQ,MAAM,kCAAkC,WAAW,OAAO,QAAQ,OAAO,SAAS;AAAA,IAC5F;AAEA,WAAO,sCAAsC;AAAA,MAC3C;AAAA,MACA,WAAW;AAAA,MACX,YAAY,OAAO;AAAA,MACnB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,6BAA6B,KAAK,oCAAoC,OAAO,MAAM,EAAE;AAAA,EAC9F;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/update-item-pictures.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n addMercadoLibreItemPicture,\n getMercadoLibreItem,\n updateMercadoLibreItem,\n} from \"../../services/mercadolibre/mercadolibre-items.js\";\nimport {\n buildMercadoLibreWriteSuccessResponse,\n handleMercadoLibreWriteError,\n mercadolibreProfileIdSchemaField,\n resolveMercadoLibreWriteProfile,\n} from \"./write-helpers.js\";\n\nexport const meliUpdateItemPicturesSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n itemId: z.string().trim().min(1).describe(\"MercadoLibre item id.\"),\n mode: z.enum([\"add\", \"replace\"]).describe(\"Whether to add new pictures or replace the full pictures array.\"),\n pictures: z\n .array(z.object({ source: z.string().trim().url().describe(\"Public image URL.\") }))\n .min(1)\n .max(12)\n .describe(\"One or more public image URLs to attach.\"),\n});\n\nexport async function meliUpdateItemPicturesHandler(\n params: z.infer<typeof meliUpdateItemPicturesSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreWriteProfile(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const before = await getMercadoLibreItem(profileId, params.itemId);\n\n let after: Record<string, unknown>;\n if (params.mode === \"replace\") {\n after = await updateMercadoLibreItem(profileId, params.itemId, {\n pictures: params.pictures,\n });\n } else {\n for (const picture of params.pictures) {\n await addMercadoLibreItemPicture(profileId, params.itemId, picture.source);\n }\n after = await getMercadoLibreItem(profileId, params.itemId);\n }\n\n return buildMercadoLibreWriteSuccessResponse({\n profileId,\n operation: \"update_item_pictures\",\n resourceId: params.itemId,\n message: `MercadoLibre item pictures ${params.mode === \"replace\" ? \"replaced\" : \"updated\"} successfully.`,\n before,\n after,\n details: {\n mode: params.mode,\n pictures_count: params.pictures.length,\n },\n });\n } catch (err) {\n return handleMercadoLibreWriteError(err, `Failed to update pictures for ${params.itemId}`);\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,+BAA+B,EAAE,OAAO;AAAA,EACnD,WAAW;AAAA,EACX,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EACjE,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,CAAC,EAAE,SAAS,iEAAiE;AAAA,EAC3G,UAAU,EACP,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,mBAAmB,EAAE,CAAC,CAAC,EACjF,IAAI,CAAC,EACL,IAAI,EAAE,EACN,SAAS,0CAA0C;AACxD,CAAC;AAED,eAAsB,8BACpB,QACA;AACA,MAAI;AACF,UAAM,oBAAoB,MAAM,gCAAgC,OAAO,SAAS;AAChF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,oBAAoB,WAAW,OAAO,MAAM;AAEjE,QAAI;AACJ,QAAI,OAAO,SAAS,WAAW;AAC7B,cAAQ,MAAM,uBAAuB,WAAW,OAAO,QAAQ;AAAA,QAC7D,UAAU,OAAO;AAAA,MACnB,CAAC;AAAA,IACH,OAAO;AACL,iBAAW,WAAW,OAAO,UAAU;AACrC,cAAM,2BAA2B,WAAW,OAAO,QAAQ,QAAQ,MAAM;AAAA,MAC3E;AACA,cAAQ,MAAM,oBAAoB,WAAW,OAAO,MAAM;AAAA,IAC5D;AAEA,WAAO,sCAAsC;AAAA,MAC3C;AAAA,MACA,WAAW;AAAA,MACX,YAAY,OAAO;AAAA,MACnB,SAAS,8BAA8B,OAAO,SAAS,YAAY,aAAa,SAAS;AAAA,MACzF;AAAA,MACA;AAAA,MACA,SAAS;AAAA,QACP,MAAM,OAAO;AAAA,QACb,gBAAgB,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,6BAA6B,KAAK,iCAAiC,OAAO,MAAM,EAAE;AAAA,EAC3F;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/validate-connection.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { getMercadoLibreConnectionRow } from \"../../config/mercadolibre-profile-store.js\";\nimport { getMercadoLibreAccessForProfile } from \"../../config/mercadolibre.js\";\nimport { getMercadoLibreUsersMe, formatMercadoLibreError } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nexport const meliValidateConnectionSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n});\n\nexport async function meliValidateConnectionHandler(\n params: z.infer<typeof meliValidateConnectionSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const before = await getMercadoLibreConnectionRow(profileId);\n const access = await getMercadoLibreAccessForProfile(profileId);\n const account = await getMercadoLibreUsersMe(profileId);\n const after = await getMercadoLibreConnectionRow(profileId);\n\n const refreshed =\n before?.expiresAt?.toISOString() !== after?.expiresAt?.toISOString() ||\n before?.encryptedAccessToken !== after?.encryptedAccessToken;\n\n return object(\n stripNulls({\n profile_id: profileId,\n validation_status: after?.status ?? \"active\",\n refreshed,\n seller_id: access.sellerId,\n account_id: account.id,\n nickname: account.nickname,\n expires_at: access.expiresAt,\n scopes: access.scopes,\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to validate MercadoLibre connection\"));\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,oCAAoC;AAC7C,SAAS,uCAAuC;AAChD,SAAS,wBAAwB,+BAA+B;AAChE,SAAS,kBAAkB;AAC3B,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAE1C,MAAM,+BAA+B,EAAE,OAAO;AAAA,EACnD,WAAW;AACb,CAAC;AAED,eAAsB,8BACpB,QACA;AACA,MAAI;AACF,UAAM,oBAAoB,MAAM,sCAAsC,OAAO,SAAS;AACtF,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,YAAY,kBAAkB,MAAM;AAC1C,UAAM,SAAS,MAAM,6BAA6B,SAAS;AAC3D,UAAM,SAAS,MAAM,gCAAgC,SAAS;AAC9D,UAAM,UAAU,MAAM,uBAAuB,SAAS;AACtD,UAAM,QAAQ,MAAM,6BAA6B,SAAS;AAE1D,UAAM,YACJ,QAAQ,WAAW,YAAY,MAAM,OAAO,WAAW,YAAY,KACnE,QAAQ,yBAAyB,OAAO;AAE1C,WAAO;AAAA,MACL,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,mBAAmB,OAAO,UAAU;AAAA,QACpC;AAAA,QACA,WAAW,OAAO;AAAA,QAClB,YAAY,QAAQ;AAAA,QACpB,UAAU,QAAQ;AAAA,QAClB,YAAY,OAAO;AAAA,QACnB,QAAQ,OAAO;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,wBAAwB,KAAK,4CAA4C,CAAC;AAAA,EACzF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/mercadolibre/write-helpers.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatMercadoLibreError } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const mercadolibreProfileIdSchemaField = z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit MercadoLibre profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n );\n\nexport async function resolveMercadoLibreWriteProfile(profileId?: string) {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution;\n }\n\n return {\n ok: true as const,\n value: {\n profileId: profileResolution.value.profileId,\n },\n };\n}\n\nexport function buildMercadoLibreWriteSuccessResponse(params: {\n profileId: string;\n operation: string;\n resourceId?: string;\n message: string;\n before?: Record<string, unknown> | null;\n after?: Record<string, unknown> | null;\n details?: Record<string, unknown>;\n}) {\n return object(\n stripNulls({\n ok: true,\n profile_id: params.profileId,\n operation: params.operation,\n resource_id: params.resourceId,\n message: params.message,\n summary: {\n before: params.before,\n after: params.after,\n },\n details: params.details,\n })\n );\n}\n\nexport function handleMercadoLibreWriteError(err: unknown, fallback: string) {\n return error(formatMercadoLibreError(err, fallback));\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,+BAA+B;AACxC,SAAS,kBAAkB;AAC3B,SAAS,6CAA6C;AAE/C,MAAM,mCAAmC,EAC7C,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,EACC;AACF;AAEF,eAAsB,gCAAgC,WAAoB;AACxE,QAAM,oBAAoB,MAAM,sCAAsC,SAAS;AAC/E,MAAI,CAAC,kBAAkB,IAAI;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,MACL,WAAW,kBAAkB,MAAM;AAAA,IACrC;AAAA,EACF;AACF;AAEO,SAAS,sCAAsC,QAQnD;AACD,SAAO;AAAA,IACL,WAAW;AAAA,MACT,IAAI;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,WAAW,OAAO;AAAA,MAClB,aAAa,OAAO;AAAA,MACpB,SAAS,OAAO;AAAA,MAChB,SAAS;AAAA,QACP,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,SAAS,OAAO;AAAA,IAClB,CAAC;AAAA,EACH;AACF;AAEO,SAAS,6BAA6B,KAAc,UAAkB;AAC3E,SAAO,MAAM,wBAAwB,KAAK,QAAQ,CAAC;AACrD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|