vue-llm 1.4.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 dadashi44
3
+ Copyright (c) 2026 dadashi44 (Dauren Abasov)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.es.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **Streaming**: parser de SSE y deltas de texto, razonamiento y llamadas a herramientas
29
29
  - **Seguridad**: la protección `dangerouslyAllowBrowser` mantiene a salvo las API keys
30
30
  - **Chat UI**: un chat completo que es tuyo: `npx shadcn-vue add https://vue-llm.js.org/r/chat.json`, además de los headless `usePromptInput` y `useAutoScroll`
31
+ - **MCP**: herramientas de cualquier servidor MCP (búsqueda, archivos, GitHub, bases de datos) en `useChat` y en el servidor (`vue-llm/mcp`)
31
32
  - **Vue DevTools**: una pestaña LLM con cada chat, línea de tiempo de peticiones, tiempo hasta el primer token, llamadas a herramientas y consumo de tokens (`vue-llm/devtools`)
32
33
  - **Módulo de Nuxt**: auto-imports, componentes, DevTools en desarrollo y runtime config en el servidor
33
34
  - **Cero dependencias en tiempo de ejecución**: solo `vue` como peer dependency (Vue 3.3+; los composables también en Vue 2.7)
package/README.ja.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **ストリーミング** — SSE パーサー、テキスト・推論・ツール呼び出しの差分
29
29
  - **セキュリティ** — `dangerouslyAllowBrowser` ガードで API キーを保護
30
30
  - **チャット UI** — 自分で所有できる完全なチャット:`npx shadcn-vue add https://vue-llm.js.org/r/chat.json`。ヘッドレスな `usePromptInput` と `useAutoScroll` も利用可能
31
+ - **MCP** — 任意の MCP サーバーのツール(検索、ファイル、GitHub、データベース)を `useChat` とサーバーで利用(`vue-llm/mcp`)
31
32
  - **Vue DevTools** — すべてのチャット、リクエストのタイムライン、最初のトークンまでの時間、ツール呼び出し、トークン使用量を表示する LLM タブ(`vue-llm/devtools`)
32
33
  - **Nuxt モジュール** — 自動インポート、コンポーネント、開発時の DevTools、サーバーサイドの runtime config
33
34
  - **ランタイム依存ゼロ** — peer dependency は `vue` のみ(Vue 3.3 以降。コンポーザブルは Vue 2.7 でも動作)
package/README.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **Streaming** — SSE parser, text/reasoning/tool-call deltas
29
29
  - **Security** — `dangerouslyAllowBrowser` guard protects API keys
30
30
  - **Chat UI** — a complete chat you own: `npx shadcn-vue add https://vue-llm.js.org/r/chat.json`, plus headless `usePromptInput` and `useAutoScroll`
31
+ - **MCP** — tools of any MCP server (search, files, GitHub, databases) in `useChat` and on the server (`vue-llm/mcp`)
31
32
  - **Vue DevTools** — an LLM tab with every chat, request timeline, time to first token, tool calls and token usage (`vue-llm/devtools`)
32
33
  - **Nuxt module** — auto-imports, components, DevTools in development, server-side runtime config
33
34
  - **Zero runtime deps** — only `vue` as peer dependency (Vue 3.3+, composables also on Vue 2.7)
package/README.pt-BR.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **Streaming** — parser de SSE, deltas de texto/raciocínio/chamadas de ferramentas
29
29
  - **Segurança** — a proteção `dangerouslyAllowBrowser` protege as API keys
30
30
  - **Chat UI** — um chat completo que é seu: `npx shadcn-vue add https://vue-llm.js.org/r/chat.json`, além dos headless `usePromptInput` e `useAutoScroll`
31
+ - **MCP** — ferramentas de qualquer servidor MCP (busca, arquivos, GitHub, bancos de dados) no `useChat` e no servidor (`vue-llm/mcp`)
31
32
  - **Vue DevTools** — uma aba LLM com todos os chats, linha do tempo das requisições, tempo até o primeiro token, chamadas de ferramentas e uso de tokens (`vue-llm/devtools`)
32
33
  - **Módulo Nuxt** — auto-imports, componentes, DevTools em desenvolvimento, runtime config no servidor
33
34
  - **Zero dependências de runtime** — só `vue` como peer dependency (Vue 3.3+, composables também no Vue 2.7)
package/README.ru.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **Стриминг** — SSE-парсер, дельты текста, рассуждений и вызовов инструментов
29
29
  - **Безопасность** — защита `dangerouslyAllowBrowser` бережёт API-ключи
30
30
  - **Chat UI** — готовый чат, код которого принадлежит вам: `npx shadcn-vue add https://vue-llm.js.org/r/chat.json`, плюс headless `usePromptInput` и `useAutoScroll`
31
+ - **MCP** — инструменты любого MCP-сервера (поиск, файлы, GitHub, базы данных) в `useChat` и на сервере (`vue-llm/mcp`)
31
32
  - **Vue DevTools** — вкладка LLM со всеми чатами, таймлайном запросов, временем до первого токена, вызовами инструментов и расходом токенов (`vue-llm/devtools`)
32
33
  - **Nuxt-модуль** — автоимпорты, компоненты, DevTools в режиме разработки, серверный runtime config
33
34
  - **Ноль runtime-зависимостей** — только `vue` в peer-зависимостях (Vue 3.3+, композаблы работают и на Vue 2.7)
package/README.zh-CN.md CHANGED
@@ -28,6 +28,7 @@
28
28
  - **流式处理**:SSE 解析器,文本/推理/工具调用增量
29
29
  - **安全**:`dangerouslyAllowBrowser` 保护机制,防止 API key 泄露
30
30
  - **聊天界面**:一套完全属于你的聊天界面:`npx shadcn-vue add https://vue-llm.js.org/r/chat.json`,另有无头的 `usePromptInput` 和 `useAutoScroll`
31
+ - **MCP**:在 `useChat` 和服务端使用任意 MCP 服务器的工具(搜索、文件、GitHub、数据库)(`vue-llm/mcp`)
31
32
  - **Vue DevTools**:LLM 标签页,展示所有聊天、请求时间线、首 token 时间、工具调用和 token 用量(`vue-llm/devtools`)
32
33
  - **Nuxt 模块**:自动导入、组件、开发环境下的 DevTools、服务端运行时配置
33
34
  - **零运行时依赖**:唯一的 peer 依赖是 `vue`(Vue 3.3+,组合式函数也支持 Vue 2.7)
package/dist/mcp.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function s(e){if("toolResult"in e&&!("content"in e))return e.toolResult;const t=e.content??[],i=t.every(u)?t.map(r=>r.text):void 0;if(e.isError)throw new Error(i?.join(`
2
+ `)||"MCP tool call failed");return e.structuredContent!==void 0?e.structuredContent:i?i.join(`
3
+ `):t}function u(e){return typeof e=="object"&&e!==null&&e.type==="text"&&typeof e.text=="string"}async function d(e,t={}){const i=[];let r;do{const n=await e.listTools(r?{cursor:r}:void 0,{signal:t.signal});i.push(...n.tools),r=n.nextCursor}while(r);return i.filter(n=>!t.include||t.include.includes(n.name)).filter(n=>!t.exclude?.includes(n.name)).map(n=>({name:l(t.prefix?`${t.prefix}_${n.name}`:n.name),description:n.description??n.title??"",parameters:n.inputSchema,async execute(c,o){const a=await e.callTool({name:n.name,arguments:c??{}},void 0,{signal:o?.signal??o?.request?.signal});return s(a)}}))}exports.mcpTools=d;
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Model Context Protocol tools for vue-llm.
3
+ *
4
+ * Takes a connected client from the official `@modelcontextprotocol/sdk` (any transport:
5
+ * Streamable HTTP, SSE, stdio) and turns the tools of its server into tools for `useChat`
6
+ * and `createLLMHandler`. vue-llm does not depend on the SDK; any object with the same
7
+ * `listTools` and `callTool` methods works.
8
+ */
9
+ /** A tool as listed by an MCP server */
10
+ export interface MCPToolInfo {
11
+ name: string;
12
+ title?: string;
13
+ description?: string;
14
+ inputSchema: Record<string, unknown>;
15
+ }
16
+ /** Result of an MCP `tools/call` request */
17
+ export interface MCPCallToolResult {
18
+ content?: unknown[];
19
+ structuredContent?: Record<string, unknown>;
20
+ isError?: boolean;
21
+ /** Result field of servers on protocol version 2024-10-07 */
22
+ toolResult?: unknown;
23
+ }
24
+ /** The part of the MCP SDK `Client` that vue-llm uses */
25
+ export interface MCPClient {
26
+ listTools(params?: {
27
+ cursor?: string;
28
+ }, options?: {
29
+ signal?: AbortSignal;
30
+ }): Promise<{
31
+ tools: MCPToolInfo[];
32
+ nextCursor?: string;
33
+ }>;
34
+ callTool(params: {
35
+ name: string;
36
+ arguments?: Record<string, unknown>;
37
+ }, resultSchema?: undefined, options?: {
38
+ signal?: AbortSignal;
39
+ }): Promise<MCPCallToolResult>;
40
+ }
41
+ export interface MCPToolsOptions {
42
+ /** Only these tools, by their name on the MCP server */
43
+ include?: string[];
44
+ /** Leave out these tools, by their name on the MCP server */
45
+ exclude?: string[];
46
+ /** Added before each name as `prefix_name`, to tell apart tools of several servers */
47
+ prefix?: string;
48
+ /** Cancels listing the tools */
49
+ signal?: AbortSignal;
50
+ }
51
+ /** Context passed by `useChat` (with `signal`) and by `createLLMHandler` (with `request`) */
52
+ export interface MCPToolContext {
53
+ toolCallId: string;
54
+ signal?: AbortSignal;
55
+ request?: Request;
56
+ }
57
+ /** A tool that works in `useChat({ tools })` and in `createLLMHandler({ tools })` */
58
+ export interface MCPTool {
59
+ name: string;
60
+ description: string;
61
+ parameters: Record<string, unknown>;
62
+ execute: (args: unknown, context: MCPToolContext) => Promise<unknown>;
63
+ }
64
+ /**
65
+ * Lists the tools of a connected MCP client and wraps each one as a vue-llm tool.
66
+ *
67
+ * ```ts
68
+ * import { Client } from '@modelcontextprotocol/sdk/client/index.js'
69
+ * import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
70
+ * import { mcpTools } from 'vue-llm/mcp'
71
+ *
72
+ * const client = new Client({ name: 'my-app', version: '1.0.0' })
73
+ * await client.connect(new StreamableHTTPClientTransport(new URL('https://example.com/mcp')))
74
+ *
75
+ * createLLMHandler({ provider, tools: await mcpTools(client) })
76
+ * ```
77
+ */
78
+ export declare function mcpTools(client: MCPClient, options?: MCPToolsOptions): Promise<MCPTool[]>;
package/dist/mcp.js ADDED
@@ -0,0 +1,39 @@
1
+ function s(e) {
2
+ return e.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
3
+ }
4
+ function l(e) {
5
+ if ("toolResult" in e && !("content" in e)) return e.toolResult;
6
+ const t = e.content ?? [], i = t.every(u) ? t.map((r) => r.text) : void 0;
7
+ if (e.isError)
8
+ throw new Error(i?.join(`
9
+ `) || "MCP tool call failed");
10
+ return e.structuredContent !== void 0 ? e.structuredContent : i ? i.join(`
11
+ `) : t;
12
+ }
13
+ function u(e) {
14
+ return typeof e == "object" && e !== null && e.type === "text" && typeof e.text == "string";
15
+ }
16
+ async function d(e, t = {}) {
17
+ const i = [];
18
+ let r;
19
+ do {
20
+ const n = await e.listTools(r ? { cursor: r } : void 0, { signal: t.signal });
21
+ i.push(...n.tools), r = n.nextCursor;
22
+ } while (r);
23
+ return i.filter((n) => !t.include || t.include.includes(n.name)).filter((n) => !t.exclude?.includes(n.name)).map((n) => ({
24
+ name: s(t.prefix ? `${t.prefix}_${n.name}` : n.name),
25
+ description: n.description ?? n.title ?? "",
26
+ parameters: n.inputSchema,
27
+ async execute(o, c) {
28
+ const a = await e.callTool(
29
+ { name: n.name, arguments: o ?? {} },
30
+ void 0,
31
+ { signal: c?.signal ?? c?.request?.signal }
32
+ );
33
+ return l(a);
34
+ }
35
+ }));
36
+ }
37
+ export {
38
+ d as mcpTools
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-llm",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "description": "AI SDK for Vue and Nuxt: streaming useChat, tool calling, Generative UI and in-browser WebGPU models for OpenAI, Anthropic, Gemini and Ollama.",
6
6
  "keywords": [
@@ -76,6 +76,11 @@
76
76
  "import": "./dist/devtools.js",
77
77
  "require": "./dist/devtools.cjs"
78
78
  },
79
+ "./mcp": {
80
+ "types": "./dist/mcp.d.ts",
81
+ "import": "./dist/mcp.js",
82
+ "require": "./dist/mcp.cjs"
83
+ },
79
84
  "./style.css": "./dist/vue-llm.css",
80
85
  "./package.json": "./package.json"
81
86
  },
@@ -125,6 +130,7 @@
125
130
  "@eslint/js": "^9.17.0",
126
131
  "@lucide/vue": "^1.62.0",
127
132
  "@mlc-ai/web-llm": "^0.2.86",
133
+ "@modelcontextprotocol/sdk": "^1.32.2",
128
134
  "@nuxt/kit": "^3.16.0",
129
135
  "@stylistic/eslint-plugin": "^5.10.0",
130
136
  "@tailwindcss/vite": "^4.3.3",