vite-plugin-mcp-server
v0.1.6
Published
```bash npm i vite-plugin-mcp-server -D ```
Downloads
33
Readme
使用方法
npm i vite-plugin-mcp-server -Dimport { defineConfig } from "vite";
import { z } from "zod";
import vitePluginMcpServer from "vite-plugin-mcp-server";
export default defineConfig({
plugins: [
vitePluginMcpServer({
port: 3333,
register(server) {
server.tool(
'get-weather',
'Get the weather of a city',
{
city: z.string().describe("The city to get the weather of"),
},
async (params) => {
return {
content: [
{
type: "text",
text: `The weather of ${params.city} is sunny`,
},
],
};
}
)
},
}),
],
});import { defineConfig } from "vite";
import z from "zod";
import vitePluginMcpServer from "vite-plugin-mcp-server";
export default defineConfig({
plugins: [
vitePluginMcpServer({
port: 3333,
tools: [
{
name: "get-weather",
description: "Get the weather of a city",
parameters: {
city: z.string().describe("The city to get the weather of"),
},
handler: async (params) => {
return {
content: [
{
type: "text",
text: `The weather of ${params.city} is sunny`,
},
],
};
},
},
],
}),
],
});http://localhost:3333/sse