@vitemcp/server 1.9.17 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -1
- package/dist/ViteMCP.cjs +4 -4
- package/dist/ViteMCP.d.cts +18 -1
- package/dist/ViteMCP.d.ts +18 -1
- package/dist/ViteMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-4BX2CT5Z.js → chunk-AOZIQIXA.js} +5 -1
- package/dist/{chunk-4BX2CT5Z.js.map → chunk-AOZIQIXA.js.map} +1 -1
- package/dist/{chunk-JMDI672G.js → chunk-BLXUZUZ4.js} +16 -1
- package/dist/chunk-BLXUZUZ4.js.map +1 -0
- package/dist/{chunk-B3LLXB6O.js → chunk-BMW6BWBO.js} +32 -11
- package/dist/chunk-BMW6BWBO.js.map +1 -0
- package/dist/{chunk-TNT3APOK.cjs → chunk-CJLWQH7G.cjs} +37 -16
- package/dist/chunk-CJLWQH7G.cjs.map +1 -0
- package/dist/{chunk-QPVEGWOL.cjs → chunk-NZGRSB2D.cjs} +17 -2
- package/dist/chunk-NZGRSB2D.cjs.map +1 -0
- package/dist/{chunk-ZEYQBA72.cjs → chunk-R3JUTGZL.cjs} +5 -1
- package/dist/chunk-R3JUTGZL.cjs.map +1 -0
- package/dist/edge/index.cjs +23 -10
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +11 -0
- package/dist/edge/index.d.ts +11 -0
- package/dist/edge/index.js +19 -6
- package/dist/edge/index.js.map +1 -1
- package/dist/openapi/index.cjs +43 -43
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +33 -33
- package/dist/openapi/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-B3LLXB6O.js.map +0 -1
- package/dist/chunk-JMDI672G.js.map +0 -1
- package/dist/chunk-QPVEGWOL.cjs.map +0 -1
- package/dist/chunk-TNT3APOK.cjs.map +0 -1
- package/dist/chunk-ZEYQBA72.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -748,6 +748,35 @@ server.addTool({
|
|
|
748
748
|
});
|
|
749
749
|
```
|
|
750
750
|
|
|
751
|
+
#### Passing the caller's context
|
|
752
|
+
|
|
753
|
+
`embedded()` runs a loader outside any request, so by default its
|
|
754
|
+
`context.auth` is `undefined` and `canAccess` is not consulted. Pass the tool's
|
|
755
|
+
`context` to resolve the URI as `resources/read` would for that caller: the
|
|
756
|
+
loader receives that context, `auth` included, and a resource or template whose
|
|
757
|
+
`canAccess` refuses the caller is not found.
|
|
758
|
+
|
|
759
|
+
```js
|
|
760
|
+
server.addTool({
|
|
761
|
+
name: "get_my_profile",
|
|
762
|
+
description: "Retrieve the caller's own profile",
|
|
763
|
+
parameters: z.object({}),
|
|
764
|
+
execute: async (args, context) => {
|
|
765
|
+
return {
|
|
766
|
+
content: [
|
|
767
|
+
{
|
|
768
|
+
type: "resource",
|
|
769
|
+
resource: await server.embedded("user://me", context),
|
|
770
|
+
},
|
|
771
|
+
],
|
|
772
|
+
};
|
|
773
|
+
},
|
|
774
|
+
});
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Pass it whenever the URI comes from the tool's arguments, so the tool cannot
|
|
778
|
+
reach a resource its caller could not read directly.
|
|
779
|
+
|
|
751
780
|
### Prompts
|
|
752
781
|
|
|
753
782
|
[Prompts](https://modelcontextprotocol.io/docs/concepts/prompts) enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs. They provide a powerful way to standardize and share common LLM interactions.
|
|
@@ -1768,6 +1797,36 @@ const transport = new StreamableHTTPClientTransport(
|
|
|
1768
1797
|
await client.connect(transport);
|
|
1769
1798
|
```
|
|
1770
1799
|
|
|
1800
|
+
#### Request limits
|
|
1801
|
+
|
|
1802
|
+
Two limits bound what one request can make the server do:
|
|
1803
|
+
|
|
1804
|
+
- `httpStream.maxBodySize` caps the MCP endpoint's request body, in bytes
|
|
1805
|
+
(default: 1 MiB). A larger body is refused with a `400`, without being held
|
|
1806
|
+
in memory.
|
|
1807
|
+
- `maxToolInputElements` caps how many array elements and object members,
|
|
1808
|
+
counted together, one `tools/call` may carry in its arguments (default:
|
|
1809
|
+
10,000). A call over it gets an error result before any schema validates it.
|
|
1810
|
+
The body cap alone does not bound what validation costs: half a million
|
|
1811
|
+
invalid elements fit in 1 MiB.
|
|
1812
|
+
|
|
1813
|
+
```ts
|
|
1814
|
+
const server = new ViteMCP({
|
|
1815
|
+
name: "Bulk importer",
|
|
1816
|
+
version: "1.0.0",
|
|
1817
|
+
// Its tools take arrays of up to 50,000 numbers.
|
|
1818
|
+
maxToolInputElements: 60_000,
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
server.start({
|
|
1822
|
+
transportType: "httpStream",
|
|
1823
|
+
httpStream: { port: 8080, maxBodySize: 4 * 1024 * 1024 },
|
|
1824
|
+
});
|
|
1825
|
+
```
|
|
1826
|
+
|
|
1827
|
+
`maxToolInputElements` applies on every transport, stdio included. Pass
|
|
1828
|
+
`Infinity` to lift it.
|
|
1829
|
+
|
|
1771
1830
|
#### HTTPS Support
|
|
1772
1831
|
|
|
1773
1832
|
Pass SSL certificates to terminate TLS directly:
|
|
@@ -2030,7 +2089,7 @@ When running on edge runtimes:
|
|
|
2030
2089
|
- **No filesystem access**: Use fetch APIs for external data
|
|
2031
2090
|
- **V8 Isolates**: Fast cold starts and efficient resource usage
|
|
2032
2091
|
- **Global deployment**: Automatic distribution to edge locations
|
|
2033
|
-
- **Request size**: The MCP endpoint refuses a body over `maxBodySize` (1 MiB by default, as on Node). Routes added through `getApp()` are not covered
|
|
2092
|
+
- **Request size**: The MCP endpoint refuses a body over `maxBodySize` (1 MiB by default, as on Node), and a tool call whose arguments hold more than `maxToolInputElements` elements (10,000 by default, as on Node). Routes added through `getApp()` are not covered
|
|
2034
2093
|
- **Schema libraries**: Zod, ArkType and Valibot describe a tool as they do on Node. Any other library that carries no JSON Schema of its own is not converted here: a tool written in one is left out and reported through the logger
|
|
2035
2094
|
|
|
2036
2095
|
#### Custom Routes on Edge
|
package/dist/ViteMCP.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkCJLWQH7Gcjs = require('./chunk-CJLWQH7G.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -25,8 +25,8 @@ var _chunkTNT3APOKcjs = require('./chunk-TNT3APOK.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
29
|
-
require('./chunk-
|
|
28
|
+
var _chunkR3JUTGZLcjs = require('./chunk-R3JUTGZL.cjs');
|
|
29
|
+
require('./chunk-NZGRSB2D.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
@@ -52,5 +52,5 @@ require('./chunk-QPVEGWOL.cjs');
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
exports.AuthProvider =
|
|
55
|
+
exports.AuthProvider = _chunkR3JUTGZLcjs.AuthProvider; exports.AzureProvider = _chunkR3JUTGZLcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkCJLWQH7Gcjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkR3JUTGZLcjs.GitHubProvider; exports.GoogleProvider = _chunkR3JUTGZLcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkCJLWQH7Gcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkR3JUTGZLcjs.OAuthProvider; exports.OAuthProxy = _chunkR3JUTGZLcjs.OAuthProxy; exports.OAuthProxyError = _chunkR3JUTGZLcjs.OAuthProxyError; exports.ServerState = _chunkCJLWQH7Gcjs.ServerState; exports.UnexpectedStateError = _chunkCJLWQH7Gcjs.UnexpectedStateError; exports.UserError = _chunkCJLWQH7Gcjs.UserError; exports.ViteMCP = _chunkCJLWQH7Gcjs.ViteMCP; exports.ViteMCPError = _chunkCJLWQH7Gcjs.ViteMCPError; exports.audioContent = _chunkCJLWQH7Gcjs.audioContent; exports.delay = _chunkCJLWQH7Gcjs.delay; exports.getAuthSession = _chunkR3JUTGZLcjs.getAuthSession; exports.imageContent = _chunkCJLWQH7Gcjs.imageContent; exports.jsonSchemaAdapter = _chunkCJLWQH7Gcjs.jsonSchemaAdapter; exports.requireAll = _chunkR3JUTGZLcjs.requireAll; exports.requireAny = _chunkR3JUTGZLcjs.requireAny; exports.requireAuth = _chunkR3JUTGZLcjs.requireAuth; exports.requireRole = _chunkR3JUTGZLcjs.requireRole; exports.requireScopes = _chunkR3JUTGZLcjs.requireScopes;
|
|
56
56
|
//# sourceMappingURL=ViteMCP.cjs.map
|
package/dist/ViteMCP.d.cts
CHANGED
|
@@ -364,6 +364,17 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
364
364
|
icons?: Icon[];
|
|
365
365
|
instructions?: string;
|
|
366
366
|
logger?: Logger;
|
|
367
|
+
/**
|
|
368
|
+
* Most array elements and object members, counted together, that one
|
|
369
|
+
* `tools/call` may carry in its arguments (default: 10,000). A call over it
|
|
370
|
+
* gets an error result before any schema sees it. Pass `Infinity` to lift
|
|
371
|
+
* the limit.
|
|
372
|
+
*
|
|
373
|
+
* `httpStream.maxBodySize` alone does not bound the cost of validating a
|
|
374
|
+
* call: half a million invalid elements fit in 1 MiB, and Zod kept half a
|
|
375
|
+
* gigabyte of issues reporting them.
|
|
376
|
+
*/
|
|
377
|
+
maxToolInputElements?: number;
|
|
367
378
|
name: string;
|
|
368
379
|
oauth?: {
|
|
369
380
|
authorizationServer?: Record<string, unknown>;
|
|
@@ -457,8 +468,14 @@ declare class ViteMCP<T extends ViteMCPAuth = ViteMCPAuth> {
|
|
|
457
468
|
/**
|
|
458
469
|
* Resolves a resource (or resource template) URI to an embeddable resource
|
|
459
470
|
* body, for returning inline from a tool.
|
|
471
|
+
*
|
|
472
|
+
* Pass the calling tool's `context` to resolve the URI as `resources/read`
|
|
473
|
+
* would for that caller: the loader receives that context, `auth` included,
|
|
474
|
+
* and a resource or template whose `canAccess` refuses the caller is not
|
|
475
|
+
* found. Without one, the loader runs outside any request, with `auth`
|
|
476
|
+
* undefined, and `canAccess` is not consulted.
|
|
460
477
|
*/
|
|
461
|
-
embedded(uri: string): Promise<LoadedResource>;
|
|
478
|
+
embedded(uri: string, context?: LoadContext<T>): Promise<LoadedResource>;
|
|
462
479
|
/** The Hono app serving the HTTP transport, for mounting custom routes. */
|
|
463
480
|
getApp(): Hono;
|
|
464
481
|
/**
|
package/dist/ViteMCP.d.ts
CHANGED
|
@@ -364,6 +364,17 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
364
364
|
icons?: Icon[];
|
|
365
365
|
instructions?: string;
|
|
366
366
|
logger?: Logger;
|
|
367
|
+
/**
|
|
368
|
+
* Most array elements and object members, counted together, that one
|
|
369
|
+
* `tools/call` may carry in its arguments (default: 10,000). A call over it
|
|
370
|
+
* gets an error result before any schema sees it. Pass `Infinity` to lift
|
|
371
|
+
* the limit.
|
|
372
|
+
*
|
|
373
|
+
* `httpStream.maxBodySize` alone does not bound the cost of validating a
|
|
374
|
+
* call: half a million invalid elements fit in 1 MiB, and Zod kept half a
|
|
375
|
+
* gigabyte of issues reporting them.
|
|
376
|
+
*/
|
|
377
|
+
maxToolInputElements?: number;
|
|
367
378
|
name: string;
|
|
368
379
|
oauth?: {
|
|
369
380
|
authorizationServer?: Record<string, unknown>;
|
|
@@ -457,8 +468,14 @@ declare class ViteMCP<T extends ViteMCPAuth = ViteMCPAuth> {
|
|
|
457
468
|
/**
|
|
458
469
|
* Resolves a resource (or resource template) URI to an embeddable resource
|
|
459
470
|
* body, for returning inline from a tool.
|
|
471
|
+
*
|
|
472
|
+
* Pass the calling tool's `context` to resolve the URI as `resources/read`
|
|
473
|
+
* would for that caller: the loader receives that context, `auth` included,
|
|
474
|
+
* and a resource or template whose `canAccess` refuses the caller is not
|
|
475
|
+
* found. Without one, the loader runs outside any request, with `auth`
|
|
476
|
+
* undefined, and `canAccess` is not consulted.
|
|
460
477
|
*/
|
|
461
|
-
embedded(uri: string): Promise<LoadedResource>;
|
|
478
|
+
embedded(uri: string, context?: LoadContext<T>): Promise<LoadedResource>;
|
|
462
479
|
/** The Hono app serving the HTTP transport, for mounting custom routes. */
|
|
463
480
|
getApp(): Hono;
|
|
464
481
|
/**
|
package/dist/ViteMCP.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
delay,
|
|
11
11
|
imageContent,
|
|
12
12
|
jsonSchemaAdapter
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BMW6BWBO.js";
|
|
14
14
|
import {
|
|
15
15
|
AuthProvider,
|
|
16
16
|
AzureProvider,
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
requireAuth,
|
|
26
26
|
requireRole,
|
|
27
27
|
requireScopes
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-AOZIQIXA.js";
|
|
29
|
+
import "./chunk-BLXUZUZ4.js";
|
|
30
30
|
export {
|
|
31
31
|
AuthProvider,
|
|
32
32
|
AzureProvider,
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkR3JUTGZLcjs = require('../chunk-R3JUTGZL.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkZEYQBA72cjs = require('../chunk-ZEYQBA72.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkR3JUTGZLcjs.AuthProvider; exports.AzureProvider = _chunkR3JUTGZLcjs.AzureProvider; exports.ConsentManager = _chunkR3JUTGZLcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkR3JUTGZLcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkR3JUTGZLcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkR3JUTGZLcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkR3JUTGZLcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkR3JUTGZLcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkR3JUTGZLcjs.DiskStore; exports.EncryptedTokenStorage = _chunkR3JUTGZLcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkR3JUTGZLcjs.GitHubProvider; exports.GoogleProvider = _chunkR3JUTGZLcjs.GoogleProvider; exports.JWKSVerifier = _chunkR3JUTGZLcjs.JWKSVerifier; exports.JWTIssuer = _chunkR3JUTGZLcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkR3JUTGZLcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkR3JUTGZLcjs.OAuthProvider; exports.OAuthProxy = _chunkR3JUTGZLcjs.OAuthProxy; exports.OAuthProxyError = _chunkR3JUTGZLcjs.OAuthProxyError; exports.PKCEUtils = _chunkR3JUTGZLcjs.PKCEUtils; exports.getAuthSession = _chunkR3JUTGZLcjs.getAuthSession; exports.requireAll = _chunkR3JUTGZLcjs.requireAll; exports.requireAny = _chunkR3JUTGZLcjs.requireAny; exports.requireAuth = _chunkR3JUTGZLcjs.requireAuth; exports.requireRole = _chunkR3JUTGZLcjs.requireRole; exports.requireScopes = _chunkR3JUTGZLcjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.js
CHANGED
|
@@ -1254,6 +1254,7 @@ function loopbackRedirectMatches(declared, requested) {
|
|
|
1254
1254
|
|
|
1255
1255
|
// src/auth/utils/pkce.ts
|
|
1256
1256
|
import { createHash as createHash2, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
1257
|
+
var CODE_VERIFIER = /^[A-Za-z0-9._~-]{43,128}$/;
|
|
1257
1258
|
var PKCEUtils = class _PKCEUtils {
|
|
1258
1259
|
/**
|
|
1259
1260
|
* Generate a code challenge from a verifier
|
|
@@ -1309,6 +1310,9 @@ var PKCEUtils = class _PKCEUtils {
|
|
|
1309
1310
|
if (!verifier || !challenge) {
|
|
1310
1311
|
return false;
|
|
1311
1312
|
}
|
|
1313
|
+
if (!CODE_VERIFIER.test(verifier)) {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1312
1316
|
if (method === "plain") {
|
|
1313
1317
|
return equalsConstantTime(verifier, challenge);
|
|
1314
1318
|
}
|
|
@@ -3875,4 +3879,4 @@ export {
|
|
|
3875
3879
|
DiskStore,
|
|
3876
3880
|
JWKSVerifier
|
|
3877
3881
|
};
|
|
3878
|
-
//# sourceMappingURL=chunk-
|
|
3882
|
+
//# sourceMappingURL=chunk-AOZIQIXA.js.map
|