Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot] 6d7bc4ccbb Release (#1883)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: marcusschiesser <17126+marcusschiesser@users.noreply.github.com>
2025-04-23 17:24:54 +07:00
Huu Le 294f502441 feat: support SSE for MCP tools adapter (#1882) 2025-04-23 15:54:37 +07:00
github-actions[bot] 056594452c Release @llamaindex/readers@3.1.0 (#1880)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: marcusschiesser <17126+marcusschiesser@users.noreply.github.com>
2025-04-22 19:14:09 +07:00
Huu Le 1e59695cef Restructure reader packages (#1877)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2025-04-22 17:20:08 +07:00
56 changed files with 448 additions and 218 deletions
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/doc
## 0.2.14
### Patch Changes
- Updated dependencies [1e59695]
- @llamaindex/readers@3.1.0
## 0.2.13
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/doc",
"version": "0.2.13",
"version": "0.2.14",
"private": true,
"scripts": {
"postinstall": "fumadocs-mdx",
@@ -57,6 +57,41 @@ const researchAgent = agent({
});
```
## MCP tools
If you have a MCP server running, you can fetch tools from the server and use them in your agents.
```ts
// 1. Import MCP tools adapter
import { mcp } from "@llamaindex/tools";
import { agent } from "llamaindex";
// 2. Initialize a MCP client
// by npx
const server = mcp({
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "."],
verbose: true,
});
// or by SSE
const server = mcp({
url: "http://localhost:8000/mcp",
verbose: true,
});
// 3. Get tools from MCP server
const tools = await server.tools();
// Now you can create an agent with the tools
const agent = agent({
name: "My Agent",
systemPrompt: "You are a helpful assistant that can use the provided tools to answer questions.",
llm: openai({ model: "gpt-4o" }),
tools: tools,
});
```
## Function tool
You can still use the `FunctionTool` class to define a tool.
@@ -5,6 +5,12 @@ title: DiscordReader
DiscordReader is a simple data loader that reads all messages in a given Discord channel and returns them as Document objects.
It uses the [@discordjs/rest](https://github.com/discordjs/discord.js/tree/main/packages/rest) library to fetch the messages.
## Installation
```package-install
npm install @llamaindex/discord
```
## Usage
First step is to create a Discord Application and generating a bot token [here](https://discord.com/developers/applications).
@@ -12,7 +18,7 @@ In your Discord Application, go to the `OAuth2` tab and generate an invite URL b
This will invite the bot with the necessary permissions to read messages.
Copy the URL in your browser and select the server you want your bot to join.
<include cwd>../../examples/readers/src/discord.ts</include>
<include cwd>../../examples/discord/reader.ts</include>
### Params
@@ -21,27 +21,18 @@ To install readers call:
We offer readers for different file formats.
```ts twoslash
import { CSVReader } from '@llamaindex/readers/csv'
import { PDFReader } from '@llamaindex/readers/pdf'
import { JSONReader } from '@llamaindex/readers/json'
import { MarkdownReader } from '@llamaindex/readers/markdown'
import { HTMLReader } from '@llamaindex/readers/html'
// you can find more readers in the documentation
```ts twoslash
import { CSVReader } from '@llamaindex/readers/csv';
import { DocxReader } from '@llamaindex/readers/docx';
import { HTMLReader } from '@llamaindex/readers/html';
import { ImageReader } from '@llamaindex/readers/image';
import { JSONReader } from '@llamaindex/readers/json';
import { MarkdownReader } from '@llamaindex/readers/markdown';
import { ObsidianReader } from '@llamaindex/readers/obsidian';
import { PDFReader } from '@llamaindex/readers/pdf';
import { TextFileReader } from '@llamaindex/readers/text';
```
Additionally the following loaders exist without separate documentation:
- `AssemblyAIReader` transcribes audio using [AssemblyAI](https://www.assemblyai.com/).
- [AudioTranscriptReader](/docs/api/classes/AudioTranscriptReader): loads entire transcript as a single document.
- [AudioTranscriptParagraphsReader](/docs/api/classes/AudioTranscriptParagraphsReader): creates a document per paragraph.
- [AudioTranscriptSentencesReader](/docs/api/classes/AudioTranscriptSentencesReader): creates a document per sentence.
- [AudioSubtitlesReader](/docs/api/classes/AudioTranscriptParagraphsReader): creates a document containing the subtitles of a transcript.
- [NotionReader](/docs/api/classes/NotionReader) loads [Notion](https://www.notion.so/) pages.
- [SimpleMongoReader](/docs/api/classes/SimpleMongoReader) loads data from a [MongoDB](https://www.mongodb.com/).
Check the [LlamaIndexTS Github](https://github.com/run-llama/LlamaIndexTS) for the most up to date overview of integrations.
## SimpleDirectoryReader
[Open in StackBlitz](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples/readers?file=src/simple-directory-reader.ts&title=Simple%20Directory%20Reader)
@@ -1,5 +1,12 @@
# @llamaindex/next-node-runtime
## 0.1.23
### Patch Changes
- Updated dependencies [1e59695]
- @llamaindex/readers@3.1.0
## 0.1.22
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.1.22",
"version": "0.1.23",
"private": true,
"scripts": {
"dev": "next dev",
+24
View File
@@ -1,5 +1,29 @@
# examples
## 0.3.11
### Patch Changes
- Updated dependencies [294f502]
- @llamaindex/tools@0.0.6
## 0.3.10
### Patch Changes
- Updated dependencies [1e59695]
- Updated dependencies [1e59695]
- Updated dependencies [1e59695]
- Updated dependencies [1e59695]
- Updated dependencies [1e59695]
- Updated dependencies [1e59695]
- @llamaindex/assemblyai@0.1.1
- @llamaindex/mongodb@0.0.17
- @llamaindex/azure@0.1.12
- @llamaindex/readers@3.1.0
- @llamaindex/notion@0.1.1
- @llamaindex/discord@0.1.1
## 0.3.9
### Patch Changes
+7 -3
View File
@@ -9,6 +9,12 @@ async function main() {
args: ["-y", "@modelcontextprotocol/server-filesystem", "."],
verbose: true,
});
// You can also connect to the MCP server using SSE
// See: https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse
// const server = mcp({
// url: "http://localhost:8000/mcp",
// verbose: true,
// });
try {
// Create an agent that uses the MCP tools
@@ -21,9 +27,7 @@ async function main() {
});
// Run a task
const response = await myAgent.run(
"what are the files in the current directory?",
);
const response = await myAgent.run("What are the available tools?");
console.log("Agent response:", response.data);
} finally {
@@ -1,7 +1,7 @@
import {
AudioTranscriptReader,
TranscribeParams,
} from "@llamaindex/readers/assembly-ai";
} from "@llamaindex/assemblyai";
import { program } from "commander";
import { VectorStoreIndex } from "llamaindex";
import { stdin as input, stdout as output } from "node:process";
+3 -3
View File
@@ -1,11 +1,11 @@
import { CosmosClient } from "@azure/cosmos";
import { DefaultAzureCredential } from "@azure/identity";
import { AzureCosmosDBNoSQLConfig } from "@llamaindex/azure";
import { OpenAI, OpenAIEmbedding } from "@llamaindex/openai";
import {
AzureCosmosDBNoSQLConfig,
SimpleCosmosDBReader,
SimpleCosmosDBReaderLoaderConfig,
} from "@llamaindex/readers/cosmosdb";
} from "@llamaindex/azure";
import { OpenAI, OpenAIEmbedding } from "@llamaindex/openai";
import * as dotenv from "dotenv";
import {
Settings,
@@ -1,4 +1,4 @@
import { DiscordReader } from "@llamaindex/readers/discord";
import { DiscordReader } from "@llamaindex/discord";
async function main() {
// Create an instance of the DiscordReader. Set token here or DISCORD_TOKEN environment variable
+1 -1
View File
@@ -1,4 +1,4 @@
import { SimpleMongoReader } from "@llamaindex/readers/mongo";
import { SimpleMongoReader } from "@llamaindex/mongodb";
import { Document, VectorStoreIndex } from "llamaindex";
import { MongoClient } from "mongodb";
+4 -2
View File
@@ -1,5 +1,7 @@
import { MongoDBAtlasVectorSearch } from "@llamaindex/mongodb";
import { SimpleMongoReader } from "@llamaindex/readers/mongo";
import {
MongoDBAtlasVectorSearch,
SimpleMongoReader,
} from "@llamaindex/mongodb";
import * as dotenv from "dotenv";
import { storageContextFromDefaults, VectorStoreIndex } from "llamaindex";
import { MongoClient } from "mongodb";
@@ -1,4 +1,4 @@
import { NotionReader } from "@llamaindex/readers/notion";
import { NotionReader } from "@llamaindex/notion";
import { Client } from "@notionhq/client";
import { program } from "commander";
import { VectorStoreIndex } from "llamaindex";
@@ -8,8 +8,6 @@ import { createInterface } from "node:readline/promises";
program
.argument("[page]", "Notion page id (must be provided)")
.action(async (page, _options) => {
// Initializing a client
if (!process.env.NOTION_TOKEN) {
console.log(
"No NOTION_TOKEN found in environment variables. You will need to register an integration https://www.notion.com/my-integrations and put it in your NOTION_TOKEN environment variable.",
@@ -64,10 +62,8 @@ program
const documents = await reader.loadData(page);
console.log(documents);
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments(documents);
// Create query engine
const queryEngine = index.asQueryEngine();
const rl = createInterface({ input, output });
@@ -80,7 +76,6 @@ program
const response = await queryEngine.query({ query });
// Output response
console.log(response.toString());
}
});
+8 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/examples",
"version": "0.3.9",
"version": "0.3.11",
"private": true,
"scripts": {
"lint": "eslint .",
@@ -13,7 +13,7 @@
"@azure/search-documents": "^12.1.0",
"@llamaindex/anthropic": "^0.3.3",
"@llamaindex/astra": "^0.0.16",
"@llamaindex/azure": "^0.1.11",
"@llamaindex/azure": "^0.1.12",
"@llamaindex/chroma": "^0.0.16",
"@llamaindex/clip": "^0.0.52",
"@llamaindex/cloud": "^4.0.3",
@@ -28,7 +28,7 @@
"@llamaindex/milvus": "^0.1.11",
"@llamaindex/mistral": "^0.1.2",
"@llamaindex/mixedbread": "^0.0.16",
"@llamaindex/mongodb": "^0.0.16",
"@llamaindex/mongodb": "^0.0.17",
"@llamaindex/elastic-search": "^0.1.2",
"@llamaindex/node-parser": "^2.0.2",
"@llamaindex/ollama": "^0.1.2",
@@ -37,7 +37,7 @@
"@llamaindex/portkey-ai": "^0.0.44",
"@llamaindex/postgres": "^0.0.45",
"@llamaindex/qdrant": "^0.1.11",
"@llamaindex/readers": "^3.0.2",
"@llamaindex/readers": "^3.1.0",
"@llamaindex/replicate": "^0.0.44",
"@llamaindex/upstash": "^0.0.16",
"@llamaindex/vercel": "^0.1.2",
@@ -51,9 +51,12 @@
"@llamaindex/jinaai": "^0.0.12",
"@llamaindex/perplexity": "^0.0.9",
"@llamaindex/supabase": "^0.1.1",
"@llamaindex/tools": "^0.0.5",
"@llamaindex/tools": "^0.0.6",
"@notionhq/client": "^2.2.15",
"@pinecone-database/pinecone": "^4.0.0",
"@llamaindex/assemblyai": "^0.1.1",
"@llamaindex/discord": "^0.1.1",
"@llamaindex/notion": "^0.1.1",
"@vercel/postgres": "^0.10.0",
"ai": "^4.0.0",
"ajv": "^8.17.1",
-1
View File
@@ -11,7 +11,6 @@
"start:pdf": "node --import tsx ./src/pdf.ts",
"start:llamaparse": "node --import tsx ./src/llamaparse.ts",
"start:notion": "node --import tsx ./src/notion.ts",
"start:assemblyai": "node --import tsx ./src/assemblyai.ts",
"start:llamaparse-dir": "node --import tsx ./src/simple-directory-reader-with-llamaparse.ts",
"start:llamaparse-json": "node --import tsx ./src/llamaparse-json.ts",
"start:discord": "node --import tsx ./src/discord.ts",
@@ -0,0 +1,7 @@
# @llamaindex/assemblyai
## 0.1.1
### Patch Changes
- 1e59695: Introduce an independent package for assemblyai
@@ -0,0 +1,32 @@
{
"name": "@llamaindex/assemblyai",
"description": "AssemblyAI Reader for LlamaIndex",
"version": "0.1.1",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/providers/assemblyai"
},
"scripts": {
"build": "bunchee",
"dev": "bunchee --watch"
},
"dependencies": {
"assemblyai": "^4.8.0",
"@llamaindex/core": "workspace:*",
"@llamaindex/env": "workspace:*"
}
}
@@ -0,0 +1 @@
export * from "./reader";
@@ -0,0 +1,19 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "./lib",
"tsBuildInfoFile": "./lib/.tsbuildinfo"
},
"include": ["./src"],
"references": [
{
"path": "../../core/tsconfig.json"
},
{
"path": "../../env/tsconfig.json"
}
]
}
+7
View File
@@ -0,0 +1,7 @@
# @llamaindex/discord
## 0.1.1
### Patch Changes
- 1e59695: Introduce an independent package for discord
+33
View File
@@ -0,0 +1,33 @@
{
"name": "@llamaindex/discord",
"description": "Discord Reader for LlamaIndex",
"version": "0.1.1",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/providers/discord"
},
"scripts": {
"build": "bunchee",
"dev": "bunchee --watch"
},
"dependencies": {
"@discordjs/rest": "^2.3.0",
"discord-api-types": "^0.37.105",
"@llamaindex/core": "workspace:*",
"@llamaindex/env": "workspace:*"
}
}
+1
View File
@@ -0,0 +1 @@
export * from "./reader";
@@ -1,4 +1,3 @@
// todo: move to `providers`
import { REST, type RESTOptions } from "@discordjs/rest";
import { Document, type BaseReader } from "@llamaindex/core/schema";
import { getEnv } from "@llamaindex/env";
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "./lib",
"tsBuildInfoFile": "./lib/.tsbuildinfo"
},
"include": ["./src"],
"references": [
{
"path": "../../core/tsconfig.json"
},
{
"path": "../../env/tsconfig.json"
}
]
}
+7
View File
@@ -0,0 +1,7 @@
# @llamaindex/notion
## 0.1.1
### Patch Changes
- 1e59695: Introduce an independent package for notion
+32
View File
@@ -0,0 +1,32 @@
{
"name": "@llamaindex/notion",
"description": "Notion Reader for LlamaIndex",
"version": "0.1.1",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/providers/notion"
},
"scripts": {
"build": "bunchee",
"dev": "bunchee --watch"
},
"dependencies": {
"notion-md-crawler": "^1.0.0",
"@llamaindex/core": "workspace:*",
"@llamaindex/env": "workspace:*"
}
}
+1
View File
@@ -0,0 +1 @@
export * from "./reader";
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "./lib",
"tsBuildInfoFile": "./lib/.tsbuildinfo"
},
"include": ["./src"],
"references": [
{
"path": "../../core/tsconfig.json"
},
{
"path": "../../env/tsconfig.json"
}
]
}
@@ -1,5 +1,11 @@
# @llamaindex/azure
## 0.1.12
### Patch Changes
- 1e59695: Add CosmosDB reader
## 0.1.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/azure",
"description": "Azure Storage for LlamaIndex",
"version": "0.1.11",
"version": "0.1.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -7,3 +7,5 @@ export * from "./vectorStore/AzureCosmosDBNoSqlVectorStore.js";
export * from "./vectorStore/AzureQueryResultSearch.js";
export * from "./tools/AzureDynamicSessionTool.node.js";
export * from "./readers/index.js";
@@ -0,0 +1 @@
export * from "./cosmosdb";
@@ -1,10 +1,10 @@
import { CosmosClient } from "@azure/cosmos";
import { Document } from "@llamaindex/core/schema";
import { describe, expect, it, vi } from "vitest";
import {
SimpleCosmosDBReader,
type SimpleCosmosDBReaderLoaderConfig,
} from "@llamaindex/readers/cosmosdb";
import { describe, expect, it, vi } from "vitest";
} from "../src/readers/cosmosdb";
const createMockClient = (mockData?: unknown[]) => {
const client = {
@@ -1,5 +1,11 @@
# @llamaindex/mongodb
## 0.0.17
### Patch Changes
- 1e59695: Add MongoDB reader
## 0.0.16
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/mongodb",
"description": "MongoDB Storage for LlamaIndex",
"version": "0.0.16",
"version": "0.0.17",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,3 +1,4 @@
export * from "./docStore/MongoDBDocumentStore";
export * from "./kvStore/MongoKVStore";
export * from "./MongoDBAtlasVectorStore";
export * from "./readers/index.js";
@@ -0,0 +1 @@
export * from "./mongo";
@@ -1,4 +1,3 @@
// todo: should move to providers
import type { Metadata } from "@llamaindex/core/schema";
import { type BaseReader, Document } from "@llamaindex/core/schema";
import type { Filter, MongoClient, Document as MongoDocument } from "mongodb";
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/readers
## 3.1.0
### Minor Changes
- 1e59695: Move MongoDB, CosmosDB, AssemblyAI, Notion, and Discord to their own packages
## 3.0.2
### Patch Changes
-14
View File
@@ -1,14 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"edge-light": "./dist/index.edge-light.js",
"workerd": "./dist/index.workerd.js",
"default": "./dist/index.js"
}
},
"private": true
}
-14
View File
@@ -1,14 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"edge-light": "./dist/index.edge-light.js",
"workerd": "./dist/index.workerd.js",
"default": "./dist/index.js"
}
},
"private": true
}
-14
View File
@@ -1,14 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"edge-light": "./dist/index.edge-light.js",
"workerd": "./dist/index.workerd.js",
"default": "./dist/index.js"
}
},
"private": true
}
-14
View File
@@ -1,14 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"edge-light": "./dist/index.edge-light.js",
"workerd": "./dist/index.workerd.js",
"default": "./dist/index.js"
}
},
"private": true
}
-14
View File
@@ -1,14 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"edge-light": "./dist/index.edge-light.js",
"workerd": "./dist/index.workerd.js",
"default": "./dist/index.js"
}
},
"private": true
}
+1 -62
View File
@@ -1,31 +1,11 @@
{
"name": "@llamaindex/readers",
"description": "LlamaIndex Readers",
"version": "3.0.2",
"version": "3.1.0",
"type": "module",
"exports": {
"./node/hook": "./node/dist/hook.js",
"./node": "./node/dist/index.js",
"./assembly-ai": {
"require": {
"types": "./assembly-ai/dist/index.d.cts",
"default": "./assembly-ai/dist/index.cjs"
},
"import": {
"types": "./assembly-ai/dist/index.d.ts",
"default": "./assembly-ai/dist/index.js"
}
},
"./cosmosdb": {
"require": {
"types": "./cosmosdb/dist/index.d.cts",
"default": "./cosmosdb/dist/index.cjs"
},
"import": {
"types": "./cosmosdb/dist/index.d.ts",
"default": "./cosmosdb/dist/index.js"
}
},
"./csv": {
"edge-light": {
"types": "./csv/dist/index.edge-light.d.ts",
@@ -62,16 +42,6 @@
"default": "./directory/dist/index.js"
}
},
"./discord": {
"require": {
"types": "./discord/dist/index.d.cts",
"default": "./discord/dist/index.cjs"
},
"import": {
"types": "./discord/dist/index.d.ts",
"default": "./discord/dist/index.js"
}
},
"./docx": {
"require": {
"types": "./docx/dist/index.d.cts",
@@ -122,26 +92,6 @@
"default": "./markdown/dist/index.js"
}
},
"./mongo": {
"require": {
"types": "./mongo/dist/index.d.cts",
"default": "./mongo/dist/index.cjs"
},
"import": {
"types": "./mongo/dist/index.d.ts",
"default": "./mongo/dist/index.js"
}
},
"./notion": {
"require": {
"types": "./notion/dist/index.d.cts",
"default": "./notion/dist/index.cjs"
},
"import": {
"types": "./notion/dist/index.d.ts",
"default": "./notion/dist/index.js"
}
},
"./obsidian": {
"edge-light": {
"types": "./obsidian/dist/index.edge-light.d.ts",
@@ -182,18 +132,13 @@
}
},
"files": [
"assembly-ai",
"cosmosdb",
"csv",
"directory",
"discord",
"docx",
"html",
"image",
"json",
"markdown",
"mongo",
"notion",
"obsidian",
"pdf",
"text",
@@ -220,15 +165,9 @@
"@llamaindex/env": "workspace:*"
},
"dependencies": {
"@azure/cosmos": "^4.1.1",
"@discordjs/rest": "^2.3.0",
"@discoveryjs/json-ext": "^0.6.1",
"assemblyai": "^4.8.0",
"csv-parse": "^5.5.6",
"discord-api-types": "^0.37.105",
"mammoth": "^1.7.2",
"mongodb": "^6.7.0",
"notion-md-crawler": "^1.0.0",
"unpdf": "^0.12.1"
}
}
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/tools
## 0.0.6
### Patch Changes
- 294f502: Support SSE for MCP tools adapter
## 0.0.5
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/tools",
"description": "LlamaIndex Tools",
"version": "0.0.5",
"version": "0.0.6",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+35 -6
View File
@@ -2,6 +2,10 @@ import type { JSONValue } from "@llamaindex/core/global";
import type { BaseToolWithCall } from "@llamaindex/core/llms";
import { FunctionTool } from "@llamaindex/core/tools";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import {
SSEClientTransport,
type SSEClientTransportOptions,
} from "@modelcontextprotocol/sdk/client/sse.js";
import {
StdioClientTransport,
type StdioServerParameters,
@@ -13,7 +17,7 @@ interface ToolInput {
[key: string]: unknown;
}
type MCPClientOptions = StdioServerParameters & {
type MCPCommonOptions = {
/**
* The prefix to add to the tool name
*/
@@ -32,11 +36,20 @@ type MCPClientOptions = StdioServerParameters & {
verbose?: boolean;
};
type StdioMCPClientOptions = StdioServerParameters & MCPCommonOptions;
type SSEMCPClientOptions = SSEClientTransportOptions &
MCPCommonOptions & {
url: string;
};
type MCPClientOptions = StdioMCPClientOptions | SSEMCPClientOptions;
class MCPClient {
private mcp: Client;
private transport: StdioClientTransport | null = null;
private transport: StdioClientTransport | SSEClientTransport | null = null;
private verbose: boolean;
private toolNamePrefix?: string | undefined;
private connected: boolean = false;
constructor(options: MCPClientOptions) {
this.mcp = new Client({
@@ -46,18 +59,34 @@ class MCPClient {
this.verbose = options.verbose ?? false;
this.toolNamePrefix = options.toolNamePrefix;
this.connectToSever(options);
if ("url" in options) {
this.transport = new SSEClientTransport(
new URL(options.url),
options as SSEClientTransportOptions,
);
} else {
this.transport = new StdioClientTransport(
options as StdioServerParameters,
);
}
this.connected = false;
}
async connectToSever(options: StdioServerParameters) {
async connectToSever() {
if (this.verbose) {
console.log("Connecting to MCP server...");
}
this.transport = new StdioClientTransport(options);
if (!this.transport) {
throw new Error("Initialized with invalid options");
}
await this.mcp.connect(this.transport);
this.connected = true;
}
async listTools(): Promise<Tool[]> {
private async listTools(): Promise<Tool[]> {
if (!this.connected) {
await this.connectToSever();
}
const tools = await this.mcp.listTools();
return tools.tools;
}
+74 -27
View File
@@ -611,11 +611,14 @@ importers:
'@llamaindex/anthropic':
specifier: ^0.3.3
version: link:../packages/providers/anthropic
'@llamaindex/assemblyai':
specifier: ^0.1.1
version: link:../packages/providers/assemblyai
'@llamaindex/astra':
specifier: ^0.0.16
version: link:../packages/providers/storage/astra
'@llamaindex/azure':
specifier: ^0.1.11
specifier: ^0.1.12
version: link:../packages/providers/storage/azure
'@llamaindex/chroma':
specifier: ^0.0.16
@@ -638,6 +641,9 @@ importers:
'@llamaindex/deepseek':
specifier: ^0.0.12
version: link:../packages/providers/deepseek
'@llamaindex/discord':
specifier: ^0.1.1
version: link:../packages/providers/discord
'@llamaindex/elastic-search':
specifier: ^0.1.2
version: link:../packages/providers/storage/elastic-search
@@ -672,11 +678,14 @@ importers:
specifier: ^0.0.16
version: link:../packages/providers/mixedbread
'@llamaindex/mongodb':
specifier: ^0.0.16
specifier: ^0.0.17
version: link:../packages/providers/storage/mongodb
'@llamaindex/node-parser':
specifier: ^2.0.2
version: link:../packages/node-parser
'@llamaindex/notion':
specifier: ^0.1.1
version: link:../packages/providers/notion
'@llamaindex/ollama':
specifier: ^0.1.2
version: link:../packages/providers/ollama
@@ -699,7 +708,7 @@ importers:
specifier: ^0.1.11
version: link:../packages/providers/storage/qdrant
'@llamaindex/readers':
specifier: ^3.0.2
specifier: ^3.1.0
version: link:../packages/readers
'@llamaindex/replicate':
specifier: ^0.0.44
@@ -711,7 +720,7 @@ importers:
specifier: ^0.0.12
version: link:../packages/providers/together
'@llamaindex/tools':
specifier: ^0.0.5
specifier: ^0.0.6
version: link:../packages/tools
'@llamaindex/upstash':
specifier: ^0.0.16
@@ -1102,6 +1111,18 @@ importers:
specifier: ^2.1.5
version: 2.1.5(@edge-runtime/vm@5.0.0)(@types/node@22.14.1)(happy-dom@17.4.4)(lightningcss@1.29.3)(msw@2.7.4(@types/node@22.14.1)(typescript@5.8.3))(terser@5.39.0)
packages/providers/assemblyai:
dependencies:
'@llamaindex/core':
specifier: workspace:*
version: link:../../core
'@llamaindex/env':
specifier: workspace:*
version: link:../../env
assemblyai:
specifier: ^4.8.0
version: 4.9.0(bufferutil@4.0.9)
packages/providers/clip:
dependencies:
'@huggingface/transformers':
@@ -1150,6 +1171,21 @@ importers:
specifier: workspace:*
version: link:../openai
packages/providers/discord:
dependencies:
'@discordjs/rest':
specifier: ^2.3.0
version: 2.4.3
'@llamaindex/core':
specifier: workspace:*
version: link:../../core
'@llamaindex/env':
specifier: workspace:*
version: link:../../env
discord-api-types:
specifier: ^0.37.105
version: 0.37.120
packages/providers/fireworks:
dependencies:
'@llamaindex/env':
@@ -1247,6 +1283,18 @@ importers:
specifier: ^2.2.11
version: 2.2.11
packages/providers/notion:
dependencies:
'@llamaindex/core':
specifier: workspace:*
version: link:../../core
'@llamaindex/env':
specifier: workspace:*
version: link:../../env
notion-md-crawler:
specifier: ^1.0.0
version: 1.0.1
packages/providers/ollama:
dependencies:
'@llamaindex/core':
@@ -1603,33 +1651,15 @@ importers:
packages/readers:
dependencies:
'@azure/cosmos':
specifier: ^4.1.1
version: 4.3.0
'@discordjs/rest':
specifier: ^2.3.0
version: 2.4.3
'@discoveryjs/json-ext':
specifier: ^0.6.1
version: 0.6.3
assemblyai:
specifier: ^4.8.0
version: 4.9.0(bufferutil@4.0.9)
csv-parse:
specifier: ^5.5.6
version: 5.6.0
discord-api-types:
specifier: ^0.37.105
version: 0.37.120
mammoth:
specifier: ^1.7.2
version: 1.9.0
mongodb:
specifier: ^6.7.0
version: 6.7.0(@aws-sdk/credential-providers@3.787.0)(socks@2.8.4)
notion-md-crawler:
specifier: ^1.0.0
version: 1.0.1
unpdf:
specifier: ^0.12.1
version: 0.12.1
@@ -10441,6 +10471,7 @@ packages:
node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
deprecated: Use your platform's native DOMException instead
node-fetch-native@1.6.6:
resolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==}
@@ -20773,7 +20804,7 @@ snapshots:
'@typescript-eslint/parser': 8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3)
eslint: 9.22.0(jiti@2.4.2)
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@9.22.0(jiti@2.4.2))
eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2))
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2))
eslint-plugin-jsx-a11y: 6.10.2(eslint@9.22.0(jiti@2.4.2))
eslint-plugin-react: 7.37.2(eslint@9.22.0(jiti@2.4.2))
@@ -20803,6 +20834,22 @@ snapshots:
transitivePeerDependencies:
- supports-color
eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2)):
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.0
enhanced-resolve: 5.18.1
eslint: 9.22.0(jiti@2.4.2)
fast-glob: 3.3.3
get-tsconfig: 4.10.0
is-bun-module: 1.3.0
is-glob: 4.0.3
stable-hash: 0.0.4
optionalDependencies:
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2))
transitivePeerDependencies:
- supports-color
eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0)(eslint@9.16.0(jiti@2.4.2)):
dependencies:
'@nolyfill/is-core-module': 1.0.39
@@ -20831,7 +20878,7 @@ snapshots:
is-glob: 4.0.3
stable-hash: 0.0.4
optionalDependencies:
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2))
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.7.3))(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2))
transitivePeerDependencies:
- supports-color
@@ -20857,14 +20904,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
eslint-module-utils@2.12.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2)):
eslint-module-utils@2.12.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2)):
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3)
eslint: 9.22.0(jiti@2.4.2)
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@9.22.0(jiti@2.4.2))
eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2))
transitivePeerDependencies:
- supports-color
@@ -20937,7 +20984,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.22.0(jiti@2.4.2)
eslint-import-resolver-node: 0.3.9
eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@9.22.0(jiti@2.4.2))
eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.30.1(eslint@9.22.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2)))(eslint@9.22.0(jiti@2.4.2))
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/unit-test
## 0.1.23
### Patch Changes
- Updated dependencies [1e59695]
- @llamaindex/readers@3.1.0
## 0.1.22
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/unit-test",
"private": true,
"version": "0.1.22",
"version": "0.1.23",
"type": "module",
"scripts": {
"test": "vitest run"