ebay-mcp 1.13.2 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +3 -3
- package/README.es.md +3 -3
- package/README.fr.md +3 -3
- package/README.ja.md +3 -3
- package/README.ko.md +3 -3
- package/README.md +163 -41
- package/README.pt-BR.md +3 -3
- package/README.ru.md +3 -3
- package/README.zh-CN.md +3 -3
- package/build/api/account-management/account.js +633 -297
- package/build/api/analytics-and-report/analytics.js +111 -65
- package/build/api/client.js +199 -140
- package/build/api/clientRequestError.js +23 -0
- package/build/api/clientTrading.js +213 -0
- package/build/api/clientTradingError.js +4 -0
- package/build/api/communication/feedback.js +147 -59
- package/build/api/communication/message.js +134 -81
- package/build/api/communication/negotiation.js +65 -53
- package/build/api/communication/notification.js +458 -164
- package/build/api/developer/developer.js +99 -45
- package/build/api/index.js +23 -8
- package/build/api/listing-management/inventory.js +884 -338
- package/build/api/listing-metadata/metadata.js +416 -170
- package/build/api/listing-metadata/taxonomy.js +187 -42
- package/build/api/marketing-and-promotions/marketing.js +1392 -598
- package/build/api/marketing-and-promotions/recommendation.js +49 -24
- package/build/api/order-management/dispute.js +226 -45
- package/build/api/order-management/fulfillment.js +144 -71
- package/build/api/order-management/orderIssueHelpers.js +61 -0
- package/build/api/other/compliance.js +50 -38
- package/build/api/other/edelivery.js +603 -159
- package/build/api/other/finding.js +280 -0
- package/build/api/other/identity.js +30 -15
- package/build/api/other/translation.js +29 -14
- package/build/api/other/vero.js +113 -27
- package/build/api/rateLimitTracker.js +55 -0
- package/build/api/shared/request.js +189 -98
- package/build/api/trading/trading.js +154 -87
- package/build/auth/credentialSession.js +250 -0
- package/build/auth/oauth.js +298 -171
- package/build/auth/{oauth-metadata.js → oauthMetadata.js} +22 -6
- package/build/auth/oauthMiddleware.js +104 -0
- package/build/auth/{scope-utils.js → scopeUtils.js} +101 -28
- package/build/auth/tokenVerifier.js +243 -0
- package/build/auth/tokenVerifierError.js +21 -0
- package/build/config/environment.js +148 -113
- package/build/config/{tool-families.js → toolFamilies.js} +30 -14
- package/build/index.js +25 -19
- package/build/mcp/{http-transport.js → httpTransport.js} +102 -52
- package/build/mcp/readOnlyFilter.js +67 -0
- package/build/mcp/runtime.js +31 -13
- package/build/mcp/{tool-gating.js → toolGating.js} +77 -49
- package/build/mcp/{ui-bridge.js → uiBridge.js} +80 -23
- package/build/schemas/account-management/account.js +144 -6
- package/build/schemas/analytics/analytics.js +33 -19
- package/build/schemas/communication/messages.js +12 -42
- package/build/schemas/developer/developer.js +135 -0
- package/build/schemas/fulfillment/orders.js +183 -21
- package/build/schemas/index.js +27 -19
- package/build/schemas/inventory-management/inventory.js +17 -9
- package/build/schemas/marketing/marketing.js +480 -25
- package/build/schemas/metadata/metadata.js +11 -6
- package/build/schemas/other/finding.js +27 -0
- package/build/schemas/other/otherApis.js +424 -0
- package/build/schemas/taxonomy/taxonomy.js +11 -5
- package/build/scripts/{auto-setup.js → autoSetup.js} +87 -74
- package/build/scripts/{build-ui.js → buildUi.js} +6 -1
- package/build/scripts/{dev-sync.js → devSync.js} +169 -110
- package/build/scripts/diagnostics.js +52 -44
- package/build/scripts/{download-specs.js → downloadSpecs.js} +29 -21
- package/build/scripts/{interactive-setup.js → interactiveSetup.js} +84 -78
- package/build/scripts/setup.js +241 -178
- package/build/scripts/{setup-shared.js → setupShared.js} +29 -7
- package/build/scripts/skills.js +35 -27
- package/build/scripts/updateApiStatusDoc.js +71 -0
- package/build/serverHttp.js +90 -0
- package/build/skills/content.js +124 -118
- package/build/skills/index.js +22 -10
- package/build/skills/install.js +21 -10
- package/build/skills/markers.js +50 -15
- package/build/skills/{registry-snapshot.js → registrySnapshot.js} +8 -2
- package/build/skills/render.js +41 -14
- package/build/skills/targets.js +49 -17
- package/build/tools/categories/account.js +166 -264
- package/build/tools/categories/analytics.js +11 -22
- package/build/tools/categories/browse.js +17 -0
- package/build/tools/categories/communication.js +124 -399
- package/build/tools/categories/connector.js +23 -20
- package/build/tools/categories/developer.js +46 -159
- package/build/tools/categories/fulfillment.js +84 -215
- package/build/tools/categories/index.js +6 -14
- package/build/tools/categories/inventory.js +238 -293
- package/build/tools/categories/marketing.js +677 -39
- package/build/tools/categories/metadata.js +190 -117
- package/build/tools/categories/other.js +81 -208
- package/build/tools/categories/taxonomy.js +29 -20
- package/build/tools/categories/{token-management.js → tokenManagement.js} +187 -192
- package/build/tools/categories/trading.js +16 -47
- package/build/tools/contracts.js +34 -24
- package/build/tools/{define-tool.js → defineTool.js} +44 -29
- package/build/tools/registry.js +87 -29
- package/build/tools/schemas.js +3 -57
- package/build/tools/ui/archetypes.js +1 -0
- package/build/tools/ui/{map-helpers.js → mapHelpers.js} +69 -19
- package/build/tools/ui/maps.js +294 -80
- package/build/types/index.js +1 -1
- package/build/ui/card.html +14 -14
- package/build/ui/chart.html +14 -14
- package/build/ui/stat.html +87 -0
- package/build/ui/table.html +14 -14
- package/build/utils/apiStatusFeed.js +95 -0
- package/build/utils/cliOutput.js +15 -0
- package/build/utils/cliUi.js +108 -0
- package/build/utils/communication/feedback.js +57 -77
- package/build/utils/communication/message.js +69 -98
- package/build/utils/communication/negotiation.js +30 -57
- package/build/utils/communication/notification.js +112 -252
- package/build/utils/{date-converter.js → dateConverter.js} +62 -30
- package/build/utils/effectSchema.js +203 -0
- package/build/utils/effectSchemaAdapter.js +121 -0
- package/build/utils/effectSchemaChainMethods.js +146 -0
- package/build/utils/effectSchemaRefinements.js +104 -0
- package/build/utils/effectSchemaStringMethods.js +63 -0
- package/build/utils/effectSchemaTypes.js +47 -0
- package/build/utils/{env-parser.js → envParser.js} +10 -2
- package/build/utils/errors.js +7 -3
- package/build/utils/http.js +148 -89
- package/build/utils/{llm-client-detector.js → llmClientDetector.js} +295 -274
- package/build/utils/logger.js +127 -51
- package/build/utils/{oauth-helper.js → oauthHelper.js} +127 -90
- package/build/utils/other/compliance.js +18 -38
- package/build/utils/other/identity.js +2 -2
- package/build/utils/other/translation.js +4 -4
- package/build/utils/other/vero.js +36 -20
- package/build/utils/schemaHelpers.js +22 -0
- package/build/utils/scopeHelper.js +270 -0
- package/build/utils/securityChecker.js +316 -0
- package/build/utils/{setup-validator.js → setupValidator.js} +113 -94
- package/build/utils/{setup-wizard.js → setupWizard.js} +57 -46
- package/build/utils/{token-utils.js → tokenUtils.js} +2 -2
- package/build/utils/trading/trading.js +35 -0
- package/build/utils/typeGuards.js +12 -0
- package/build/utils/version.js +65 -29
- package/package.json +10 -8
- package/build/api/client-trading.js +0 -124
- package/build/api/communication/shared.js +0 -59
- package/build/api/shared/query-params.js +0 -16
- package/build/auth/credential-session.js +0 -166
- package/build/auth/oauth-middleware.js +0 -100
- package/build/auth/token-verifier.js +0 -186
- package/build/schemas/other/other-apis.js +0 -390
- package/build/scripts/update-api-status-doc.js +0 -44
- package/build/server-http.js +0 -85
- package/build/tools/definitions/marketing.js +0 -1381
- package/build/tools/tool-handlers/marketing.js +0 -312
- package/build/utils/account-management/account.js +0 -818
- package/build/utils/api-status-feed.js +0 -84
- package/build/utils/cli-ui.js +0 -47
- package/build/utils/order-management/dispute.js +0 -369
- package/build/utils/order-management/fulfillment.js +0 -205
- package/build/utils/other/edelivery.js +0 -235
- package/build/utils/schema-helpers.js +0 -13
- package/build/utils/scope-helper.js +0 -207
- package/build/utils/security-checker.js +0 -248
- package/build/utils/type-guards.js +0 -6
- /package/build/auth/{oauth-types.js → oauthTypes.js} +0 -0
- /package/build/{server-http.d.ts → serverHttp.d.ts} +0 -0
- /package/build/tools/ui/{view-models.js → viewModels.js} +0 -0
- /package/build/types/{ebay-enums.js → ebayEnums.js} +0 -0
|
@@ -2,10 +2,11 @@ import { config } from 'dotenv';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'fs';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { dirname, join } from 'path';
|
|
5
|
-
import {
|
|
6
|
-
import { getToolGatingConfigError } from '../config/tool-families.js';
|
|
7
|
-
import { getVersion } from '../utils/version.js';
|
|
5
|
+
import { getToolGatingConfigError } from '../config/toolFamilies.js';
|
|
8
6
|
import { getErrorMessage } from '../utils/errors.js';
|
|
7
|
+
import { getVersion } from '../utils/version.js';
|
|
8
|
+
import { Effect, Either } from 'effect';
|
|
9
|
+
import process from 'node:process';
|
|
9
10
|
// Get the current directory for loading scope files and .env
|
|
10
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
12
|
const __dirname = dirname(__filename);
|
|
@@ -13,65 +14,98 @@ const __dirname = dirname(__filename);
|
|
|
13
14
|
// MCP servers inherit cwd from the host (e.g. Claude Code's project dir), so
|
|
14
15
|
// process.cwd() may point to an unrelated project with a different .env.
|
|
15
16
|
config({ path: join(__dirname, '../../.env'), quiet: true });
|
|
17
|
+
const writeConfigDiagnostic = (message) => {
|
|
18
|
+
process.stderr.write(`[eBay MCP] ${message}\n`);
|
|
19
|
+
};
|
|
16
20
|
/**
|
|
17
|
-
*
|
|
21
|
+
* Build logger settings from environment variables.
|
|
22
|
+
*
|
|
23
|
+
* @returns Logger level and file-logging flag used by the shared logger.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const logging = getLoggingConfig();
|
|
28
|
+
* ```
|
|
18
29
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const scopes = JSON.parse(scopesData);
|
|
24
|
-
// Filter out empty objects and extract unique scope strings
|
|
25
|
-
const uniqueScopes = new Set();
|
|
26
|
-
scopes.forEach((item) => {
|
|
27
|
-
if (item.Scope) {
|
|
28
|
-
uniqueScopes.add(item.Scope);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return Array.from(uniqueScopes);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error('Failed to load production scopes:', error);
|
|
35
|
-
// Return a minimal set of core scopes as fallback
|
|
36
|
-
return ['https://api.ebay.com/oauth/api_scope'];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
30
|
+
export const getLoggingConfig = () => ({
|
|
31
|
+
logLevel: process.env.EBAY_LOG_LEVEL || 'info',
|
|
32
|
+
enableFileLogging: process.env.EBAY_ENABLE_FILE_LOGGING === 'true',
|
|
33
|
+
});
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
35
|
+
* Build MCP Apps UI gating config from environment variables.
|
|
36
|
+
*
|
|
37
|
+
* @returns UI runtime feature flag derived from `EBAY_MCP_UI`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const uiConfig = getUiRuntimeConfig();
|
|
42
|
+
* ```
|
|
41
43
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
export const getUiRuntimeConfig = () => ({
|
|
45
|
+
enabled: process.env.EBAY_MCP_UI !== 'off',
|
|
46
|
+
});
|
|
47
|
+
/** Loads and parses scopes from one checked-in scope JSON file. */
|
|
48
|
+
const loadScopes = (fileName, label) => {
|
|
49
|
+
const loaded = Effect.runSync(Effect.either(Effect.try({
|
|
50
|
+
try: () => {
|
|
51
|
+
const scopesPath = join(__dirname, '../../docs/auth', fileName);
|
|
52
|
+
const scopesData = readFileSync(scopesPath, 'utf-8');
|
|
53
|
+
const scopes = JSON.parse(scopesData);
|
|
54
|
+
// Filter out empty objects and extract unique scope strings
|
|
55
|
+
const uniqueScopes = new Set();
|
|
56
|
+
scopes.forEach((item) => {
|
|
57
|
+
if (item.Scope) {
|
|
58
|
+
uniqueScopes.add(item.Scope);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return Array.from(uniqueScopes);
|
|
62
|
+
},
|
|
63
|
+
catch: (error) => error,
|
|
64
|
+
})));
|
|
65
|
+
if (Either.isLeft(loaded)) {
|
|
66
|
+
const error = loaded.left;
|
|
67
|
+
writeConfigDiagnostic(`Failed to load ${label} scopes: ${getErrorMessage(error)}`);
|
|
58
68
|
// Return a minimal set of core scopes as fallback
|
|
59
69
|
return ['https://api.ebay.com/oauth/api_scope'];
|
|
60
70
|
}
|
|
61
|
-
|
|
71
|
+
return loaded.right;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Loads and parses production scopes from the checked-in eBay scope table.
|
|
75
|
+
*/
|
|
76
|
+
const getProductionScopes = () => loadScopes('production_scopes.json', 'production');
|
|
62
77
|
/**
|
|
63
|
-
*
|
|
78
|
+
* Loads and parses sandbox scopes from the checked-in eBay scope table.
|
|
64
79
|
*/
|
|
65
|
-
|
|
80
|
+
const getSandboxScopes = () => loadScopes('sandbox_scopes.json', 'sandbox');
|
|
81
|
+
/**
|
|
82
|
+
* Gets default OAuth scopes for the specified eBay environment.
|
|
83
|
+
*
|
|
84
|
+
* @param environment eBay environment whose checked-in scope table should be loaded.
|
|
85
|
+
* @returns Unique OAuth scope URIs for the selected environment.
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const scopes = getDefaultScopes('production');
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export const getDefaultScopes = (environment) => {
|
|
66
92
|
if (environment === 'production') {
|
|
67
93
|
return getProductionScopes();
|
|
68
94
|
}
|
|
69
95
|
return getSandboxScopes();
|
|
70
|
-
}
|
|
96
|
+
};
|
|
71
97
|
/**
|
|
72
|
-
*
|
|
98
|
+
* Validates requested scopes against the selected eBay environment.
|
|
99
|
+
*
|
|
100
|
+
* @param scopes OAuth scopes requested by a token-management call or setup flow.
|
|
101
|
+
* @param environment eBay environment to validate against.
|
|
102
|
+
* @returns Requested scopes plus warnings for environment-only or unknown scopes.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const result = validateScopes(scopes, 'sandbox');
|
|
106
|
+
* ```
|
|
73
107
|
*/
|
|
74
|
-
export
|
|
108
|
+
export const validateScopes = (scopes, environment) => {
|
|
75
109
|
const validScopes = getDefaultScopes(environment);
|
|
76
110
|
const validScopeSet = new Set(validScopes);
|
|
77
111
|
const warnings = [];
|
|
@@ -95,11 +129,17 @@ export function validateScopes(scopes, environment) {
|
|
|
95
129
|
}
|
|
96
130
|
});
|
|
97
131
|
return { warnings, validScopes: requestedValidScopes };
|
|
98
|
-
}
|
|
132
|
+
};
|
|
99
133
|
/**
|
|
100
|
-
*
|
|
134
|
+
* Validates environment configuration on startup.
|
|
135
|
+
*
|
|
136
|
+
* @returns Startup validation result consumed by server entrypoints and diagnostics.
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const validation = validateEnvironmentConfig();
|
|
140
|
+
* ```
|
|
101
141
|
*/
|
|
102
|
-
export
|
|
142
|
+
export const validateEnvironmentConfig = () => {
|
|
103
143
|
const proxyAuth = getProxyAuthConfig();
|
|
104
144
|
const warnings = [...proxyAuth.warnings];
|
|
105
145
|
const errors = [...proxyAuth.errors];
|
|
@@ -132,19 +172,6 @@ export function validateEnvironmentConfig() {
|
|
|
132
172
|
if (toolGatingError) {
|
|
133
173
|
errors.push(toolGatingError);
|
|
134
174
|
}
|
|
135
|
-
// Validate that scope files exist
|
|
136
|
-
try {
|
|
137
|
-
getProductionScopes();
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
errors.push(`Failed to load production scopes: ${getErrorMessage(error)}`);
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
getSandboxScopes();
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
errors.push(`Failed to load sandbox scopes: ${getErrorMessage(error)}`);
|
|
147
|
-
}
|
|
148
175
|
const isValid = errors.length === 0;
|
|
149
176
|
return {
|
|
150
177
|
isValid,
|
|
@@ -152,11 +179,17 @@ export function validateEnvironmentConfig() {
|
|
|
152
179
|
errors,
|
|
153
180
|
infos: proxyAuth.infos,
|
|
154
181
|
};
|
|
155
|
-
}
|
|
182
|
+
};
|
|
156
183
|
/**
|
|
157
184
|
* Build EbayConfig from environment variables with safe defaults.
|
|
185
|
+
*
|
|
186
|
+
* @returns Runtime eBay API configuration derived from environment variables.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const config = getEbayConfig();
|
|
190
|
+
* ```
|
|
158
191
|
*/
|
|
159
|
-
export
|
|
192
|
+
export const getEbayConfig = () => {
|
|
160
193
|
const clientId = process.env.EBAY_CLIENT_ID ?? '';
|
|
161
194
|
const clientSecret = process.env.EBAY_CLIENT_SECRET ?? '';
|
|
162
195
|
const environment = process.env.EBAY_ENVIRONMENT === 'production' ? 'production' : 'sandbox';
|
|
@@ -170,7 +203,7 @@ export function getEbayConfig() {
|
|
|
170
203
|
// In proxy auth mode the upstream proxy supplies auth, so absent credentials are
|
|
171
204
|
// expected and must not nag (tokens can otherwise be generated from a refresh token).
|
|
172
205
|
if (!disableAuthHeader && (clientId === '' || clientSecret === '')) {
|
|
173
|
-
|
|
206
|
+
writeConfigDiagnostic('Missing required eBay credentials. Please set:\n1) EBAY_CLIENT_ID\n2) EBAY_CLIENT_SECRET\nin your .env file at project root');
|
|
174
207
|
}
|
|
175
208
|
return {
|
|
176
209
|
clientId,
|
|
@@ -185,31 +218,41 @@ export function getEbayConfig() {
|
|
|
185
218
|
apiBaseUrl,
|
|
186
219
|
disableAuthHeader,
|
|
187
220
|
};
|
|
188
|
-
}
|
|
221
|
+
};
|
|
189
222
|
/**
|
|
190
223
|
* Get the eBay REST API base URL for the configured environment.
|
|
191
224
|
*
|
|
192
|
-
* @param
|
|
193
|
-
*
|
|
225
|
+
* @param environment eBay environment used when no override is configured.
|
|
226
|
+
* @param overrideBaseUrl Base URL override from `EBAY_MCP_API_BASE_URL`.
|
|
227
|
+
* @returns REST API base URL for direct eBay or proxy traffic.
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* const baseUrl = getBaseUrl('sandbox');
|
|
231
|
+
* ```
|
|
194
232
|
*/
|
|
195
|
-
export
|
|
233
|
+
export const getBaseUrl = (environment, overrideBaseUrl) => {
|
|
196
234
|
if (overrideBaseUrl) {
|
|
197
235
|
return overrideBaseUrl;
|
|
198
236
|
}
|
|
199
237
|
return environment === 'production' ? 'https://api.ebay.com' : 'https://api.sandbox.ebay.com';
|
|
200
|
-
}
|
|
238
|
+
};
|
|
201
239
|
/**
|
|
202
240
|
* Get base URL for Identity API (uses apiz subdomain).
|
|
203
241
|
*
|
|
204
|
-
* @param
|
|
205
|
-
*
|
|
242
|
+
* @param environment eBay environment used when no override is configured.
|
|
243
|
+
* @param overrideBaseUrl Base URL override from `EBAY_MCP_API_BASE_URL`.
|
|
244
|
+
* @returns Identity API base URL for direct eBay or proxy traffic.
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* const identityBaseUrl = getIdentityBaseUrl('production');
|
|
248
|
+
* ```
|
|
206
249
|
*/
|
|
207
|
-
export
|
|
250
|
+
export const getIdentityBaseUrl = (environment, overrideBaseUrl) => {
|
|
208
251
|
if (overrideBaseUrl) {
|
|
209
252
|
return overrideBaseUrl;
|
|
210
253
|
}
|
|
211
254
|
return environment === 'production' ? 'https://apiz.ebay.com' : 'https://apiz.sandbox.ebay.com';
|
|
212
|
-
}
|
|
255
|
+
};
|
|
213
256
|
/** Hosts treated as loopback when deciding whether a cleartext base URL is safe. */
|
|
214
257
|
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]', '0.0.0.0']);
|
|
215
258
|
/**
|
|
@@ -222,8 +265,14 @@ const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]', '0.0.0
|
|
|
222
265
|
* a base URL (requests would hit real eBay unauthenticated), and pointing the base
|
|
223
266
|
* URL at a plaintext `http://` non-loopback host while auth is still on (real eBay
|
|
224
267
|
* tokens would traverse the wire in cleartext).
|
|
268
|
+
*
|
|
269
|
+
* @returns Parsed proxy auth configuration and startup diagnostics.
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const proxyAuth = getProxyAuthConfig();
|
|
273
|
+
* ```
|
|
225
274
|
*/
|
|
226
|
-
export
|
|
275
|
+
export const getProxyAuthConfig = () => {
|
|
227
276
|
const disableAuthHeader = process.env.EBAY_MCP_DISABLE_AUTH_HEADER === 'true';
|
|
228
277
|
const rawBaseUrl = (process.env.EBAY_MCP_API_BASE_URL ?? '').trim();
|
|
229
278
|
const warnings = [];
|
|
@@ -232,11 +281,15 @@ export function getProxyAuthConfig() {
|
|
|
232
281
|
let apiBaseUrl;
|
|
233
282
|
let parsedBaseUrl;
|
|
234
283
|
if (rawBaseUrl) {
|
|
235
|
-
try
|
|
236
|
-
|
|
284
|
+
const parsed = Effect.runSync(Effect.either(Effect.try({
|
|
285
|
+
try: () => new URL(rawBaseUrl),
|
|
286
|
+
catch: (error) => error,
|
|
287
|
+
})));
|
|
288
|
+
if (Either.isRight(parsed)) {
|
|
289
|
+
parsedBaseUrl = parsed.right;
|
|
237
290
|
apiBaseUrl = rawBaseUrl.replace(/\/+$/, '');
|
|
238
291
|
}
|
|
239
|
-
|
|
292
|
+
else {
|
|
240
293
|
errors.push(`EBAY_MCP_API_BASE_URL is not a valid URL: "${rawBaseUrl}". ` +
|
|
241
294
|
'Provide an absolute URL such as "http://localhost:8080".');
|
|
242
295
|
}
|
|
@@ -258,45 +311,27 @@ export function getProxyAuthConfig() {
|
|
|
258
311
|
'or set EBAY_MCP_DISABLE_AUTH_HEADER=true.');
|
|
259
312
|
}
|
|
260
313
|
return { apiBaseUrl, disableAuthHeader, warnings, errors, infos };
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Resolve either the OAuth token endpoint or a full user-consent authorization URL.
|
|
264
|
-
*/
|
|
265
|
-
export function getAuthUrl(clientIdOrEnvironment, redirectUri, environment, locale = LocaleEnum.en_US, prompt = 'login', responseType = 'code', state, scopes) {
|
|
266
|
-
// If only one argument and it's an environment, return the token endpoint
|
|
267
|
-
if (arguments.length === 1 &&
|
|
268
|
-
(clientIdOrEnvironment === 'production' || clientIdOrEnvironment === 'sandbox')) {
|
|
269
|
-
return `${getBaseUrl(clientIdOrEnvironment)}/identity/v1/oauth2/token`;
|
|
270
|
-
}
|
|
271
|
-
// Otherwise, generate the full OAuth authorization URL
|
|
272
|
-
const clientId = clientIdOrEnvironment;
|
|
273
|
-
const env = environment ?? 'sandbox';
|
|
274
|
-
const scope = getDefaultScopes(env);
|
|
275
|
-
if (!(clientId && redirectUri)) {
|
|
276
|
-
console.error('clientId, redirectUri (RuName), and scope are required,please initialize the class properly.');
|
|
277
|
-
return '';
|
|
278
|
-
}
|
|
279
|
-
const authBase = env === 'production' ? 'https://auth.ebay.com' : 'https://auth.sandbox.ebay.com';
|
|
280
|
-
const scopeList = scopes?.join('%20') || scope.join('%20');
|
|
281
|
-
const authorizeParams = new URLSearchParams({
|
|
282
|
-
client_id: clientId,
|
|
283
|
-
redirect_uri: redirectUri,
|
|
284
|
-
response_type: responseType,
|
|
285
|
-
prompt,
|
|
286
|
-
locale,
|
|
287
|
-
...(state ? { state } : {}),
|
|
288
|
-
});
|
|
289
|
-
return `${authBase}/oauth2/authorize?${authorizeParams.toString()}&scope=${scopeList}`;
|
|
290
|
-
}
|
|
314
|
+
};
|
|
291
315
|
/**
|
|
292
316
|
* Generate the OAuth authorization URL for user consent
|
|
293
317
|
* This URL should be opened in a browser for the user to grant permissions
|
|
294
318
|
*
|
|
295
319
|
* Note: Scopes are optional - eBay will automatically grant the appropriate scopes
|
|
296
320
|
* based on your application's keyset configuration if scopes are not specified.
|
|
321
|
+
*
|
|
322
|
+
* @param clientId eBay application client ID.
|
|
323
|
+
* @param redirectUri eBay RuName redirect value, not a localhost URL.
|
|
324
|
+
* @param environment eBay environment that should host the authorization page.
|
|
325
|
+
* @param scopes OAuth scopes to request; defaults to the selected environment scopes.
|
|
326
|
+
* @param state Opaque CSRF value returned by eBay to the redirect URI.
|
|
327
|
+
* @returns Fully qualified OAuth authorization URL for user consent.
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const url = getOAuthAuthorizationUrl(clientId, ruName, 'sandbox');
|
|
331
|
+
* ```
|
|
297
332
|
*/
|
|
298
|
-
export
|
|
299
|
-
environment, scopes,
|
|
333
|
+
export const getOAuthAuthorizationUrl = (clientId, redirectUri, // MUST be eBay RuName, NOT a URL
|
|
334
|
+
environment, scopes, state) => {
|
|
300
335
|
const authBase = environment === 'production' ? 'https://auth.ebay.com' : 'https://auth.sandbox.ebay.com';
|
|
301
336
|
let scopeList;
|
|
302
337
|
if (scopes && scopes.length > 0) {
|
|
@@ -313,12 +348,12 @@ environment, scopes, locale, state) {
|
|
|
313
348
|
...(state ? { state } : {}),
|
|
314
349
|
});
|
|
315
350
|
return `${authBase}/oauth2/authorize?${params.toString()}&scope=${scopeList}`;
|
|
316
|
-
}
|
|
351
|
+
};
|
|
317
352
|
const iconUrl = (size) => {
|
|
318
353
|
const url = new URL(`../../public/icons/${size}.png`, import.meta.url);
|
|
319
354
|
const path = fileURLToPath(url);
|
|
320
355
|
if (!existsSync(path)) {
|
|
321
|
-
|
|
356
|
+
writeConfigDiagnostic(`Icon not found at ${path}. Ensure public/icons is included in the package.`);
|
|
322
357
|
}
|
|
323
358
|
return url.toString();
|
|
324
359
|
};
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module is deliberately free of any import from the tool tree
|
|
5
5
|
* (`@/tools/*`). `config/environment.ts` validates `EBAY_MCP_TOOLS` and is itself
|
|
6
|
-
* imported by tool handlers (e.g. `tools/categories/
|
|
6
|
+
* imported by tool handlers (e.g. `tools/categories/tokenManagement.ts`), so
|
|
7
7
|
* pulling the registry in here would create an import cycle. The heavier pieces
|
|
8
8
|
* that genuinely need the registry — the discovery catalogue and the meta-tools —
|
|
9
|
-
* live in `@/mcp/
|
|
9
|
+
* live in `@/mcp/toolGating.ts`, which imports these primitives.
|
|
10
10
|
*
|
|
11
11
|
* The family keys below must stay in lock-step with `toolCategories`; a unit test
|
|
12
12
|
* asserts the two agree so adding a category without updating this list fails CI.
|
|
13
13
|
*/
|
|
14
|
+
import process from 'node:process';
|
|
14
15
|
/**
|
|
15
16
|
* Canonical tool-family keys, mirroring `toolCategories[].key`. These are the
|
|
16
17
|
* accepted tokens in a static `EBAY_MCP_TOOLS` list (e.g. `inventory,fulfillment`).
|
|
@@ -26,18 +27,17 @@ export const TOOL_FAMILY_KEYS = [
|
|
|
26
27
|
'metadata',
|
|
27
28
|
'taxonomy',
|
|
28
29
|
'communication',
|
|
30
|
+
'browse',
|
|
29
31
|
'other',
|
|
30
32
|
'developer',
|
|
31
33
|
'trading',
|
|
32
34
|
];
|
|
33
35
|
const FAMILY_KEY_SET = new Set(TOOL_FAMILY_KEYS);
|
|
34
36
|
/** Splits a raw `EBAY_MCP_TOOLS` list into trimmed, lowercased, non-empty tokens. */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.filter(Boolean);
|
|
40
|
-
}
|
|
37
|
+
const parseFamilyTokens = (raw) => raw
|
|
38
|
+
.split(',')
|
|
39
|
+
.map((token) => token.trim().toLowerCase())
|
|
40
|
+
.filter(Boolean);
|
|
41
41
|
/**
|
|
42
42
|
* Resolves `EBAY_MCP_TOOLS` into a {@link ToolGatingMode}.
|
|
43
43
|
*
|
|
@@ -45,8 +45,16 @@ function parseFamilyTokens(raw) {
|
|
|
45
45
|
* `static` mode so the dedicated validator ({@link getToolGatingConfigError}) can
|
|
46
46
|
* report them precisely. Callers that act on the mode should treat only
|
|
47
47
|
* {@link TOOL_FAMILY_KEYS} members as registerable.
|
|
48
|
+
*
|
|
49
|
+
* @param env - Environment object containing optional `EBAY_MCP_TOOLS`.
|
|
50
|
+
* @returns Tool gating mode parsed from the environment.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const mode = resolveToolGatingMode({ EBAY_MCP_TOOLS: 'inventory,fulfillment' });
|
|
55
|
+
* ```
|
|
48
56
|
*/
|
|
49
|
-
export
|
|
57
|
+
export const resolveToolGatingMode = (env = process.env) => {
|
|
50
58
|
const raw = env.EBAY_MCP_TOOLS?.trim();
|
|
51
59
|
if (!raw || raw.toLowerCase() === 'all') {
|
|
52
60
|
return { kind: 'all' };
|
|
@@ -55,25 +63,33 @@ export function resolveToolGatingMode(env = process.env) {
|
|
|
55
63
|
return { kind: 'dynamic' };
|
|
56
64
|
}
|
|
57
65
|
return { kind: 'static', families: parseFamilyTokens(raw) };
|
|
58
|
-
}
|
|
66
|
+
};
|
|
59
67
|
/**
|
|
60
68
|
* Validates `EBAY_MCP_TOOLS` and returns a human-readable error string, or
|
|
61
69
|
* `undefined` when the value is valid. Surfaced through
|
|
62
70
|
* `validateEnvironmentConfig` so a typo fails loudly at startup (server exits)
|
|
63
71
|
* rather than silently leaving the agent with fewer tools than intended.
|
|
72
|
+
*
|
|
73
|
+
* @param env - Environment object containing optional `EBAY_MCP_TOOLS`.
|
|
74
|
+
* @returns Human-readable validation error, or undefined when valid.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const error = getToolGatingConfigError({ EBAY_MCP_TOOLS: 'inventory' });
|
|
79
|
+
* ```
|
|
64
80
|
*/
|
|
65
|
-
export
|
|
81
|
+
export const getToolGatingConfigError = (env = process.env) => {
|
|
66
82
|
const mode = resolveToolGatingMode(env);
|
|
67
83
|
if (mode.kind !== 'static') {
|
|
68
|
-
return
|
|
84
|
+
return;
|
|
69
85
|
}
|
|
70
86
|
if (mode.families.length === 0) {
|
|
71
87
|
return `EBAY_MCP_TOOLS is set but lists no tool families. Use "all", "dynamic", or a comma-separated list of: ${TOOL_FAMILY_KEYS.join(', ')}.`;
|
|
72
88
|
}
|
|
73
89
|
const unknown = mode.families.filter((family) => !FAMILY_KEY_SET.has(family));
|
|
74
90
|
if (unknown.length === 0) {
|
|
75
|
-
return
|
|
91
|
+
return;
|
|
76
92
|
}
|
|
77
93
|
const noun = unknown.length === 1 ? 'family' : 'families';
|
|
78
94
|
return `EBAY_MCP_TOOLS contains unknown tool ${noun}: ${unknown.join(', ')}. Valid families: ${TOOL_FAMILY_KEYS.join(', ')}.`;
|
|
79
|
-
}
|
|
95
|
+
};
|
package/build/index.js
CHANGED
|
@@ -5,28 +5,29 @@ import { createEbayMcpRuntime } from './mcp/runtime.js';
|
|
|
5
5
|
import { runSetup } from './scripts/setup.js';
|
|
6
6
|
import { runSkillsWizard } from './scripts/skills.js';
|
|
7
7
|
import { getErrorMessage } from './utils/errors.js';
|
|
8
|
-
import { serverLogger, getLogPaths } from './utils/logger.js';
|
|
8
|
+
import { serverLogger, getLogPaths, isFileLoggingEnabled } from './utils/logger.js';
|
|
9
9
|
import { getCachedUpdateNotice } from './utils/version.js';
|
|
10
|
+
import { Effect, Either } from 'effect';
|
|
11
|
+
import process from 'node:process';
|
|
10
12
|
const args = process.argv.slice(2);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const runCliCommand = async (label, command) => {
|
|
14
|
+
const result = await Effect.runPromise(Effect.either(Effect.tryPromise({
|
|
15
|
+
try: command,
|
|
16
|
+
catch: (error) => error,
|
|
17
|
+
})));
|
|
18
|
+
if (Either.isLeft(result)) {
|
|
19
|
+
serverLogger.error(`${label} failed`, {
|
|
20
|
+
error: getErrorMessage(result.left, String(result.left)),
|
|
21
|
+
});
|
|
18
22
|
process.exit(1);
|
|
19
23
|
}
|
|
24
|
+
process.exit(0);
|
|
25
|
+
};
|
|
26
|
+
if (args.includes('setup')) {
|
|
27
|
+
await runCliCommand('Setup', runSetup);
|
|
20
28
|
}
|
|
21
29
|
if (args.includes('skills')) {
|
|
22
|
-
|
|
23
|
-
await runSkillsWizard();
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
console.error('Skills install failed:', error instanceof Error ? error.message : error);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
+
await runCliCommand('Skills install', runSkillsWizard);
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* eBay API MCP Server
|
|
@@ -83,7 +84,7 @@ class EbayMcpServer {
|
|
|
83
84
|
serverLogger.info('Initializing API client');
|
|
84
85
|
await this.initialize();
|
|
85
86
|
// Log log file locations if file logging is enabled
|
|
86
|
-
if (
|
|
87
|
+
if (isFileLoggingEnabled()) {
|
|
87
88
|
const paths = getLogPaths();
|
|
88
89
|
serverLogger.info('File logging enabled', {
|
|
89
90
|
logDir: paths.logDir,
|
|
@@ -98,10 +99,15 @@ class EbayMcpServer {
|
|
|
98
99
|
}
|
|
99
100
|
// Start the server
|
|
100
101
|
const server = new EbayMcpServer();
|
|
101
|
-
|
|
102
|
+
const started = await Effect.runPromise(Effect.either(Effect.tryPromise({
|
|
103
|
+
try: () => server.run(),
|
|
104
|
+
catch: (error) => error,
|
|
105
|
+
})));
|
|
106
|
+
if (Either.isLeft(started)) {
|
|
107
|
+
const error = started.left;
|
|
102
108
|
serverLogger.error('Fatal error running server', {
|
|
103
109
|
error: getErrorMessage(error, String(error)),
|
|
104
110
|
stack: error instanceof Error ? error.stack : undefined,
|
|
105
111
|
});
|
|
106
112
|
process.exit(1);
|
|
107
|
-
}
|
|
113
|
+
}
|