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,260 @@
1
+ import { config } from 'dotenv';
2
+ import { readFileSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+ import { LocaleEnum } from '../types/ebay-enums.js';
6
+ config();
7
+ // Get the current directory for loading scope files
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ /**
11
+ * Load and parse production scopes from JSON file
12
+ */
13
+ function getProductionScopes() {
14
+ try {
15
+ const scopesPath = join(__dirname, '../../docs/auth/production_scopes.json');
16
+ const scopesData = readFileSync(scopesPath, 'utf-8');
17
+ const scopes = JSON.parse(scopesData);
18
+ // Filter out empty objects and extract unique scope strings
19
+ const uniqueScopes = new Set();
20
+ scopes.forEach((item) => {
21
+ if (item.Scope) {
22
+ uniqueScopes.add(item.Scope);
23
+ }
24
+ });
25
+ return Array.from(uniqueScopes);
26
+ }
27
+ catch (error) {
28
+ console.error('Failed to load production scopes:', error);
29
+ // Return a minimal set of core scopes as fallback
30
+ return ['https://api.ebay.com/oauth/api_scope'];
31
+ }
32
+ }
33
+ /**
34
+ * Load and parse sandbox scopes from JSON file
35
+ */
36
+ function getSandboxScopes() {
37
+ try {
38
+ const scopesPath = join(__dirname, '../../docs/auth/sandbox_scopes.json');
39
+ const scopesData = readFileSync(scopesPath, 'utf-8');
40
+ const scopes = JSON.parse(scopesData);
41
+ // Filter out empty objects and extract unique scope strings
42
+ const uniqueScopes = new Set();
43
+ scopes.forEach((item) => {
44
+ if (item.Scope) {
45
+ uniqueScopes.add(item.Scope);
46
+ }
47
+ });
48
+ return Array.from(uniqueScopes);
49
+ }
50
+ catch (error) {
51
+ console.error('Failed to load sandbox scopes:', error);
52
+ // Return a minimal set of core scopes as fallback
53
+ return ['https://api.ebay.com/oauth/api_scope'];
54
+ }
55
+ }
56
+ /**
57
+ * Get default scopes for the specified environment
58
+ */
59
+ export function getDefaultScopes(environment) {
60
+ return environment === 'production' ? getProductionScopes() : getSandboxScopes();
61
+ }
62
+ /**
63
+ * Validate scopes against environment and return warnings for invalid scopes
64
+ */
65
+ export function validateScopes(scopes, environment) {
66
+ const validScopes = getDefaultScopes(environment);
67
+ const validScopeSet = new Set(validScopes);
68
+ const warnings = [];
69
+ const requestedValidScopes = [];
70
+ scopes.forEach((scope) => {
71
+ if (validScopeSet.has(scope)) {
72
+ requestedValidScopes.push(scope);
73
+ }
74
+ else {
75
+ // Check if this is a scope for the other environment
76
+ const otherEnvironment = environment === 'production' ? 'sandbox' : 'production';
77
+ const otherScopes = getDefaultScopes(otherEnvironment);
78
+ if (otherScopes.includes(scope)) {
79
+ warnings.push(`Scope "${scope}" is only available in ${otherEnvironment} environment, not in ${environment}. This scope will be requested but may be rejected by eBay.`);
80
+ }
81
+ else {
82
+ warnings.push(`Scope "${scope}" is not recognized for ${environment} environment. This scope will be requested but may be rejected by eBay.`);
83
+ }
84
+ // Still include it in case it's a new scope not in our JSON files
85
+ requestedValidScopes.push(scope);
86
+ }
87
+ });
88
+ return { warnings, validScopes: requestedValidScopes };
89
+ }
90
+ /**
91
+ * Validate environment configuration on startup
92
+ */
93
+ export function validateEnvironmentConfig() {
94
+ const warnings = [];
95
+ const errors = [];
96
+ // Check required environment variables
97
+ if (!process.env.EBAY_CLIENT_ID) {
98
+ errors.push('EBAY_CLIENT_ID is not set. OAuth will not work.');
99
+ }
100
+ if (!process.env.EBAY_CLIENT_SECRET) {
101
+ errors.push('EBAY_CLIENT_SECRET is not set. OAuth will not work.');
102
+ }
103
+ // Validate EBAY_ENVIRONMENT
104
+ const environment = process.env.EBAY_ENVIRONMENT;
105
+ if (environment && environment !== 'production' && environment !== 'sandbox') {
106
+ errors.push(`EBAY_ENVIRONMENT must be either "production" or "sandbox", got: "${environment}"`);
107
+ }
108
+ // Check if environment is set
109
+ if (!environment) {
110
+ warnings.push('EBAY_ENVIRONMENT not set. Defaulting to "sandbox". Set EBAY_ENVIRONMENT=production for production use.');
111
+ }
112
+ // Check if redirect URI is set (needed for OAuth user flow)
113
+ if (!process.env.EBAY_REDIRECT_URI) {
114
+ warnings.push('EBAY_REDIRECT_URI is not set. User OAuth flow will not work. Set this to enable user token generation.');
115
+ }
116
+ // Validate that scope files exist
117
+ try {
118
+ getProductionScopes();
119
+ }
120
+ catch (error) {
121
+ errors.push(`Failed to load production scopes: ${error instanceof Error ? error.message : 'Unknown error'}`);
122
+ }
123
+ try {
124
+ getSandboxScopes();
125
+ }
126
+ catch (error) {
127
+ errors.push(`Failed to load sandbox scopes: ${error instanceof Error ? error.message : 'Unknown error'}`);
128
+ }
129
+ const isValid = errors.length === 0;
130
+ return {
131
+ isValid,
132
+ warnings,
133
+ errors,
134
+ };
135
+ }
136
+ export function getEbayConfig() {
137
+ const clientId = process.env.EBAY_CLIENT_ID ?? '';
138
+ const clientSecret = process.env.EBAY_CLIENT_SECRET ?? '';
139
+ const environment = (process.env.EBAY_ENVIRONMENT ?? 'sandbox');
140
+ const accessToken = process.env.EBAY_USER_ACCESS_TOKEN ?? '';
141
+ const refreshToken = process.env.EBAY_USER_REFRESH_TOKEN ?? '';
142
+ const appAccessToken = process.env.EBAY_APP_ACCESS_TOKEN ?? '';
143
+ // Only require client credentials - tokens can be optional (generated from refresh token)
144
+ if (clientId === '' || clientSecret === '') {
145
+ console.error('Missing required eBay credentials. Please set:\n1) EBAY_CLIENT_ID\n2) EBAY_CLIENT_SECRET\nin your .env file at project root');
146
+ }
147
+ return {
148
+ clientId,
149
+ clientSecret,
150
+ redirectUri: process.env.EBAY_REDIRECT_URI,
151
+ environment,
152
+ accessToken,
153
+ refreshToken,
154
+ appAccessToken,
155
+ };
156
+ }
157
+ export function getBaseUrl(environment) {
158
+ return environment === 'production' ? 'https://api.ebay.com' : 'https://api.sandbox.ebay.com';
159
+ }
160
+ /**
161
+ * Get base URL for Identity API (uses apiz subdomain)
162
+ */
163
+ export function getIdentityBaseUrl(environment) {
164
+ return environment === 'production' ? 'https://apiz.ebay.com' : 'https://apiz.sandbox.ebay.com';
165
+ }
166
+ export function getAuthUrl(clientIdOrEnvironment, redirectUri, environment, locale = LocaleEnum.en_US, prompt = 'login', responseType = 'code', state, scopes) {
167
+ // If only one argument and it's an environment, return the token endpoint
168
+ if (arguments.length === 1 && (clientIdOrEnvironment === 'production' || clientIdOrEnvironment === 'sandbox')) {
169
+ return `${getBaseUrl(clientIdOrEnvironment)}/identity/v1/oauth2/token`;
170
+ }
171
+ // Otherwise, generate the full OAuth authorization URL
172
+ const clientId = clientIdOrEnvironment;
173
+ const env = environment || 'sandbox';
174
+ const scope = getDefaultScopes(env);
175
+ if (!(clientId && redirectUri)) {
176
+ console.error("clientId, redirectUri (RuName), and scope are required,please initialize the class properly.");
177
+ return '';
178
+ }
179
+ const authDomain = env === 'production' ? 'https://auth.ebay.com' : 'https://auth.sandbox.ebay.com';
180
+ const params = new URLSearchParams({
181
+ client_id: clientId,
182
+ redirect_uri: redirectUri,
183
+ response_type: responseType,
184
+ scope: scopes?.join(' ') || scope.join(' '),
185
+ prompt,
186
+ locale,
187
+ ...(state ? { state } : {}),
188
+ });
189
+ return `${authDomain}/oauth2/authorize?${params.toString()}`;
190
+ }
191
+ /**
192
+ * Generate the OAuth authorization URL for user consent
193
+ * This URL should be opened in a browser for the user to grant permissions
194
+ *
195
+ * Note: Scopes are optional - eBay will automatically grant the appropriate scopes
196
+ * based on your application's keyset configuration if scopes are not specified.
197
+ */
198
+ export function getOAuthAuthorizationUrl(clientId, redirectUri, // MUST be eBay RuName, NOT a URL
199
+ environment, scopes, locale, state) {
200
+ // Build the authorize URL using auth2 endpoint (correct eBay OAuth endpoint)
201
+ const authDomain = environment === 'production' ? 'https://auth2.ebay.com' : 'https://auth2.sandbox.ebay.com';
202
+ const authorizeEndpoint = `${authDomain}/oauth2/authorize`;
203
+ // Build query parameters for the authorize endpoint
204
+ const params = new URLSearchParams({
205
+ client_id: clientId,
206
+ redirect_uri: redirectUri,
207
+ });
208
+ // Add scopes only if provided (optional - eBay handles automatically if not specified)
209
+ if (scopes && scopes.length > 0) {
210
+ params.append('scope', scopes.join(' '));
211
+ }
212
+ else {
213
+ // Use default scopes for the environment if no scopes are specified
214
+ const defaultScopes = getDefaultScopes(environment);
215
+ params.append('scope', defaultScopes.join(' '));
216
+ }
217
+ // Always add state parameter (empty if not provided)
218
+ params.append('state', state || '');
219
+ // Add response_type
220
+ params.append('response_type', 'code');
221
+ // Add hd parameter (required by eBay)
222
+ params.append('hd', '');
223
+ // Build the signin URL that redirects to authorize
224
+ const signinDomain = environment === 'production' ? 'https://signin.ebay.com' : 'https://signin.sandbox.ebay.com';
225
+ const ruParam = encodeURIComponent(`${authorizeEndpoint}?${params.toString()}`);
226
+ return `${signinDomain}/signin?ru=${ruParam}&sgfl=oauth2_login&AppName=${clientId}`;
227
+ }
228
+ export const mcpConfig = {
229
+ name: 'eBay API Model Context Protocol Server',
230
+ version: '1.4.2',
231
+ title: 'eBay API Model Context Protocol Server',
232
+ websiteUrl: 'https://github.com/ebay/ebay-mcp-server',
233
+ icons: [
234
+ {
235
+ src: './48x48.png',
236
+ mimeType: 'image/png',
237
+ sizes: ['48x48'],
238
+ },
239
+ {
240
+ src: './128x128.png',
241
+ mimeType: 'image/png',
242
+ sizes: ['128x128'],
243
+ },
244
+ {
245
+ src: './256x256.png',
246
+ mimeType: 'image/png',
247
+ sizes: ['256x256'],
248
+ },
249
+ {
250
+ src: './512x512.png',
251
+ mimeType: 'image/png',
252
+ sizes: ['512x512'],
253
+ },
254
+ {
255
+ src: './1024x1024.png',
256
+ mimeType: 'image/png',
257
+ sizes: ['1024x1024'],
258
+ },
259
+ ],
260
+ };
@@ -0,0 +1 @@
1
+ export {};
package/build/index.js ADDED
@@ -0,0 +1,98 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { EbaySellerApi } from './api/index.js';
4
+ import { getEbayConfig, mcpConfig, validateEnvironmentConfig } from './config/environment.js';
5
+ import { getToolDefinitions, executeTool } from './tools/index.js';
6
+ /**
7
+ * eBay API MCP Server
8
+ * Provides access to eBay APIs through Model Context Protocol
9
+ */
10
+ class EbayMcpServer {
11
+ server;
12
+ api;
13
+ constructor() {
14
+ this.server = new McpServer(mcpConfig);
15
+ // Initialize eBay API client
16
+ this.api = new EbaySellerApi(getEbayConfig());
17
+ this.setupHandlers();
18
+ this.setupErrorHandling();
19
+ }
20
+ /**
21
+ * Initialize the API (load tokens from storage)
22
+ */
23
+ async initialize() {
24
+ await this.api.initialize();
25
+ }
26
+ setupHandlers() {
27
+ const tools = getToolDefinitions();
28
+ // Register each tool with the MCP server
29
+ for (const toolDef of tools) {
30
+ this.server.registerTool(toolDef.name, {
31
+ description: toolDef.description,
32
+ inputSchema: toolDef.inputSchema,
33
+ }, async (args) => {
34
+ try {
35
+ const result = await executeTool(this.api, toolDef.name, args);
36
+ return {
37
+ content: [
38
+ {
39
+ type: 'text',
40
+ text: JSON.stringify(result, null, 2),
41
+ },
42
+ ],
43
+ };
44
+ }
45
+ catch (error) {
46
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
47
+ return {
48
+ content: [
49
+ {
50
+ type: 'text',
51
+ text: JSON.stringify({ error: errorMessage }, null, 2),
52
+ },
53
+ ],
54
+ isError: true,
55
+ };
56
+ }
57
+ });
58
+ }
59
+ }
60
+ setupErrorHandling() {
61
+ process.on('SIGINT', async () => {
62
+ await this.server.close();
63
+ process.exit(0);
64
+ });
65
+ }
66
+ async run() {
67
+ // Validate environment configuration
68
+ const validation = validateEnvironmentConfig();
69
+ // Display warnings
70
+ if (validation.warnings.length > 0) {
71
+ console.error('\n⚠️ Environment Configuration Warnings:');
72
+ validation.warnings.forEach((warning) => {
73
+ console.error(` • ${warning}`);
74
+ });
75
+ console.error('');
76
+ }
77
+ // Display errors and exit if configuration is invalid
78
+ if (!validation.isValid) {
79
+ console.error('\n❌ Environment Configuration Errors:');
80
+ validation.errors.forEach((error) => {
81
+ console.error(` • ${error}`);
82
+ });
83
+ console.error('\nPlease fix the configuration errors and restart the server.\n');
84
+ process.exit(1);
85
+ }
86
+ // Initialize API (load tokens from storage)
87
+ await this.initialize();
88
+ const transport = new StdioServerTransport();
89
+ await this.server.connect(transport);
90
+ console.error('eBay API MCP Server running on stdio');
91
+ }
92
+ }
93
+ // Start the server
94
+ const server = new EbayMcpServer();
95
+ server.run().catch((error) => {
96
+ console.error('Fatal error running server:', error);
97
+ process.exit(1);
98
+ });