@vitemcp/server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/README.md +2001 -0
- package/dist/OAuthProvider-Cg7nUJJT.d.cts +961 -0
- package/dist/OAuthProvider-Cg7nUJJT.d.ts +961 -0
- package/dist/ViteMCP.cjs +1115 -0
- package/dist/ViteMCP.cjs.map +1 -0
- package/dist/ViteMCP.d.cts +400 -0
- package/dist/ViteMCP.d.ts +400 -0
- package/dist/ViteMCP.js +1115 -0
- package/dist/ViteMCP.js.map +1 -0
- package/dist/auth/index.cjs +55 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +411 -0
- package/dist/auth/index.d.ts +411 -0
- package/dist/auth/index.js +55 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/bin/vitemcp.cjs +237 -0
- package/dist/bin/vitemcp.cjs.map +1 -0
- package/dist/bin/vitemcp.d.cts +1 -0
- package/dist/bin/vitemcp.d.ts +1 -0
- package/dist/bin/vitemcp.js +237 -0
- package/dist/bin/vitemcp.js.map +1 -0
- package/dist/chunk-57MXTIW7.cjs +3119 -0
- package/dist/chunk-57MXTIW7.cjs.map +1 -0
- package/dist/chunk-NZIPGNND.js +3119 -0
- package/dist/chunk-NZIPGNND.js.map +1 -0
- package/dist/edge/index.cjs +115 -0
- package/dist/edge/index.cjs.map +1 -0
- package/dist/edge/index.d.cts +84 -0
- package/dist/edge/index.d.ts +84 -0
- package/dist/edge/index.js +115 -0
- package/dist/edge/index.js.map +1 -0
- package/package.json +152 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-Cg7nUJJT.js';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-Cg7nUJJT.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Consent Management
|
|
6
|
+
* Handles user consent flow for OAuth authorization
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Manages consent screens and cookie signing
|
|
11
|
+
*/
|
|
12
|
+
declare class ConsentManager {
|
|
13
|
+
private signingKey;
|
|
14
|
+
constructor(signingKey: string);
|
|
15
|
+
/**
|
|
16
|
+
* Create HTTP response with consent screen
|
|
17
|
+
*/
|
|
18
|
+
createConsentResponse(transaction: OAuthTransaction, provider: string): Response;
|
|
19
|
+
/**
|
|
20
|
+
* Generate HTML for consent screen
|
|
21
|
+
*/
|
|
22
|
+
generateConsentScreen(data: ConsentData): string;
|
|
23
|
+
/**
|
|
24
|
+
* Sign consent data for cookie
|
|
25
|
+
*/
|
|
26
|
+
signConsentCookie(data: ConsentData): string;
|
|
27
|
+
/**
|
|
28
|
+
* Validate and parse consent cookie
|
|
29
|
+
*/
|
|
30
|
+
validateConsentCookie(cookie: string): ConsentData | null;
|
|
31
|
+
/**
|
|
32
|
+
* Escape HTML to prevent XSS
|
|
33
|
+
*/
|
|
34
|
+
private escapeHtml;
|
|
35
|
+
/**
|
|
36
|
+
* Format scope for display
|
|
37
|
+
*/
|
|
38
|
+
private formatScope;
|
|
39
|
+
/**
|
|
40
|
+
* Generate default signing key if none provided
|
|
41
|
+
*/
|
|
42
|
+
private generateDefaultKey;
|
|
43
|
+
/**
|
|
44
|
+
* Sign a payload using HMAC-SHA256
|
|
45
|
+
*/
|
|
46
|
+
private sign;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Disk-based Token Storage Implementation
|
|
51
|
+
* Provides persistent file-based storage for OAuth tokens and transaction state
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
interface DiskStoreOptions {
|
|
55
|
+
/**
|
|
56
|
+
* How often to run cleanup (in milliseconds)
|
|
57
|
+
* @default 60000 (1 minute)
|
|
58
|
+
*/
|
|
59
|
+
cleanupIntervalMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Directory path for storing data
|
|
62
|
+
*/
|
|
63
|
+
directory: string;
|
|
64
|
+
/**
|
|
65
|
+
* File extension for stored files
|
|
66
|
+
* @default ".json"
|
|
67
|
+
*/
|
|
68
|
+
fileExtension?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Disk-based token storage with TTL support
|
|
72
|
+
* Persists tokens to filesystem for survival across server restarts
|
|
73
|
+
*/
|
|
74
|
+
declare class DiskStore implements TokenStorage {
|
|
75
|
+
private cleanupInterval;
|
|
76
|
+
private directory;
|
|
77
|
+
private fileExtension;
|
|
78
|
+
constructor(options: DiskStoreOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Clean up expired entries
|
|
81
|
+
*/
|
|
82
|
+
cleanup(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete a value
|
|
85
|
+
*/
|
|
86
|
+
delete(key: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Destroy the storage and clear cleanup interval
|
|
89
|
+
*/
|
|
90
|
+
destroy(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Retrieve a value
|
|
93
|
+
*/
|
|
94
|
+
get(key: string): Promise<null | unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Save a value with optional TTL
|
|
97
|
+
*/
|
|
98
|
+
save(key: string, value: unknown, ttl?: number): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Get the number of stored items
|
|
101
|
+
*/
|
|
102
|
+
size(): Promise<number>;
|
|
103
|
+
/**
|
|
104
|
+
* Atomically retrieve a value and delete it.
|
|
105
|
+
*
|
|
106
|
+
* rename() is atomic on POSIX filesystems, so when several processes race
|
|
107
|
+
* for the same key exactly one rename succeeds and the losers see ENOENT.
|
|
108
|
+
* That is what makes single-use authorization codes safe when more than one
|
|
109
|
+
* process shares the directory.
|
|
110
|
+
*/
|
|
111
|
+
take(key: string): Promise<null | unknown>;
|
|
112
|
+
/**
|
|
113
|
+
* Ensure storage directory exists
|
|
114
|
+
*/
|
|
115
|
+
private ensureDirectory;
|
|
116
|
+
/**
|
|
117
|
+
* Get file path for a key
|
|
118
|
+
*/
|
|
119
|
+
private getFilePath;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* JWT Issuer for OAuth Proxy
|
|
124
|
+
* Issues and validates short-lived JWTs that reference upstream provider tokens
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* JWT Claims for ViteMCP tokens
|
|
128
|
+
*/
|
|
129
|
+
interface JWTClaims {
|
|
130
|
+
/** Additional custom claims from upstream tokens */
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
/** Audience */
|
|
133
|
+
aud: string;
|
|
134
|
+
client_id: string;
|
|
135
|
+
/** Expiration time (seconds since epoch) */
|
|
136
|
+
exp: number;
|
|
137
|
+
/** Issued at time (seconds since epoch) */
|
|
138
|
+
iat: number;
|
|
139
|
+
/** Issuer */
|
|
140
|
+
iss: string;
|
|
141
|
+
/** JWT ID (unique identifier) */
|
|
142
|
+
jti: string;
|
|
143
|
+
/** Scopes */
|
|
144
|
+
scope: string[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* JWT Issuer configuration
|
|
148
|
+
*/
|
|
149
|
+
interface JWTIssuerConfig {
|
|
150
|
+
/** Token expiration in seconds (default: 3600 = 1 hour) */
|
|
151
|
+
accessTokenTtl?: number;
|
|
152
|
+
/** Audience for issued tokens */
|
|
153
|
+
audience: string;
|
|
154
|
+
/** Issuer identifier */
|
|
155
|
+
issuer: string;
|
|
156
|
+
/** Refresh token expiration in seconds (default: 2592000 = 30 days) */
|
|
157
|
+
refreshTokenTtl?: number;
|
|
158
|
+
/** Secret key for signing tokens */
|
|
159
|
+
signingKey: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Token validation result
|
|
163
|
+
*/
|
|
164
|
+
interface TokenValidationResult {
|
|
165
|
+
/** Decoded claims if valid */
|
|
166
|
+
claims?: JWTClaims;
|
|
167
|
+
/** Error message if invalid */
|
|
168
|
+
error?: string;
|
|
169
|
+
/** Whether token is valid */
|
|
170
|
+
valid: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* JWT Issuer
|
|
174
|
+
* Issues and validates HS256-signed JWTs for the OAuth proxy
|
|
175
|
+
*/
|
|
176
|
+
declare class JWTIssuer {
|
|
177
|
+
private accessTokenTtl;
|
|
178
|
+
private audience;
|
|
179
|
+
private issuer;
|
|
180
|
+
private refreshTokenTtl;
|
|
181
|
+
private signingKey;
|
|
182
|
+
constructor(config: JWTIssuerConfig);
|
|
183
|
+
/**
|
|
184
|
+
* Derive a signing key from a secret
|
|
185
|
+
* Uses PBKDF2 for key derivation
|
|
186
|
+
*/
|
|
187
|
+
static deriveKey(secret: string, iterations?: number): Promise<string>;
|
|
188
|
+
/**
|
|
189
|
+
* Issue an access token
|
|
190
|
+
*/
|
|
191
|
+
issueAccessToken(clientId: string, scope: string[], additionalClaims?: Record<string, unknown>, expiresIn?: number): string;
|
|
192
|
+
/**
|
|
193
|
+
* Issue a refresh token
|
|
194
|
+
*/
|
|
195
|
+
issueRefreshToken(clientId: string, scope: string[], additionalClaims?: Record<string, unknown>, expiresIn?: number): string;
|
|
196
|
+
/**
|
|
197
|
+
* Validate a JWT token
|
|
198
|
+
*/
|
|
199
|
+
verify(token: string): Promise<TokenValidationResult>;
|
|
200
|
+
/**
|
|
201
|
+
* Generate unique JWT ID
|
|
202
|
+
*/
|
|
203
|
+
private generateJti;
|
|
204
|
+
/**
|
|
205
|
+
* Sign data with HMAC-SHA256
|
|
206
|
+
*/
|
|
207
|
+
private sign;
|
|
208
|
+
/**
|
|
209
|
+
* Sign a JWT token
|
|
210
|
+
*/
|
|
211
|
+
private signToken;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* JWKS (JSON Web Key Set) Verifier
|
|
216
|
+
* Provides JWT verification using public keys from JWKS endpoints
|
|
217
|
+
*
|
|
218
|
+
* Requires the 'jose' package as an optional peer dependency.
|
|
219
|
+
* Install with: npm install jose
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Token verification result
|
|
224
|
+
*/
|
|
225
|
+
interface JWKSVerificationResult {
|
|
226
|
+
claims?: JWTClaims;
|
|
227
|
+
error?: string;
|
|
228
|
+
valid: boolean;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* JWKS configuration options
|
|
232
|
+
*/
|
|
233
|
+
interface JWKSVerifierConfig {
|
|
234
|
+
/**
|
|
235
|
+
* Expected token audience
|
|
236
|
+
*/
|
|
237
|
+
audience?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Cache duration for JWKS keys in milliseconds
|
|
240
|
+
* @default 3600000 (1 hour)
|
|
241
|
+
*/
|
|
242
|
+
cacheDuration?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Cooldown duration between JWKS refetches in milliseconds
|
|
245
|
+
* @default 30000 (30 seconds)
|
|
246
|
+
*/
|
|
247
|
+
cooldownDuration?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Expected token issuer
|
|
250
|
+
*/
|
|
251
|
+
issuer?: string;
|
|
252
|
+
/**
|
|
253
|
+
* JWKS endpoint URL (e.g., https://provider.com/.well-known/jwks.json)
|
|
254
|
+
*/
|
|
255
|
+
jwksUri: string;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verifies JWTs against a JWKS endpoint. Requires the optional `jose` package.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const verifier = new JWKSVerifier({
|
|
263
|
+
* audience: "your-client-id",
|
|
264
|
+
* issuer: "https://accounts.google.com",
|
|
265
|
+
* jwksUri: "https://accounts.google.com/.well-known/jwks.json",
|
|
266
|
+
* });
|
|
267
|
+
* const { valid, claims } = await verifier.verify(token);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare class JWKSVerifier implements TokenVerifier {
|
|
271
|
+
private config;
|
|
272
|
+
private jose;
|
|
273
|
+
private joseLoaded;
|
|
274
|
+
private jwksCache;
|
|
275
|
+
constructor(config: JWKSVerifierConfig);
|
|
276
|
+
/**
|
|
277
|
+
* Get the JWKS URI being used
|
|
278
|
+
*/
|
|
279
|
+
getJwksUri(): string;
|
|
280
|
+
/**
|
|
281
|
+
* Refresh the JWKS cache
|
|
282
|
+
* Useful if you need to force a key refresh
|
|
283
|
+
*/
|
|
284
|
+
refreshKeys(): Promise<void>;
|
|
285
|
+
/**
|
|
286
|
+
* Verify a JWT token using JWKS
|
|
287
|
+
*
|
|
288
|
+
* @param token - The JWT token to verify
|
|
289
|
+
* @returns Verification result with claims if valid
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const result = await verifier.verify(token);
|
|
294
|
+
* if (result.valid) {
|
|
295
|
+
* console.log('User:', result.claims?.client_id);
|
|
296
|
+
* } else {
|
|
297
|
+
* console.error('Invalid token:', result.error);
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
verify(token: string): Promise<TokenVerificationResult>;
|
|
302
|
+
/**
|
|
303
|
+
* Lazy load the jose library
|
|
304
|
+
* Only loads when verification is first attempted
|
|
305
|
+
*/
|
|
306
|
+
private loadJose;
|
|
307
|
+
/**
|
|
308
|
+
* Parse scope from token payload
|
|
309
|
+
* Handles both string (space-separated) and array formats
|
|
310
|
+
*/
|
|
311
|
+
private parseScope;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* PKCE (Proof Key for Code Exchange) Utilities
|
|
316
|
+
* Implements RFC 7636 for OAuth 2.0 public clients
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* PKCE utility class for generating and validating code challenges
|
|
321
|
+
*/
|
|
322
|
+
declare class PKCEUtils {
|
|
323
|
+
/**
|
|
324
|
+
* Generate a code challenge from a verifier
|
|
325
|
+
* @param verifier The code verifier
|
|
326
|
+
* @param method Challenge method: 'S256' or 'plain' (default: 'S256')
|
|
327
|
+
* @returns Base64URL-encoded challenge string
|
|
328
|
+
*/
|
|
329
|
+
static generateChallenge(verifier: string, method?: "plain" | "S256"): string;
|
|
330
|
+
/**
|
|
331
|
+
* Generate a complete PKCE pair (verifier + challenge)
|
|
332
|
+
* @param method Challenge method: 'S256' or 'plain' (default: 'S256')
|
|
333
|
+
* @returns Object containing verifier and challenge
|
|
334
|
+
*/
|
|
335
|
+
static generatePair(method?: "plain" | "S256"): PKCEPair;
|
|
336
|
+
/**
|
|
337
|
+
* Generate a cryptographically secure code verifier
|
|
338
|
+
* @param length Length of verifier (43-128 characters, default: 128)
|
|
339
|
+
* @returns Base64URL-encoded verifier string
|
|
340
|
+
*/
|
|
341
|
+
static generateVerifier(length?: number): string;
|
|
342
|
+
/**
|
|
343
|
+
* Validate a code verifier against a challenge
|
|
344
|
+
* @param verifier The code verifier to validate
|
|
345
|
+
* @param challenge The expected challenge
|
|
346
|
+
* @param method The challenge method used
|
|
347
|
+
* @returns True if verifier matches challenge
|
|
348
|
+
*/
|
|
349
|
+
static validateChallenge(verifier: string, challenge: string, method: string): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Encode a buffer as base64url (RFC 4648)
|
|
352
|
+
* @param buffer Buffer to encode
|
|
353
|
+
* @returns Base64URL-encoded string
|
|
354
|
+
*/
|
|
355
|
+
private static base64URLEncode;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Token Storage Implementations
|
|
360
|
+
* Secure storage for OAuth tokens and transaction state
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Encrypted token storage wrapper
|
|
365
|
+
* Encrypts values using AES-256-GCM before storing
|
|
366
|
+
*/
|
|
367
|
+
declare class EncryptedTokenStorage implements TokenStorage {
|
|
368
|
+
private algorithm;
|
|
369
|
+
private backend;
|
|
370
|
+
private encryptionKey;
|
|
371
|
+
constructor(backend: TokenStorage, encryptionKey: string);
|
|
372
|
+
cleanup(): Promise<void>;
|
|
373
|
+
delete(key: string): Promise<void>;
|
|
374
|
+
get(key: string): Promise<null | unknown>;
|
|
375
|
+
save(key: string, value: unknown, ttl?: number): Promise<void>;
|
|
376
|
+
/**
|
|
377
|
+
* Delegates to the backend so that the atomicity of the underlying store is
|
|
378
|
+
* preserved; falls back to get + delete when the backend cannot do better.
|
|
379
|
+
*/
|
|
380
|
+
take(key: string): Promise<null | unknown>;
|
|
381
|
+
private decrypt;
|
|
382
|
+
private decryptStored;
|
|
383
|
+
private encrypt;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* In-memory token storage with TTL support
|
|
387
|
+
*/
|
|
388
|
+
declare class MemoryTokenStorage implements TokenStorage {
|
|
389
|
+
private cleanupInterval;
|
|
390
|
+
private store;
|
|
391
|
+
constructor(cleanupIntervalMs?: number);
|
|
392
|
+
cleanup(): Promise<void>;
|
|
393
|
+
delete(key: string): Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Destroy the storage and clear cleanup interval
|
|
396
|
+
*/
|
|
397
|
+
destroy(): void;
|
|
398
|
+
get(key: string): Promise<null | unknown>;
|
|
399
|
+
save(key: string, value: unknown, ttl?: number): Promise<void>;
|
|
400
|
+
/**
|
|
401
|
+
* Get the number of stored items
|
|
402
|
+
*/
|
|
403
|
+
size(): number;
|
|
404
|
+
/**
|
|
405
|
+
* Atomic by construction: the read and the delete happen in a single
|
|
406
|
+
* synchronous block, so no other task can observe the value in between.
|
|
407
|
+
*/
|
|
408
|
+
take(key: string): Promise<null | unknown>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export { ConsentData, ConsentManager, DiskStore, EncryptedTokenStorage, type JWKSVerificationResult, JWKSVerifier, type JWKSVerifierConfig, type JWTClaims, JWTIssuer, MemoryTokenStorage, OAuthTransaction, PKCEPair, PKCEUtils, TokenStorage, TokenVerificationResult, TokenVerifier };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthProvider,
|
|
3
|
+
AzureProvider,
|
|
4
|
+
ConsentManager,
|
|
5
|
+
DEFAULT_ACCESS_TOKEN_TTL,
|
|
6
|
+
DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH,
|
|
7
|
+
DEFAULT_AUTHORIZATION_CODE_TTL,
|
|
8
|
+
DEFAULT_REFRESH_TOKEN_TTL,
|
|
9
|
+
DEFAULT_TRANSACTION_TTL,
|
|
10
|
+
DiskStore,
|
|
11
|
+
EncryptedTokenStorage,
|
|
12
|
+
GitHubProvider,
|
|
13
|
+
GoogleProvider,
|
|
14
|
+
JWKSVerifier,
|
|
15
|
+
JWTIssuer,
|
|
16
|
+
MemoryTokenStorage,
|
|
17
|
+
OAuthProvider,
|
|
18
|
+
OAuthProxy,
|
|
19
|
+
OAuthProxyError,
|
|
20
|
+
PKCEUtils,
|
|
21
|
+
getAuthSession,
|
|
22
|
+
requireAll,
|
|
23
|
+
requireAny,
|
|
24
|
+
requireAuth,
|
|
25
|
+
requireRole,
|
|
26
|
+
requireScopes
|
|
27
|
+
} from "../chunk-NZIPGNND.js";
|
|
28
|
+
export {
|
|
29
|
+
AuthProvider,
|
|
30
|
+
AzureProvider,
|
|
31
|
+
ConsentManager,
|
|
32
|
+
DEFAULT_ACCESS_TOKEN_TTL,
|
|
33
|
+
DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH,
|
|
34
|
+
DEFAULT_AUTHORIZATION_CODE_TTL,
|
|
35
|
+
DEFAULT_REFRESH_TOKEN_TTL,
|
|
36
|
+
DEFAULT_TRANSACTION_TTL,
|
|
37
|
+
DiskStore,
|
|
38
|
+
EncryptedTokenStorage,
|
|
39
|
+
GitHubProvider,
|
|
40
|
+
GoogleProvider,
|
|
41
|
+
JWKSVerifier,
|
|
42
|
+
JWTIssuer,
|
|
43
|
+
MemoryTokenStorage,
|
|
44
|
+
OAuthProvider,
|
|
45
|
+
OAuthProxy,
|
|
46
|
+
OAuthProxyError,
|
|
47
|
+
PKCEUtils,
|
|
48
|
+
getAuthSession,
|
|
49
|
+
requireAll,
|
|
50
|
+
requireAny,
|
|
51
|
+
requireAuth,
|
|
52
|
+
requireRole,
|
|
53
|
+
requireScopes
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3
|
+
// src/bin/vitemcp.ts
|
|
4
|
+
var _execa = require('execa');
|
|
5
|
+
var _promises = require('fs/promises');
|
|
6
|
+
var _os = require('os');
|
|
7
|
+
var _path = require('path');
|
|
8
|
+
var _yargs = require('yargs'); var _yargs2 = _interopRequireDefault(_yargs);
|
|
9
|
+
var _helpers = require('yargs/helpers');
|
|
10
|
+
|
|
11
|
+
// src/bin/devCommand.ts
|
|
12
|
+
var DEV_SERVER_NAME = "dev";
|
|
13
|
+
var buildDevConfig = (file) => JSON.stringify(
|
|
14
|
+
{
|
|
15
|
+
mcpServers: {
|
|
16
|
+
[DEV_SERVER_NAME]: {
|
|
17
|
+
args: ["tsx", file],
|
|
18
|
+
command: "npx"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
null,
|
|
23
|
+
2
|
|
24
|
+
);
|
|
25
|
+
var buildDevCommand = (options) => {
|
|
26
|
+
const { configPath, file, tool, toolArgs, watch = false } = options;
|
|
27
|
+
if (tool) {
|
|
28
|
+
if (!configPath) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"configPath is required when calling a tool non-interactively"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
"npx",
|
|
35
|
+
"@wong2/mcp-cli",
|
|
36
|
+
"-c",
|
|
37
|
+
configPath,
|
|
38
|
+
"call-tool",
|
|
39
|
+
`${DEV_SERVER_NAME}:${tool}`,
|
|
40
|
+
...toolArgs === void 0 ? [] : ["--args", toolArgs]
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return [
|
|
44
|
+
"npx",
|
|
45
|
+
"@wong2/mcp-cli",
|
|
46
|
+
"npx",
|
|
47
|
+
"tsx",
|
|
48
|
+
...watch ? ["--watch"] : [],
|
|
49
|
+
file
|
|
50
|
+
];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/bin/vitemcp.ts
|
|
54
|
+
await _yargs2.default.call(void 0, _helpers.hideBin.call(void 0, process.argv)).scriptName("vitemcp").command(
|
|
55
|
+
"dev <file>",
|
|
56
|
+
"Start a development server",
|
|
57
|
+
(yargs2) => {
|
|
58
|
+
return yargs2.positional("file", {
|
|
59
|
+
demandOption: true,
|
|
60
|
+
describe: "The path to the server file",
|
|
61
|
+
type: "string"
|
|
62
|
+
}).option("args", {
|
|
63
|
+
describe: `JSON arguments passed to the tool (requires --tool), e.g. '{"a":1}'`,
|
|
64
|
+
type: "string"
|
|
65
|
+
}).option("tool", {
|
|
66
|
+
alias: "t",
|
|
67
|
+
describe: "Call a tool non-interactively instead of launching the inspector",
|
|
68
|
+
type: "string"
|
|
69
|
+
}).option("watch", {
|
|
70
|
+
alias: "w",
|
|
71
|
+
default: false,
|
|
72
|
+
describe: "Watch for file changes and restart server",
|
|
73
|
+
type: "boolean"
|
|
74
|
+
}).option("verbose", {
|
|
75
|
+
alias: "v",
|
|
76
|
+
default: false,
|
|
77
|
+
describe: "Enable verbose logging",
|
|
78
|
+
type: "boolean"
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async (argv) => {
|
|
82
|
+
let configDir;
|
|
83
|
+
try {
|
|
84
|
+
if (argv.args !== void 0 && !argv.tool) {
|
|
85
|
+
console.error("[ViteMCP Error] --args requires --tool");
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (argv.tool && argv.watch) {
|
|
90
|
+
console.warn(
|
|
91
|
+
"[ViteMCP] --watch is ignored when calling a tool with --tool: the server runs for a single call."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
let configPath;
|
|
95
|
+
if (argv.tool) {
|
|
96
|
+
configDir = await _promises.mkdtemp.call(void 0, _path.join.call(void 0, _os.tmpdir.call(void 0, ), "vitemcp-dev-"));
|
|
97
|
+
configPath = _path.join.call(void 0, configDir, "mcp-cli.json");
|
|
98
|
+
await _promises.writeFile.call(void 0, configPath, buildDevConfig(argv.file), "utf8");
|
|
99
|
+
}
|
|
100
|
+
const [command, ...commandArgs] = buildDevCommand({
|
|
101
|
+
configPath,
|
|
102
|
+
file: argv.file,
|
|
103
|
+
tool: argv.tool,
|
|
104
|
+
toolArgs: argv.args,
|
|
105
|
+
watch: argv.watch
|
|
106
|
+
});
|
|
107
|
+
if (argv.verbose) {
|
|
108
|
+
console.log(
|
|
109
|
+
`[ViteMCP] Starting server: ${[command, ...commandArgs].join(" ")}`
|
|
110
|
+
);
|
|
111
|
+
console.log(`[ViteMCP] File: ${argv.file}`);
|
|
112
|
+
console.log(
|
|
113
|
+
`[ViteMCP] Watch mode: ${argv.watch ? "enabled" : "disabled"}`
|
|
114
|
+
);
|
|
115
|
+
if (argv.tool) {
|
|
116
|
+
console.log(`[ViteMCP] Tool: ${argv.tool}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
await _execa.execa.call(void 0, command, commandArgs, {
|
|
120
|
+
stderr: "inherit",
|
|
121
|
+
stdin: "inherit",
|
|
122
|
+
stdout: "inherit"
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error(
|
|
126
|
+
"[ViteMCP Error] Failed to start development server:",
|
|
127
|
+
error instanceof Error ? error.message : String(error)
|
|
128
|
+
);
|
|
129
|
+
if (argv.verbose && error instanceof Error && error.stack) {
|
|
130
|
+
console.error("[ViteMCP Debug] Stack trace:", error.stack);
|
|
131
|
+
}
|
|
132
|
+
process.exitCode = 1;
|
|
133
|
+
} finally {
|
|
134
|
+
if (configDir) {
|
|
135
|
+
await _promises.rm.call(void 0, configDir, { force: true, recursive: true });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
).command(
|
|
140
|
+
"inspect <file>",
|
|
141
|
+
"Inspect a server file",
|
|
142
|
+
(yargs2) => {
|
|
143
|
+
return yargs2.positional("file", {
|
|
144
|
+
demandOption: true,
|
|
145
|
+
describe: "The path to the server file",
|
|
146
|
+
type: "string"
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
async (argv) => {
|
|
150
|
+
try {
|
|
151
|
+
await _execa.execa.call(void 0, {
|
|
152
|
+
stderr: "inherit",
|
|
153
|
+
stdout: "inherit"
|
|
154
|
+
})`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(
|
|
157
|
+
"[ViteMCP Error] Failed to inspect server:",
|
|
158
|
+
error instanceof Error ? error.message : String(error)
|
|
159
|
+
);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
).command(
|
|
164
|
+
"validate <file>",
|
|
165
|
+
"Validate a ViteMCP server file for syntax and basic structure",
|
|
166
|
+
(yargs2) => {
|
|
167
|
+
return yargs2.positional("file", {
|
|
168
|
+
demandOption: true,
|
|
169
|
+
describe: "The path to the server file",
|
|
170
|
+
type: "string"
|
|
171
|
+
}).option("strict", {
|
|
172
|
+
alias: "s",
|
|
173
|
+
default: false,
|
|
174
|
+
describe: "Enable strict validation (type checking)",
|
|
175
|
+
type: "boolean"
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
async (argv) => {
|
|
179
|
+
try {
|
|
180
|
+
const { existsSync } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs")));
|
|
181
|
+
const { resolve } = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
|
|
182
|
+
const filePath = resolve(argv.file);
|
|
183
|
+
if (!existsSync(filePath)) {
|
|
184
|
+
console.error(`[ViteMCP Error] File not found: ${filePath}`);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
console.log(`[ViteMCP] Validating server file: ${filePath}`);
|
|
188
|
+
const command = argv.strict ? `npx tsc --noEmit --strict ${filePath}` : `npx tsc --noEmit ${filePath}`;
|
|
189
|
+
try {
|
|
190
|
+
await _execa.execa.call(void 0, {
|
|
191
|
+
shell: true,
|
|
192
|
+
stderr: "pipe",
|
|
193
|
+
stdout: "pipe"
|
|
194
|
+
})`${command}`;
|
|
195
|
+
console.log("[ViteMCP] \u2713 TypeScript compilation successful");
|
|
196
|
+
} catch (tsError) {
|
|
197
|
+
console.error("[ViteMCP] \u2717 TypeScript compilation failed");
|
|
198
|
+
if (tsError instanceof Error && "stderr" in tsError) {
|
|
199
|
+
console.error(tsError.stderr);
|
|
200
|
+
}
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
await _execa.execa.call(void 0, {
|
|
205
|
+
shell: true,
|
|
206
|
+
stderr: "pipe",
|
|
207
|
+
stdout: "pipe"
|
|
208
|
+
})`node -e "
|
|
209
|
+
(async () => {
|
|
210
|
+
try {
|
|
211
|
+
const { ViteMCP } = await import('@vitemcp/server');
|
|
212
|
+
await import('file://${filePath}');
|
|
213
|
+
console.log('[ViteMCP] ✓ Server structure validation passed');
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error('[ViteMCP] ✗ Server structure validation failed:', error.message);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
})();
|
|
219
|
+
"`;
|
|
220
|
+
} catch (e) {
|
|
221
|
+
console.error("[ViteMCP] \u2717 Server structure validation failed");
|
|
222
|
+
console.error("Make sure the file properly imports and uses ViteMCP");
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
console.log(
|
|
226
|
+
"[ViteMCP] \u2713 All validations passed! Server file looks good."
|
|
227
|
+
);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(
|
|
230
|
+
"[ViteMCP Error] Validation failed:",
|
|
231
|
+
error instanceof Error ? error.message : String(error)
|
|
232
|
+
);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
).help().parseAsync();
|
|
237
|
+
//# sourceMappingURL=vitemcp.cjs.map
|