ebay-mcp 1.4.3

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.
Files changed (205) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +586 -0
  3. package/build/api/account-management/account.d.ts +216 -0
  4. package/build/api/account-management/account.js +305 -0
  5. package/build/api/analytics-and-report/analytics.d.ts +33 -0
  6. package/build/api/analytics-and-report/analytics.js +102 -0
  7. package/build/api/client.d.ts +89 -0
  8. package/build/api/client.js +343 -0
  9. package/build/api/communication/feedback.d.ts +45 -0
  10. package/build/api/communication/feedback.js +119 -0
  11. package/build/api/communication/message.d.ts +55 -0
  12. package/build/api/communication/message.js +131 -0
  13. package/build/api/communication/negotiation.d.ts +39 -0
  14. package/build/api/communication/negotiation.js +97 -0
  15. package/build/api/communication/notification.d.ts +128 -0
  16. package/build/api/communication/notification.js +373 -0
  17. package/build/api/index.d.ts +96 -0
  18. package/build/api/index.js +121 -0
  19. package/build/api/listing-management/inventory.d.ts +216 -0
  20. package/build/api/listing-management/inventory.js +633 -0
  21. package/build/api/listing-metadata/metadata.d.ts +154 -0
  22. package/build/api/listing-metadata/metadata.js +485 -0
  23. package/build/api/listing-metadata/taxonomy.d.ts +38 -0
  24. package/build/api/listing-metadata/taxonomy.js +58 -0
  25. package/build/api/marketing-and-promotions/marketing.d.ts +395 -0
  26. package/build/api/marketing-and-promotions/marketing.js +565 -0
  27. package/build/api/marketing-and-promotions/recommendation.d.ts +20 -0
  28. package/build/api/marketing-and-promotions/recommendation.js +32 -0
  29. package/build/api/order-management/dispute.d.ts +65 -0
  30. package/build/api/order-management/dispute.js +69 -0
  31. package/build/api/order-management/fulfillment.d.ts +80 -0
  32. package/build/api/order-management/fulfillment.js +89 -0
  33. package/build/api/other/compliance.d.ts +26 -0
  34. package/build/api/other/compliance.js +47 -0
  35. package/build/api/other/edelivery.d.ts +153 -0
  36. package/build/api/other/edelivery.js +219 -0
  37. package/build/api/other/identity.d.ts +17 -0
  38. package/build/api/other/identity.js +24 -0
  39. package/build/api/other/translation.d.ts +14 -0
  40. package/build/api/other/translation.js +22 -0
  41. package/build/api/other/vero.d.ts +30 -0
  42. package/build/api/other/vero.js +48 -0
  43. package/build/auth/oauth-metadata.d.ts +46 -0
  44. package/build/auth/oauth-metadata.js +59 -0
  45. package/build/auth/oauth-middleware.d.ts +35 -0
  46. package/build/auth/oauth-middleware.js +99 -0
  47. package/build/auth/oauth-types.d.ts +66 -0
  48. package/build/auth/oauth-types.js +4 -0
  49. package/build/auth/oauth.d.ts +93 -0
  50. package/build/auth/oauth.js +383 -0
  51. package/build/auth/scope-utils.d.ts +70 -0
  52. package/build/auth/scope-utils.js +304 -0
  53. package/build/auth/token-verifier.d.ts +57 -0
  54. package/build/auth/token-verifier.js +172 -0
  55. package/build/config/environment.d.ts +61 -0
  56. package/build/config/environment.js +260 -0
  57. package/build/index.d.ts +1 -0
  58. package/build/index.js +98 -0
  59. package/build/schemas/account-management/account.d.ts +5324 -0
  60. package/build/schemas/account-management/account.js +366 -0
  61. package/build/schemas/analytics/analytics.d.ts +167 -0
  62. package/build/schemas/analytics/analytics.js +191 -0
  63. package/build/schemas/communication/messages.d.ts +1872 -0
  64. package/build/schemas/communication/messages.js +348 -0
  65. package/build/schemas/fulfillment/orders.d.ts +4655 -0
  66. package/build/schemas/fulfillment/orders.js +317 -0
  67. package/build/schemas/index.d.ts +2100 -0
  68. package/build/schemas/index.js +68 -0
  69. package/build/schemas/inventory-management/inventory.d.ts +6419 -0
  70. package/build/schemas/inventory-management/inventory.js +450 -0
  71. package/build/schemas/marketing/marketing.d.ts +14181 -0
  72. package/build/schemas/marketing/marketing.js +1088 -0
  73. package/build/schemas/metadata/metadata.d.ts +5259 -0
  74. package/build/schemas/metadata/metadata.js +614 -0
  75. package/build/schemas/other/other-apis.d.ts +257 -0
  76. package/build/schemas/other/other-apis.js +372 -0
  77. package/build/schemas/taxonomy/taxonomy.d.ts +215 -0
  78. package/build/schemas/taxonomy/taxonomy.js +571 -0
  79. package/build/scripts/auto-setup.d.ts +12 -0
  80. package/build/scripts/auto-setup.js +277 -0
  81. package/build/scripts/diagnostics.d.ts +8 -0
  82. package/build/scripts/diagnostics.js +299 -0
  83. package/build/scripts/download-specs.d.ts +1 -0
  84. package/build/scripts/download-specs.js +116 -0
  85. package/build/scripts/interactive-setup.d.ts +21 -0
  86. package/build/scripts/interactive-setup.js +723 -0
  87. package/build/server-http.d.ts +11 -0
  88. package/build/server-http.js +361 -0
  89. package/build/tools/definitions/account-with-schemas.d.ts +39 -0
  90. package/build/tools/definitions/account-with-schemas.js +170 -0
  91. package/build/tools/definitions/account.d.ts +12 -0
  92. package/build/tools/definitions/account.js +428 -0
  93. package/build/tools/definitions/analytics.d.ts +25 -0
  94. package/build/tools/definitions/analytics.js +66 -0
  95. package/build/tools/definitions/communication.d.ts +12 -0
  96. package/build/tools/definitions/communication.js +151 -0
  97. package/build/tools/definitions/fulfillment.d.ts +12 -0
  98. package/build/tools/definitions/fulfillment.js +326 -0
  99. package/build/tools/definitions/index.d.ts +25 -0
  100. package/build/tools/definitions/index.js +37 -0
  101. package/build/tools/definitions/inventory.d.ts +12 -0
  102. package/build/tools/definitions/inventory.js +429 -0
  103. package/build/tools/definitions/marketing.d.ts +12 -0
  104. package/build/tools/definitions/marketing.js +1095 -0
  105. package/build/tools/definitions/metadata.d.ts +12 -0
  106. package/build/tools/definitions/metadata.js +188 -0
  107. package/build/tools/definitions/other.d.ts +13 -0
  108. package/build/tools/definitions/other.js +309 -0
  109. package/build/tools/definitions/taxonomy.d.ts +25 -0
  110. package/build/tools/definitions/taxonomy.js +64 -0
  111. package/build/tools/definitions/token-management.d.ts +35 -0
  112. package/build/tools/definitions/token-management.js +103 -0
  113. package/build/tools/index.d.ts +11 -0
  114. package/build/tools/index.js +1003 -0
  115. package/build/tools/schemas.d.ts +14764 -0
  116. package/build/tools/schemas.js +667 -0
  117. package/build/tools/tool-definitions.d.ts +35 -0
  118. package/build/tools/tool-definitions.js +3534 -0
  119. package/build/types/application-settings/developerAnalyticsV1BetaOas3.d.ts +197 -0
  120. package/build/types/application-settings/developerAnalyticsV1BetaOas3.js +5 -0
  121. package/build/types/application-settings/developerClientRegistrationV1Oas3.d.ts +155 -0
  122. package/build/types/application-settings/developerClientRegistrationV1Oas3.js +5 -0
  123. package/build/types/application-settings/developerKeyManagementV1Oas3.d.ts +246 -0
  124. package/build/types/application-settings/developerKeyManagementV1Oas3.js +5 -0
  125. package/build/types/ebay-enums.d.ts +1204 -0
  126. package/build/types/ebay-enums.js +1330 -0
  127. package/build/types/ebay.d.ts +143 -0
  128. package/build/types/ebay.js +123 -0
  129. package/build/types/index.d.ts +6 -0
  130. package/build/types/index.js +10 -0
  131. package/build/types/sell-apps/account-management/sellAccountV1Oas3.d.ts +2579 -0
  132. package/build/types/sell-apps/account-management/sellAccountV1Oas3.js +5 -0
  133. package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.d.ts +446 -0
  134. package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.js +5 -0
  135. package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.d.ts +705 -0
  136. package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.js +5 -0
  137. package/build/types/sell-apps/communication/commerceMessageV1Oas3.d.ts +590 -0
  138. package/build/types/sell-apps/communication/commerceMessageV1Oas3.js +5 -0
  139. package/build/types/sell-apps/communication/commerceNotificationV1Oas3.d.ts +1276 -0
  140. package/build/types/sell-apps/communication/commerceNotificationV1Oas3.js +5 -0
  141. package/build/types/sell-apps/communication/sellNegotiationV1Oas3.d.ts +277 -0
  142. package/build/types/sell-apps/communication/sellNegotiationV1Oas3.js +5 -0
  143. package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.d.ts +3133 -0
  144. package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.js +5 -0
  145. package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.d.ts +2289 -0
  146. package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.js +5 -0
  147. package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.d.ts +6650 -0
  148. package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.js +5 -0
  149. package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.d.ts +172 -0
  150. package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.js +5 -0
  151. package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.d.ts +1869 -0
  152. package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.js +5 -0
  153. package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.d.ts +178 -0
  154. package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.js +5 -0
  155. package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.d.ts +128 -0
  156. package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.js +5 -0
  157. package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.d.ts +417 -0
  158. package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.js +5 -0
  159. package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.d.ts +273 -0
  160. package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.js +5 -0
  161. package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.d.ts +2537 -0
  162. package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.js +5 -0
  163. package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.d.ts +6650 -0
  164. package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.js +5 -0
  165. package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.d.ts +172 -0
  166. package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.js +5 -0
  167. package/build/utils/account-management/account.d.ts +1094 -0
  168. package/build/utils/account-management/account.js +831 -0
  169. package/build/utils/communication/feedback.d.ts +152 -0
  170. package/build/utils/communication/feedback.js +216 -0
  171. package/build/utils/communication/message.d.ts +174 -0
  172. package/build/utils/communication/message.js +242 -0
  173. package/build/utils/communication/negotiation.d.ts +123 -0
  174. package/build/utils/communication/negotiation.js +150 -0
  175. package/build/utils/communication/notification.d.ts +370 -0
  176. package/build/utils/communication/notification.js +369 -0
  177. package/build/utils/date-converter.d.ts +59 -0
  178. package/build/utils/date-converter.js +160 -0
  179. package/build/utils/llm-client-detector.d.ts +54 -0
  180. package/build/utils/llm-client-detector.js +318 -0
  181. package/build/utils/oauth-helper.d.ts +37 -0
  182. package/build/utils/oauth-helper.js +315 -0
  183. package/build/utils/order-management/dispute.d.ts +346 -0
  184. package/build/utils/order-management/dispute.js +369 -0
  185. package/build/utils/order-management/fulfillment.d.ts +200 -0
  186. package/build/utils/order-management/fulfillment.js +205 -0
  187. package/build/utils/other/compliance.d.ts +49 -0
  188. package/build/utils/other/compliance.js +76 -0
  189. package/build/utils/other/edelivery.d.ts +310 -0
  190. package/build/utils/other/edelivery.js +241 -0
  191. package/build/utils/other/identity.d.ts +13 -0
  192. package/build/utils/other/identity.js +13 -0
  193. package/build/utils/other/translation.d.ts +28 -0
  194. package/build/utils/other/translation.js +41 -0
  195. package/build/utils/other/vero.d.ts +61 -0
  196. package/build/utils/other/vero.js +90 -0
  197. package/build/utils/scope-helper.d.ts +49 -0
  198. package/build/utils/scope-helper.js +207 -0
  199. package/build/utils/security-checker.d.ts +46 -0
  200. package/build/utils/security-checker.js +248 -0
  201. package/build/utils/setup-validator.d.ts +25 -0
  202. package/build/utils/setup-validator.js +305 -0
  203. package/build/utils/token-utils.d.ts +40 -0
  204. package/build/utils/token-utils.js +40 -0
  205. package/package.json +115 -0
@@ -0,0 +1,1003 @@
1
+ import { getOAuthAuthorizationUrl, validateScopes } from '../config/environment.js';
2
+ import { accountTools, analyticsTools, communicationTools, fulfillmentTools, inventoryTools, marketingTools, metadataTools, otherApiTools, taxonomyTools, tokenManagementTools, } from '../tools/definitions/index.js';
3
+ import { convertToTimestamp, validateTokenExpiry } from '../utils/date-converter.js';
4
+ // Import Zod schemas for input validation
5
+ import { getAwaitingFeedbackSchema, getFeedbackRatingSummarySchema, getFeedbackSchema, leaveFeedbackForBuyerSchema, respondToFeedbackSchema, } from '../utils/communication/feedback.js';
6
+ import { bulkUpdateConversationSchema, getConversationSchema, getConversationsSchema, sendMessageSchema, updateConversationSchema, } from '../utils/communication/message.js';
7
+ import { findEligibleItemsSchema, getOffersToBuyersSchema, sendOfferToInterestedBuyersSchema, } from '../utils/communication/negotiation.js';
8
+ import { createDestinationSchema, createSubscriptionFilterSchema, createSubscriptionSchema, deleteDestinationSchema, deleteSubscriptionFilterSchema, deleteSubscriptionSchema, disableSubscriptionSchema, enableSubscriptionSchema, getConfigSchema, getDestinationSchema, getPublicKeySchema, getSubscriptionFilterSchema, getSubscriptionSchema, getSubscriptionsSchema, getTopicSchema, getTopicsSchema, testSubscriptionSchema, updateConfigSchema, updateDestinationSchema, updateSubscriptionSchema, } from '../utils/communication/notification.js';
9
+ /**
10
+ * Get all tool definitions for the MCP server
11
+ */
12
+ export function getToolDefinitions() {
13
+ return [
14
+ ...tokenManagementTools,
15
+ ...accountTools,
16
+ ...inventoryTools,
17
+ ...fulfillmentTools,
18
+ ...marketingTools,
19
+ ...analyticsTools,
20
+ ...metadataTools,
21
+ ...taxonomyTools,
22
+ ...communicationTools,
23
+ ...otherApiTools,
24
+ ];
25
+ }
26
+ /**
27
+ * Execute a tool based on its name
28
+ */
29
+ export async function executeTool(api, toolName, args) {
30
+ switch (toolName) {
31
+ // ChatGPT Connector Tools
32
+ case 'search': {
33
+ // For this example, we'll treat the query as a search for inventory items.
34
+ // A more robust implementation might search across different types of content.
35
+ const response = await api.inventory.getInventoryItems(args.limit ?? 10);
36
+ const results = response.inventoryItems?.map((item, index) => ({
37
+ id: `item-${index}`,
38
+ title: item.product?.title ?? 'No Title',
39
+ // The URL should be a canonical link to the item, which we don't have here.
40
+ // We'll use a placeholder.
41
+ url: `https://www.ebay.com/`, // Placeholder URL
42
+ })) ?? [];
43
+ // Format the response as required by the ChatGPT connector spec.
44
+ return {
45
+ content: [
46
+ {
47
+ type: 'text',
48
+ text: JSON.stringify({ results }),
49
+ },
50
+ ],
51
+ };
52
+ }
53
+ case 'fetch': {
54
+ const sku = args.id;
55
+ const item = await api.inventory.getInventoryItem(sku);
56
+ // Format the response as required by the ChatGPT connector spec.
57
+ const result = {
58
+ id: sku,
59
+ title: item.product?.title ?? 'No Title',
60
+ text: item.product?.description ?? 'No description available.',
61
+ url: `https://www.ebay.com/`, // Placeholder URL
62
+ metadata: {
63
+ source: 'ebay_inventory',
64
+ aspects: item.product?.aspects,
65
+ condition: item.condition,
66
+ },
67
+ };
68
+ return {
69
+ content: [
70
+ {
71
+ type: 'text',
72
+ text: JSON.stringify(result),
73
+ },
74
+ ],
75
+ };
76
+ }
77
+ case 'ebay_get_oauth_url': {
78
+ // Get config from environment
79
+ const clientId = process.env.EBAY_CLIENT_ID ?? '';
80
+ const environment = (process.env.EBAY_ENVIRONMENT ?? 'sandbox');
81
+ const envRedirectUri = process.env.EBAY_REDIRECT_URI;
82
+ // Use redirectUri from args if provided, otherwise use from .env
83
+ const redirectUri = args.redirectUri ?? envRedirectUri;
84
+ const scopes = args.scopes;
85
+ const state = args.state;
86
+ if (!clientId) {
87
+ throw new Error('EBAY_CLIENT_ID environment variable is required to generate OAuth URL');
88
+ }
89
+ if (!redirectUri) {
90
+ throw new Error('Redirect URI is required. Either provide it as a parameter or set EBAY_REDIRECT_URI in your .env file.');
91
+ }
92
+ // Validate scopes if custom scopes are provided
93
+ let scopeWarnings = [];
94
+ let validatedScopes = scopes;
95
+ if (scopes && scopes.length > 0) {
96
+ const validation = validateScopes(scopes, environment);
97
+ scopeWarnings = validation.warnings;
98
+ validatedScopes = validation.validScopes;
99
+ }
100
+ const authUrl = getOAuthAuthorizationUrl(clientId, redirectUri, environment, validatedScopes, state);
101
+ const result = {
102
+ authorizationUrl: authUrl,
103
+ redirectUri,
104
+ instructions: 'Open this URL in a browser to authorize the application. After authorization, you will be redirected to your redirect URI with an authorization code that can be exchanged for an access token.',
105
+ environment,
106
+ scopes: scopes ?? 'default (all Sell API scopes)',
107
+ };
108
+ // Include warnings if any scopes are invalid for the environment
109
+ if (scopeWarnings.length > 0) {
110
+ result.warnings = scopeWarnings;
111
+ }
112
+ return result;
113
+ }
114
+ case 'ebay_set_user_tokens': {
115
+ const accessToken = args.accessToken;
116
+ const refreshToken = args.refreshToken;
117
+ if (!accessToken || !refreshToken) {
118
+ throw new Error('Both accessToken and refreshToken are required');
119
+ }
120
+ await api.setUserTokens(accessToken, refreshToken);
121
+ return {
122
+ success: true,
123
+ message: 'User tokens successfully stored. These tokens will be used for all subsequent API requests and will be automatically refreshed when needed.',
124
+ tokenInfo: api.getTokenInfo(),
125
+ };
126
+ }
127
+ case 'ebay_get_token_status': {
128
+ const tokenInfo = api.getTokenInfo();
129
+ const hasUserTokens = api.hasUserTokens();
130
+ return {
131
+ hasUserToken: tokenInfo.hasUserToken,
132
+ hasAppAccessToken: tokenInfo.hasAppAccessToken,
133
+ authenticated: api.isAuthenticated(),
134
+ currentTokenType: tokenInfo.hasUserToken
135
+ ? 'user_token (10,000-50,000 req/day)'
136
+ : tokenInfo.hasAppAccessToken
137
+ ? 'app_access_token (1,000 req/day)'
138
+ : 'none',
139
+ message: hasUserTokens
140
+ ? 'Using user access token with automatic refresh'
141
+ : 'Using app access token from client credentials flow (lower rate limits). Consider setting user tokens for higher rate limits.',
142
+ };
143
+ }
144
+ case 'ebay_clear_tokens': {
145
+ const authClient = api.getAuthClient().getOAuthClient();
146
+ authClient.clearAllTokens();
147
+ return {
148
+ success: true,
149
+ message: 'All tokens cleared successfully. You will need to re-authenticate for subsequent API calls.',
150
+ };
151
+ }
152
+ case 'ebay_convert_date_to_timestamp': {
153
+ const dateInput = args.dateInput;
154
+ try {
155
+ const timestamp = convertToTimestamp(dateInput);
156
+ return {
157
+ success: true,
158
+ timestamp,
159
+ input: dateInput,
160
+ formattedDate: new Date(timestamp).toISOString(),
161
+ message: `Successfully converted to timestamp: ${timestamp}ms (${new Date(timestamp).toISOString()})`,
162
+ };
163
+ }
164
+ catch (error) {
165
+ throw new Error(`Failed to convert date: ${error instanceof Error ? error.message : String(error)}`);
166
+ }
167
+ }
168
+ case 'ebay_validate_token_expiry': {
169
+ const accessTokenExpiry = args.accessTokenExpiry;
170
+ const refreshTokenExpiry = args.refreshTokenExpiry;
171
+ try {
172
+ // Convert to timestamps
173
+ const accessExpiry = convertToTimestamp(accessTokenExpiry);
174
+ const refreshExpiry = convertToTimestamp(refreshTokenExpiry);
175
+ // Validate
176
+ const validation = validateTokenExpiry(accessExpiry, refreshExpiry);
177
+ return {
178
+ ...validation,
179
+ accessTokenExpiryTimestamp: accessExpiry,
180
+ refreshTokenExpiryTimestamp: refreshExpiry,
181
+ accessTokenExpiryDate: new Date(accessExpiry).toISOString(),
182
+ refreshTokenExpiryDate: new Date(refreshExpiry).toISOString(),
183
+ };
184
+ }
185
+ catch (error) {
186
+ throw new Error(`Failed to validate token expiry: ${error instanceof Error ? error.message : String(error)}`);
187
+ }
188
+ }
189
+ case 'ebay_set_user_tokens_with_expiry': {
190
+ const accessToken = args.accessToken;
191
+ const refreshToken = args.refreshToken;
192
+ const accessTokenExpiry = args.accessTokenExpiry;
193
+ const refreshTokenExpiry = args.refreshTokenExpiry;
194
+ const autoRefresh = args.autoRefresh ?? true;
195
+ if (!accessToken || !refreshToken) {
196
+ throw new Error('Both accessToken and refreshToken are required');
197
+ }
198
+ try {
199
+ // Convert expiry times to timestamps if provided
200
+ let accessExpiry;
201
+ let refreshExpiry;
202
+ if (accessTokenExpiry !== undefined) {
203
+ accessExpiry = convertToTimestamp(accessTokenExpiry);
204
+ }
205
+ if (refreshTokenExpiry !== undefined) {
206
+ refreshExpiry = convertToTimestamp(refreshTokenExpiry);
207
+ }
208
+ // Set tokens (will use defaults if expiry times not provided)
209
+ await api.setUserTokens(accessToken, refreshToken);
210
+ // If autoRefresh is enabled, attempt to get a fresh access token
211
+ // (The OAuth client will handle refresh internally if needed)
212
+ if (autoRefresh) {
213
+ try {
214
+ const authClient = api.getAuthClient().getOAuthClient();
215
+ await authClient.getAccessToken();
216
+ return {
217
+ success: true,
218
+ message: 'User tokens stored successfully in memory. Access token validated and refreshed if needed. To persist tokens, update EBAY_USER_REFRESH_TOKEN in .env file.',
219
+ tokenInfo: api.getTokenInfo(),
220
+ refreshed: true,
221
+ };
222
+ }
223
+ catch (refreshError) {
224
+ return {
225
+ success: true,
226
+ message: 'User tokens stored, but failed to validate/refresh access token. You may need to re-authorize.',
227
+ tokenInfo: api.getTokenInfo(),
228
+ refreshed: false,
229
+ refreshError: refreshError instanceof Error ? refreshError.message : 'Unknown error',
230
+ };
231
+ }
232
+ }
233
+ return {
234
+ success: true,
235
+ message: 'User tokens successfully stored in memory. These tokens will be used for all subsequent API requests and will be automatically refreshed when needed. To persist tokens, update EBAY_USER_REFRESH_TOKEN in .env file.',
236
+ tokenInfo: api.getTokenInfo(),
237
+ refreshed: false,
238
+ };
239
+ }
240
+ catch (error) {
241
+ throw new Error(`Failed to set user tokens: ${error instanceof Error ? error.message : String(error)}`);
242
+ }
243
+ }
244
+ case 'ebay_display_credentials': {
245
+ // Get configuration from environment
246
+ const clientId = process.env.EBAY_CLIENT_ID ?? '';
247
+ const clientSecret = process.env.EBAY_CLIENT_SECRET ?? '';
248
+ const environment = process.env.EBAY_ENVIRONMENT ?? 'sandbox';
249
+ const redirectUri = process.env.EBAY_REDIRECT_URI ?? '';
250
+ const refreshToken = process.env.EBAY_USER_REFRESH_TOKEN ?? '';
251
+ // Get current token info from API
252
+ const tokenInfo = api.getTokenInfo();
253
+ const authClient = api.getAuthClient().getOAuthClient();
254
+ // Helper function to mask sensitive tokens
255
+ const maskToken = (token) => {
256
+ if (!token || token.length < 12)
257
+ return '***';
258
+ return `${token.substring(0, 6)}...${token.substring(token.length - 6)}`;
259
+ };
260
+ // Get internal token details from the auth client
261
+ const internalTokens = authClient.getUserTokens();
262
+ const appToken = authClient.getCachedAppAccessToken();
263
+ const appTokenExpiry = authClient.getCachedAppAccessTokenExpiry();
264
+ return {
265
+ credentials: {
266
+ clientId: clientId ? maskToken(clientId) : 'Not set',
267
+ clientSecret: clientSecret ? '****** (set)' : 'Not set',
268
+ environment,
269
+ redirectUri: redirectUri || 'Not set',
270
+ },
271
+ tokens: {
272
+ refreshToken: refreshToken ? maskToken(refreshToken) : 'Not set (in .env)',
273
+ accessToken: internalTokens?.userAccessToken
274
+ ? maskToken(internalTokens.userAccessToken)
275
+ : 'Not available',
276
+ accessTokenExpiry: internalTokens?.userAccessTokenExpiry
277
+ ? {
278
+ timestamp: internalTokens.userAccessTokenExpiry,
279
+ date: new Date(internalTokens.userAccessTokenExpiry).toISOString(),
280
+ expired: Date.now() >= internalTokens.userAccessTokenExpiry,
281
+ }
282
+ : 'Not available',
283
+ refreshTokenExpiry: internalTokens?.userRefreshTokenExpiry
284
+ ? {
285
+ timestamp: internalTokens.userRefreshTokenExpiry,
286
+ date: new Date(internalTokens.userRefreshTokenExpiry).toISOString(),
287
+ expired: Date.now() >= internalTokens.userRefreshTokenExpiry,
288
+ }
289
+ : 'Not available',
290
+ appToken: appToken ? maskToken(appToken) : 'Not cached',
291
+ appTokenExpiry: appTokenExpiry
292
+ ? {
293
+ timestamp: appTokenExpiry,
294
+ date: new Date(appTokenExpiry).toISOString(),
295
+ expired: Date.now() >= appTokenExpiry,
296
+ }
297
+ : 'Not available',
298
+ },
299
+ status: {
300
+ hasUserToken: tokenInfo.hasUserToken,
301
+ hasAppAccessToken: tokenInfo.hasAppAccessToken,
302
+ authenticated: api.isAuthenticated(),
303
+ currentTokenType: tokenInfo.hasUserToken
304
+ ? 'user_token (10,000-50,000 req/day)'
305
+ : tokenInfo.hasAppAccessToken
306
+ ? 'app_access_token (1,000 req/day)'
307
+ : 'none',
308
+ },
309
+ scopes: internalTokens?.scope ? internalTokens.scope.split(' ') : [],
310
+ };
311
+ }
312
+ case 'ebay_refresh_access_token': {
313
+ const authClient = api.getAuthClient().getOAuthClient();
314
+ // Check if user tokens are available
315
+ if (!api.hasUserTokens()) {
316
+ throw new Error('No user tokens available. Please set user tokens first using ebay_set_user_tokens_with_expiry or add EBAY_USER_REFRESH_TOKEN to your .env file.');
317
+ }
318
+ try {
319
+ // Call the public refreshUserToken method
320
+ await authClient.refreshUserToken();
321
+ // Get updated token info
322
+ const internalTokens = authClient.getUserTokens();
323
+ return {
324
+ success: true,
325
+ message: 'Access token refreshed successfully',
326
+ accessToken: internalTokens?.userAccessToken
327
+ ? `${internalTokens.userAccessToken.substring(0, 6)}...${internalTokens.userAccessToken.substring(internalTokens.userAccessToken.length - 6)}`
328
+ : 'Not available',
329
+ accessTokenExpiry: internalTokens?.userAccessTokenExpiry
330
+ ? {
331
+ timestamp: internalTokens.userAccessTokenExpiry,
332
+ date: new Date(internalTokens.userAccessTokenExpiry).toISOString(),
333
+ expiresInSeconds: Math.floor((internalTokens.userAccessTokenExpiry - Date.now()) / 1000),
334
+ }
335
+ : 'Not available',
336
+ tokenInfo: api.getTokenInfo(),
337
+ };
338
+ }
339
+ catch (error) {
340
+ throw new Error(`Failed to refresh access token: ${error instanceof Error ? error.message : String(error)}`);
341
+ }
342
+ }
343
+ // Account Management
344
+ case 'ebay_get_custom_policies':
345
+ return await api.account.getCustomPolicies(args.policyTypes);
346
+ case 'ebay_get_fulfillment_policies':
347
+ return await api.account.getFulfillmentPolicies(args.marketplaceId);
348
+ case 'ebay_get_payment_policies':
349
+ return await api.account.getPaymentPolicies(args.marketplaceId);
350
+ case 'ebay_get_return_policies':
351
+ return await api.account.getReturnPolicies(args.marketplaceId);
352
+ // Fulfillment Policy CRUD
353
+ case 'ebay_create_fulfillment_policy':
354
+ return await api.account.createFulfillmentPolicy(args.policy);
355
+ case 'ebay_get_fulfillment_policy':
356
+ return await api.account.getFulfillmentPolicy(args.fulfillmentPolicyId);
357
+ case 'ebay_get_fulfillment_policy_by_name':
358
+ return await api.account.getFulfillmentPolicyByName(args.marketplaceId, args.name);
359
+ case 'ebay_update_fulfillment_policy':
360
+ return await api.account.updateFulfillmentPolicy(args.fulfillmentPolicyId, args.policy);
361
+ case 'ebay_delete_fulfillment_policy':
362
+ return await api.account.deleteFulfillmentPolicy(args.fulfillmentPolicyId);
363
+ // Payment Policy CRUD
364
+ case 'ebay_create_payment_policy':
365
+ return await api.account.createPaymentPolicy(args.policy);
366
+ case 'ebay_get_payment_policy':
367
+ return await api.account.getPaymentPolicy(args.paymentPolicyId);
368
+ case 'ebay_get_payment_policy_by_name':
369
+ return await api.account.getPaymentPolicyByName(args.marketplaceId, args.name);
370
+ case 'ebay_update_payment_policy':
371
+ return await api.account.updatePaymentPolicy(args.paymentPolicyId, args.policy);
372
+ case 'ebay_delete_payment_policy':
373
+ return await api.account.deletePaymentPolicy(args.paymentPolicyId);
374
+ // Return Policy CRUD
375
+ case 'ebay_create_return_policy':
376
+ return await api.account.createReturnPolicy(args.policy);
377
+ case 'ebay_get_return_policy':
378
+ return await api.account.getReturnPolicy(args.returnPolicyId);
379
+ case 'ebay_get_return_policy_by_name':
380
+ return await api.account.getReturnPolicyByName(args.marketplaceId, args.name);
381
+ case 'ebay_update_return_policy':
382
+ return await api.account.updateReturnPolicy(args.returnPolicyId, args.policy);
383
+ case 'ebay_delete_return_policy':
384
+ return await api.account.deleteReturnPolicy(args.returnPolicyId);
385
+ // Custom Policy CRUD
386
+ case 'ebay_create_custom_policy':
387
+ return await api.account.createCustomPolicy(args.policy);
388
+ case 'ebay_get_custom_policy':
389
+ return await api.account.getCustomPolicy(args.customPolicyId);
390
+ case 'ebay_update_custom_policy':
391
+ return await api.account.updateCustomPolicy(args.customPolicyId, args.policy);
392
+ case 'ebay_delete_custom_policy':
393
+ return await api.account.deleteCustomPolicy(args.customPolicyId);
394
+ // KYC, Payments, Programs, Sales Tax, Subscription
395
+ case 'ebay_get_kyc':
396
+ return await api.account.getKyc();
397
+ case 'ebay_opt_in_to_payments_program':
398
+ return await api.account.optInToPaymentsProgram(args.marketplaceId, args.paymentsProgramType);
399
+ case 'ebay_get_payments_program_status':
400
+ return await api.account.getPaymentsProgramStatus(args.marketplaceId, args.paymentsProgramType);
401
+ case 'ebay_get_rate_tables':
402
+ return await api.account.getRateTables();
403
+ case 'ebay_create_or_replace_sales_tax':
404
+ return await api.account.createOrReplaceSalesTax(args.countryCode, args.jurisdictionId, args.salesTaxBase);
405
+ case 'ebay_bulk_create_or_replace_sales_tax':
406
+ return await api.account.bulkCreateOrReplaceSalesTax(args.requests);
407
+ case 'ebay_delete_sales_tax':
408
+ return await api.account.deleteSalesTax(args.countryCode, args.jurisdictionId);
409
+ case 'ebay_get_sales_tax':
410
+ return await api.account.getSalesTax(args.countryCode, args.jurisdictionId);
411
+ case 'ebay_get_sales_taxes':
412
+ return await api.account.getSalesTaxes(args.countryCode);
413
+ case 'ebay_get_subscription':
414
+ return await api.account.getSubscription(args.limitType);
415
+ case 'ebay_opt_in_to_program':
416
+ return await api.account.optInToProgram(args.request);
417
+ case 'ebay_opt_out_of_program':
418
+ return await api.account.optOutOfProgram(args.request);
419
+ case 'ebay_get_opted_in_programs':
420
+ return await api.account.getOptedInPrograms();
421
+ case 'ebay_get_privileges':
422
+ return await api.account.getPrivileges();
423
+ case 'ebay_get_advertising_eligibility':
424
+ return await api.account.getAdvertisingEligibility(args.marketplaceId, args.programTypes);
425
+ case 'ebay_get_payments_program':
426
+ return await api.account.getPaymentsProgram(args.marketplaceId, args.paymentsProgramType);
427
+ case 'ebay_get_payments_program_onboarding':
428
+ return await api.account.getPaymentsProgramOnboarding(args.marketplaceId, args.paymentsProgramType);
429
+ // Inventory Management
430
+ case 'ebay_get_inventory_items':
431
+ return await api.inventory.getInventoryItems(args.limit, args.offset);
432
+ case 'ebay_get_inventory_item':
433
+ return await api.inventory.getInventoryItem(args.sku);
434
+ case 'ebay_create_inventory_item':
435
+ return await api.inventory.createOrReplaceInventoryItem(args.sku, args.inventoryItem);
436
+ case 'ebay_delete_inventory_item':
437
+ return await api.inventory.deleteInventoryItem(args.sku);
438
+ // Bulk Operations
439
+ case 'ebay_bulk_create_or_replace_inventory_item':
440
+ return await api.inventory.bulkCreateOrReplaceInventoryItem(args.requests);
441
+ case 'ebay_bulk_get_inventory_item':
442
+ return await api.inventory.bulkGetInventoryItem(args.requests);
443
+ case 'ebay_bulk_update_price_quantity':
444
+ return await api.inventory.bulkUpdatePriceQuantity(args.requests);
445
+ // Product Compatibility
446
+ case 'ebay_get_product_compatibility':
447
+ return await api.inventory.getProductCompatibility(args.sku);
448
+ case 'ebay_create_or_replace_product_compatibility':
449
+ return await api.inventory.createOrReplaceProductCompatibility(args.sku, args.compatibility);
450
+ case 'ebay_delete_product_compatibility':
451
+ return await api.inventory.deleteProductCompatibility(args.sku);
452
+ // Inventory Item Groups
453
+ case 'ebay_get_inventory_item_group':
454
+ return await api.inventory.getInventoryItemGroup(args.inventoryItemGroupKey);
455
+ case 'ebay_create_or_replace_inventory_item_group':
456
+ return await api.inventory.createOrReplaceInventoryItemGroup(args.inventoryItemGroupKey, args.inventoryItemGroup);
457
+ case 'ebay_delete_inventory_item_group':
458
+ return await api.inventory.deleteInventoryItemGroup(args.inventoryItemGroupKey);
459
+ // Location Management
460
+ case 'ebay_get_inventory_locations':
461
+ return await api.inventory.getInventoryLocations(args.limit, args.offset);
462
+ case 'ebay_get_inventory_location':
463
+ return await api.inventory.getInventoryLocation(args.merchantLocationKey);
464
+ case 'ebay_create_or_replace_inventory_location':
465
+ return await api.inventory.createOrReplaceInventoryLocation(args.merchantLocationKey, args.location);
466
+ case 'ebay_delete_inventory_location':
467
+ return await api.inventory.deleteInventoryLocation(args.merchantLocationKey);
468
+ case 'ebay_disable_inventory_location':
469
+ return await api.inventory.disableInventoryLocation(args.merchantLocationKey);
470
+ case 'ebay_enable_inventory_location':
471
+ return await api.inventory.enableInventoryLocation(args.merchantLocationKey);
472
+ case 'ebay_update_location_details':
473
+ return await api.inventory.updateLocationDetails(args.merchantLocationKey, args.locationDetails);
474
+ // Offer Management
475
+ case 'ebay_get_offers':
476
+ return await api.inventory.getOffers(args.sku, args.marketplaceId, args.limit);
477
+ case 'ebay_get_offer':
478
+ return await api.inventory.getOffer(args.offerId);
479
+ case 'ebay_create_offer':
480
+ return await api.inventory.createOffer(args.offer);
481
+ case 'ebay_update_offer':
482
+ return await api.inventory.updateOffer(args.offerId, args.offer);
483
+ case 'ebay_delete_offer':
484
+ return await api.inventory.deleteOffer(args.offerId);
485
+ case 'ebay_publish_offer':
486
+ return await api.inventory.publishOffer(args.offerId);
487
+ case 'ebay_withdraw_offer':
488
+ return await api.inventory.withdrawOffer(args.offerId);
489
+ case 'ebay_bulk_create_offer':
490
+ return await api.inventory.bulkCreateOffer(args.requests);
491
+ case 'ebay_bulk_publish_offer':
492
+ return await api.inventory.bulkPublishOffer(args.requests);
493
+ case 'ebay_get_listing_fees':
494
+ return await api.inventory.getListingFees(args.offers);
495
+ // Listing Migration
496
+ case 'ebay_bulk_migrate_listing':
497
+ return await api.inventory.bulkMigrateListing(args.requests);
498
+ // Listing Locations
499
+ case 'ebay_get_listing_locations':
500
+ return await api.inventory.getListingLocations(args.listingId, args.sku);
501
+ // Inventory Item Group Publishing
502
+ case 'ebay_publish_offer_by_inventory_item_group':
503
+ return await api.inventory.publishOfferByInventoryItemGroup(args.request);
504
+ case 'ebay_withdraw_offer_by_inventory_item_group':
505
+ return await api.inventory.withdrawOfferByInventoryItemGroup(args.request);
506
+ // Order Management
507
+ case 'ebay_get_orders':
508
+ return await api.fulfillment.getOrders(args.filter, args.limit, args.offset);
509
+ case 'ebay_get_order':
510
+ return await api.fulfillment.getOrder(args.orderId);
511
+ case 'ebay_create_shipping_fulfillment':
512
+ return await api.fulfillment.createShippingFulfillment(args.orderId, args.fulfillment);
513
+ case 'ebay_issue_refund':
514
+ return await api.fulfillment.issueRefund(args.orderId, args.refundData);
515
+ // Marketing - Campaign Management
516
+ case 'ebay_get_campaigns':
517
+ return await api.marketing.getCampaigns(args.campaignStatus, args.marketplaceId, args.limit);
518
+ case 'ebay_get_campaign':
519
+ return await api.marketing.getCampaign(args.campaignId);
520
+ case 'ebay_get_campaign_by_name':
521
+ return await api.marketing.getCampaignByName(args.campaignName);
522
+ case 'ebay_create_campaign':
523
+ return await api.marketing.createCampaign(args.campaign);
524
+ case 'ebay_clone_campaign':
525
+ return await api.marketing.cloneCampaign(args.campaignId, args.cloneData);
526
+ case 'ebay_pause_campaign':
527
+ return await api.marketing.pauseCampaign(args.campaignId);
528
+ case 'ebay_resume_campaign':
529
+ return await api.marketing.resumeCampaign(args.campaignId);
530
+ case 'ebay_end_campaign':
531
+ return await api.marketing.endCampaign(args.campaignId);
532
+ case 'ebay_update_campaign_identification':
533
+ return await api.marketing.updateCampaignIdentification(args.campaignId, args.updateData);
534
+ // Marketing - Ad Operations (Bulk)
535
+ case 'ebay_bulk_create_ads_by_inventory_reference':
536
+ return await api.marketing.bulkCreateAdsByInventoryReference(args.campaignId, args.ads);
537
+ case 'ebay_bulk_create_ads_by_listing_id':
538
+ return await api.marketing.bulkCreateAdsByListingId(args.campaignId, args.ads);
539
+ case 'ebay_bulk_delete_ads_by_inventory_reference':
540
+ return await api.marketing.bulkDeleteAdsByInventoryReference(args.campaignId, args.ads);
541
+ case 'ebay_bulk_delete_ads_by_listing_id':
542
+ return await api.marketing.bulkDeleteAdsByListingId(args.campaignId, args.ads);
543
+ case 'ebay_bulk_update_ads_bid_by_inventory_reference':
544
+ return await api.marketing.bulkUpdateAdsBidByInventoryReference(args.campaignId, args.ads);
545
+ case 'ebay_bulk_update_ads_bid_by_listing_id':
546
+ return await api.marketing.bulkUpdateAdsBidByListingId(args.campaignId, args.ads);
547
+ case 'ebay_bulk_update_ads_status':
548
+ return await api.marketing.bulkUpdateAdsStatus(args.campaignId, args.ads);
549
+ case 'ebay_bulk_update_ads_status_by_listing_id':
550
+ return await api.marketing.bulkUpdateAdsStatusByListingId(args.campaignId, args.ads);
551
+ // Marketing - Ad Operations (Single)
552
+ case 'ebay_create_ad':
553
+ return await api.marketing.createAd(args.campaignId, args.ad);
554
+ case 'ebay_create_ads_by_inventory_reference':
555
+ return await api.marketing.createAdsByInventoryReference(args.campaignId, args.ads);
556
+ case 'ebay_get_ad':
557
+ return await api.marketing.getAd(args.campaignId, args.adId);
558
+ case 'ebay_get_ads':
559
+ return await api.marketing.getAds(args.campaignId, args.adGroupIds, args.adStatus, args.limit, args.listingIds, args.offset);
560
+ case 'ebay_get_ads_by_inventory_reference':
561
+ return await api.marketing.getAdsByInventoryReference(args.campaignId, args.inventoryReferenceId, args.inventoryReferenceType);
562
+ case 'ebay_get_ads_by_listing_id':
563
+ return await api.marketing.getAdsByListingId(args.campaignId, args.listingId);
564
+ case 'ebay_delete_ad':
565
+ return await api.marketing.deleteAd(args.campaignId, args.adId);
566
+ case 'ebay_clone_ad':
567
+ return await api.marketing.cloneAd(args.campaignId, args.adId, args.ad);
568
+ case 'ebay_update_ad_bid':
569
+ return await api.marketing.updateBid(args.campaignId, args.adId, args.bidData);
570
+ // Marketing - Ad Group Management
571
+ case 'ebay_create_ad_group':
572
+ return await api.marketing.createAdGroup(args.campaignId, args.adGroup);
573
+ case 'ebay_get_ad_group':
574
+ return await api.marketing.getAdGroup(args.campaignId, args.adGroupId);
575
+ case 'ebay_get_ad_groups':
576
+ return await api.marketing.getAdGroups(args.campaignId, args.adGroupStatus, args.limit, args.offset);
577
+ case 'ebay_clone_ad_group':
578
+ return await api.marketing.cloneAdGroup(args.campaignId, args.adGroupId, args.adGroup);
579
+ case 'ebay_update_ad_group_bids':
580
+ return await api.marketing.updateAdGroupBids(args.campaignId, args.adGroupId, args.bidsData);
581
+ case 'ebay_update_ad_group_keywords':
582
+ return await api.marketing.updateAdGroupKeywords(args.campaignId, args.adGroupId, args.keywordsData);
583
+ // Marketing - Keyword Management
584
+ case 'ebay_create_keyword':
585
+ return await api.marketing.createKeyword(args.campaignId, args.adGroupId, args.keyword);
586
+ case 'ebay_get_keyword':
587
+ return await api.marketing.getKeyword(args.campaignId, args.adGroupId, args.keywordId);
588
+ case 'ebay_get_keywords':
589
+ return await api.marketing.getKeywords(args.campaignId, args.adGroupId, args.keywordStatus, args.limit, args.offset);
590
+ case 'ebay_delete_keyword':
591
+ return await api.marketing.deleteKeyword(args.campaignId, args.adGroupId, args.keywordId);
592
+ case 'ebay_update_keyword_bid':
593
+ return await api.marketing.updateKeywordBid(args.campaignId, args.adGroupId, args.keywordId, args.bidData);
594
+ case 'ebay_bulk_create_keywords':
595
+ return await api.marketing.bulkCreateKeywords(args.campaignId, args.adGroupId, args.keywords);
596
+ case 'ebay_bulk_delete_keywords':
597
+ return await api.marketing.bulkDeleteKeywords(args.campaignId, args.adGroupId, args.keywords);
598
+ case 'ebay_bulk_update_keyword_bids':
599
+ return await api.marketing.bulkUpdateKeywordBids(args.campaignId, args.adGroupId, args.keywords);
600
+ // Marketing - Negative Keywords (Campaign Level)
601
+ case 'ebay_create_negative_keyword':
602
+ return await api.marketing.createNegativeKeyword(args.campaignId, args.negativeKeyword);
603
+ case 'ebay_get_negative_keyword':
604
+ return await api.marketing.getNegativeKeyword(args.campaignId, args.negativeKeywordId);
605
+ case 'ebay_get_negative_keywords':
606
+ return await api.marketing.getNegativeKeywords(args.campaignId, args.limit, args.offset);
607
+ case 'ebay_delete_negative_keyword':
608
+ return await api.marketing.deleteNegativeKeyword(args.campaignId, args.negativeKeywordId);
609
+ case 'ebay_update_negative_keyword':
610
+ return await api.marketing.updateNegativeKeyword(args.campaignId, args.negativeKeywordId, args.negativeKeyword);
611
+ case 'ebay_bulk_create_negative_keywords':
612
+ return await api.marketing.bulkCreateNegativeKeywords(args.campaignId, args.negativeKeywords);
613
+ case 'ebay_bulk_update_negative_keywords':
614
+ return await api.marketing.bulkUpdateNegativeKeywords(args.campaignId, args.negativeKeywords);
615
+ case 'ebay_bulk_delete_negative_keywords':
616
+ return await api.marketing.bulkDeleteNegativeKeywords(args.campaignId, args.negativeKeywords);
617
+ // Marketing - Negative Keywords (Ad Group Level)
618
+ case 'ebay_create_negative_keyword_for_ad_group':
619
+ return await api.marketing.createNegativeKeywordForAdGroup(args.adGroupId, args.negativeKeyword);
620
+ case 'ebay_get_negative_keyword_for_ad_group':
621
+ return await api.marketing.getNegativeKeywordForAdGroup(args.adGroupId, args.negativeKeywordId);
622
+ case 'ebay_get_negative_keywords_for_ad_group':
623
+ return await api.marketing.getNegativeKeywordsForAdGroup(args.adGroupId, args.limit, args.offset);
624
+ case 'ebay_delete_negative_keyword_for_ad_group':
625
+ return await api.marketing.deleteNegativeKeywordForAdGroup(args.adGroupId, args.negativeKeywordId);
626
+ case 'ebay_update_negative_keyword_for_ad_group':
627
+ return await api.marketing.updateNegativeKeywordForAdGroup(args.adGroupId, args.negativeKeywordId, args.negativeKeyword);
628
+ case 'ebay_bulk_create_negative_keywords_for_ad_group':
629
+ return await api.marketing.bulkCreateNegativeKeywordsForAdGroup(args.adGroupId, args.negativeKeywords);
630
+ case 'ebay_bulk_update_negative_keywords_for_ad_group':
631
+ return await api.marketing.bulkUpdateNegativeKeywordsForAdGroup(args.adGroupId, args.negativeKeywords);
632
+ case 'ebay_bulk_delete_negative_keywords_for_ad_group':
633
+ return await api.marketing.bulkDeleteNegativeKeywordsForAdGroup(args.adGroupId, args.negativeKeywords);
634
+ // Marketing - Targeting
635
+ case 'ebay_create_targeting':
636
+ return await api.marketing.createTargeting(args.campaignId, args.targeting);
637
+ case 'ebay_get_targeting':
638
+ return await api.marketing.getTargeting(args.campaignId);
639
+ case 'ebay_update_targeting':
640
+ return await api.marketing.updateTargeting(args.campaignId, args.targeting);
641
+ // Marketing - Suggestions
642
+ case 'ebay_suggest_bids':
643
+ return await api.marketing.suggestBids(args.campaignId, args.adGroupId);
644
+ case 'ebay_suggest_keywords':
645
+ return await api.marketing.suggestKeywords(args.campaignId, args.adGroupId, args.suggestion);
646
+ // Marketing - Reporting
647
+ case 'ebay_create_report_task':
648
+ return await api.marketing.createReportTask(args.reportTask);
649
+ case 'ebay_get_report_task':
650
+ return await api.marketing.getReportTask(args.reportTaskId);
651
+ case 'ebay_get_report_tasks':
652
+ return await api.marketing.getReportTasks(args.reportTaskStatuses, args.limit, args.offset);
653
+ case 'ebay_get_ad_report':
654
+ return await api.marketing.getAdReport(args.dimension, args.metric, args.reportStartDate, args.reportEndDate, args.sort, args.listingIds, args.marketplaceId);
655
+ case 'ebay_get_ad_report_metadata':
656
+ return await api.marketing.getAdReportMetadata();
657
+ case 'ebay_get_ad_report_metadata_for_report_type':
658
+ return await api.marketing.getAdReportMetadataForReportType(args.reportType);
659
+ // Marketing - Promotions (Item Promotion)
660
+ case 'ebay_get_promotions':
661
+ return await api.marketing.getPromotions(args.marketplaceId, args.limit);
662
+ case 'ebay_get_item_promotion':
663
+ return await api.marketing.getItemPromotion(args.promotionId);
664
+ case 'ebay_create_item_promotion':
665
+ return await api.marketing.createPromotion(args.promotion);
666
+ case 'ebay_update_item_promotion':
667
+ return await api.marketing.updateItemPromotion(args.promotionId, args.promotion);
668
+ case 'ebay_delete_item_promotion':
669
+ return await api.marketing.deleteItemPromotion(args.promotionId);
670
+ case 'ebay_pause_item_promotion':
671
+ return await api.marketing.pauseItemPromotion(args.promotionId);
672
+ case 'ebay_resume_item_promotion':
673
+ return await api.marketing.resumeItemPromotion(args.promotionId);
674
+ case 'ebay_get_promotion_report':
675
+ return await api.marketing.getPromotionReport(args.marketplaceId, args.promotionStatus, args.limit, args.offset);
676
+ case 'ebay_get_promotion_summary_report':
677
+ return await api.marketing.getPromotionSummaryReport(args.marketplaceId);
678
+ // Recommendation
679
+ case 'ebay_find_listing_recommendations':
680
+ return await api.recommendation.findListingRecommendations(args.listingIds ? { listingIds: args.listingIds } : undefined, args.filter, args.limit, args.offset, args.marketplaceId);
681
+ // Analytics
682
+ case 'ebay_get_traffic_report':
683
+ return await api.analytics.getTrafficReport(args.dimension, args.filter, args.metric, args.sort);
684
+ case 'ebay_find_seller_standards_profiles':
685
+ return await api.analytics.findSellerStandardsProfiles();
686
+ case 'ebay_get_seller_standards_profile':
687
+ return await api.analytics.getSellerStandardsProfile(args.program, args.cycle);
688
+ case 'ebay_get_customer_service_metric':
689
+ return await api.analytics.getCustomerServiceMetric(args.customerServiceMetricType, args.evaluationType, args.evaluationMarketplaceId);
690
+ // Metadata
691
+ case 'ebay_get_automotive_parts_compatibility_policies':
692
+ return await api.metadata.getAutomotivePartsCompatibilityPolicies(args.marketplaceId, args.filter);
693
+ case 'ebay_get_category_policies':
694
+ return await api.metadata.getCategoryPolicies(args.marketplaceId, args.filter);
695
+ case 'ebay_get_extended_producer_responsibility_policies':
696
+ return await api.metadata.getExtendedProducerResponsibilityPolicies(args.marketplaceId, args.filter);
697
+ case 'ebay_get_hazardous_materials_labels':
698
+ return await api.metadata.getHazardousMaterialsLabels(args.marketplaceId);
699
+ case 'ebay_get_item_condition_policies':
700
+ return await api.metadata.getItemConditionPolicies(args.marketplaceId, args.filter);
701
+ case 'ebay_get_listing_structure_policies':
702
+ return await api.metadata.getListingStructurePolicies(args.marketplaceId, args.filter);
703
+ case 'ebay_get_negotiated_price_policies':
704
+ return await api.metadata.getNegotiatedPricePolicies(args.marketplaceId, args.filter);
705
+ case 'ebay_get_product_safety_labels':
706
+ return await api.metadata.getProductSafetyLabels(args.marketplaceId);
707
+ case 'ebay_get_regulatory_policies':
708
+ return await api.metadata.getRegulatoryPolicies(args.marketplaceId, args.filter);
709
+ case 'ebay_get_return_policy_metadata':
710
+ return await api.metadata.getReturnPolicies(args.marketplaceId, args.filter);
711
+ case 'ebay_get_shipping_cost_type_policies':
712
+ return await api.metadata.getShippingCostTypePolicies(args.marketplaceId, args.filter);
713
+ case 'ebay_get_classified_ad_policies':
714
+ return await api.metadata.getClassifiedAdPolicies(args.marketplaceId, args.filter);
715
+ case 'ebay_get_currencies':
716
+ return await api.metadata.getCurrencies(args.marketplaceId);
717
+ case 'ebay_get_listing_type_policies':
718
+ return await api.metadata.getListingTypePolicies(args.marketplaceId, args.filter);
719
+ case 'ebay_get_motors_listing_policies':
720
+ return await api.metadata.getMotorsListingPolicies(args.marketplaceId, args.filter);
721
+ case 'ebay_get_shipping_policies':
722
+ return await api.metadata.getShippingPolicies(args.marketplaceId, args.filter);
723
+ case 'ebay_get_site_visibility_policies':
724
+ return await api.metadata.getSiteVisibilityPolicies(args.marketplaceId, args.filter);
725
+ case 'ebay_get_compatibilities_by_specification':
726
+ return await api.metadata.getCompatibilitiesBySpecification(args.specification);
727
+ case 'ebay_get_compatibility_property_names':
728
+ return await api.metadata.getCompatibilityPropertyNames(args.data);
729
+ case 'ebay_get_compatibility_property_values':
730
+ return await api.metadata.getCompatibilityPropertyValues(args.data);
731
+ case 'ebay_get_multi_compatibility_property_values':
732
+ return await api.metadata.getMultiCompatibilityPropertyValues(args.data);
733
+ case 'ebay_get_product_compatibilities':
734
+ return await api.metadata.getProductCompatibilities(args.data);
735
+ case 'ebay_get_sales_tax_jurisdictions':
736
+ return await api.metadata.getSalesTaxJurisdictions(args.countryCode);
737
+ // Taxonomy
738
+ case 'ebay_get_default_category_tree_id':
739
+ return await api.taxonomy.getDefaultCategoryTreeId(args.marketplaceId);
740
+ case 'ebay_get_category_tree':
741
+ return await api.taxonomy.getCategoryTree(args.categoryTreeId);
742
+ case 'ebay_get_category_suggestions':
743
+ return await api.taxonomy.getCategorySuggestions(args.categoryTreeId, args.query);
744
+ case 'ebay_get_item_aspects_for_category':
745
+ return await api.taxonomy.getItemAspectsForCategory(args.categoryTreeId, args.categoryId);
746
+ // Communication - Negotiation
747
+ case 'ebay_get_offers_to_buyers': {
748
+ const validated = getOffersToBuyersSchema.parse(args);
749
+ return await api.negotiation.getOffersToBuyers(validated.filter, validated.limit ? Number(validated.limit) : undefined, validated.offset ? Number(validated.offset) : undefined);
750
+ }
751
+ case 'ebay_send_offer_to_interested_buyers': {
752
+ const validated = sendOfferToInterestedBuyersSchema.parse(args);
753
+ return await api.negotiation.sendOfferToInterestedBuyers(validated);
754
+ }
755
+ case 'ebay_find_eligible_items': {
756
+ const validated = findEligibleItemsSchema.parse(args);
757
+ return await api.negotiation.findEligibleItems(validated.marketplace_id, validated.limit ? Number(validated.limit) : undefined, validated.offset ? Number(validated.offset) : undefined);
758
+ }
759
+ // Communication - Message
760
+ case 'ebay_search_messages': {
761
+ const validated = getConversationsSchema.parse(args);
762
+ return await api.message.searchMessages(undefined, validated.limit ? Number(validated.limit) : undefined, validated.offset ? Number(validated.offset) : undefined);
763
+ }
764
+ case 'ebay_get_message': {
765
+ const validated = getConversationSchema.parse(args);
766
+ return await api.message.getMessage(validated.conversation_id);
767
+ }
768
+ case 'ebay_send_message': {
769
+ const validated = sendMessageSchema.parse(args);
770
+ return await api.message.sendMessage(validated);
771
+ }
772
+ case 'ebay_reply_to_message': {
773
+ // This is a deprecated method that maps to sendMessage
774
+ // We'll validate with a simple schema
775
+ if (!args.messageId || !args.messageContent) {
776
+ throw new Error('messageId and messageContent are required');
777
+ }
778
+ return await api.message.replyToMessage(args.messageId, args.messageContent);
779
+ }
780
+ case 'ebay_get_conversations': {
781
+ const validated = getConversationsSchema.parse(args);
782
+ return await api.message.getConversations(undefined, validated.limit ? Number(validated.limit) : undefined, validated.offset ? Number(validated.offset) : undefined);
783
+ }
784
+ case 'ebay_get_conversation': {
785
+ const validated = getConversationSchema.parse(args);
786
+ return await api.message.getConversation(validated.conversation_id);
787
+ }
788
+ case 'ebay_bulk_update_conversation': {
789
+ const validated = bulkUpdateConversationSchema.parse(args);
790
+ return await api.message.bulkUpdateConversation(validated);
791
+ }
792
+ case 'ebay_update_conversation': {
793
+ const validated = updateConversationSchema.parse(args);
794
+ return await api.message.updateConversation(validated);
795
+ }
796
+ // Communication - Notification
797
+ case 'ebay_get_notification_config': {
798
+ getConfigSchema.parse(args); // Validate empty args
799
+ return await api.notification.getConfig();
800
+ }
801
+ case 'ebay_update_notification_config': {
802
+ const validated = updateConfigSchema.parse(args);
803
+ return await api.notification.updateConfig(validated);
804
+ }
805
+ case 'ebay_get_notification_destinations':
806
+ return await api.notification.getDestinations(args.limit, args.continuationToken);
807
+ case 'ebay_create_notification_destination': {
808
+ const validated = createDestinationSchema.parse(args);
809
+ return await api.notification.createDestination(validated);
810
+ }
811
+ case 'ebay_get_notification_destination': {
812
+ const validated = getDestinationSchema.parse(args);
813
+ return await api.notification.getDestination(validated.destination_id);
814
+ }
815
+ case 'ebay_update_notification_destination': {
816
+ const validated = updateDestinationSchema.parse(args);
817
+ return await api.notification.updateDestination(validated.destination_id, validated);
818
+ }
819
+ case 'ebay_delete_notification_destination': {
820
+ const validated = deleteDestinationSchema.parse(args);
821
+ return await api.notification.deleteDestination(validated.destination_id);
822
+ }
823
+ case 'ebay_get_notification_subscriptions': {
824
+ const validated = getSubscriptionsSchema.parse(args);
825
+ return await api.notification.getSubscriptions(validated.limit ? Number(validated.limit) : undefined, validated.continuation_token);
826
+ }
827
+ case 'ebay_create_notification_subscription': {
828
+ const validated = createSubscriptionSchema.parse(args);
829
+ return await api.notification.createSubscription(validated);
830
+ }
831
+ case 'ebay_get_notification_subscription': {
832
+ const validated = getSubscriptionSchema.parse(args);
833
+ return await api.notification.getSubscription(validated.subscription_id);
834
+ }
835
+ case 'ebay_update_notification_subscription': {
836
+ const validated = updateSubscriptionSchema.parse(args);
837
+ return await api.notification.updateSubscription(validated.subscription_id, validated);
838
+ }
839
+ case 'ebay_delete_notification_subscription': {
840
+ const validated = deleteSubscriptionSchema.parse(args);
841
+ return await api.notification.deleteSubscription(validated.subscription_id);
842
+ }
843
+ case 'ebay_disable_notification_subscription': {
844
+ const validated = disableSubscriptionSchema.parse(args);
845
+ return await api.notification.disableSubscription(validated.subscription_id);
846
+ }
847
+ case 'ebay_enable_notification_subscription': {
848
+ const validated = enableSubscriptionSchema.parse(args);
849
+ return await api.notification.enableSubscription(validated.subscription_id);
850
+ }
851
+ case 'ebay_test_notification_subscription': {
852
+ const validated = testSubscriptionSchema.parse(args);
853
+ return await api.notification.testSubscription(validated.subscription_id);
854
+ }
855
+ case 'ebay_get_notification_topic': {
856
+ const validated = getTopicSchema.parse(args);
857
+ return await api.notification.getTopic(validated.topic_id);
858
+ }
859
+ case 'ebay_get_notification_topics': {
860
+ const validated = getTopicsSchema.parse(args);
861
+ return await api.notification.getTopics(validated.limit ? Number(validated.limit) : undefined, validated.continuation_token);
862
+ }
863
+ case 'ebay_create_notification_subscription_filter': {
864
+ const validated = createSubscriptionFilterSchema.parse(args);
865
+ return await api.notification.createSubscriptionFilter(validated.subscription_id, validated);
866
+ }
867
+ case 'ebay_get_notification_subscription_filter': {
868
+ const validated = getSubscriptionFilterSchema.parse(args);
869
+ return await api.notification.getSubscriptionFilter(validated.subscription_id, validated.filter_id);
870
+ }
871
+ case 'ebay_delete_notification_subscription_filter': {
872
+ const validated = deleteSubscriptionFilterSchema.parse(args);
873
+ return await api.notification.deleteSubscriptionFilter(validated.subscription_id, validated.filter_id);
874
+ }
875
+ case 'ebay_get_notification_public_key': {
876
+ const validated = getPublicKeySchema.parse(args);
877
+ return await api.notification.getPublicKey(validated.public_key_id);
878
+ }
879
+ // Communication - Feedback
880
+ case 'ebay_get_feedback': {
881
+ const validated = getFeedbackSchema.parse(args);
882
+ return await api.feedback.getFeedback(validated.transaction_id ?? '');
883
+ }
884
+ case 'ebay_leave_feedback_for_buyer': {
885
+ const validated = leaveFeedbackForBuyerSchema.parse(args);
886
+ return await api.feedback.leaveFeedbackForBuyer(validated);
887
+ }
888
+ case 'ebay_get_feedback_summary': {
889
+ getFeedbackRatingSummarySchema.parse(args); // Validate empty args
890
+ return await api.feedback.getFeedbackSummary();
891
+ }
892
+ case 'ebay_get_awaiting_feedback': {
893
+ const validated = getAwaitingFeedbackSchema.parse(args);
894
+ return await api.feedback.getAwaitingFeedback(validated.filter, validated.limit ? Number(validated.limit) : undefined, validated.offset ? Number(validated.offset) : undefined);
895
+ }
896
+ case 'ebay_respond_to_feedback': {
897
+ const validated = respondToFeedbackSchema.parse(args);
898
+ return await api.feedback.respondToFeedback(validated.feedback_id ?? '', validated.response_text ?? '');
899
+ }
900
+ // Other APIs - Identity
901
+ case 'ebay_get_user':
902
+ return await api.identity.getUser();
903
+ // Other APIs - Compliance
904
+ case 'ebay_get_listing_violations':
905
+ return await api.compliance.getListingViolations(args.complianceType, args.offset, args.limit);
906
+ case 'ebay_get_listing_violations_summary':
907
+ return await api.compliance.getListingViolationsSummary(args.complianceType);
908
+ case 'ebay_suppress_violation':
909
+ return await api.compliance.suppressViolation(args.listingViolationId);
910
+ // Other APIs - VERO
911
+ case 'ebay_create_vero_report':
912
+ return await api.vero.createVeroReport(args.reportData);
913
+ case 'ebay_get_vero_report':
914
+ return await api.vero.getVeroReport(args.veroReportId);
915
+ case 'ebay_get_vero_report_items':
916
+ return await api.vero.getVeroReportItems(args.filter, args.limit, args.offset);
917
+ case 'ebay_get_vero_reason_code':
918
+ return await api.vero.getVeroReasonCode(args.veroReasonCodeId);
919
+ case 'ebay_get_vero_reason_codes':
920
+ return await api.vero.getVeroReasonCodes();
921
+ // Other APIs - Translation
922
+ case 'ebay_translate':
923
+ return await api.translation.translate(args.from, args.to, args.translationContext, args.text);
924
+ // Other APIs - eDelivery
925
+ case 'ebay_create_shipping_quote':
926
+ return await api.edelivery.createShippingQuote(args.shippingQuoteRequest);
927
+ case 'ebay_get_shipping_quote':
928
+ return await api.edelivery.getShippingQuote(args.shippingQuoteId);
929
+ // eDelivery - Cost & Preferences
930
+ case 'ebay_get_actual_costs':
931
+ return await api.edelivery.getActualCosts(args.params);
932
+ case 'ebay_get_address_preferences':
933
+ return await api.edelivery.getAddressPreferences();
934
+ case 'ebay_create_address_preference':
935
+ return await api.edelivery.createAddressPreference(args.addressPreference);
936
+ case 'ebay_get_consign_preferences':
937
+ return await api.edelivery.getConsignPreferences();
938
+ case 'ebay_create_consign_preference':
939
+ return await api.edelivery.createConsignPreference(args.consignPreference);
940
+ // eDelivery - Agents & Services
941
+ case 'ebay_get_agents':
942
+ return await api.edelivery.getAgents(args.params);
943
+ case 'ebay_get_battery_qualifications':
944
+ return await api.edelivery.getBatteryQualifications(args.params);
945
+ case 'ebay_get_dropoff_sites':
946
+ return await api.edelivery.getDropoffSites(args.params);
947
+ case 'ebay_get_shipping_services':
948
+ return await api.edelivery.getShippingServices(args.params);
949
+ // eDelivery - Bundles
950
+ case 'ebay_create_bundle':
951
+ return await api.edelivery.createBundle(args.bundleRequest);
952
+ case 'ebay_get_bundle':
953
+ return await api.edelivery.getBundle(args.bundleId);
954
+ case 'ebay_cancel_bundle':
955
+ return await api.edelivery.cancelBundle(args.bundleId);
956
+ case 'ebay_get_bundle_label':
957
+ return await api.edelivery.getBundleLabel(args.bundleId);
958
+ // eDelivery - Packages (Single)
959
+ case 'ebay_create_package':
960
+ return await api.edelivery.createPackage(args.packageRequest);
961
+ case 'ebay_get_package':
962
+ return await api.edelivery.getPackage(args.packageId);
963
+ case 'ebay_delete_package':
964
+ return await api.edelivery.deletePackage(args.packageId);
965
+ case 'ebay_get_package_by_order_line_item':
966
+ return await api.edelivery.getPackageByOrderLineItem(args.orderLineItemId);
967
+ case 'ebay_cancel_package':
968
+ return await api.edelivery.cancelPackage(args.packageId);
969
+ case 'ebay_clone_package':
970
+ return await api.edelivery.clonePackage(args.packageId);
971
+ case 'ebay_confirm_package':
972
+ return await api.edelivery.confirmPackage(args.packageId);
973
+ // eDelivery - Packages (Bulk)
974
+ case 'ebay_bulk_cancel_packages':
975
+ return await api.edelivery.bulkCancelPackages(args.bulkCancelRequest);
976
+ case 'ebay_bulk_confirm_packages':
977
+ return await api.edelivery.bulkConfirmPackages(args.bulkConfirmRequest);
978
+ case 'ebay_bulk_delete_packages':
979
+ return await api.edelivery.bulkDeletePackages(args.bulkDeleteRequest);
980
+ // eDelivery - Labels & Tracking
981
+ case 'ebay_get_labels':
982
+ return await api.edelivery.getLabels(args.params);
983
+ case 'ebay_get_handover_sheet':
984
+ return await api.edelivery.getHandoverSheet(args.params);
985
+ case 'ebay_get_tracking':
986
+ return await api.edelivery.getTracking(args.params);
987
+ // eDelivery - Other
988
+ case 'ebay_create_complaint':
989
+ return await api.edelivery.createComplaint(args.complaintRequest);
990
+ case 'SearchClaudeCodeDocs':
991
+ // Placeholder implementation for SearchClaudeCodeDocs
992
+ return {
993
+ content: [
994
+ {
995
+ type: 'text',
996
+ text: `Tool 'SearchClaudeCodeDocs' called with query: ${args.query}. This tool is not yet fully implemented.`,
997
+ },
998
+ ],
999
+ };
1000
+ default:
1001
+ throw new Error(`Unknown tool: ${toolName}`);
1002
+ }
1003
+ }