@vitemcp/server 1.8.4 → 1.8.6
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/dist/{OAuthProvider-CWBi3c3D.d.cts → OAuthProvider-COBBSCMI.d.cts} +14 -3
- package/dist/{OAuthProvider-CWBi3c3D.d.ts → OAuthProvider-COBBSCMI.d.ts} +14 -3
- package/dist/ViteMCP.cjs +2 -2
- package/dist/ViteMCP.d.cts +2 -2
- package/dist/ViteMCP.d.ts +2 -2
- package/dist/ViteMCP.js +1 -1
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/bin/vitemcp.cjs +119 -34
- package/dist/bin/vitemcp.cjs.map +1 -1
- package/dist/bin/vitemcp.js +127 -42
- package/dist/bin/vitemcp.js.map +1 -1
- package/dist/{chunk-GCCQBATS.js → chunk-5KNSU2F3.js} +91 -27
- package/dist/chunk-5KNSU2F3.js.map +1 -0
- package/dist/{chunk-VTEMGFQZ.cjs → chunk-Y3GRHB77.cjs} +104 -40
- package/dist/chunk-Y3GRHB77.cjs.map +1 -0
- package/dist/openapi/index.cjs +1 -1
- package/dist/openapi/index.d.cts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GCCQBATS.js.map +0 -1
- package/dist/chunk-VTEMGFQZ.cjs.map +0 -1
|
@@ -664,6 +664,17 @@ declare class OAuthProxy {
|
|
|
664
664
|
* Issue swapped tokens for refresh flow
|
|
665
665
|
*/
|
|
666
666
|
private issueSwappedTokensForRefresh;
|
|
667
|
+
/**
|
|
668
|
+
* Whether the callback URL a transaction carries is still one its client
|
|
669
|
+
* declares.
|
|
670
|
+
*
|
|
671
|
+
* Resolved through `resolveClient` rather than a raw store lookup so a CIMD
|
|
672
|
+
* client is visible here too, and so a document that has since dropped the
|
|
673
|
+
* URI stops matching — the mid-flow revocation this check exists for.
|
|
674
|
+
* Loopback ports are matched per RFC 8252 §7.3, exactly as `authorize()`
|
|
675
|
+
* matched them, so the two legs cannot disagree about the same URI.
|
|
676
|
+
*/
|
|
677
|
+
private isTransactionCallbackRegistered;
|
|
667
678
|
/**
|
|
668
679
|
* Match a parsed URI against an allow-list pattern, one URI component at a
|
|
669
680
|
* time: scheme, host, port, then everything from the path onwards. A `*`
|
|
@@ -704,13 +715,13 @@ declare class OAuthProxy {
|
|
|
704
715
|
*/
|
|
705
716
|
private refreshUpstreamTokens;
|
|
706
717
|
/**
|
|
707
|
-
*
|
|
718
|
+
* The client behind a client_id, on whichever leg of the flow asks.
|
|
708
719
|
*
|
|
709
720
|
* A URL-formatted client_id is resolved as a Client ID Metadata Document
|
|
710
721
|
* (the preferred mechanism on this revision); anything else must have been
|
|
711
|
-
* registered through DCR.
|
|
722
|
+
* registered through DCR. Throws `invalid_client` when it is neither.
|
|
712
723
|
*/
|
|
713
|
-
private
|
|
724
|
+
private resolveClient;
|
|
714
725
|
/**
|
|
715
726
|
* Put a claimed refresh-token mapping back after a rotation failed, keeping
|
|
716
727
|
* whatever lifetime it had left.
|
|
@@ -664,6 +664,17 @@ declare class OAuthProxy {
|
|
|
664
664
|
* Issue swapped tokens for refresh flow
|
|
665
665
|
*/
|
|
666
666
|
private issueSwappedTokensForRefresh;
|
|
667
|
+
/**
|
|
668
|
+
* Whether the callback URL a transaction carries is still one its client
|
|
669
|
+
* declares.
|
|
670
|
+
*
|
|
671
|
+
* Resolved through `resolveClient` rather than a raw store lookup so a CIMD
|
|
672
|
+
* client is visible here too, and so a document that has since dropped the
|
|
673
|
+
* URI stops matching — the mid-flow revocation this check exists for.
|
|
674
|
+
* Loopback ports are matched per RFC 8252 §7.3, exactly as `authorize()`
|
|
675
|
+
* matched them, so the two legs cannot disagree about the same URI.
|
|
676
|
+
*/
|
|
677
|
+
private isTransactionCallbackRegistered;
|
|
667
678
|
/**
|
|
668
679
|
* Match a parsed URI against an allow-list pattern, one URI component at a
|
|
669
680
|
* time: scheme, host, port, then everything from the path onwards. A `*`
|
|
@@ -704,13 +715,13 @@ declare class OAuthProxy {
|
|
|
704
715
|
*/
|
|
705
716
|
private refreshUpstreamTokens;
|
|
706
717
|
/**
|
|
707
|
-
*
|
|
718
|
+
* The client behind a client_id, on whichever leg of the flow asks.
|
|
708
719
|
*
|
|
709
720
|
* A URL-formatted client_id is resolved as a Client ID Metadata Document
|
|
710
721
|
* (the preferred mechanism on this revision); anything else must have been
|
|
711
|
-
* registered through DCR.
|
|
722
|
+
* registered through DCR. Throws `invalid_client` when it is neither.
|
|
712
723
|
*/
|
|
713
|
-
private
|
|
724
|
+
private resolveClient;
|
|
714
725
|
/**
|
|
715
726
|
* Put a claimed refresh-token mapping back after a rotation failed, keeping
|
|
716
727
|
* whatever lifetime it had left.
|
package/dist/ViteMCP.cjs
CHANGED
|
@@ -25,7 +25,7 @@ var _chunkWL4YFT27cjs = require('./chunk-WL4YFT27.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _chunkY3GRHB77cjs = require('./chunk-Y3GRHB77.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
@@ -51,5 +51,5 @@ var _chunkVTEMGFQZcjs = require('./chunk-VTEMGFQZ.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkY3GRHB77cjs.AuthProvider; exports.AzureProvider = _chunkY3GRHB77cjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkWL4YFT27cjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkY3GRHB77cjs.GitHubProvider; exports.GoogleProvider = _chunkY3GRHB77cjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkWL4YFT27cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkY3GRHB77cjs.OAuthProvider; exports.OAuthProxy = _chunkY3GRHB77cjs.OAuthProxy; exports.OAuthProxyError = _chunkY3GRHB77cjs.OAuthProxyError; exports.ServerState = _chunkWL4YFT27cjs.ServerState; exports.UnexpectedStateError = _chunkWL4YFT27cjs.UnexpectedStateError; exports.UserError = _chunkWL4YFT27cjs.UserError; exports.ViteMCP = _chunkWL4YFT27cjs.ViteMCP; exports.ViteMCPError = _chunkWL4YFT27cjs.ViteMCPError; exports.audioContent = _chunkWL4YFT27cjs.audioContent; exports.delay = _chunkWL4YFT27cjs.delay; exports.getAuthSession = _chunkY3GRHB77cjs.getAuthSession; exports.imageContent = _chunkWL4YFT27cjs.imageContent; exports.jsonSchemaAdapter = _chunkWL4YFT27cjs.jsonSchemaAdapter; exports.requireAll = _chunkY3GRHB77cjs.requireAll; exports.requireAny = _chunkY3GRHB77cjs.requireAny; exports.requireAuth = _chunkY3GRHB77cjs.requireAuth; exports.requireRole = _chunkY3GRHB77cjs.requireRole; exports.requireScopes = _chunkY3GRHB77cjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=ViteMCP.cjs.map
|
package/dist/ViteMCP.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
6
6
|
export { setTimeout as delay } from 'timers/promises';
|
|
7
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
8
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
7
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-COBBSCMI.cjs';
|
|
8
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-COBBSCMI.cjs';
|
|
9
9
|
|
|
10
10
|
declare class DiscoveryDocumentCache {
|
|
11
11
|
#private;
|
package/dist/ViteMCP.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
6
6
|
export { setTimeout as delay } from 'timers/promises';
|
|
7
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
8
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
7
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-COBBSCMI.js';
|
|
8
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-COBBSCMI.js';
|
|
9
9
|
|
|
10
10
|
declare class DiscoveryDocumentCache {
|
|
11
11
|
#private;
|
package/dist/ViteMCP.js
CHANGED
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkY3GRHB77cjs = require('../chunk-Y3GRHB77.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkVTEMGFQZcjs = require('../chunk-VTEMGFQZ.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkY3GRHB77cjs.AuthProvider; exports.AzureProvider = _chunkY3GRHB77cjs.AzureProvider; exports.ConsentManager = _chunkY3GRHB77cjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkY3GRHB77cjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkY3GRHB77cjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkY3GRHB77cjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkY3GRHB77cjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkY3GRHB77cjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkY3GRHB77cjs.DiskStore; exports.EncryptedTokenStorage = _chunkY3GRHB77cjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkY3GRHB77cjs.GitHubProvider; exports.GoogleProvider = _chunkY3GRHB77cjs.GoogleProvider; exports.JWKSVerifier = _chunkY3GRHB77cjs.JWKSVerifier; exports.JWTIssuer = _chunkY3GRHB77cjs.JWTIssuer; exports.MemoryTokenStorage = _chunkY3GRHB77cjs.MemoryTokenStorage; exports.OAuthProvider = _chunkY3GRHB77cjs.OAuthProvider; exports.OAuthProxy = _chunkY3GRHB77cjs.OAuthProxy; exports.OAuthProxyError = _chunkY3GRHB77cjs.OAuthProxyError; exports.PKCEUtils = _chunkY3GRHB77cjs.PKCEUtils; exports.getAuthSession = _chunkY3GRHB77cjs.getAuthSession; exports.requireAll = _chunkY3GRHB77cjs.requireAll; exports.requireAny = _chunkY3GRHB77cjs.requireAny; exports.requireAuth = _chunkY3GRHB77cjs.requireAuth; exports.requireRole = _chunkY3GRHB77cjs.requireRole; exports.requireScopes = _chunkY3GRHB77cjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-COBBSCMI.cjs';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-COBBSCMI.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Consent Management
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-COBBSCMI.js';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-COBBSCMI.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Consent Management
|
package/dist/auth/index.js
CHANGED
package/dist/bin/vitemcp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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 }; }
|
|
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 }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
3
3
|
// src/bin/vitemcp.ts
|
|
4
4
|
var _execa = require('execa');
|
|
5
5
|
var _promises = require('fs/promises');
|
|
@@ -50,6 +50,102 @@ var buildDevCommand = (options) => {
|
|
|
50
50
|
];
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
// src/bin/validateCommand.ts
|
|
54
|
+
var _crypto = require('crypto');
|
|
55
|
+
|
|
56
|
+
var _fs = require('fs');
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var _url = require('url');
|
|
60
|
+
var STRUCTURE_CHECK_SCRIPT = `
|
|
61
|
+
(async () => {
|
|
62
|
+
let failure;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
await import("@vitemcp/server");
|
|
66
|
+
await import(process.argv[1]);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (failure === undefined) {
|
|
72
|
+
process.stdout.write(
|
|
73
|
+
"[ViteMCP] \u2713 Server structure validation passed\\n",
|
|
74
|
+
() => process.exit(0),
|
|
75
|
+
);
|
|
76
|
+
} else {
|
|
77
|
+
process.stderr.write(
|
|
78
|
+
"[ViteMCP] \u2717 Server structure validation failed: " + failure + "\\n",
|
|
79
|
+
() => process.exit(1),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
`;
|
|
84
|
+
var STANDALONE_COMPILER_OPTIONS = {
|
|
85
|
+
allowImportingTsExtensions: true,
|
|
86
|
+
module: "esnext",
|
|
87
|
+
moduleResolution: "bundler",
|
|
88
|
+
skipLibCheck: true,
|
|
89
|
+
target: "es2022"
|
|
90
|
+
};
|
|
91
|
+
var PROJECT_OVERRIDES = { composite: false, incremental: false };
|
|
92
|
+
var buildStructureCheckCommand = (file, execPath = process.execPath) => [
|
|
93
|
+
execPath,
|
|
94
|
+
"-e",
|
|
95
|
+
STRUCTURE_CHECK_SCRIPT,
|
|
96
|
+
_url.pathToFileURL.call(void 0, file).href
|
|
97
|
+
];
|
|
98
|
+
var buildTypeCheckCommand = (config, strict = false) => [
|
|
99
|
+
"npx",
|
|
100
|
+
"tsc",
|
|
101
|
+
"--noEmit",
|
|
102
|
+
"--project",
|
|
103
|
+
config,
|
|
104
|
+
...strict ? ["--strict"] : []
|
|
105
|
+
];
|
|
106
|
+
var buildTypeCheckConfig = (file, tsconfig) => JSON.stringify(
|
|
107
|
+
tsconfig ? {
|
|
108
|
+
compilerOptions: PROJECT_OVERRIDES,
|
|
109
|
+
extends: tsconfig,
|
|
110
|
+
files: [file],
|
|
111
|
+
include: []
|
|
112
|
+
} : {
|
|
113
|
+
compilerOptions: STANDALONE_COMPILER_OPTIONS,
|
|
114
|
+
files: [file],
|
|
115
|
+
include: []
|
|
116
|
+
},
|
|
117
|
+
null,
|
|
118
|
+
2
|
|
119
|
+
);
|
|
120
|
+
var findTsconfig = (dir) => {
|
|
121
|
+
for (let current = dir; ; current = _path.dirname.call(void 0, current)) {
|
|
122
|
+
const candidate = _path.join.call(void 0, current, "tsconfig.json");
|
|
123
|
+
if (_fs.existsSync.call(void 0, candidate)) {
|
|
124
|
+
return candidate;
|
|
125
|
+
}
|
|
126
|
+
if (_path.dirname.call(void 0, current) === current) {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var formatCommandFailure = (result) => [result.stderr, result.stdout].map((output) => typeof output === "string" ? output.trim() : "").filter(Boolean).join("\n");
|
|
132
|
+
var runTypeCheck = async (file, strict = false) => {
|
|
133
|
+
const tsconfig = findTsconfig(_path.dirname.call(void 0, file));
|
|
134
|
+
const config = _path.join.call(void 0,
|
|
135
|
+
_path.dirname.call(void 0, _nullishCoalesce(tsconfig, () => ( file))),
|
|
136
|
+
`tsconfig.vitemcp-validate-${_crypto.randomUUID.call(void 0, )}.json`
|
|
137
|
+
);
|
|
138
|
+
await _promises.writeFile.call(void 0, config, buildTypeCheckConfig(file, tsconfig), {
|
|
139
|
+
flag: "wx"
|
|
140
|
+
});
|
|
141
|
+
try {
|
|
142
|
+
const [command, ...args] = buildTypeCheckCommand(config, strict);
|
|
143
|
+
return await _execa.execa.call(void 0, command, args, { reject: false });
|
|
144
|
+
} finally {
|
|
145
|
+
await _promises.rm.call(void 0, config, { force: true });
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
53
149
|
// src/bin/vitemcp.ts
|
|
54
150
|
await _yargs2.default.call(void 0, _helpers.hideBin.call(void 0, process.argv)).scriptName("vitemcp").command(
|
|
55
151
|
"dev <file>",
|
|
@@ -177,49 +273,38 @@ await _yargs2.default.call(void 0, _helpers.hideBin.call(void 0, process.argv)).
|
|
|
177
273
|
},
|
|
178
274
|
async (argv) => {
|
|
179
275
|
try {
|
|
180
|
-
const { existsSync } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs")));
|
|
276
|
+
const { existsSync: existsSync2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("fs")));
|
|
181
277
|
const { resolve } = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
|
|
182
278
|
const filePath = resolve(argv.file);
|
|
183
|
-
if (!
|
|
279
|
+
if (!existsSync2(filePath)) {
|
|
184
280
|
console.error(`[ViteMCP Error] File not found: ${filePath}`);
|
|
185
281
|
process.exit(1);
|
|
186
282
|
}
|
|
187
283
|
console.log(`[ViteMCP] Validating server file: ${filePath}`);
|
|
188
|
-
const
|
|
189
|
-
|
|
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) {
|
|
284
|
+
const typeCheck = await runTypeCheck(filePath, argv.strict);
|
|
285
|
+
if (typeCheck.failed) {
|
|
197
286
|
console.error("[ViteMCP] \u2717 TypeScript compilation failed");
|
|
198
|
-
|
|
199
|
-
|
|
287
|
+
const diagnostics = formatCommandFailure(typeCheck);
|
|
288
|
+
if (diagnostics) {
|
|
289
|
+
console.error(diagnostics);
|
|
200
290
|
}
|
|
201
291
|
process.exit(1);
|
|
202
292
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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");
|
|
293
|
+
console.log("[ViteMCP] \u2713 TypeScript compilation successful");
|
|
294
|
+
const [structureCommand, ...structureArgs] = buildStructureCheckCommand(filePath);
|
|
295
|
+
const structureCheck = await _execa.execa.call(void 0, structureCommand, structureArgs, {
|
|
296
|
+
reject: false
|
|
297
|
+
});
|
|
298
|
+
if (structureCheck.failed) {
|
|
299
|
+
const reason = formatCommandFailure(structureCheck);
|
|
300
|
+
if (reason) {
|
|
301
|
+
console.error(reason);
|
|
302
|
+
} else {
|
|
303
|
+
console.error("[ViteMCP] \u2717 Server structure validation failed");
|
|
304
|
+
console.error(
|
|
305
|
+
"Make sure the file properly imports and uses ViteMCP"
|
|
306
|
+
);
|
|
307
|
+
}
|
|
223
308
|
process.exit(1);
|
|
224
309
|
}
|
|
225
310
|
console.log(
|
package/dist/bin/vitemcp.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/server/server/dist/bin/vitemcp.cjs","../../src/bin/vitemcp.ts","../../src/bin/devCommand.ts"],"names":["yargs"],"mappings":"AAAA;AACA;AACA;ACAA,8BAAsB;AACtB,uCAAuC;AACvC,wBAAuB;AACvB,4BAAqB;AACrB,4EAAkB;AAClB,wCAAwB;ADExB;AACA;AEqBO,IAAM,gBAAA,EAAkB,KAAA;AAWxB,IAAM,eAAA,EAAiB,CAAC,IAAA,EAAA,GAC7B,IAAA,CAAK,SAAA;AAAA,EACH;AAAA,IACE,UAAA,EAAY;AAAA,MACV,CAAC,eAAe,CAAA,EAAG;AAAA,QACjB,IAAA,EAAM,CAAC,KAAA,EAAO,IAAI,CAAA;AAAA,QAClB,OAAA,EAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA;AAeK,IAAM,gBAAA,EAAkB,CAC7B,OAAA,EAAA,GAC0B;AAC1B,EAAA,MAAM,EAAE,UAAA,EAAY,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,MAAA,EAAQ,MAAM,EAAA,EAAI,OAAA;AAE5D,EAAA,GAAA,CAAI,IAAA,EAAM;AACR,IAAA,GAAA,CAAI,CAAC,UAAA,EAAY;AACf,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,gBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,WAAA;AAAA,MACA,CAAA,EAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAEA,EAAA;AACE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;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A;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGD;AACC,EAAA;AACA,EAAA;AACCA,EAAAA;AACC,IAAA;AAEI,MAAA;AACA,MAAA;AACA,MAAA;AAGD,IAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACL,EAAA;AAEA,EAAA;AACE,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AAEA,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AAEA,MAAA;AAEA,MAAA;AAIA,MAAA;AACE,QAAA;AAAY,UAAA;AACH,UAAA;AACC,UAAA;AACA,QAAA;AAGV,QAAA;AACF,MAAA;AACE,QAAA;AAEA,QAAA;AACE,UAAA;AAA4B,QAAA;AAG9B,QAAA;AACF,MAAA;AAEA,MAAA;AACE,QAAA;AAAY,UAAA;AACH,UAAA;AACC,UAAA;AACA,QAAA;AACT;AAAA;AAAA;AAAA,qCAAA;AAIoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAA;AAQvC,MAAA;AACE,QAAA;AACA,QAAA;AAEA,QAAA;AACF,MAAA;AAEA,MAAA;AAAQ,QAAA;AAER,MAAA;AACF,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGI","file":"/home/runner/work/server/server/dist/bin/vitemcp.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { execa } from \"execa\";\nimport { mkdtemp, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { buildDevCommand, buildDevConfig } from \"./devCommand.js\";\n\nawait yargs(hideBin(process.argv))\n .scriptName(\"vitemcp\")\n .command(\n \"dev <file>\",\n \"Start a development server\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"args\", {\n describe:\n \"JSON arguments passed to the tool (requires --tool), e.g. '{\\\"a\\\":1}'\",\n type: \"string\",\n })\n\n .option(\"tool\", {\n alias: \"t\",\n describe:\n \"Call a tool non-interactively instead of launching the inspector\",\n type: \"string\",\n })\n\n .option(\"watch\", {\n alias: \"w\",\n default: false,\n describe: \"Watch for file changes and restart server\",\n type: \"boolean\",\n })\n\n .option(\"verbose\", {\n alias: \"v\",\n default: false,\n describe: \"Enable verbose logging\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n let configDir: string | undefined;\n\n try {\n if (argv.args !== undefined && !argv.tool) {\n console.error(\"[ViteMCP Error] --args requires --tool\");\n process.exitCode = 1;\n return;\n }\n\n if (argv.tool && argv.watch) {\n console.warn(\n \"[ViteMCP] --watch is ignored when calling a tool with --tool: the server runs for a single call.\",\n );\n }\n\n let configPath: string | undefined;\n\n if (argv.tool) {\n configDir = await mkdtemp(join(tmpdir(), \"vitemcp-dev-\"));\n configPath = join(configDir, \"mcp-cli.json\");\n await writeFile(configPath, buildDevConfig(argv.file), \"utf8\");\n }\n\n const [command, ...commandArgs] = buildDevCommand({\n configPath,\n file: argv.file,\n tool: argv.tool,\n toolArgs: argv.args,\n watch: argv.watch,\n });\n\n if (argv.verbose) {\n console.log(\n `[ViteMCP] Starting server: ${[command, ...commandArgs].join(\" \")}`,\n );\n console.log(`[ViteMCP] File: ${argv.file}`);\n console.log(\n `[ViteMCP] Watch mode: ${argv.watch ? \"enabled\" : \"disabled\"}`,\n );\n\n if (argv.tool) {\n console.log(`[ViteMCP] Tool: ${argv.tool}`);\n }\n }\n\n await execa(command, commandArgs, {\n stderr: \"inherit\",\n stdin: \"inherit\",\n stdout: \"inherit\",\n });\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to start development server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n if (argv.verbose && error instanceof Error && error.stack) {\n console.error(\"[ViteMCP Debug] Stack trace:\", error.stack);\n }\n\n // Not process.exit(): that would skip the `finally` block below and\n // leak the temporary config directory on every failed tool call.\n process.exitCode = 1;\n } finally {\n if (configDir) {\n await rm(configDir, { force: true, recursive: true });\n }\n }\n },\n )\n\n .command(\n \"inspect <file>\",\n \"Inspect a server file\",\n (yargs) => {\n return yargs.positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n });\n },\n\n async (argv) => {\n try {\n await execa({\n stderr: \"inherit\",\n stdout: \"inherit\",\n })`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to inspect server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .command(\n \"validate <file>\",\n \"Validate a ViteMCP server file for syntax and basic structure\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"strict\", {\n alias: \"s\",\n default: false,\n describe: \"Enable strict validation (type checking)\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n try {\n const { existsSync } = await import(\"fs\");\n const { resolve } = await import(\"path\");\n const filePath = resolve(argv.file);\n\n if (!existsSync(filePath)) {\n console.error(`[ViteMCP Error] File not found: ${filePath}`);\n process.exit(1);\n }\n\n console.log(`[ViteMCP] Validating server file: ${filePath}`);\n\n const command = argv.strict\n ? `npx tsc --noEmit --strict ${filePath}`\n : `npx tsc --noEmit ${filePath}`;\n\n try {\n await execa({\n shell: true,\n stderr: \"pipe\",\n stdout: \"pipe\",\n })`${command}`;\n\n console.log(\"[ViteMCP] ✓ TypeScript compilation successful\");\n } catch (tsError) {\n console.error(\"[ViteMCP] ✗ TypeScript compilation failed\");\n\n if (tsError instanceof Error && \"stderr\" in tsError) {\n console.error(tsError.stderr);\n }\n\n process.exit(1);\n }\n\n try {\n await execa({\n shell: true,\n stderr: \"pipe\",\n stdout: \"pipe\",\n })`node -e \"\n (async () => {\n try {\n const { ViteMCP } = await import('@vitemcp/server');\n await import('file://${filePath}');\n console.log('[ViteMCP] ✓ Server structure validation passed');\n } catch (error) {\n console.error('[ViteMCP] ✗ Server structure validation failed:', error.message);\n process.exit(1);\n }\n })();\n \"`;\n } catch {\n console.error(\"[ViteMCP] ✗ Server structure validation failed\");\n console.error(\"Make sure the file properly imports and uses ViteMCP\");\n\n process.exit(1);\n }\n\n console.log(\n \"[ViteMCP] ✓ All validations passed! Server file looks good.\",\n );\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Validation failed:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .help()\n .parseAsync();\n","export type DevCommandOptions = {\n /**\n * Path to a temporary mcp-cli config file that registers the dev server.\n * Only used in non-interactive mode (when `tool` is set).\n */\n configPath?: string;\n /**\n * Path to the server file to run.\n */\n file: string;\n /**\n * Name of the tool to call non-interactively. When omitted, the dev\n * command launches the interactive mcp-cli inspector instead.\n */\n tool?: string;\n /**\n * JSON string of arguments forwarded to the tool via mcp-cli `--args`.\n * Only used in non-interactive mode.\n */\n toolArgs?: string;\n /**\n * Watch the file for changes and restart the server. Only used in\n * interactive mode; a non-interactive call runs the server once.\n */\n watch?: boolean;\n};\n\n/**\n * The server name registered in the generated mcp-cli config. mcp-cli\n * addresses non-interactive targets as `<server-name>:<tool>`.\n */\nexport const DEV_SERVER_NAME = \"dev\";\n\n/**\n * Build the JSON config that registers the dev server with mcp-cli so it can\n * be invoked non-interactively. mcp-cli's non-interactive mode resolves the\n * server by name from a config file's `mcpServers` map, so an inline command\n * cannot be passed directly alongside `call-tool`.\n *\n * The server is never started in watch mode here: a non-interactive call\n * connects, calls one tool, and exits, so there is nothing to restart into.\n */\nexport const buildDevConfig = (file: string): string =>\n JSON.stringify(\n {\n mcpServers: {\n [DEV_SERVER_NAME]: {\n args: [\"tsx\", file],\n command: \"npx\",\n },\n },\n },\n null,\n 2,\n );\n\n/**\n * Build the argv that the dev command runs.\n *\n * This is an argv array rather than a shell string so that nothing has to be\n * quoted: file paths, tool names and JSON `--args` are passed to the child\n * process verbatim. Quoting through a shell would be wrong on Windows, where\n * cmd.exe treats single quotes as literal characters rather than as quoting.\n *\n * - Without `tool`: launches the interactive @wong2/mcp-cli inspector\n * against an inline `npx tsx <file>` server (existing behaviour).\n * - With `tool`: runs @wong2/mcp-cli in non-interactive mode against a\n * generated config file, calling the named tool and forwarding `--args`.\n */\nexport const buildDevCommand = (\n options: DevCommandOptions,\n): [string, ...string[]] => {\n const { configPath, file, tool, toolArgs, watch = false } = options;\n\n if (tool) {\n if (!configPath) {\n throw new Error(\n \"configPath is required when calling a tool non-interactively\",\n );\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"-c\",\n configPath,\n \"call-tool\",\n `${DEV_SERVER_NAME}:${tool}`,\n ...(toolArgs === undefined ? [] : [\"--args\", toolArgs]),\n ];\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"npx\",\n \"tsx\",\n ...(watch ? [\"--watch\"] : []),\n file,\n ];\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/server/server/dist/bin/vitemcp.cjs","../../src/bin/vitemcp.ts","../../src/bin/devCommand.ts","../../src/bin/validateCommand.ts"],"names":["yargs"],"mappings":"AAAA;AACA;AACA;ACAA,8BAAsB;AACtB,uCAAuC;AACvC,wBAAuB;AACvB,4BAAqB;AACrB,4EAAkB;AAClB,wCAAwB;ADExB;AACA;AEqBO,IAAM,gBAAA,EAAkB,KAAA;AAWxB,IAAM,eAAA,EAAiB,CAAC,IAAA,EAAA,GAC7B,IAAA,CAAK,SAAA;AAAA,EACH;AAAA,IACE,UAAA,EAAY;AAAA,MACV,CAAC,eAAe,CAAA,EAAG;AAAA,QACjB,IAAA,EAAM,CAAC,KAAA,EAAO,IAAI,CAAA;AAAA,QAClB,OAAA,EAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA;AAeK,IAAM,gB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EA,EAAA;AACE,IAAA;AACE,MAAA;AAAY,QAAA;AACF,QAAA;AAET,MAAA;AACH,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGD;AACC,EAAA;AACA,EAAA;AACCA,EAAAA;AACC,IAAA;AAEI,MAAA;AACA,MAAA;AACA,MAAA;AAGD,IAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACL,EAAA;AAEA,EAAA;AACE,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AAEA,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AAEA,MAAA;AAEA,MAAA;AAEA,MAAA;AACE,QAAA;AAEA,QAAA;AAEA,QAAA;AACE,UAAA;AAAyB,QAAA;AAG3B,QAAA;AACF,MAAA;AAEA,MAAA;AAEA,MAAA;AAEA,MAAA;AAAoE,QAAA;AAEnE,MAAA;AAED,MAAA;AAIE,QAAA;AAEA,QAAA;AACE,UAAA;AAAoB,QAAA;AAEpB,UAAA;AACA,UAAA;AAAQ,YAAA;AACN,UAAA;AACF,QAAA;AAGF,QAAA;AACF,MAAA;AAEA,MAAA;AAAQ,QAAA;AAER,MAAA;AACF,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGI","file":"/home/runner/work/server/server/dist/bin/vitemcp.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { execa } from \"execa\";\nimport { mkdtemp, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { buildDevCommand, buildDevConfig } from \"./devCommand.js\";\nimport {\n buildStructureCheckCommand,\n formatCommandFailure,\n runTypeCheck,\n} from \"./validateCommand.js\";\n\nawait yargs(hideBin(process.argv))\n .scriptName(\"vitemcp\")\n .command(\n \"dev <file>\",\n \"Start a development server\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"args\", {\n describe:\n \"JSON arguments passed to the tool (requires --tool), e.g. '{\\\"a\\\":1}'\",\n type: \"string\",\n })\n\n .option(\"tool\", {\n alias: \"t\",\n describe:\n \"Call a tool non-interactively instead of launching the inspector\",\n type: \"string\",\n })\n\n .option(\"watch\", {\n alias: \"w\",\n default: false,\n describe: \"Watch for file changes and restart server\",\n type: \"boolean\",\n })\n\n .option(\"verbose\", {\n alias: \"v\",\n default: false,\n describe: \"Enable verbose logging\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n let configDir: string | undefined;\n\n try {\n if (argv.args !== undefined && !argv.tool) {\n console.error(\"[ViteMCP Error] --args requires --tool\");\n process.exitCode = 1;\n return;\n }\n\n if (argv.tool && argv.watch) {\n console.warn(\n \"[ViteMCP] --watch is ignored when calling a tool with --tool: the server runs for a single call.\",\n );\n }\n\n let configPath: string | undefined;\n\n if (argv.tool) {\n configDir = await mkdtemp(join(tmpdir(), \"vitemcp-dev-\"));\n configPath = join(configDir, \"mcp-cli.json\");\n await writeFile(configPath, buildDevConfig(argv.file), \"utf8\");\n }\n\n const [command, ...commandArgs] = buildDevCommand({\n configPath,\n file: argv.file,\n tool: argv.tool,\n toolArgs: argv.args,\n watch: argv.watch,\n });\n\n if (argv.verbose) {\n console.log(\n `[ViteMCP] Starting server: ${[command, ...commandArgs].join(\" \")}`,\n );\n console.log(`[ViteMCP] File: ${argv.file}`);\n console.log(\n `[ViteMCP] Watch mode: ${argv.watch ? \"enabled\" : \"disabled\"}`,\n );\n\n if (argv.tool) {\n console.log(`[ViteMCP] Tool: ${argv.tool}`);\n }\n }\n\n await execa(command, commandArgs, {\n stderr: \"inherit\",\n stdin: \"inherit\",\n stdout: \"inherit\",\n });\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to start development server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n if (argv.verbose && error instanceof Error && error.stack) {\n console.error(\"[ViteMCP Debug] Stack trace:\", error.stack);\n }\n\n // Not process.exit(): that would skip the `finally` block below and\n // leak the temporary config directory on every failed tool call.\n process.exitCode = 1;\n } finally {\n if (configDir) {\n await rm(configDir, { force: true, recursive: true });\n }\n }\n },\n )\n\n .command(\n \"inspect <file>\",\n \"Inspect a server file\",\n (yargs) => {\n return yargs.positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n });\n },\n\n async (argv) => {\n try {\n await execa({\n stderr: \"inherit\",\n stdout: \"inherit\",\n })`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to inspect server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .command(\n \"validate <file>\",\n \"Validate a ViteMCP server file for syntax and basic structure\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"strict\", {\n alias: \"s\",\n default: false,\n describe: \"Enable strict validation (type checking)\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n try {\n const { existsSync } = await import(\"fs\");\n const { resolve } = await import(\"path\");\n const filePath = resolve(argv.file);\n\n if (!existsSync(filePath)) {\n console.error(`[ViteMCP Error] File not found: ${filePath}`);\n process.exit(1);\n }\n\n console.log(`[ViteMCP] Validating server file: ${filePath}`);\n\n const typeCheck = await runTypeCheck(filePath, argv.strict);\n\n if (typeCheck.failed) {\n console.error(\"[ViteMCP] ✗ TypeScript compilation failed\");\n\n const diagnostics = formatCommandFailure(typeCheck);\n\n if (diagnostics) {\n console.error(diagnostics);\n }\n\n process.exit(1);\n }\n\n console.log(\"[ViteMCP] ✓ TypeScript compilation successful\");\n\n const [structureCommand, ...structureArgs] =\n buildStructureCheckCommand(filePath);\n const structureCheck = await execa(structureCommand, structureArgs, {\n reject: false,\n });\n\n if (structureCheck.failed) {\n // The child explains the failure on stderr, which execa captures.\n // Without replaying it the user only ever sees the generic hint, even\n // when their server file has an error they could act on.\n const reason = formatCommandFailure(structureCheck);\n\n if (reason) {\n console.error(reason);\n } else {\n console.error(\"[ViteMCP] ✗ Server structure validation failed\");\n console.error(\n \"Make sure the file properly imports and uses ViteMCP\",\n );\n }\n\n process.exit(1);\n }\n\n console.log(\n \"[ViteMCP] ✓ All validations passed! Server file looks good.\",\n );\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Validation failed:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .help()\n .parseAsync();\n","export type DevCommandOptions = {\n /**\n * Path to a temporary mcp-cli config file that registers the dev server.\n * Only used in non-interactive mode (when `tool` is set).\n */\n configPath?: string;\n /**\n * Path to the server file to run.\n */\n file: string;\n /**\n * Name of the tool to call non-interactively. When omitted, the dev\n * command launches the interactive mcp-cli inspector instead.\n */\n tool?: string;\n /**\n * JSON string of arguments forwarded to the tool via mcp-cli `--args`.\n * Only used in non-interactive mode.\n */\n toolArgs?: string;\n /**\n * Watch the file for changes and restart the server. Only used in\n * interactive mode; a non-interactive call runs the server once.\n */\n watch?: boolean;\n};\n\n/**\n * The server name registered in the generated mcp-cli config. mcp-cli\n * addresses non-interactive targets as `<server-name>:<tool>`.\n */\nexport const DEV_SERVER_NAME = \"dev\";\n\n/**\n * Build the JSON config that registers the dev server with mcp-cli so it can\n * be invoked non-interactively. mcp-cli's non-interactive mode resolves the\n * server by name from a config file's `mcpServers` map, so an inline command\n * cannot be passed directly alongside `call-tool`.\n *\n * The server is never started in watch mode here: a non-interactive call\n * connects, calls one tool, and exits, so there is nothing to restart into.\n */\nexport const buildDevConfig = (file: string): string =>\n JSON.stringify(\n {\n mcpServers: {\n [DEV_SERVER_NAME]: {\n args: [\"tsx\", file],\n command: \"npx\",\n },\n },\n },\n null,\n 2,\n );\n\n/**\n * Build the argv that the dev command runs.\n *\n * This is an argv array rather than a shell string so that nothing has to be\n * quoted: file paths, tool names and JSON `--args` are passed to the child\n * process verbatim. Quoting through a shell would be wrong on Windows, where\n * cmd.exe treats single quotes as literal characters rather than as quoting.\n *\n * - Without `tool`: launches the interactive @wong2/mcp-cli inspector\n * against an inline `npx tsx <file>` server (existing behaviour).\n * - With `tool`: runs @wong2/mcp-cli in non-interactive mode against a\n * generated config file, calling the named tool and forwarding `--args`.\n */\nexport const buildDevCommand = (\n options: DevCommandOptions,\n): [string, ...string[]] => {\n const { configPath, file, tool, toolArgs, watch = false } = options;\n\n if (tool) {\n if (!configPath) {\n throw new Error(\n \"configPath is required when calling a tool non-interactively\",\n );\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"-c\",\n configPath,\n \"call-tool\",\n `${DEV_SERVER_NAME}:${tool}`,\n ...(toolArgs === undefined ? [] : [\"--args\", toolArgs]),\n ];\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"npx\",\n \"tsx\",\n ...(watch ? [\"--watch\"] : []),\n file,\n ];\n};\n","import { randomUUID } from \"crypto\";\nimport { execa } from \"execa\";\nimport { existsSync } from \"fs\";\nimport { rm, writeFile } from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * The script `vitemcp validate` runs to check that a server file loads.\n *\n * The file arrives as `process.argv[1]` rather than being spliced into this\n * source. Spliced into a string literal, a Windows path loses its backslashes\n * to the child's own parser (`C:\\Users\\dev\\server.ts` reaches the import as\n * `C:Usersdevserver.ts`), and a quote or `#` in any path breaks the import —\n * each reported to the user as a problem with their file.\n *\n * It exits as soon as the import settles, once its verdict is flushed. A\n * server file normally starts its transport on load, which would otherwise\n * keep this process, and the command waiting on it, alive forever.\n */\nexport const STRUCTURE_CHECK_SCRIPT = `\n(async () => {\n let failure;\n\n try {\n await import(\"@vitemcp/server\");\n await import(process.argv[1]);\n } catch (error) {\n failure = error instanceof Error ? error.message : String(error);\n }\n\n if (failure === undefined) {\n process.stdout.write(\n \"[ViteMCP] ✓ Server structure validation passed\\\\n\",\n () => process.exit(0),\n );\n } else {\n process.stderr.write(\n \"[ViteMCP] ✗ Server structure validation failed: \" + failure + \"\\\\n\",\n () => process.exit(1),\n );\n }\n})();\n`;\n\n/**\n * Compiler options for a file with no `tsconfig.json` above it. The compiler's\n * own defaults target ES5, which rejects top-level await and the `#private`\n * members in `@vitemcp/server`'s declarations, so no server file could pass.\n */\nconst STANDALONE_COMPILER_OPTIONS = {\n allowImportingTsExtensions: true,\n module: \"esnext\",\n moduleResolution: \"bundler\",\n skipLibCheck: true,\n target: \"es2022\",\n};\n\n/**\n * What the throwaway config overrides in the project's own. `composite`\n * demands that every file the server imports be listed as a root, and only the\n * server file is; `incremental` writes a `.tsbuildinfo` named after the\n * throwaway config into the project.\n */\nconst PROJECT_OVERRIDES = { composite: false, incremental: false };\n\n/**\n * Build the argv for the structure check.\n *\n * An argv array rather than a shell string, as in `buildDevCommand`, so nothing\n * has to be quoted. The file is converted to a `file:` URL here, so the child\n * imports it as given and never has to build the URL itself; and the child is\n * the Node binary running this CLI, so no PATH lookup is involved.\n */\nexport const buildStructureCheckCommand = (\n file: string,\n execPath: string = process.execPath,\n): [string, ...string[]] => [\n execPath,\n \"-e\",\n STRUCTURE_CHECK_SCRIPT,\n pathToFileURL(file).href,\n];\n\n/**\n * Build the argv for the type check. An argv array for the same reason as the\n * structure check: through a shell, a path containing a space reaches `tsc` as\n * several root files.\n */\nexport const buildTypeCheckCommand = (\n config: string,\n strict = false,\n): [string, ...string[]] => [\n \"npx\",\n \"tsc\",\n \"--noEmit\",\n \"--project\",\n config,\n ...(strict ? [\"--strict\"] : []),\n];\n\n/**\n * Build the throwaway config that type-checks one file.\n *\n * `tsc` ignores `tsconfig.json` whenever a file is named on its command line\n * and falls back to defaults no server file passes, so the file is named in a\n * config that extends the project's own instead. `include: []` keeps an\n * inherited `include` from pulling the rest of the project in.\n */\nexport const buildTypeCheckConfig = (file: string, tsconfig?: string): string =>\n JSON.stringify(\n tsconfig\n ? {\n compilerOptions: PROJECT_OVERRIDES,\n extends: tsconfig,\n files: [file],\n include: [],\n }\n : {\n compilerOptions: STANDALONE_COMPILER_OPTIONS,\n files: [file],\n include: [],\n },\n null,\n 2,\n );\n\n/**\n * The `tsconfig.json` that governs a file in `dir`: the nearest one at or above\n * it, which is also the one an editor checks the file against.\n */\nexport const findTsconfig = (dir: string): string | undefined => {\n for (let current = dir; ; current = dirname(current)) {\n const candidate = join(current, \"tsconfig.json\");\n\n if (existsSync(candidate)) {\n return candidate;\n }\n\n if (dirname(current) === current) {\n return undefined;\n }\n }\n};\n\n/**\n * The output of a failed check, for replaying to the user.\n *\n * `tsc` writes its diagnostics to stdout, and only a failure to launch it\n * reaches stderr, so reading stderr alone reported every real type error with\n * no detail. The structure check explains itself on stderr.\n */\nexport const formatCommandFailure = (result: {\n stderr?: unknown;\n stdout?: unknown;\n}): string =>\n [result.stderr, result.stdout]\n .map((output) => (typeof output === \"string\" ? output.trim() : \"\"))\n .filter(Boolean)\n .join(\"\\n\");\n\n/**\n * Type-check `file` under the compiler options of the project it belongs to.\n *\n * The throwaway config is written beside the project's own rather than to the\n * OS temp directory, because the compiler resolves type packages — the `types`\n * option and every visible `@types` package — from the config's directory. It\n * is removed before this returns, so a caller may exit straight away.\n */\nexport const runTypeCheck = async (file: string, strict = false) => {\n const tsconfig = findTsconfig(dirname(file));\n const config = join(\n dirname(tsconfig ?? file),\n `tsconfig.vitemcp-validate-${randomUUID()}.json`,\n );\n\n await writeFile(config, buildTypeCheckConfig(file, tsconfig), {\n flag: \"wx\",\n });\n\n try {\n const [command, ...args] = buildTypeCheckCommand(config, strict);\n\n return await execa(command, args, { reject: false });\n } finally {\n await rm(config, { force: true });\n }\n};\n"]}
|