@vitemcp/server 1.3.1 → 1.5.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 +55 -0
- package/dist/ViteMCP.cjs +41 -4
- package/dist/ViteMCP.cjs.map +1 -1
- package/dist/ViteMCP.d.cts +36 -4
- package/dist/ViteMCP.d.ts +36 -4
- package/dist/ViteMCP.js +41 -4
- package/dist/ViteMCP.js.map +1 -1
- package/package.json +1 -1
package/dist/ViteMCP.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CacheScope, InputRequest, InputRequiredResult, ToolAnnotations, McpServer } from '@modelcontextprotocol/server';
|
|
2
|
-
export { CacheScope, InputRequest, InputRequiredResult, ToolAnnotations } from '@modelcontextprotocol/server';
|
|
1
|
+
import { CacheScope, InputRequest, InputRequiredResult, Icon, ToolAnnotations, McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
export { CacheScope, Icon, InputRequest, InputRequiredResult, ToolAnnotations } from '@modelcontextprotocol/server';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
@@ -321,12 +321,26 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
321
321
|
allowAnonymous?: boolean;
|
|
322
322
|
auth?: AuthProvider<T extends OAuthSession ? T : OAuthSession>;
|
|
323
323
|
authenticate?: Authenticate<T>;
|
|
324
|
+
/**
|
|
325
|
+
* What this server is, for a human reading a client's server list.
|
|
326
|
+
*
|
|
327
|
+
* Distinct from `instructions`, which is addressed to the model and tells it
|
|
328
|
+
* how to use what this server exposes.
|
|
329
|
+
*/
|
|
330
|
+
description?: string;
|
|
324
331
|
health?: {
|
|
325
332
|
enabled?: boolean;
|
|
326
333
|
message?: string;
|
|
327
334
|
path?: string;
|
|
328
335
|
status?: number;
|
|
329
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* Icons a client may show next to this server, most specific first.
|
|
339
|
+
*
|
|
340
|
+
* `src` is a URL the client fetches, so it must be reachable from wherever
|
|
341
|
+
* the client runs — not only from the server.
|
|
342
|
+
*/
|
|
343
|
+
icons?: Icon[];
|
|
330
344
|
instructions?: string;
|
|
331
345
|
logger?: Logger;
|
|
332
346
|
name: string;
|
|
@@ -336,7 +350,25 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
336
350
|
protectedResource?: Record<string, unknown>;
|
|
337
351
|
proxy?: OAuthProxy;
|
|
338
352
|
};
|
|
353
|
+
/** Display name, for clients that prefer one over the identifier `name`. */
|
|
354
|
+
title?: string;
|
|
339
355
|
version: `${number}.${number}.${number}`;
|
|
356
|
+
/** Homepage for this server, for clients that link to one. */
|
|
357
|
+
websiteUrl?: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* The structured payload on its own, without the content fallback.
|
|
361
|
+
*
|
|
362
|
+
* Returning this is how a tool states outright that an object is its structured
|
|
363
|
+
* result, for the cases where the shape alone cannot say so — a payload whose
|
|
364
|
+
* own `content` field is an array reads as a list of content blocks otherwise.
|
|
365
|
+
* ViteMCP writes the JSON text fallback, exactly as it does for a plain
|
|
366
|
+
* structured return.
|
|
367
|
+
*/
|
|
368
|
+
type StructuredResult<T = unknown> = {
|
|
369
|
+
_meta?: Record<string, unknown>;
|
|
370
|
+
isError?: boolean;
|
|
371
|
+
structuredContent: T;
|
|
340
372
|
};
|
|
341
373
|
type TextContent = {
|
|
342
374
|
text: string;
|
|
@@ -347,7 +379,7 @@ type Tool<T extends ViteMCPAuth, Params extends ToolParameters = ToolParameters,
|
|
|
347
379
|
annotations?: ToolAnnotations;
|
|
348
380
|
canAccess?: (auth: T | undefined) => boolean;
|
|
349
381
|
description?: string;
|
|
350
|
-
execute: (args: StandardSchemaV1.InferOutput<Params>, context: Context<T>) => Promise<AudioContent | ContentResult | ImageContent | InputRequiredResult | ResourceContent | ResourceLink | StandardSchemaV1.InferOutput<OutputParams> | string | TextContent | void>;
|
|
382
|
+
execute: (args: StandardSchemaV1.InferOutput<Params>, context: Context<T>) => Promise<AudioContent | ContentResult | ImageContent | InputRequiredResult | ResourceContent | ResourceLink | StandardSchemaV1.InferOutput<OutputParams> | string | StructuredResult<StandardSchemaV1.InferOutput<OutputParams>> | TextContent | void>;
|
|
351
383
|
name: string;
|
|
352
384
|
outputSchema?: OutputParams;
|
|
353
385
|
parameters?: Params;
|
|
@@ -448,4 +480,4 @@ declare class ViteMCP<T extends ViteMCPAuth = ViteMCPAuth> {
|
|
|
448
480
|
stop(): Promise<void>;
|
|
449
481
|
}
|
|
450
482
|
|
|
451
|
-
export { type AudioContent, AuthProvider, type Authenticate, type CacheHint, type Completion, type Content, type ContentResult, type Context, DiscoveryDocumentCache, type ImageContent, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type LoadedResource, type Logger, MEDIA_FETCH_TIMEOUT_MS, type MediaSource, OAuthProxy, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceLink, type ResourceTemplate, type ResourceTemplateArgument, type SerializableValue, type ServerOptions, ServerState, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, ViteMCP, type ViteMCPAuth, ViteMCPError, audioContent, imageContent, jsonSchemaAdapter };
|
|
483
|
+
export { type AudioContent, AuthProvider, type Authenticate, type CacheHint, type Completion, type Content, type ContentResult, type Context, DiscoveryDocumentCache, type ImageContent, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type LoadedResource, type Logger, MEDIA_FETCH_TIMEOUT_MS, type MediaSource, OAuthProxy, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceLink, type ResourceTemplate, type ResourceTemplateArgument, type SerializableValue, type ServerOptions, ServerState, type StructuredResult, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, ViteMCP, type ViteMCPAuth, ViteMCPError, audioContent, imageContent, jsonSchemaAdapter };
|
package/dist/ViteMCP.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CacheScope, InputRequest, InputRequiredResult, ToolAnnotations, McpServer } from '@modelcontextprotocol/server';
|
|
2
|
-
export { CacheScope, InputRequest, InputRequiredResult, ToolAnnotations } from '@modelcontextprotocol/server';
|
|
1
|
+
import { CacheScope, InputRequest, InputRequiredResult, Icon, ToolAnnotations, McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
export { CacheScope, Icon, InputRequest, InputRequiredResult, ToolAnnotations } from '@modelcontextprotocol/server';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
@@ -321,12 +321,26 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
321
321
|
allowAnonymous?: boolean;
|
|
322
322
|
auth?: AuthProvider<T extends OAuthSession ? T : OAuthSession>;
|
|
323
323
|
authenticate?: Authenticate<T>;
|
|
324
|
+
/**
|
|
325
|
+
* What this server is, for a human reading a client's server list.
|
|
326
|
+
*
|
|
327
|
+
* Distinct from `instructions`, which is addressed to the model and tells it
|
|
328
|
+
* how to use what this server exposes.
|
|
329
|
+
*/
|
|
330
|
+
description?: string;
|
|
324
331
|
health?: {
|
|
325
332
|
enabled?: boolean;
|
|
326
333
|
message?: string;
|
|
327
334
|
path?: string;
|
|
328
335
|
status?: number;
|
|
329
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* Icons a client may show next to this server, most specific first.
|
|
339
|
+
*
|
|
340
|
+
* `src` is a URL the client fetches, so it must be reachable from wherever
|
|
341
|
+
* the client runs — not only from the server.
|
|
342
|
+
*/
|
|
343
|
+
icons?: Icon[];
|
|
330
344
|
instructions?: string;
|
|
331
345
|
logger?: Logger;
|
|
332
346
|
name: string;
|
|
@@ -336,7 +350,25 @@ type ServerOptions<T extends ViteMCPAuth> = {
|
|
|
336
350
|
protectedResource?: Record<string, unknown>;
|
|
337
351
|
proxy?: OAuthProxy;
|
|
338
352
|
};
|
|
353
|
+
/** Display name, for clients that prefer one over the identifier `name`. */
|
|
354
|
+
title?: string;
|
|
339
355
|
version: `${number}.${number}.${number}`;
|
|
356
|
+
/** Homepage for this server, for clients that link to one. */
|
|
357
|
+
websiteUrl?: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* The structured payload on its own, without the content fallback.
|
|
361
|
+
*
|
|
362
|
+
* Returning this is how a tool states outright that an object is its structured
|
|
363
|
+
* result, for the cases where the shape alone cannot say so — a payload whose
|
|
364
|
+
* own `content` field is an array reads as a list of content blocks otherwise.
|
|
365
|
+
* ViteMCP writes the JSON text fallback, exactly as it does for a plain
|
|
366
|
+
* structured return.
|
|
367
|
+
*/
|
|
368
|
+
type StructuredResult<T = unknown> = {
|
|
369
|
+
_meta?: Record<string, unknown>;
|
|
370
|
+
isError?: boolean;
|
|
371
|
+
structuredContent: T;
|
|
340
372
|
};
|
|
341
373
|
type TextContent = {
|
|
342
374
|
text: string;
|
|
@@ -347,7 +379,7 @@ type Tool<T extends ViteMCPAuth, Params extends ToolParameters = ToolParameters,
|
|
|
347
379
|
annotations?: ToolAnnotations;
|
|
348
380
|
canAccess?: (auth: T | undefined) => boolean;
|
|
349
381
|
description?: string;
|
|
350
|
-
execute: (args: StandardSchemaV1.InferOutput<Params>, context: Context<T>) => Promise<AudioContent | ContentResult | ImageContent | InputRequiredResult | ResourceContent | ResourceLink | StandardSchemaV1.InferOutput<OutputParams> | string | TextContent | void>;
|
|
382
|
+
execute: (args: StandardSchemaV1.InferOutput<Params>, context: Context<T>) => Promise<AudioContent | ContentResult | ImageContent | InputRequiredResult | ResourceContent | ResourceLink | StandardSchemaV1.InferOutput<OutputParams> | string | StructuredResult<StandardSchemaV1.InferOutput<OutputParams>> | TextContent | void>;
|
|
351
383
|
name: string;
|
|
352
384
|
outputSchema?: OutputParams;
|
|
353
385
|
parameters?: Params;
|
|
@@ -448,4 +480,4 @@ declare class ViteMCP<T extends ViteMCPAuth = ViteMCPAuth> {
|
|
|
448
480
|
stop(): Promise<void>;
|
|
449
481
|
}
|
|
450
482
|
|
|
451
|
-
export { type AudioContent, AuthProvider, type Authenticate, type CacheHint, type Completion, type Content, type ContentResult, type Context, DiscoveryDocumentCache, type ImageContent, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type LoadedResource, type Logger, MEDIA_FETCH_TIMEOUT_MS, type MediaSource, OAuthProxy, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceLink, type ResourceTemplate, type ResourceTemplateArgument, type SerializableValue, type ServerOptions, ServerState, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, ViteMCP, type ViteMCPAuth, ViteMCPError, audioContent, imageContent, jsonSchemaAdapter };
|
|
483
|
+
export { type AudioContent, AuthProvider, type Authenticate, type CacheHint, type Completion, type Content, type ContentResult, type Context, DiscoveryDocumentCache, type ImageContent, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type LoadedResource, type Logger, MEDIA_FETCH_TIMEOUT_MS, type MediaSource, OAuthProxy, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceLink, type ResourceTemplate, type ResourceTemplateArgument, type SerializableValue, type ServerOptions, ServerState, type StructuredResult, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, ViteMCP, type ViteMCPAuth, ViteMCPError, audioContent, imageContent, jsonSchemaAdapter };
|
package/dist/ViteMCP.js
CHANGED
|
@@ -718,7 +718,14 @@ var ViteMCP = class {
|
|
|
718
718
|
}
|
|
719
719
|
async #buildServer(auth) {
|
|
720
720
|
const server = new McpServer(
|
|
721
|
-
{
|
|
721
|
+
{
|
|
722
|
+
description: this.#options.description,
|
|
723
|
+
icons: this.#options.icons,
|
|
724
|
+
name: this.#options.name,
|
|
725
|
+
title: this.#options.title,
|
|
726
|
+
version: this.#options.version,
|
|
727
|
+
websiteUrl: this.#options.websiteUrl
|
|
728
|
+
},
|
|
722
729
|
{ instructions: this.#options.instructions }
|
|
723
730
|
);
|
|
724
731
|
for (const tool of this.#tools) {
|
|
@@ -748,7 +755,7 @@ var ViteMCP = class {
|
|
|
748
755
|
tool.timeoutMs,
|
|
749
756
|
tool.name
|
|
750
757
|
) : tool.execute(args, context));
|
|
751
|
-
return normalizeToolResult(result);
|
|
758
|
+
return normalizeToolResult(result, tool.outputSchema !== void 0);
|
|
752
759
|
} catch (error) {
|
|
753
760
|
if (error instanceof UserError) {
|
|
754
761
|
return {
|
|
@@ -1185,7 +1192,21 @@ var promptArgsSchema = (prompt) => {
|
|
|
1185
1192
|
}
|
|
1186
1193
|
return z.object(shape);
|
|
1187
1194
|
};
|
|
1188
|
-
var
|
|
1195
|
+
var isStructuredResult = (value) => {
|
|
1196
|
+
if (!Object.hasOwn(value, "structuredContent") || value.structuredContent === void 0) {
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
if (value.isError !== void 0 && typeof value.isError !== "boolean") {
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1202
|
+
if (value._meta !== void 0 && (typeof value._meta !== "object" || value._meta === null || Array.isArray(value._meta))) {
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1205
|
+
return Object.keys(value).every(
|
|
1206
|
+
(key) => key === "structuredContent" || key === "isError" || key === "_meta" || value[key] === void 0
|
|
1207
|
+
);
|
|
1208
|
+
};
|
|
1209
|
+
var normalizeToolResult = (result, hasOutputSchema) => {
|
|
1189
1210
|
if (result === void 0 || result === null) {
|
|
1190
1211
|
return { content: [] };
|
|
1191
1212
|
}
|
|
@@ -1197,7 +1218,23 @@ var normalizeToolResult = (result) => {
|
|
|
1197
1218
|
if (value.resultType === "input_required" || Array.isArray(value.content)) {
|
|
1198
1219
|
return value;
|
|
1199
1220
|
}
|
|
1200
|
-
if (value
|
|
1221
|
+
if (isStructuredResult(value)) {
|
|
1222
|
+
return {
|
|
1223
|
+
content: [
|
|
1224
|
+
{
|
|
1225
|
+
// `undefined` is excluded already; this covers what else JSON
|
|
1226
|
+
// declines to represent, so a broken payload stays a tool error
|
|
1227
|
+
// rather than an unserializable content block.
|
|
1228
|
+
text: JSON.stringify(value.structuredContent) ?? "null",
|
|
1229
|
+
type: "text"
|
|
1230
|
+
}
|
|
1231
|
+
],
|
|
1232
|
+
structuredContent: value.structuredContent,
|
|
1233
|
+
...value.isError === void 0 ? {} : { isError: value.isError },
|
|
1234
|
+
...value._meta === void 0 ? {} : { _meta: value._meta }
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
if (!hasOutputSchema && (value.type === "text" || value.type === "image" || value.type === "audio" || value.type === "resource" || value.type === "resource_link")) {
|
|
1201
1238
|
return { content: [value] };
|
|
1202
1239
|
}
|
|
1203
1240
|
return {
|