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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eBay API MCP Server with HTTP Transport and OAuth 2.1 Authorization
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* This server implements:
|
|
6
|
+
* - HTTP transport using Express
|
|
7
|
+
* - OAuth 2.1 authorization (RFC 8414, RFC 9728)
|
|
8
|
+
* - Bearer token authentication (RFC 6750)
|
|
9
|
+
* - Token verification via introspection (RFC 7662) or JWT validation
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eBay API MCP Server with HTTP Transport and OAuth 2.1 Authorization
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* This server implements:
|
|
6
|
+
* - HTTP transport using Express
|
|
7
|
+
* - OAuth 2.1 authorization (RFC 8414, RFC 9728)
|
|
8
|
+
* - Bearer token authentication (RFC 6750)
|
|
9
|
+
* - Token verification via introspection (RFC 7662) or JWT validation
|
|
10
|
+
*/
|
|
11
|
+
import express from 'express';
|
|
12
|
+
import helmet from 'helmet';
|
|
13
|
+
import cors from 'cors';
|
|
14
|
+
import { randomUUID } from 'crypto';
|
|
15
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
16
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
17
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
18
|
+
import { EbaySellerApi } from './api/index.js';
|
|
19
|
+
import { getEbayConfig, getDefaultScopes, validateEnvironmentConfig, } from './config/environment.js';
|
|
20
|
+
import { getToolDefinitions, executeTool } from './tools/index.js';
|
|
21
|
+
import { TokenVerifier } from './auth/token-verifier.js';
|
|
22
|
+
import { createBearerAuthMiddleware } from './auth/oauth-middleware.js';
|
|
23
|
+
import { createMetadataRouter, getProtectedResourceMetadataUrl } from './auth/oauth-metadata.js';
|
|
24
|
+
// Configuration from environment
|
|
25
|
+
const CONFIG = {
|
|
26
|
+
// Server settings
|
|
27
|
+
host: process.env.MCP_HOST || 'localhost',
|
|
28
|
+
port: Number(process.env.MCP_PORT) || 3000,
|
|
29
|
+
// OAuth settings
|
|
30
|
+
oauth: {
|
|
31
|
+
// Authorization server metadata URL or custom metadata
|
|
32
|
+
authServerUrl: process.env.OAUTH_AUTH_SERVER_URL ?? 'http://localhost:8080/realms/master',
|
|
33
|
+
// Client credentials for token introspection
|
|
34
|
+
clientId: process.env.OAUTH_CLIENT_ID,
|
|
35
|
+
clientSecret: process.env.OAUTH_CLIENT_SECRET,
|
|
36
|
+
// Scopes required for this server
|
|
37
|
+
requiredScopes: (process.env.OAUTH_REQUIRED_SCOPES || 'mcp:tools')
|
|
38
|
+
.split(',')
|
|
39
|
+
.map((s) => s.trim()),
|
|
40
|
+
// Whether to use token introspection (true) or JWT validation (false)
|
|
41
|
+
useIntrospection: process.env.OAUTH_USE_INTROSPECTION !== 'false',
|
|
42
|
+
},
|
|
43
|
+
// Whether OAuth is enabled (disable for local development)
|
|
44
|
+
authEnabled: process.env.OAUTH_ENABLED !== 'false',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Create OAuth server metadata URL
|
|
48
|
+
*/
|
|
49
|
+
function getAuthServerMetadataUrl() {
|
|
50
|
+
// Support both OIDC Discovery and OAuth Server Metadata
|
|
51
|
+
const baseUrl = CONFIG.oauth.authServerUrl;
|
|
52
|
+
// Try OIDC Discovery first
|
|
53
|
+
if (baseUrl.includes('/realms/')) {
|
|
54
|
+
// Keycloak-style URL
|
|
55
|
+
return `${baseUrl}/.well-known/openid-configuration`;
|
|
56
|
+
}
|
|
57
|
+
// Fall back to OAuth 2.0 Authorization Server Metadata
|
|
58
|
+
return `${baseUrl}/.well-known/oauth-authorization-server`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create Express app with OAuth support
|
|
62
|
+
*/
|
|
63
|
+
async function createApp() {
|
|
64
|
+
const app = express();
|
|
65
|
+
// Enable CORS
|
|
66
|
+
app.use(cors({
|
|
67
|
+
// TODO: Restrict origin to known clients in production
|
|
68
|
+
// For development, allow all origins
|
|
69
|
+
origin: '*',
|
|
70
|
+
exposedHeaders: ['Mcp-Session-Id'],
|
|
71
|
+
}));
|
|
72
|
+
// Parse JSON bodies
|
|
73
|
+
app.use(express.json());
|
|
74
|
+
// Add security best practices (disable X-Powered-By header)
|
|
75
|
+
app.use(helmet({ xPoweredBy: false }));
|
|
76
|
+
// Request logging
|
|
77
|
+
app.use((req, res, next) => {
|
|
78
|
+
const start = Date.now();
|
|
79
|
+
res.on('finish', () => {
|
|
80
|
+
const duration = Date.now() - start;
|
|
81
|
+
console.log(`${req.method} ${req.path} -> ${res.statusCode} (${duration}ms)`);
|
|
82
|
+
});
|
|
83
|
+
next();
|
|
84
|
+
});
|
|
85
|
+
// Server URL
|
|
86
|
+
const serverUrl = `http://${CONFIG.host}:${CONFIG.port}`;
|
|
87
|
+
// Get eBay configuration for metadata
|
|
88
|
+
const ebayConfig = getEbayConfig();
|
|
89
|
+
// Add OAuth metadata endpoints
|
|
90
|
+
const metadataRouter = createMetadataRouter({
|
|
91
|
+
resourceServerUrl: serverUrl,
|
|
92
|
+
authServerMetadata: getAuthServerMetadataUrl(),
|
|
93
|
+
scopesSupported: CONFIG.oauth.requiredScopes,
|
|
94
|
+
resourceDocumentation: 'https://github.com/YosefHayim/ebay-mcp',
|
|
95
|
+
resourceName: 'eBay API MCP Server',
|
|
96
|
+
ebayEnvironment: ebayConfig.environment,
|
|
97
|
+
ebayScopes: getDefaultScopes(ebayConfig.environment),
|
|
98
|
+
});
|
|
99
|
+
app.use(metadataRouter);
|
|
100
|
+
// Health check endpoint (no auth required)
|
|
101
|
+
app.get('/health', (req, res) => {
|
|
102
|
+
res.json({
|
|
103
|
+
status: 'healthy',
|
|
104
|
+
timestamp: new Date().toISOString(),
|
|
105
|
+
oauth_enabled: CONFIG.authEnabled,
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
// Initialize token verifier if OAuth is enabled
|
|
109
|
+
let tokenVerifier;
|
|
110
|
+
let authMiddleware;
|
|
111
|
+
if (CONFIG.authEnabled) {
|
|
112
|
+
console.log('Initializing OAuth token verifier...');
|
|
113
|
+
tokenVerifier = new TokenVerifier({
|
|
114
|
+
authServerMetadata: getAuthServerMetadataUrl(),
|
|
115
|
+
clientId: CONFIG.oauth.clientId,
|
|
116
|
+
clientSecret: CONFIG.oauth.clientSecret,
|
|
117
|
+
expectedAudience: serverUrl,
|
|
118
|
+
requiredScopes: CONFIG.oauth.requiredScopes,
|
|
119
|
+
useIntrospection: CONFIG.oauth.useIntrospection,
|
|
120
|
+
});
|
|
121
|
+
try {
|
|
122
|
+
await tokenVerifier.initialize();
|
|
123
|
+
console.log('Token verifier initialized');
|
|
124
|
+
authMiddleware = createBearerAuthMiddleware({
|
|
125
|
+
verifier: tokenVerifier,
|
|
126
|
+
resourceMetadataUrl: getProtectedResourceMetadataUrl(serverUrl),
|
|
127
|
+
realm: 'ebay-mcp',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error('Failed to initialize token verifier:', error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.error('OAuth is disabled. Server running in unauthenticated mode.');
|
|
137
|
+
}
|
|
138
|
+
// MCP session storage
|
|
139
|
+
const transports = new Map();
|
|
140
|
+
/**
|
|
141
|
+
* Create a new MCP server instance
|
|
142
|
+
*/
|
|
143
|
+
function createMcpServer() {
|
|
144
|
+
const ebayConfig = getEbayConfig();
|
|
145
|
+
const api = new EbaySellerApi(ebayConfig);
|
|
146
|
+
const server = new McpServer({
|
|
147
|
+
name: 'ebay-mcp',
|
|
148
|
+
version: '1.4.0',
|
|
149
|
+
title: 'eBay API MCP Server',
|
|
150
|
+
websiteUrl: 'https://coming-soon.com',
|
|
151
|
+
icons: [
|
|
152
|
+
{
|
|
153
|
+
src: './icons/16x16.png',
|
|
154
|
+
mimeType: 'image/png',
|
|
155
|
+
sizes: ['16x16'],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
src: './icons/32x32.png',
|
|
159
|
+
mimeType: 'image/png',
|
|
160
|
+
sizes: ['32x32'],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
src: './icons/48x48.png',
|
|
164
|
+
mimeType: 'image/png',
|
|
165
|
+
sizes: ['48x48'],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
src: './icons/128x128.png',
|
|
169
|
+
mimeType: 'image/png',
|
|
170
|
+
sizes: ['128x128'],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
src: './icons/256x256.png',
|
|
174
|
+
mimeType: 'image/png',
|
|
175
|
+
sizes: ['256x256'],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
src: './icons/512x512.png',
|
|
179
|
+
mimeType: 'image/png',
|
|
180
|
+
sizes: ['512x512'],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
src: './icons/1024x1024.png',
|
|
184
|
+
mimeType: 'image/png',
|
|
185
|
+
sizes: ['1024x1024'],
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
// Register tools
|
|
190
|
+
const tools = getToolDefinitions();
|
|
191
|
+
for (const toolDef of tools) {
|
|
192
|
+
server.registerTool(toolDef.name, {
|
|
193
|
+
description: toolDef.description,
|
|
194
|
+
// ToolDefinition uses Zod schemas internally, but MCP SDK expects Zod schemas
|
|
195
|
+
// This is a safe cast since both are Zod-based schema types
|
|
196
|
+
inputSchema: toolDef.inputSchema,
|
|
197
|
+
}, async (args) => {
|
|
198
|
+
try {
|
|
199
|
+
const result = await executeTool(api, toolDef.name, args);
|
|
200
|
+
return {
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: 'text',
|
|
204
|
+
text: JSON.stringify(result, null, 2),
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
211
|
+
return {
|
|
212
|
+
content: [
|
|
213
|
+
{
|
|
214
|
+
type: 'text',
|
|
215
|
+
text: JSON.stringify({ error: errorMessage }, null, 2),
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
isError: true,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return server;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* MCP POST handler
|
|
227
|
+
*/
|
|
228
|
+
const mcpPostHandler = async (req, res) => {
|
|
229
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
230
|
+
let transport;
|
|
231
|
+
if (sessionId && transports.has(sessionId)) {
|
|
232
|
+
transport = transports.get(sessionId);
|
|
233
|
+
}
|
|
234
|
+
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
235
|
+
// Create new session
|
|
236
|
+
transport = new StreamableHTTPServerTransport({
|
|
237
|
+
sessionIdGenerator: () => randomUUID(),
|
|
238
|
+
onsessioninitialized: (sessionId) => {
|
|
239
|
+
transports.set(sessionId, transport);
|
|
240
|
+
console.log(`New MCP session initialized: ${sessionId}`);
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
transport.onclose = () => {
|
|
244
|
+
if (transport.sessionId) {
|
|
245
|
+
transports.delete(transport.sessionId);
|
|
246
|
+
console.log(`MCP session closed: ${transport.sessionId}`);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const server = createMcpServer();
|
|
250
|
+
await server.connect(transport);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
res.status(400).json({
|
|
254
|
+
jsonrpc: '2.0',
|
|
255
|
+
error: {
|
|
256
|
+
code: -32000,
|
|
257
|
+
message: 'Bad Request: No valid session ID provided',
|
|
258
|
+
},
|
|
259
|
+
id: null,
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
await transport.handleRequest(req, res, req.body);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* MCP session request handler (GET/DELETE)
|
|
267
|
+
*/
|
|
268
|
+
const handleSessionRequest = async (req, res) => {
|
|
269
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
270
|
+
if (!sessionId || !transports.has(sessionId)) {
|
|
271
|
+
res.status(400).json({
|
|
272
|
+
error: 'invalid_session',
|
|
273
|
+
error_description: 'Invalid or missing session ID',
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const transport = transports.get(sessionId);
|
|
278
|
+
await transport.handleRequest(req, res);
|
|
279
|
+
};
|
|
280
|
+
// Apply auth middleware to MCP endpoints if enabled
|
|
281
|
+
const mcpMiddleware = authMiddleware ? [authMiddleware, mcpPostHandler] : [mcpPostHandler];
|
|
282
|
+
const sessionMiddleware = authMiddleware
|
|
283
|
+
? [authMiddleware, handleSessionRequest]
|
|
284
|
+
: [handleSessionRequest];
|
|
285
|
+
// MCP endpoints
|
|
286
|
+
app.post('/', ...mcpMiddleware);
|
|
287
|
+
app.get('/', ...sessionMiddleware);
|
|
288
|
+
app.delete('/', ...sessionMiddleware);
|
|
289
|
+
return app;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Start the server
|
|
293
|
+
*/
|
|
294
|
+
async function main() {
|
|
295
|
+
try {
|
|
296
|
+
console.log('Starting eBay API MCP Server (HTTP + OAuth)...');
|
|
297
|
+
console.log();
|
|
298
|
+
// Validate environment configuration
|
|
299
|
+
const validation = validateEnvironmentConfig();
|
|
300
|
+
// Display warnings
|
|
301
|
+
if (validation.warnings.length > 0) {
|
|
302
|
+
console.log('Environment Configuration Warnings:');
|
|
303
|
+
validation.warnings.forEach((warning) => {
|
|
304
|
+
console.log(` • ${warning}`);
|
|
305
|
+
});
|
|
306
|
+
console.log();
|
|
307
|
+
}
|
|
308
|
+
// Display errors and exit if configuration is invalid
|
|
309
|
+
if (!validation.isValid) {
|
|
310
|
+
console.error('Environment Configuration Errors:');
|
|
311
|
+
validation.errors.forEach((error) => {
|
|
312
|
+
console.error(` • ${error}`);
|
|
313
|
+
});
|
|
314
|
+
console.error('\nPlease fix the configuration errors and restart the server.\n');
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
console.log('Configuration:');
|
|
318
|
+
console.log(`Host: ${CONFIG.host}`);
|
|
319
|
+
console.log(`Port: ${CONFIG.port}`);
|
|
320
|
+
console.log(`OAuth Enabled: ${CONFIG.authEnabled}`);
|
|
321
|
+
if (CONFIG.authEnabled) {
|
|
322
|
+
console.log(`Auth Server: ${CONFIG.oauth.authServerUrl}`);
|
|
323
|
+
console.log(`Required Scopes: ${CONFIG.oauth.requiredScopes.join(', ')}`);
|
|
324
|
+
console.log(`Verification Method: ${CONFIG.oauth.useIntrospection ? 'Introspection' : 'JWT'}`);
|
|
325
|
+
}
|
|
326
|
+
const app = await createApp();
|
|
327
|
+
const server = app.listen(CONFIG.port, CONFIG.host, () => {
|
|
328
|
+
const serverUrl = `http://${CONFIG.host}:${CONFIG.port}`;
|
|
329
|
+
console.log('Server is running!');
|
|
330
|
+
console.log();
|
|
331
|
+
console.log(`MCP endpoint: ${serverUrl}/`);
|
|
332
|
+
console.log(`Protected Resource Metadata: ${serverUrl}/.well-known/oauth-protected-resource`);
|
|
333
|
+
console.log(`Health check: ${serverUrl}/health`);
|
|
334
|
+
console.log();
|
|
335
|
+
if (CONFIG.authEnabled) {
|
|
336
|
+
console.log('Authorization is ENABLED');
|
|
337
|
+
console.log('Clients must provide valid Bearer tokens to access MCP endpoints');
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
console.log('Authorization is DISABLED');
|
|
341
|
+
console.log('Set OAUTH_ENABLED=true to enable OAuth protection');
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
// Graceful shutdown
|
|
345
|
+
process.on('SIGINT', () => {
|
|
346
|
+
console.log('\n Shutting down...');
|
|
347
|
+
server.close(() => {
|
|
348
|
+
console.log('✓ Server closed');
|
|
349
|
+
process.exit(0);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
console.error('Fatal error starting server:', error);
|
|
355
|
+
process.exit(1);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// Start server if run directly
|
|
359
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
360
|
+
await main();
|
|
361
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Account Management Tools with Full Schema Integration
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to integrate the new Zod schemas
|
|
5
|
+
* for both input and output validation with MCP tools.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition } from './account.js';
|
|
8
|
+
/**
|
|
9
|
+
* Account Management Tools with Output Schema Validation
|
|
10
|
+
*
|
|
11
|
+
* These tool definitions include both inputSchema and outputSchema
|
|
12
|
+
* for complete request/response validation.
|
|
13
|
+
*/
|
|
14
|
+
export declare const accountToolsWithSchemas: ToolDefinition[];
|
|
15
|
+
/**
|
|
16
|
+
* Example: Using the schemas for runtime validation
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { accountToolsWithSchemas } from '../../tools/definitions/account-with-schemas';
|
|
20
|
+
* import { EbaySellerApi } from '../../api';
|
|
21
|
+
*
|
|
22
|
+
* async function validateToolExecution() {
|
|
23
|
+
* const api = new EbaySellerApi();
|
|
24
|
+
* const tool = accountToolsWithSchemas.find(t => t.name === 'ebay_get_fulfillment_policies');
|
|
25
|
+
*
|
|
26
|
+
* // Validate input
|
|
27
|
+
* const input = { marketplaceId: 'EBAY_US' };
|
|
28
|
+
* const validatedInput = tool.inputSchema.parse(input); // Throws if invalid
|
|
29
|
+
*
|
|
30
|
+
* // Execute API call
|
|
31
|
+
* const response = await api.account.getFulfillmentPolicies(validatedInput.marketplaceId);
|
|
32
|
+
*
|
|
33
|
+
* // Validate output
|
|
34
|
+
* const validatedOutput = tool.outputSchema?.parse(response); // Throws if invalid
|
|
35
|
+
*
|
|
36
|
+
* return validatedOutput;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Account Management Tools with Full Schema Integration
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to integrate the new Zod schemas
|
|
5
|
+
* for both input and output validation with MCP tools.
|
|
6
|
+
*/
|
|
7
|
+
import { MarketplaceId } from '../../types/ebay-enums.js';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
// Import schemas from the new schemas folder
|
|
10
|
+
import { getCustomPoliciesInputSchema, getFulfillmentPoliciesInputSchema, createFulfillmentPolicyInputSchema, getPaymentPoliciesInputSchema, createPaymentPolicyInputSchema, getReturnPoliciesInputSchema, createReturnPolicyInputSchema, } from '../../schemas/account-management/account.js';
|
|
11
|
+
/**
|
|
12
|
+
* Account Management Tools with Output Schema Validation
|
|
13
|
+
*
|
|
14
|
+
* These tool definitions include both inputSchema and outputSchema
|
|
15
|
+
* for complete request/response validation.
|
|
16
|
+
*/
|
|
17
|
+
export const accountToolsWithSchemas = [
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Custom Policies
|
|
20
|
+
// ============================================================================
|
|
21
|
+
{
|
|
22
|
+
name: 'ebay_get_custom_policies',
|
|
23
|
+
description: 'Retrieve custom policies defined for the seller account',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
policyTypes: getCustomPoliciesInputSchema.shape.policyTypes,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Fulfillment Policies
|
|
30
|
+
// ============================================================================
|
|
31
|
+
{
|
|
32
|
+
name: 'ebay_get_fulfillment_policies',
|
|
33
|
+
description: 'Get fulfillment policies for the seller.\n\nRequired OAuth Scope: sell.account.readonly or sell.account\nMinimum Scope: https://api.ebay.com/oauth/api_scope/sell.account.readonly',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
marketplaceId: getFulfillmentPoliciesInputSchema.shape.marketplaceId,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'ebay_create_fulfillment_policy',
|
|
40
|
+
description: 'Create a new fulfillment policy.\n\nRequired OAuth Scope: sell.account\nMinimum Scope: https://api.ebay.com/oauth/api_scope/sell.account',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
policy: createFulfillmentPolicyInputSchema.shape.policy,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'ebay_get_fulfillment_policy',
|
|
47
|
+
description: 'Get a specific fulfillment policy by ID',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
fulfillmentPolicyId: z.string().describe('The fulfillment policy ID'),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'ebay_get_fulfillment_policy_by_name',
|
|
54
|
+
description: 'Get a fulfillment policy by name',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
marketplaceId: z.nativeEnum(MarketplaceId).describe('eBay marketplace ID'),
|
|
57
|
+
name: z.string().describe('Policy name'),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'ebay_update_fulfillment_policy',
|
|
62
|
+
description: 'Update an existing fulfillment policy',
|
|
63
|
+
inputSchema: {
|
|
64
|
+
fulfillmentPolicyId: z.string().describe('The fulfillment policy ID'),
|
|
65
|
+
policy: createFulfillmentPolicyInputSchema.shape.policy,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'ebay_delete_fulfillment_policy',
|
|
70
|
+
description: 'Delete a fulfillment policy',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
fulfillmentPolicyId: z.string().describe('The fulfillment policy ID'),
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Payment Policies
|
|
77
|
+
// ============================================================================
|
|
78
|
+
{
|
|
79
|
+
name: 'ebay_get_payment_policies',
|
|
80
|
+
description: 'Get payment policies for the seller',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
marketplaceId: getPaymentPoliciesInputSchema.shape.marketplaceId,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'ebay_create_payment_policy',
|
|
87
|
+
description: 'Create a new payment policy',
|
|
88
|
+
inputSchema: {
|
|
89
|
+
policy: createPaymentPolicyInputSchema.shape.policy,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Return Policies
|
|
94
|
+
// ============================================================================
|
|
95
|
+
{
|
|
96
|
+
name: 'ebay_get_return_policies',
|
|
97
|
+
description: 'Get return policies for the seller',
|
|
98
|
+
inputSchema: {
|
|
99
|
+
marketplaceId: getReturnPoliciesInputSchema.shape.marketplaceId,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'ebay_create_return_policy',
|
|
104
|
+
description: 'Create a new return policy',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
policy: createReturnPolicyInputSchema.shape.policy,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// Sales Tax
|
|
111
|
+
// ============================================================================
|
|
112
|
+
{
|
|
113
|
+
name: 'ebay_get_sales_taxes',
|
|
114
|
+
description: 'Get all sales tax tables for a country',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
countryCode: z.string().describe('Required: Two-letter ISO 3166-1 country code'),
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'ebay_get_sales_tax',
|
|
121
|
+
description: 'Get sales tax table for a jurisdiction',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
countryCode: z.string().describe('Two-letter ISO 3166 country code'),
|
|
124
|
+
jurisdictionId: z.string().describe('Tax jurisdiction ID'),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// KYC & Programs
|
|
129
|
+
// ============================================================================
|
|
130
|
+
{
|
|
131
|
+
name: 'ebay_get_kyc',
|
|
132
|
+
description: 'Get seller KYC (Know Your Customer) status',
|
|
133
|
+
inputSchema: {},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'ebay_get_opted_in_programs',
|
|
137
|
+
description: 'Get seller programs the account is opted into',
|
|
138
|
+
inputSchema: {},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'ebay_get_privileges',
|
|
142
|
+
description: "Get seller's current set of privileges, including whether or not the seller's eBay registration has been completed, as well as the details of their site-wide sellingLimit (the maximum dollar value and quantity of items a seller can sell per day).\n\nRequired OAuth Scope: sell.account.readonly or sell.account",
|
|
143
|
+
inputSchema: {},
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
/**
|
|
147
|
+
* Example: Using the schemas for runtime validation
|
|
148
|
+
*
|
|
149
|
+
* ```typescript
|
|
150
|
+
* import { accountToolsWithSchemas } from '../../tools/definitions/account-with-schemas';
|
|
151
|
+
* import { EbaySellerApi } from '../../api';
|
|
152
|
+
*
|
|
153
|
+
* async function validateToolExecution() {
|
|
154
|
+
* const api = new EbaySellerApi();
|
|
155
|
+
* const tool = accountToolsWithSchemas.find(t => t.name === 'ebay_get_fulfillment_policies');
|
|
156
|
+
*
|
|
157
|
+
* // Validate input
|
|
158
|
+
* const input = { marketplaceId: 'EBAY_US' };
|
|
159
|
+
* const validatedInput = tool.inputSchema.parse(input); // Throws if invalid
|
|
160
|
+
*
|
|
161
|
+
* // Execute API call
|
|
162
|
+
* const response = await api.account.getFulfillmentPolicies(validatedInput.marketplaceId);
|
|
163
|
+
*
|
|
164
|
+
* // Validate output
|
|
165
|
+
* const validatedOutput = tool.outputSchema?.parse(response); // Throws if invalid
|
|
166
|
+
*
|
|
167
|
+
* return validatedOutput;
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OutputArgs, ToolAnnotations } from '../tool-definitions.js';
|
|
3
|
+
export interface ToolDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: Record<string, z.ZodTypeAny>;
|
|
7
|
+
title?: string;
|
|
8
|
+
outputSchema?: OutputArgs;
|
|
9
|
+
annotations?: ToolAnnotations;
|
|
10
|
+
_meta?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare const accountTools: ToolDefinition[];
|