ebay-mcp-remote-edition 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +755 -0
- package/build/api/account-management/account.js +301 -0
- package/build/api/analytics-and-report/analytics.js +102 -0
- package/build/api/client-trading.js +96 -0
- package/build/api/client.js +173 -0
- package/build/api/communication/feedback.js +119 -0
- package/build/api/communication/message.js +131 -0
- package/build/api/communication/negotiation.js +97 -0
- package/build/api/communication/notification.js +373 -0
- package/build/api/developer/developer.js +81 -0
- package/build/api/index.js +109 -0
- package/build/api/listing-management/inventory.js +640 -0
- package/build/api/listing-metadata/metadata.js +485 -0
- package/build/api/listing-metadata/taxonomy.js +58 -0
- package/build/api/marketing-and-promotions/marketing.js +768 -0
- package/build/api/marketing-and-promotions/recommendation.js +32 -0
- package/build/api/order-management/dispute.js +69 -0
- package/build/api/order-management/fulfillment.js +89 -0
- package/build/api/other/compliance.js +47 -0
- package/build/api/other/edelivery.js +219 -0
- package/build/api/other/identity.js +24 -0
- package/build/api/other/translation.js +22 -0
- package/build/api/other/vero.js +48 -0
- package/build/api/trading/trading.js +78 -0
- package/build/auth/kv-store.js +40 -0
- package/build/auth/multi-user-store.js +120 -0
- package/build/auth/oauth-metadata.js +59 -0
- package/build/auth/oauth-middleware.js +99 -0
- package/build/auth/oauth-types.js +4 -0
- package/build/auth/oauth.js +235 -0
- package/build/auth/scope-utils.js +304 -0
- package/build/auth/token-store.js +46 -0
- package/build/auth/token-verifier.js +172 -0
- package/build/config/environment.js +297 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +129 -0
- package/build/schemas/account-management/account.js +375 -0
- package/build/schemas/analytics/analytics.js +191 -0
- package/build/schemas/communication/messages.js +345 -0
- package/build/schemas/fulfillment/orders.js +338 -0
- package/build/schemas/index.js +68 -0
- package/build/schemas/inventory-management/inventory.js +471 -0
- package/build/schemas/marketing/marketing.js +1103 -0
- package/build/schemas/metadata/metadata.js +618 -0
- package/build/schemas/other/other-apis.js +390 -0
- package/build/schemas/taxonomy/taxonomy.js +575 -0
- package/build/scripts/auto-setup.js +364 -0
- package/build/scripts/dev-sync.js +512 -0
- package/build/scripts/diagnostics.js +301 -0
- package/build/scripts/download-specs.js +116 -0
- package/build/scripts/interactive-setup.js +757 -0
- package/build/scripts/setup.js +1515 -0
- package/build/scripts/update-api-status-doc.js +44 -0
- package/build/server-http.d.ts +1 -0
- package/build/server-http.js +581 -0
- package/build/tools/definitions/account-with-schemas.js +170 -0
- package/build/tools/definitions/account.js +428 -0
- package/build/tools/definitions/analytics.js +66 -0
- package/build/tools/definitions/communication.js +394 -0
- package/build/tools/definitions/developer.js +195 -0
- package/build/tools/definitions/fulfillment.js +326 -0
- package/build/tools/definitions/index.js +41 -0
- package/build/tools/definitions/inventory.js +464 -0
- package/build/tools/definitions/marketing.js +1486 -0
- package/build/tools/definitions/metadata.js +188 -0
- package/build/tools/definitions/other.js +309 -0
- package/build/tools/definitions/taxonomy.js +64 -0
- package/build/tools/definitions/token-management.js +148 -0
- package/build/tools/definitions/trading.js +71 -0
- package/build/tools/index.js +1200 -0
- package/build/tools/schemas.js +667 -0
- package/build/tools/tool-definitions.js +3534 -0
- package/build/types/application-settings/developerAnalyticsV1BetaOas3.js +5 -0
- package/build/types/application-settings/developerClientRegistrationV1Oas3.js +5 -0
- package/build/types/application-settings/developerKeyManagementV1Oas3.js +5 -0
- package/build/types/ebay-enums.js +1330 -0
- package/build/types/ebay.js +123 -0
- package/build/types/index.js +10 -0
- package/build/types/sell-apps/account-management/sellAccountV1Oas3.js +5 -0
- package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.js +5 -0
- package/build/types/sell-apps/communication/commerceMessageV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceNotificationV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/sellNegotiationV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.js +5 -0
- package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.js +5 -0
- package/build/utils/account-management/account.js +831 -0
- package/build/utils/api-status-feed.js +83 -0
- package/build/utils/communication/feedback.js +216 -0
- package/build/utils/communication/message.js +242 -0
- package/build/utils/communication/negotiation.js +150 -0
- package/build/utils/communication/notification.js +369 -0
- package/build/utils/date-converter.js +160 -0
- package/build/utils/llm-client-detector.js +758 -0
- package/build/utils/logger.js +198 -0
- package/build/utils/oauth-helper.js +315 -0
- package/build/utils/order-management/dispute.js +369 -0
- package/build/utils/order-management/fulfillment.js +205 -0
- package/build/utils/other/compliance.js +76 -0
- package/build/utils/other/edelivery.js +241 -0
- package/build/utils/other/identity.js +13 -0
- package/build/utils/other/translation.js +41 -0
- package/build/utils/other/vero.js +90 -0
- package/build/utils/scope-helper.js +207 -0
- package/build/utils/security-checker.js +248 -0
- package/build/utils/setup-validator.js +305 -0
- package/build/utils/token-utils.js +40 -0
- package/build/utils/version.js +56 -0
- package/docs/auth/production_scopes.json +111 -0
- package/docs/auth/sandbox_scopes.json +142 -0
- package/package.json +122 -0
- package/public/icons/1024x1024.png +0 -0
- package/public/icons/128x128.png +0 -0
- package/public/icons/16x16.png +0 -0
- package/public/icons/256x256.png +0 -0
- package/public/icons/32x32.png +0 -0
- package/public/icons/48x48.png +0 -0
- package/public/icons/512x512.png +0 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { config } from 'dotenv';
|
|
2
|
+
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
import { LocaleEnum } from '../types/ebay-enums.js';
|
|
6
|
+
import { getVersion } from '../utils/version.js';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
config({ path: join(__dirname, '../../.env'), quiet: true });
|
|
10
|
+
function readSecretConfigFile() {
|
|
11
|
+
const configFile = process.env.EBAY_CONFIG_FILE;
|
|
12
|
+
if (!configFile || !existsSync(configFile)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const raw = readFileSync(configFile, 'utf-8');
|
|
17
|
+
return JSON.parse(raw);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Failed to load EBAY_CONFIG_FILE:', error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getSecretConfigForEnvironment(environment) {
|
|
25
|
+
const secretConfig = readSecretConfigFile();
|
|
26
|
+
return secretConfig?.[environment] ?? null;
|
|
27
|
+
}
|
|
28
|
+
function getProductionScopes() {
|
|
29
|
+
try {
|
|
30
|
+
const scopesPath = join(__dirname, '../../docs/auth/production_scopes.json');
|
|
31
|
+
const scopesData = readFileSync(scopesPath, 'utf-8');
|
|
32
|
+
const scopes = JSON.parse(scopesData);
|
|
33
|
+
const uniqueScopes = new Set();
|
|
34
|
+
scopes.forEach((item) => {
|
|
35
|
+
if (item.Scope) {
|
|
36
|
+
uniqueScopes.add(item.Scope);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return Array.from(uniqueScopes);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to load production scopes:', error);
|
|
43
|
+
return ['https://api.ebay.com/oauth/api_scope'];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function getSandboxScopes() {
|
|
47
|
+
try {
|
|
48
|
+
const scopesPath = join(__dirname, '../../docs/auth/sandbox_scopes.json');
|
|
49
|
+
const scopesData = readFileSync(scopesPath, 'utf-8');
|
|
50
|
+
const scopes = JSON.parse(scopesData);
|
|
51
|
+
const uniqueScopes = new Set();
|
|
52
|
+
scopes.forEach((item) => {
|
|
53
|
+
if (item.Scope) {
|
|
54
|
+
uniqueScopes.add(item.Scope);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return Array.from(uniqueScopes);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('Failed to load sandbox scopes:', error);
|
|
61
|
+
return ['https://api.ebay.com/oauth/api_scope'];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function getDefaultScopes(environment) {
|
|
65
|
+
return environment === 'production' ? getProductionScopes() : getSandboxScopes();
|
|
66
|
+
}
|
|
67
|
+
export function getHostedOauthScopes(environment) {
|
|
68
|
+
if (environment === 'production') {
|
|
69
|
+
return [
|
|
70
|
+
'https://api.ebay.com/oauth/api_scope',
|
|
71
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
|
|
72
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing',
|
|
73
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
|
|
74
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory',
|
|
75
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
|
|
76
|
+
'https://api.ebay.com/oauth/api_scope/sell.account',
|
|
77
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
78
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
|
|
79
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
|
|
80
|
+
'https://api.ebay.com/oauth/api_scope/sell.finances',
|
|
81
|
+
'https://api.ebay.com/oauth/api_scope/sell.payment.dispute',
|
|
82
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
|
|
83
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation',
|
|
84
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation.readonly',
|
|
85
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription',
|
|
86
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription.readonly',
|
|
87
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores',
|
|
88
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores.readonly',
|
|
89
|
+
'https://api.ebay.com/oauth/scope/sell.edelivery',
|
|
90
|
+
'https://api.ebay.com/oauth/api_scope/commerce.vero',
|
|
91
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory.mapping',
|
|
92
|
+
'https://api.ebay.com/oauth/api_scope/commerce.message',
|
|
93
|
+
'https://api.ebay.com/oauth/api_scope/commerce.feedback',
|
|
94
|
+
'https://api.ebay.com/oauth/api_scope/commerce.shipping',
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
'https://api.ebay.com/oauth/api_scope',
|
|
99
|
+
'https://api.ebay.com/oauth/api_scope/buy.order.readonly',
|
|
100
|
+
'https://api.ebay.com/oauth/api_scope/buy.guest.order',
|
|
101
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
|
|
102
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing',
|
|
103
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
|
|
104
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory',
|
|
105
|
+
'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
|
|
106
|
+
'https://api.ebay.com/oauth/api_scope/sell.account',
|
|
107
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
108
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
|
|
109
|
+
'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
|
|
110
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketplace.insights.readonly',
|
|
111
|
+
'https://api.ebay.com/oauth/api_scope/commerce.catalog.readonly',
|
|
112
|
+
'https://api.ebay.com/oauth/api_scope/buy.shopping.cart',
|
|
113
|
+
'https://api.ebay.com/oauth/api_scope/buy.offer.auction',
|
|
114
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
|
|
115
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.email.readonly',
|
|
116
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.phone.readonly',
|
|
117
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.address.readonly',
|
|
118
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.name.readonly',
|
|
119
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.status.readonly',
|
|
120
|
+
'https://api.ebay.com/oauth/api_scope/sell.finances',
|
|
121
|
+
'https://api.ebay.com/oauth/api_scope/sell.payment.dispute',
|
|
122
|
+
'https://api.ebay.com/oauth/api_scope/sell.item.draft',
|
|
123
|
+
'https://api.ebay.com/oauth/api_scope/sell.item',
|
|
124
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation',
|
|
125
|
+
'https://api.ebay.com/oauth/api_scope/sell.reputation.readonly',
|
|
126
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription',
|
|
127
|
+
'https://api.ebay.com/oauth/api_scope/commerce.notification.subscription.readonly',
|
|
128
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores',
|
|
129
|
+
'https://api.ebay.com/oauth/api_scope/sell.stores.readonly',
|
|
130
|
+
'https://api.ebay.com/oauth/api_scope/commerce.vero',
|
|
131
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory.mapping',
|
|
132
|
+
'https://api.ebay.com/oauth/api_scope/commerce.message',
|
|
133
|
+
'https://api.ebay.com/oauth/api_scope/commerce.feedback',
|
|
134
|
+
'https://api.ebay.com/oauth/api_scope/commerce.shipping',
|
|
135
|
+
'https://api.ebay.com/oauth/api_scope/sell.order.read',
|
|
136
|
+
'https://api.ebay.com/oauth/api_scope/sell.order',
|
|
137
|
+
'https://api.ebay.com/oauth/api_scope/sell.auction.read',
|
|
138
|
+
'https://api.ebay.com/oauth/api_scope/sell.offer.read',
|
|
139
|
+
'https://api.ebay.com/oauth/api_scope/sell.offer',
|
|
140
|
+
'https://api.ebay.com/oauth/api_scope/sell.return.read',
|
|
141
|
+
'https://api.ebay.com/oauth/api_scope/sell.return',
|
|
142
|
+
'https://api.ebay.com/oauth/api_scope/sell.refund.read',
|
|
143
|
+
'https://api.ebay.com/oauth/api_scope/sell.resolution.read',
|
|
144
|
+
'https://api.ebay.com/oauth/api_scope/sell.inquiry.read',
|
|
145
|
+
'https://api.ebay.com/oauth/api_scope/sell.inquiry',
|
|
146
|
+
'https://api.ebay.com/oauth/api_scope/sell.cancellation.read',
|
|
147
|
+
'https://api.ebay.com/oauth/api_scope/sell.cancellation',
|
|
148
|
+
'https://api.ebay.com/oauth/api_scope/commerce.usernote',
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
export function getConfiguredEnvironment() {
|
|
152
|
+
const env = process.env.EBAY_ENVIRONMENT || process.env.EBAY_DEFAULT_ENVIRONMENT || 'production';
|
|
153
|
+
return env === 'sandbox' ? 'sandbox' : 'production';
|
|
154
|
+
}
|
|
155
|
+
export function validateScopes(scopes, environment) {
|
|
156
|
+
const validScopes = getDefaultScopes(environment);
|
|
157
|
+
const validScopeSet = new Set(validScopes);
|
|
158
|
+
const warnings = [];
|
|
159
|
+
const requestedValidScopes = [];
|
|
160
|
+
scopes.forEach((scope) => {
|
|
161
|
+
if (validScopeSet.has(scope)) {
|
|
162
|
+
requestedValidScopes.push(scope);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const otherEnvironment = environment === 'production' ? 'sandbox' : 'production';
|
|
166
|
+
const otherScopes = getDefaultScopes(otherEnvironment);
|
|
167
|
+
if (otherScopes.includes(scope)) {
|
|
168
|
+
warnings.push(`Scope "${scope}" is only available in ${otherEnvironment} environment, not in ${environment}.`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
warnings.push(`Scope "${scope}" is not recognized for ${environment} environment.`);
|
|
172
|
+
}
|
|
173
|
+
requestedValidScopes.push(scope);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return { warnings, validScopes: requestedValidScopes };
|
|
177
|
+
}
|
|
178
|
+
export function validateEnvironmentConfig() {
|
|
179
|
+
const warnings = [];
|
|
180
|
+
const errors = [];
|
|
181
|
+
const rawEnv = process.env.EBAY_ENVIRONMENT || process.env.EBAY_DEFAULT_ENVIRONMENT;
|
|
182
|
+
if (!rawEnv) {
|
|
183
|
+
warnings.push('EBAY_ENVIRONMENT not set; defaulting to sandbox');
|
|
184
|
+
}
|
|
185
|
+
else if (rawEnv !== 'production' && rawEnv !== 'sandbox') {
|
|
186
|
+
errors.push(`EBAY_ENVIRONMENT "${rawEnv}" is invalid; must be "production" or "sandbox"`);
|
|
187
|
+
}
|
|
188
|
+
if (errors.length === 0) {
|
|
189
|
+
const environment = getConfiguredEnvironment();
|
|
190
|
+
const configForEnv = getSecretConfigForEnvironment(environment);
|
|
191
|
+
if (!configForEnv) {
|
|
192
|
+
if (!process.env.EBAY_CLIENT_ID) {
|
|
193
|
+
errors.push('EBAY_CLIENT_ID is not set. OAuth will not work.');
|
|
194
|
+
}
|
|
195
|
+
if (!process.env.EBAY_CLIENT_SECRET) {
|
|
196
|
+
errors.push('EBAY_CLIENT_SECRET is not set. OAuth will not work.');
|
|
197
|
+
}
|
|
198
|
+
if (!process.env.EBAY_REDIRECT_URI) {
|
|
199
|
+
warnings.push('EBAY_REDIRECT_URI is not set for selected environment.');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
isValid: errors.length === 0,
|
|
205
|
+
warnings,
|
|
206
|
+
errors,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export function getEbayConfig(environmentOverride) {
|
|
210
|
+
const environment = environmentOverride ?? getConfiguredEnvironment();
|
|
211
|
+
const secretConfig = getSecretConfigForEnvironment(environment);
|
|
212
|
+
const fallbackClientId = environment === 'production'
|
|
213
|
+
? process.env.EBAY_PRODUCTION_CLIENT_ID || process.env.EBAY_CLIENT_ID || ''
|
|
214
|
+
: process.env.EBAY_SANDBOX_CLIENT_ID || process.env.EBAY_CLIENT_ID || '';
|
|
215
|
+
const fallbackClientSecret = environment === 'production'
|
|
216
|
+
? process.env.EBAY_PRODUCTION_CLIENT_SECRET || process.env.EBAY_CLIENT_SECRET || ''
|
|
217
|
+
: process.env.EBAY_SANDBOX_CLIENT_SECRET || process.env.EBAY_CLIENT_SECRET || '';
|
|
218
|
+
const fallbackRedirectUri = environment === 'production'
|
|
219
|
+
? process.env.EBAY_PRODUCTION_REDIRECT_URI || process.env.EBAY_REDIRECT_URI
|
|
220
|
+
: process.env.EBAY_SANDBOX_REDIRECT_URI || process.env.EBAY_REDIRECT_URI;
|
|
221
|
+
return {
|
|
222
|
+
clientId: secretConfig?.clientId || fallbackClientId,
|
|
223
|
+
clientSecret: secretConfig?.clientSecret || fallbackClientSecret,
|
|
224
|
+
redirectUri: secretConfig?.redirectUri || fallbackRedirectUri,
|
|
225
|
+
marketplaceId: (process.env.EBAY_MARKETPLACE_ID ?? '').trim() || 'EBAY_US',
|
|
226
|
+
contentLanguage: (process.env.EBAY_CONTENT_LANGUAGE ?? '').trim() || 'en-US',
|
|
227
|
+
environment,
|
|
228
|
+
accessToken: process.env.EBAY_USER_ACCESS_TOKEN ?? '',
|
|
229
|
+
refreshToken: process.env.EBAY_USER_REFRESH_TOKEN ?? '',
|
|
230
|
+
appAccessToken: process.env.EBAY_APP_ACCESS_TOKEN ?? '',
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
export function getBaseUrl(environment) {
|
|
234
|
+
return environment === 'production' ? 'https://api.ebay.com' : 'https://api.sandbox.ebay.com';
|
|
235
|
+
}
|
|
236
|
+
export function getIdentityBaseUrl(environment) {
|
|
237
|
+
return environment === 'production' ? 'https://apiz.ebay.com' : 'https://apiz.sandbox.ebay.com';
|
|
238
|
+
}
|
|
239
|
+
export function getAuthUrl(clientIdOrEnvironment, redirectUri, environment, locale = LocaleEnum.en_US, prompt = 'login', responseType = 'code', state, scopes) {
|
|
240
|
+
if (arguments.length === 1 &&
|
|
241
|
+
(clientIdOrEnvironment === 'production' || clientIdOrEnvironment === 'sandbox')) {
|
|
242
|
+
return `${getBaseUrl(clientIdOrEnvironment)}/identity/v1/oauth2/token`;
|
|
243
|
+
}
|
|
244
|
+
const clientId = clientIdOrEnvironment;
|
|
245
|
+
const env = environment ?? 'sandbox';
|
|
246
|
+
const scope = getDefaultScopes(env);
|
|
247
|
+
if (!(clientId && redirectUri)) {
|
|
248
|
+
console.error('clientId and redirectUri are required.');
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
const authBase = env === 'production' ? 'https://auth.ebay.com' : 'https://auth.sandbox.ebay.com';
|
|
252
|
+
const scopeList = scopes?.join('%20') || scope.join('%20');
|
|
253
|
+
const authorizeParams = new URLSearchParams({
|
|
254
|
+
client_id: clientId,
|
|
255
|
+
redirect_uri: redirectUri,
|
|
256
|
+
response_type: responseType,
|
|
257
|
+
prompt,
|
|
258
|
+
locale,
|
|
259
|
+
...(state ? { state } : {}),
|
|
260
|
+
});
|
|
261
|
+
return `${authBase}/oauth2/authorize?${authorizeParams.toString()}&scope=${scopeList}`;
|
|
262
|
+
}
|
|
263
|
+
export function getOAuthAuthorizationUrl(clientId, redirectUri, environment, scopes, locale, state) {
|
|
264
|
+
const authBase = environment === 'production' ? 'https://auth.ebay.com' : 'https://auth.sandbox.ebay.com';
|
|
265
|
+
const scopeList = (scopes && scopes.length > 0 ? scopes : getDefaultScopes(environment)).join('%20');
|
|
266
|
+
const params = new URLSearchParams({
|
|
267
|
+
client_id: clientId,
|
|
268
|
+
redirect_uri: redirectUri,
|
|
269
|
+
response_type: 'code',
|
|
270
|
+
...(locale ? { locale } : {}),
|
|
271
|
+
...(state ? { state } : {}),
|
|
272
|
+
});
|
|
273
|
+
return `${authBase}/oauth2/authorize?${params.toString()}&scope=${scopeList}`;
|
|
274
|
+
}
|
|
275
|
+
const iconUrl = (size) => {
|
|
276
|
+
const url = new URL(`../../public/icons/${size}.png`, import.meta.url);
|
|
277
|
+
const path = fileURLToPath(url);
|
|
278
|
+
if (!existsSync(path)) {
|
|
279
|
+
console.warn(`[eBay MCP] Icon not found at ${path}.`);
|
|
280
|
+
}
|
|
281
|
+
return url.toString();
|
|
282
|
+
};
|
|
283
|
+
export const mcpConfig = {
|
|
284
|
+
name: 'eBay API Model Context Protocol Server',
|
|
285
|
+
version: getVersion(),
|
|
286
|
+
title: 'eBay API Model Context Protocol Server',
|
|
287
|
+
websiteUrl: 'https://github.com/mrnajiboy/ebay-mcp-remote-edition',
|
|
288
|
+
icons: [
|
|
289
|
+
{ src: iconUrl('16x16'), mimeType: 'image/png', sizes: ['16x16'] },
|
|
290
|
+
{ src: iconUrl('32x32'), mimeType: 'image/png', sizes: ['32x32'] },
|
|
291
|
+
{ src: iconUrl('48x48'), mimeType: 'image/png', sizes: ['48x48'] },
|
|
292
|
+
{ src: iconUrl('128x128'), mimeType: 'image/png', sizes: ['128x128'] },
|
|
293
|
+
{ src: iconUrl('256x256'), mimeType: 'image/png', sizes: ['256x256'] },
|
|
294
|
+
{ src: iconUrl('512x512'), mimeType: 'image/png', sizes: ['512x512'] },
|
|
295
|
+
{ src: iconUrl('1024x1024'), mimeType: 'image/png', sizes: ['1024x1024'] },
|
|
296
|
+
],
|
|
297
|
+
};
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
import { serverLogger, toolLogger, getLogPaths } from './utils/logger.js';
|
|
7
|
+
import { checkForUpdates } from './utils/version.js';
|
|
8
|
+
checkForUpdates({ defer: true });
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
if (args.includes('setup')) {
|
|
11
|
+
try {
|
|
12
|
+
const { runSetup } = await import('./scripts/setup.js');
|
|
13
|
+
await runSetup();
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error('Setup failed:', error instanceof Error ? error.message : error);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* eBay API MCP Server
|
|
23
|
+
* Provides access to eBay APIs through Model Context Protocol
|
|
24
|
+
*/
|
|
25
|
+
class EbayMcpServer {
|
|
26
|
+
server;
|
|
27
|
+
api;
|
|
28
|
+
constructor() {
|
|
29
|
+
this.server = new McpServer(mcpConfig);
|
|
30
|
+
// Initialize eBay API client
|
|
31
|
+
this.api = new EbaySellerApi(getEbayConfig());
|
|
32
|
+
this.setupHandlers();
|
|
33
|
+
this.setupErrorHandling();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Initialize the API (load tokens from storage)
|
|
37
|
+
*/
|
|
38
|
+
async initialize() {
|
|
39
|
+
await this.api.initialize();
|
|
40
|
+
}
|
|
41
|
+
setupHandlers() {
|
|
42
|
+
const tools = getToolDefinitions();
|
|
43
|
+
serverLogger.info(`Registering ${tools.length} tools`);
|
|
44
|
+
// Register each tool with the MCP server
|
|
45
|
+
for (const toolDef of tools) {
|
|
46
|
+
this.server.registerTool(toolDef.name, {
|
|
47
|
+
description: toolDef.description,
|
|
48
|
+
inputSchema: toolDef.inputSchema,
|
|
49
|
+
}, async (args) => {
|
|
50
|
+
toolLogger.debug(`Executing tool: ${toolDef.name}`, { args });
|
|
51
|
+
try {
|
|
52
|
+
const result = await executeTool(this.api, toolDef.name, args);
|
|
53
|
+
toolLogger.debug(`Tool ${toolDef.name} completed successfully`);
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: JSON.stringify(result, null, 2),
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
65
|
+
toolLogger.error(`Tool ${toolDef.name} failed`, { error: errorMessage });
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
text: JSON.stringify({ error: errorMessage }, null, 2),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
isError: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
setupErrorHandling() {
|
|
80
|
+
process.on('SIGINT', async () => {
|
|
81
|
+
serverLogger.info('Received SIGINT, shutting down...');
|
|
82
|
+
await this.server.close();
|
|
83
|
+
process.exit(0);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async run() {
|
|
87
|
+
serverLogger.info('Starting eBay API MCP Server');
|
|
88
|
+
// Validate environment configuration
|
|
89
|
+
const validation = validateEnvironmentConfig();
|
|
90
|
+
// Log warnings
|
|
91
|
+
if (validation.warnings.length > 0) {
|
|
92
|
+
validation.warnings.forEach((warning) => {
|
|
93
|
+
serverLogger.warn(warning);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Log errors and exit if configuration is invalid
|
|
97
|
+
if (!validation.isValid) {
|
|
98
|
+
validation.errors.forEach((error) => {
|
|
99
|
+
serverLogger.error(error);
|
|
100
|
+
});
|
|
101
|
+
serverLogger.error('Please fix the configuration errors and restart the server.');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
// Initialize API (load tokens from storage)
|
|
105
|
+
serverLogger.info('Initializing API client');
|
|
106
|
+
await this.initialize();
|
|
107
|
+
// Log log file locations if file logging is enabled
|
|
108
|
+
if (process.env.EBAY_ENABLE_FILE_LOGGING === 'true') {
|
|
109
|
+
const paths = getLogPaths();
|
|
110
|
+
serverLogger.info('File logging enabled', {
|
|
111
|
+
logDir: paths.logDir,
|
|
112
|
+
errorLog: paths.errorLog,
|
|
113
|
+
combinedLog: paths.combinedLog,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const transport = new StdioServerTransport();
|
|
117
|
+
await this.server.connect(transport);
|
|
118
|
+
serverLogger.info('eBay API MCP Server running on stdio');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Start the server
|
|
122
|
+
const server = new EbayMcpServer();
|
|
123
|
+
server.run().catch((error) => {
|
|
124
|
+
serverLogger.error('Fatal error running server', {
|
|
125
|
+
error: error instanceof Error ? error.message : String(error),
|
|
126
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
127
|
+
});
|
|
128
|
+
process.exit(1);
|
|
129
|
+
});
|