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.
- package/LICENSE +201 -0
- package/README.md +586 -0
- package/build/api/account-management/account.d.ts +216 -0
- package/build/api/account-management/account.js +305 -0
- package/build/api/analytics-and-report/analytics.d.ts +33 -0
- package/build/api/analytics-and-report/analytics.js +102 -0
- package/build/api/client.d.ts +89 -0
- package/build/api/client.js +343 -0
- package/build/api/communication/feedback.d.ts +45 -0
- package/build/api/communication/feedback.js +119 -0
- package/build/api/communication/message.d.ts +55 -0
- package/build/api/communication/message.js +131 -0
- package/build/api/communication/negotiation.d.ts +39 -0
- package/build/api/communication/negotiation.js +97 -0
- package/build/api/communication/notification.d.ts +128 -0
- package/build/api/communication/notification.js +373 -0
- package/build/api/index.d.ts +96 -0
- package/build/api/index.js +121 -0
- package/build/api/listing-management/inventory.d.ts +216 -0
- package/build/api/listing-management/inventory.js +633 -0
- package/build/api/listing-metadata/metadata.d.ts +154 -0
- package/build/api/listing-metadata/metadata.js +485 -0
- package/build/api/listing-metadata/taxonomy.d.ts +38 -0
- package/build/api/listing-metadata/taxonomy.js +58 -0
- package/build/api/marketing-and-promotions/marketing.d.ts +395 -0
- package/build/api/marketing-and-promotions/marketing.js +565 -0
- package/build/api/marketing-and-promotions/recommendation.d.ts +20 -0
- package/build/api/marketing-and-promotions/recommendation.js +32 -0
- package/build/api/order-management/dispute.d.ts +65 -0
- package/build/api/order-management/dispute.js +69 -0
- package/build/api/order-management/fulfillment.d.ts +80 -0
- package/build/api/order-management/fulfillment.js +89 -0
- package/build/api/other/compliance.d.ts +26 -0
- package/build/api/other/compliance.js +47 -0
- package/build/api/other/edelivery.d.ts +153 -0
- package/build/api/other/edelivery.js +219 -0
- package/build/api/other/identity.d.ts +17 -0
- package/build/api/other/identity.js +24 -0
- package/build/api/other/translation.d.ts +14 -0
- package/build/api/other/translation.js +22 -0
- package/build/api/other/vero.d.ts +30 -0
- package/build/api/other/vero.js +48 -0
- package/build/auth/oauth-metadata.d.ts +46 -0
- package/build/auth/oauth-metadata.js +59 -0
- package/build/auth/oauth-middleware.d.ts +35 -0
- package/build/auth/oauth-middleware.js +99 -0
- package/build/auth/oauth-types.d.ts +66 -0
- package/build/auth/oauth-types.js +4 -0
- package/build/auth/oauth.d.ts +93 -0
- package/build/auth/oauth.js +383 -0
- package/build/auth/scope-utils.d.ts +70 -0
- package/build/auth/scope-utils.js +304 -0
- package/build/auth/token-verifier.d.ts +57 -0
- package/build/auth/token-verifier.js +172 -0
- package/build/config/environment.d.ts +61 -0
- package/build/config/environment.js +260 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +98 -0
- package/build/schemas/account-management/account.d.ts +5324 -0
- package/build/schemas/account-management/account.js +366 -0
- package/build/schemas/analytics/analytics.d.ts +167 -0
- package/build/schemas/analytics/analytics.js +191 -0
- package/build/schemas/communication/messages.d.ts +1872 -0
- package/build/schemas/communication/messages.js +348 -0
- package/build/schemas/fulfillment/orders.d.ts +4655 -0
- package/build/schemas/fulfillment/orders.js +317 -0
- package/build/schemas/index.d.ts +2100 -0
- package/build/schemas/index.js +68 -0
- package/build/schemas/inventory-management/inventory.d.ts +6419 -0
- package/build/schemas/inventory-management/inventory.js +450 -0
- package/build/schemas/marketing/marketing.d.ts +14181 -0
- package/build/schemas/marketing/marketing.js +1088 -0
- package/build/schemas/metadata/metadata.d.ts +5259 -0
- package/build/schemas/metadata/metadata.js +614 -0
- package/build/schemas/other/other-apis.d.ts +257 -0
- package/build/schemas/other/other-apis.js +372 -0
- package/build/schemas/taxonomy/taxonomy.d.ts +215 -0
- package/build/schemas/taxonomy/taxonomy.js +571 -0
- package/build/scripts/auto-setup.d.ts +12 -0
- package/build/scripts/auto-setup.js +277 -0
- package/build/scripts/diagnostics.d.ts +8 -0
- package/build/scripts/diagnostics.js +299 -0
- package/build/scripts/download-specs.d.ts +1 -0
- package/build/scripts/download-specs.js +116 -0
- package/build/scripts/interactive-setup.d.ts +21 -0
- package/build/scripts/interactive-setup.js +723 -0
- package/build/server-http.d.ts +11 -0
- package/build/server-http.js +361 -0
- package/build/tools/definitions/account-with-schemas.d.ts +39 -0
- package/build/tools/definitions/account-with-schemas.js +170 -0
- package/build/tools/definitions/account.d.ts +12 -0
- package/build/tools/definitions/account.js +428 -0
- package/build/tools/definitions/analytics.d.ts +25 -0
- package/build/tools/definitions/analytics.js +66 -0
- package/build/tools/definitions/communication.d.ts +12 -0
- package/build/tools/definitions/communication.js +151 -0
- package/build/tools/definitions/fulfillment.d.ts +12 -0
- package/build/tools/definitions/fulfillment.js +326 -0
- package/build/tools/definitions/index.d.ts +25 -0
- package/build/tools/definitions/index.js +37 -0
- package/build/tools/definitions/inventory.d.ts +12 -0
- package/build/tools/definitions/inventory.js +429 -0
- package/build/tools/definitions/marketing.d.ts +12 -0
- package/build/tools/definitions/marketing.js +1095 -0
- package/build/tools/definitions/metadata.d.ts +12 -0
- package/build/tools/definitions/metadata.js +188 -0
- package/build/tools/definitions/other.d.ts +13 -0
- package/build/tools/definitions/other.js +309 -0
- package/build/tools/definitions/taxonomy.d.ts +25 -0
- package/build/tools/definitions/taxonomy.js +64 -0
- package/build/tools/definitions/token-management.d.ts +35 -0
- package/build/tools/definitions/token-management.js +103 -0
- package/build/tools/index.d.ts +11 -0
- package/build/tools/index.js +1003 -0
- package/build/tools/schemas.d.ts +14764 -0
- package/build/tools/schemas.js +667 -0
- package/build/tools/tool-definitions.d.ts +35 -0
- package/build/tools/tool-definitions.js +3534 -0
- package/build/types/application-settings/developerAnalyticsV1BetaOas3.d.ts +197 -0
- package/build/types/application-settings/developerAnalyticsV1BetaOas3.js +5 -0
- package/build/types/application-settings/developerClientRegistrationV1Oas3.d.ts +155 -0
- package/build/types/application-settings/developerClientRegistrationV1Oas3.js +5 -0
- package/build/types/application-settings/developerKeyManagementV1Oas3.d.ts +246 -0
- package/build/types/application-settings/developerKeyManagementV1Oas3.js +5 -0
- package/build/types/ebay-enums.d.ts +1204 -0
- package/build/types/ebay-enums.js +1330 -0
- package/build/types/ebay.d.ts +143 -0
- package/build/types/ebay.js +123 -0
- package/build/types/index.d.ts +6 -0
- package/build/types/index.js +10 -0
- package/build/types/sell-apps/account-management/sellAccountV1Oas3.d.ts +2579 -0
- package/build/types/sell-apps/account-management/sellAccountV1Oas3.js +5 -0
- package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.d.ts +446 -0
- package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.d.ts +705 -0
- package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.js +5 -0
- package/build/types/sell-apps/communication/commerceMessageV1Oas3.d.ts +590 -0
- package/build/types/sell-apps/communication/commerceMessageV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/commerceNotificationV1Oas3.d.ts +1276 -0
- package/build/types/sell-apps/communication/commerceNotificationV1Oas3.js +5 -0
- package/build/types/sell-apps/communication/sellNegotiationV1Oas3.d.ts +277 -0
- package/build/types/sell-apps/communication/sellNegotiationV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.d.ts +3133 -0
- package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.js +5 -0
- package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.d.ts +2289 -0
- package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.d.ts +6650 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.d.ts +172 -0
- package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.js +5 -0
- package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.d.ts +1869 -0
- package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.d.ts +178 -0
- package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.d.ts +128 -0
- package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.js +5 -0
- package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.d.ts +417 -0
- package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.d.ts +273 -0
- package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.d.ts +2537 -0
- package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.d.ts +6650 -0
- package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.js +5 -0
- package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.d.ts +172 -0
- package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.js +5 -0
- package/build/utils/account-management/account.d.ts +1094 -0
- package/build/utils/account-management/account.js +831 -0
- package/build/utils/communication/feedback.d.ts +152 -0
- package/build/utils/communication/feedback.js +216 -0
- package/build/utils/communication/message.d.ts +174 -0
- package/build/utils/communication/message.js +242 -0
- package/build/utils/communication/negotiation.d.ts +123 -0
- package/build/utils/communication/negotiation.js +150 -0
- package/build/utils/communication/notification.d.ts +370 -0
- package/build/utils/communication/notification.js +369 -0
- package/build/utils/date-converter.d.ts +59 -0
- package/build/utils/date-converter.js +160 -0
- package/build/utils/llm-client-detector.d.ts +54 -0
- package/build/utils/llm-client-detector.js +318 -0
- package/build/utils/oauth-helper.d.ts +37 -0
- package/build/utils/oauth-helper.js +315 -0
- package/build/utils/order-management/dispute.d.ts +346 -0
- package/build/utils/order-management/dispute.js +369 -0
- package/build/utils/order-management/fulfillment.d.ts +200 -0
- package/build/utils/order-management/fulfillment.js +205 -0
- package/build/utils/other/compliance.d.ts +49 -0
- package/build/utils/other/compliance.js +76 -0
- package/build/utils/other/edelivery.d.ts +310 -0
- package/build/utils/other/edelivery.js +241 -0
- package/build/utils/other/identity.d.ts +13 -0
- package/build/utils/other/identity.js +13 -0
- package/build/utils/other/translation.d.ts +28 -0
- package/build/utils/other/translation.js +41 -0
- package/build/utils/other/vero.d.ts +61 -0
- package/build/utils/other/vero.js +90 -0
- package/build/utils/scope-helper.d.ts +49 -0
- package/build/utils/scope-helper.js +207 -0
- package/build/utils/security-checker.d.ts +46 -0
- package/build/utils/security-checker.js +248 -0
- package/build/utils/setup-validator.d.ts +25 -0
- package/build/utils/setup-validator.js +305 -0
- package/build/utils/token-utils.d.ts +40 -0
- package/build/utils/token-utils.js +40 -0
- package/package.json +115 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Setup Script for eBay API MCP Server
|
|
3
|
+
*
|
|
4
|
+
* This script automatically:
|
|
5
|
+
* 1. Detects installed MCP clients (Claude Desktop, Gemini, ChatGPT)
|
|
6
|
+
* 2. Generates MCP client configurations from .env
|
|
7
|
+
* 3. Validates environment tokens configuration
|
|
8
|
+
* 4. Validates the setup
|
|
9
|
+
*
|
|
10
|
+
* Usage: npm run auto-setup (or runs automatically after npm install)
|
|
11
|
+
*/
|
|
12
|
+
import { config } from 'dotenv';
|
|
13
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
14
|
+
import { homedir, platform } from 'os';
|
|
15
|
+
import { join, dirname } from 'path';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
17
|
+
// Load environment variables
|
|
18
|
+
config();
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = dirname(__filename);
|
|
21
|
+
const PROJECT_ROOT = join(__dirname, '../..');
|
|
22
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
23
|
+
// Color Utilities
|
|
24
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
25
|
+
const colors = {
|
|
26
|
+
reset: '\x1b[0m',
|
|
27
|
+
red: '\x1b[31m',
|
|
28
|
+
green: '\x1b[32m',
|
|
29
|
+
yellow: '\x1b[33m',
|
|
30
|
+
blue: '\x1b[34m',
|
|
31
|
+
cyan: '\x1b[36m',
|
|
32
|
+
};
|
|
33
|
+
function print(message, color) {
|
|
34
|
+
const colorCode = color ? colors[color] : '';
|
|
35
|
+
console.log(`${colorCode}${message}${colors.reset}`);
|
|
36
|
+
}
|
|
37
|
+
function printSuccess(message) {
|
|
38
|
+
print(`ā
${message}`, 'green');
|
|
39
|
+
}
|
|
40
|
+
function printWarning(message) {
|
|
41
|
+
print(`ā ļø ${message}`, 'yellow');
|
|
42
|
+
}
|
|
43
|
+
function printError(message) {
|
|
44
|
+
print(`ā ${message}`, 'red');
|
|
45
|
+
}
|
|
46
|
+
function printInfo(message) {
|
|
47
|
+
print(`ā¹ļø ${message}`, 'cyan');
|
|
48
|
+
}
|
|
49
|
+
function printHeader(message) {
|
|
50
|
+
print('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā', 'blue');
|
|
51
|
+
print(` ${message}`, 'cyan');
|
|
52
|
+
print('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n', 'blue');
|
|
53
|
+
}
|
|
54
|
+
function getConfigPaths() {
|
|
55
|
+
const home = homedir();
|
|
56
|
+
const os = platform();
|
|
57
|
+
const paths = {};
|
|
58
|
+
// Claude Desktop config paths
|
|
59
|
+
if (os === 'darwin') {
|
|
60
|
+
paths.claude = join(home, 'Library/Application Support/Claude/claude_desktop_config.json');
|
|
61
|
+
}
|
|
62
|
+
else if (os === 'win32') {
|
|
63
|
+
paths.claude = join(home, 'AppData/Roaming/Claude/claude_desktop_config.json');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
paths.claude = join(home, '.config/Claude/claude_desktop_config.json');
|
|
67
|
+
}
|
|
68
|
+
// Gemini config path
|
|
69
|
+
paths.gemini = join(home, '.config/gemini/config.json');
|
|
70
|
+
// ChatGPT config path
|
|
71
|
+
paths.chatgpt = join(home, '.config/chatgpt/config.json');
|
|
72
|
+
return paths;
|
|
73
|
+
}
|
|
74
|
+
function detectMCPClients() {
|
|
75
|
+
const configPaths = getConfigPaths();
|
|
76
|
+
const clients = [];
|
|
77
|
+
for (const [name, configPath] of Object.entries(configPaths)) {
|
|
78
|
+
const detected = existsSync(configPath) || existsSync(dirname(configPath));
|
|
79
|
+
clients.push({
|
|
80
|
+
name,
|
|
81
|
+
configPath,
|
|
82
|
+
detected,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return clients;
|
|
86
|
+
}
|
|
87
|
+
function generateMCPServerConfig() {
|
|
88
|
+
const buildPath = join(PROJECT_ROOT, 'build/index.js');
|
|
89
|
+
const config = {
|
|
90
|
+
command: 'node',
|
|
91
|
+
args: [buildPath],
|
|
92
|
+
env: {
|
|
93
|
+
EBAY_CLIENT_ID: process.env.EBAY_CLIENT_ID || '',
|
|
94
|
+
EBAY_CLIENT_SECRET: process.env.EBAY_CLIENT_SECRET || '',
|
|
95
|
+
EBAY_ENVIRONMENT: process.env.EBAY_ENVIRONMENT || 'sandbox',
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
// Add optional environment variables if they exist
|
|
99
|
+
if (process.env.EBAY_REDIRECT_URI) {
|
|
100
|
+
config.env.EBAY_REDIRECT_URI = process.env.EBAY_REDIRECT_URI;
|
|
101
|
+
}
|
|
102
|
+
if (process.env.EBAY_USER_ACCESS_TOKEN) {
|
|
103
|
+
config.env.EBAY_USER_ACCESS_TOKEN = process.env.EBAY_USER_ACCESS_TOKEN;
|
|
104
|
+
}
|
|
105
|
+
if (process.env.EBAY_USER_REFRESH_TOKEN) {
|
|
106
|
+
config.env.EBAY_USER_REFRESH_TOKEN = process.env.EBAY_USER_REFRESH_TOKEN;
|
|
107
|
+
}
|
|
108
|
+
if (process.env.EBAY_APP_ACCESS_TOKEN) {
|
|
109
|
+
config.env.EBAY_APP_ACCESS_TOKEN = process.env.EBAY_APP_ACCESS_TOKEN;
|
|
110
|
+
}
|
|
111
|
+
return config;
|
|
112
|
+
}
|
|
113
|
+
function updateClientConfig(client, serverConfig) {
|
|
114
|
+
try {
|
|
115
|
+
// Ensure directory exists
|
|
116
|
+
const configDir = dirname(client.configPath);
|
|
117
|
+
if (!existsSync(configDir)) {
|
|
118
|
+
mkdirSync(configDir, { recursive: true });
|
|
119
|
+
}
|
|
120
|
+
let config = { mcpServers: {} };
|
|
121
|
+
if (existsSync(client.configPath)) {
|
|
122
|
+
try {
|
|
123
|
+
const existing = readFileSync(client.configPath, 'utf-8');
|
|
124
|
+
const parsed = JSON.parse(existing);
|
|
125
|
+
config = {
|
|
126
|
+
...parsed,
|
|
127
|
+
mcpServers: parsed.mcpServers || {},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
printWarning(`Invalid JSON in ${client.configPath}, creating backup and new config`);
|
|
132
|
+
const backup = `${client.configPath}.backup.${Date.now()}`;
|
|
133
|
+
writeFileSync(backup, readFileSync(client.configPath));
|
|
134
|
+
printInfo(`Backup saved to: ${backup}`);
|
|
135
|
+
config = { mcpServers: {} };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Update eBay server config
|
|
139
|
+
config.mcpServers.ebay = serverConfig;
|
|
140
|
+
// Write config
|
|
141
|
+
writeFileSync(client.configPath, JSON.stringify(config, null, 2));
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
printError(`Failed to update ${client.name} config: ${error}`);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
150
|
+
// Token Validation (Environment-based only)
|
|
151
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
152
|
+
function validateTokens() {
|
|
153
|
+
// Check if user refresh token is provided in .env
|
|
154
|
+
const hasUserRefreshToken = process.env.EBAY_USER_REFRESH_TOKEN;
|
|
155
|
+
if (!hasUserRefreshToken) {
|
|
156
|
+
printInfo('No EBAY_USER_REFRESH_TOKEN in .env - will use app tokens (1k req/day)');
|
|
157
|
+
printInfo('For higher rate limits (10k-50k req/day), add EBAY_USER_REFRESH_TOKEN to .env');
|
|
158
|
+
return true; // Not an error, just informational
|
|
159
|
+
}
|
|
160
|
+
printSuccess('User refresh token found in .env - high rate limits enabled');
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
164
|
+
// Validation
|
|
165
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
166
|
+
function validateEnvironment() {
|
|
167
|
+
const errors = [];
|
|
168
|
+
const warnings = [];
|
|
169
|
+
// Check .env file exists
|
|
170
|
+
const envPath = join(PROJECT_ROOT, '.env');
|
|
171
|
+
if (!existsSync(envPath)) {
|
|
172
|
+
errors.push('.env file not found. Copy .env.example to .env and fill in your credentials.');
|
|
173
|
+
return { valid: false, errors, warnings };
|
|
174
|
+
}
|
|
175
|
+
// Check required variables
|
|
176
|
+
if (!process.env.EBAY_CLIENT_ID) {
|
|
177
|
+
errors.push('EBAY_CLIENT_ID is not set in .env');
|
|
178
|
+
}
|
|
179
|
+
if (!process.env.EBAY_CLIENT_SECRET) {
|
|
180
|
+
errors.push('EBAY_CLIENT_SECRET is not set in .env');
|
|
181
|
+
}
|
|
182
|
+
const environment = process.env.EBAY_ENVIRONMENT;
|
|
183
|
+
if (environment && environment !== 'production' && environment !== 'sandbox') {
|
|
184
|
+
errors.push(`EBAY_ENVIRONMENT must be "production" or "sandbox", got: "${environment}"`);
|
|
185
|
+
}
|
|
186
|
+
if (!process.env.EBAY_REDIRECT_URI) {
|
|
187
|
+
warnings.push('EBAY_REDIRECT_URI is not set - user OAuth flow will not work. This is required for 10k-50k req/day rate limits.');
|
|
188
|
+
}
|
|
189
|
+
// Check build directory exists
|
|
190
|
+
const buildPath = join(PROJECT_ROOT, 'build/index.js');
|
|
191
|
+
if (!existsSync(buildPath)) {
|
|
192
|
+
warnings.push('Build directory not found. Run "npm run build" first.');
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
valid: errors.length === 0,
|
|
196
|
+
errors,
|
|
197
|
+
warnings,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
201
|
+
// Main
|
|
202
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
203
|
+
async function main() {
|
|
204
|
+
printHeader('eBay API MCP Server - Auto Setup');
|
|
205
|
+
// Step 1: Validate environment
|
|
206
|
+
printInfo('Step 1/4: Validating environment configuration...');
|
|
207
|
+
const validation = validateEnvironment();
|
|
208
|
+
if (validation.errors.length > 0) {
|
|
209
|
+
printError('Environment validation failed:');
|
|
210
|
+
validation.errors.forEach((error) => print(` ⢠${error}`, 'red'));
|
|
211
|
+
print('\nPlease fix these errors and run again.', 'yellow');
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
if (validation.warnings.length > 0) {
|
|
215
|
+
validation.warnings.forEach((warning) => printWarning(warning));
|
|
216
|
+
}
|
|
217
|
+
printSuccess('Environment validation passed');
|
|
218
|
+
// Step 2: Detect MCP clients
|
|
219
|
+
print('\nStep 2/4: Detecting installed MCP clients...');
|
|
220
|
+
const clients = detectMCPClients();
|
|
221
|
+
const detectedClients = clients.filter((c) => c.detected);
|
|
222
|
+
if (detectedClients.length === 0) {
|
|
223
|
+
printWarning('No MCP clients detected on this system');
|
|
224
|
+
printInfo('Supported clients: Claude Desktop, Gemini, ChatGPT');
|
|
225
|
+
printInfo('Install a client and run this script again');
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
printSuccess(`Detected ${detectedClients.length} MCP client(s):`);
|
|
229
|
+
detectedClients.forEach((client) => {
|
|
230
|
+
print(` ⢠${client.name.charAt(0).toUpperCase() + client.name.slice(1)}`, 'green');
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// Step 3: Generate configurations
|
|
234
|
+
if (detectedClients.length > 0) {
|
|
235
|
+
print('\nStep 3/4: Generating MCP client configurations...');
|
|
236
|
+
const serverConfig = generateMCPServerConfig();
|
|
237
|
+
for (const client of detectedClients) {
|
|
238
|
+
const success = updateClientConfig(client, serverConfig);
|
|
239
|
+
if (success) {
|
|
240
|
+
printSuccess(`Generated config for ${client.name} at: ${client.configPath}`);
|
|
241
|
+
client.configGenerated = true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
print('\nStep 3/4: Skipping config generation (no clients detected)');
|
|
247
|
+
}
|
|
248
|
+
// Step 4: Validate tokens
|
|
249
|
+
print('\nStep 4/4: Validating token configuration...');
|
|
250
|
+
validateTokens();
|
|
251
|
+
// Final summary
|
|
252
|
+
printHeader('Setup Complete! š');
|
|
253
|
+
const generatedCount = detectedClients.filter((c) => c.configGenerated).length;
|
|
254
|
+
if (generatedCount > 0) {
|
|
255
|
+
printSuccess(`Successfully configured ${generatedCount} MCP client(s)`);
|
|
256
|
+
print('\nš Next Steps:', 'cyan');
|
|
257
|
+
print(' 1. Restart your MCP clients (Claude Desktop, Gemini, etc.)');
|
|
258
|
+
print(' 2. Verify connection in MCP client settings/logs');
|
|
259
|
+
print(' 3. Test with: "List my eBay inventory items"');
|
|
260
|
+
if (validation.warnings.some((w) => w.includes('EBAY_REDIRECT_URI'))) {
|
|
261
|
+
print('\nš” Pro Tip:', 'yellow');
|
|
262
|
+
print(' Add EBAY_REDIRECT_URI to .env for user OAuth (10k-50k req/day rate limits)');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
printInfo('No configurations generated (no MCP clients detected)');
|
|
267
|
+
print('\nš To complete setup:', 'cyan');
|
|
268
|
+
print(' 1. Install an MCP client (Claude Desktop, Gemini, or ChatGPT)');
|
|
269
|
+
print(' 2. Run: npm run auto-setup');
|
|
270
|
+
}
|
|
271
|
+
print('\nš Documentation: https://github.com/YosefHayim/ebay-mcp#readme\n');
|
|
272
|
+
}
|
|
273
|
+
// Run the script
|
|
274
|
+
main().catch((error) => {
|
|
275
|
+
printError(`Auto-setup failed: ${error}`);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
});
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics Script - Troubleshooting and system health checks
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* npm run diagnose
|
|
6
|
+
* npx ebay-mcp --diagnose
|
|
7
|
+
*/
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { runSecurityChecks, displaySecurityResults } from '../utils/security-checker.js';
|
|
13
|
+
import { validateSetup, displayRecommendations } from '../utils/setup-validator.js';
|
|
14
|
+
import { detectLLMClients } from '../utils/llm-client-detector.js';
|
|
15
|
+
import { displayScopeVerification, parseScopeString } from '../utils/scope-helper.js';
|
|
16
|
+
import { EbaySellerApi } from '../api/index.js';
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
const PROJECT_ROOT = join(__dirname, '../..');
|
|
20
|
+
/**
|
|
21
|
+
* Parse .env file
|
|
22
|
+
*/
|
|
23
|
+
function parseEnvFile(filePath) {
|
|
24
|
+
const env = {};
|
|
25
|
+
if (!existsSync(filePath)) {
|
|
26
|
+
return env;
|
|
27
|
+
}
|
|
28
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
29
|
+
const lines = content.split('\n');
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
const trimmed = line.trim();
|
|
32
|
+
if (!trimmed || trimmed.startsWith('#')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const match = /^([^=]+)=(.*)$/.exec(trimmed);
|
|
36
|
+
if (match) {
|
|
37
|
+
const key = match[1].trim();
|
|
38
|
+
let value = match[2].trim();
|
|
39
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
40
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
41
|
+
value = value.slice(1, -1);
|
|
42
|
+
}
|
|
43
|
+
env[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return env;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check API connectivity
|
|
50
|
+
*/
|
|
51
|
+
async function checkApiConnectivity() {
|
|
52
|
+
try {
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
55
|
+
const response = await fetch('https://api.ebay.com/health', {
|
|
56
|
+
signal: controller.signal,
|
|
57
|
+
});
|
|
58
|
+
clearTimeout(timeout);
|
|
59
|
+
return { canReachEbay: response.ok || response.status === 404 };
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return {
|
|
63
|
+
canReachEbay: false,
|
|
64
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Test eBay API authentication
|
|
70
|
+
*/
|
|
71
|
+
async function testEbayAuthentication(config) {
|
|
72
|
+
try {
|
|
73
|
+
const api = new EbaySellerApi(config);
|
|
74
|
+
await api.initialize();
|
|
75
|
+
// Try to get user info
|
|
76
|
+
const userInfo = await api.identity.getUser();
|
|
77
|
+
return { success: true, userInfo };
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Display diagnostic header
|
|
88
|
+
*/
|
|
89
|
+
function displayHeader() {
|
|
90
|
+
console.clear();
|
|
91
|
+
console.log(chalk.bold.cyan(`
|
|
92
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
93
|
+
ā ā
|
|
94
|
+
ā eBay MCP Server Diagnostics ā
|
|
95
|
+
ā ā
|
|
96
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
97
|
+
`));
|
|
98
|
+
console.log(chalk.gray(`Run date: ${new Date().toISOString()}\n`));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Display system information
|
|
102
|
+
*/
|
|
103
|
+
function displaySystemInfo() {
|
|
104
|
+
console.log(chalk.bold.cyan('š» System Information\n'));
|
|
105
|
+
console.log(` ${chalk.gray('Node.js:')} ${process.version}`);
|
|
106
|
+
console.log(` ${chalk.gray('Platform:')} ${process.platform}`);
|
|
107
|
+
console.log(` ${chalk.gray('Architecture:')} ${process.arch}`);
|
|
108
|
+
console.log(` ${chalk.gray('CWD:')} ${process.cwd()}`);
|
|
109
|
+
console.log('');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Display configuration status
|
|
113
|
+
*/
|
|
114
|
+
function displayConfigurationStatus(envVars) {
|
|
115
|
+
console.log(chalk.bold.cyan('āļø Configuration Status\n'));
|
|
116
|
+
const checks = [
|
|
117
|
+
{ key: 'EBAY_CLIENT_ID', label: 'Client ID', redact: true },
|
|
118
|
+
{ key: 'EBAY_CLIENT_SECRET', label: 'Client Secret', redact: true },
|
|
119
|
+
{ key: 'EBAY_REDIRECT_URI', label: 'Redirect URI', redact: false },
|
|
120
|
+
{ key: 'EBAY_ENVIRONMENT', label: 'Environment', redact: false },
|
|
121
|
+
{ key: 'EBAY_USER_REFRESH_TOKEN', label: 'User Refresh Token', redact: true },
|
|
122
|
+
{ key: 'EBAY_USER_ACCESS_TOKEN', label: 'User Access Token', redact: true },
|
|
123
|
+
{ key: 'EBAY_APP_ACCESS_TOKEN', label: 'App Access Token', redact: true },
|
|
124
|
+
];
|
|
125
|
+
for (const check of checks) {
|
|
126
|
+
const value = envVars[check.key];
|
|
127
|
+
let status;
|
|
128
|
+
let displayValue;
|
|
129
|
+
if (value && value.trim() && !value.includes('_here')) {
|
|
130
|
+
status = chalk.green('ā Set');
|
|
131
|
+
displayValue = check.redact ? `${value.substring(0, 10)}...` : value;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
status = chalk.red('ā Not set');
|
|
135
|
+
displayValue = chalk.gray('(not configured)');
|
|
136
|
+
}
|
|
137
|
+
console.log(` ${status} ${chalk.bold(check.label)}: ${displayValue}`);
|
|
138
|
+
}
|
|
139
|
+
console.log('');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Display LLM client status
|
|
143
|
+
*/
|
|
144
|
+
function displayLLMClientStatus() {
|
|
145
|
+
console.log(chalk.bold.cyan('š¤ LLM Client Detection\n'));
|
|
146
|
+
const clients = detectLLMClients();
|
|
147
|
+
for (const client of clients) {
|
|
148
|
+
const detected = client.detected ? chalk.green('ā Detected') : chalk.gray('ā Not found');
|
|
149
|
+
const configured = client.configExists
|
|
150
|
+
? chalk.green('[Configured]')
|
|
151
|
+
: chalk.gray('[Not configured]');
|
|
152
|
+
console.log(` ${detected} ${chalk.bold(client.displayName)} ${configured}`);
|
|
153
|
+
if (client.detected) {
|
|
154
|
+
console.log(chalk.gray(` Config: ${client.configPath}`));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
console.log('');
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Test API authentication and display results
|
|
161
|
+
*/
|
|
162
|
+
async function displayAuthenticationTest(config) {
|
|
163
|
+
console.log(chalk.bold.cyan('š API Authentication Test\n'));
|
|
164
|
+
const result = await testEbayAuthentication(config);
|
|
165
|
+
if (result.success) {
|
|
166
|
+
console.log(chalk.green(' ā Successfully authenticated with eBay API\n'));
|
|
167
|
+
if (result.userInfo) {
|
|
168
|
+
console.log(chalk.bold.white(' User Information:'));
|
|
169
|
+
console.log(chalk.gray(JSON.stringify(result.userInfo, null, 2)));
|
|
170
|
+
console.log('');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log(chalk.red(' ā Authentication failed\n'));
|
|
175
|
+
console.log(chalk.yellow(` Error: ${result.error}\n`));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Generate diagnostic report
|
|
180
|
+
*/
|
|
181
|
+
async function generateDiagnosticReport(exportPath) {
|
|
182
|
+
const envPath = join(PROJECT_ROOT, '.env');
|
|
183
|
+
const envVars = parseEnvFile(envPath);
|
|
184
|
+
// Run security checks
|
|
185
|
+
const securityResults = await runSecurityChecks(PROJECT_ROOT);
|
|
186
|
+
// Run configuration validation
|
|
187
|
+
const validationSummary = await validateSetup(PROJECT_ROOT);
|
|
188
|
+
// Detect LLM clients
|
|
189
|
+
const llmClients = detectLLMClients();
|
|
190
|
+
// Check API connectivity
|
|
191
|
+
const apiConnection = await checkApiConnectivity();
|
|
192
|
+
const report = {
|
|
193
|
+
timestamp: new Date().toISOString(),
|
|
194
|
+
environment: {
|
|
195
|
+
nodeVersion: process.version,
|
|
196
|
+
platform: process.platform,
|
|
197
|
+
arch: process.arch,
|
|
198
|
+
},
|
|
199
|
+
security: securityResults,
|
|
200
|
+
configuration: validationSummary,
|
|
201
|
+
llmClients,
|
|
202
|
+
apiConnection,
|
|
203
|
+
};
|
|
204
|
+
// If we have credentials, test authentication
|
|
205
|
+
if (envVars.EBAY_CLIENT_ID && envVars.EBAY_CLIENT_SECRET) {
|
|
206
|
+
const config = {
|
|
207
|
+
clientId: envVars.EBAY_CLIENT_ID,
|
|
208
|
+
clientSecret: envVars.EBAY_CLIENT_SECRET,
|
|
209
|
+
redirectUri: envVars.EBAY_REDIRECT_URI,
|
|
210
|
+
environment: (envVars.EBAY_ENVIRONMENT || 'sandbox'),
|
|
211
|
+
};
|
|
212
|
+
const authResult = await testEbayAuthentication(config);
|
|
213
|
+
report.tokenInfo = {
|
|
214
|
+
hasUserToken: !!envVars.EBAY_USER_REFRESH_TOKEN,
|
|
215
|
+
hasAppToken: !!envVars.EBAY_APP_ACCESS_TOKEN,
|
|
216
|
+
};
|
|
217
|
+
if (authResult.success) {
|
|
218
|
+
report.tokenInfo.scopes = envVars.EBAY_USER_REFRESH_TOKEN
|
|
219
|
+
? parseScopeString(envVars.EBAY_USER_REFRESH_TOKEN)
|
|
220
|
+
: [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Export report if path provided
|
|
224
|
+
if (exportPath) {
|
|
225
|
+
writeFileSync(exportPath, JSON.stringify(report, null, 2), 'utf-8');
|
|
226
|
+
console.log(chalk.green(`\nā Diagnostic report exported to: ${exportPath}\n`));
|
|
227
|
+
}
|
|
228
|
+
return report;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Main diagnostics function
|
|
232
|
+
*/
|
|
233
|
+
async function runDiagnostics(exportReport = false) {
|
|
234
|
+
displayHeader();
|
|
235
|
+
displaySystemInfo();
|
|
236
|
+
// Security checks
|
|
237
|
+
const securityResults = await runSecurityChecks(PROJECT_ROOT);
|
|
238
|
+
displaySecurityResults(securityResults);
|
|
239
|
+
// Configuration status
|
|
240
|
+
const envPath = join(PROJECT_ROOT, '.env');
|
|
241
|
+
const envVars = parseEnvFile(envPath);
|
|
242
|
+
displayConfigurationStatus(envVars);
|
|
243
|
+
// LLM client detection
|
|
244
|
+
displayLLMClientStatus();
|
|
245
|
+
// API connectivity
|
|
246
|
+
console.log(chalk.bold.cyan('š API Connectivity\n'));
|
|
247
|
+
const apiConnection = await checkApiConnectivity();
|
|
248
|
+
if (apiConnection.canReachEbay) {
|
|
249
|
+
console.log(chalk.green(' ā Can reach eBay API servers\n'));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
console.log(chalk.red(' ā Cannot reach eBay API servers'));
|
|
253
|
+
console.log(chalk.yellow(` Error: ${apiConnection.error}\n`));
|
|
254
|
+
}
|
|
255
|
+
// Configuration validation
|
|
256
|
+
console.log(chalk.bold.cyan('š Configuration Validation\n'));
|
|
257
|
+
const validationSummary = await validateSetup(PROJECT_ROOT);
|
|
258
|
+
displayRecommendations(validationSummary);
|
|
259
|
+
// If we have credentials, test authentication
|
|
260
|
+
if (envVars.EBAY_CLIENT_ID && envVars.EBAY_CLIENT_SECRET) {
|
|
261
|
+
const config = {
|
|
262
|
+
clientId: envVars.EBAY_CLIENT_ID,
|
|
263
|
+
clientSecret: envVars.EBAY_CLIENT_SECRET,
|
|
264
|
+
redirectUri: envVars.EBAY_REDIRECT_URI,
|
|
265
|
+
environment: (envVars.EBAY_ENVIRONMENT || 'sandbox'),
|
|
266
|
+
};
|
|
267
|
+
await displayAuthenticationTest(config);
|
|
268
|
+
// Scope verification if user has refresh token
|
|
269
|
+
if (envVars.EBAY_USER_REFRESH_TOKEN) {
|
|
270
|
+
try {
|
|
271
|
+
const api = new EbaySellerApi(config);
|
|
272
|
+
await api.initialize();
|
|
273
|
+
const authClient = api.getAuthClient();
|
|
274
|
+
const tokenInfo = authClient.getTokenInfo();
|
|
275
|
+
if (tokenInfo.scopeInfo) {
|
|
276
|
+
displayScopeVerification(tokenInfo.scopeInfo.tokenScopes, config.environment);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
console.log(chalk.yellow('ā ļø Could not verify token scopes\n'));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Export report if requested
|
|
285
|
+
if (exportReport) {
|
|
286
|
+
const reportPath = join(PROJECT_ROOT, `ebay-mcp-diagnostic-${Date.now()}.json`);
|
|
287
|
+
await generateDiagnosticReport(reportPath);
|
|
288
|
+
}
|
|
289
|
+
console.log(chalk.bold.green('ā
Diagnostics complete!\n'));
|
|
290
|
+
console.log(chalk.gray('For more help, visit:'));
|
|
291
|
+
console.log(chalk.blue.underline(' https://github.com/YosefHayim/ebay-mcp#troubleshooting\n'));
|
|
292
|
+
}
|
|
293
|
+
// CLI handler
|
|
294
|
+
const args = process.argv.slice(2);
|
|
295
|
+
const exportReport = args.includes('--export') || args.includes('-e');
|
|
296
|
+
runDiagnostics(exportReport).catch((error) => {
|
|
297
|
+
console.error(chalk.red('\nā Diagnostics failed:'), error);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|