npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@composio/llamaindex

v0.8.1

Published

Agentic Provider for llamaindex in Composio SDK

Downloads

4,018

Readme

@composio/llamaindex

Agentic Provider for Llamaindex in Composio SDK.

Features

  • Seamless LlamaIndex Integration: Tools are automatically compatible with LlamaIndex agents and workflows
  • Full Modifier Support: Support for both schema and execution modifiers with beforeExecute/afterExecute hooks
  • Streaming Support: Works with LlamaIndex streaming agents using agentStreamEvent
  • Tool Execution: Execute tools with proper parameter handling and JSON schema validation
  • Type Safety: Full TypeScript support with proper type definitions
  • Zod Schema Integration: Automatic conversion from JSON Schema to Zod for LlamaIndex compatibility

Installation

npm install @composio/llamaindex
# or
yarn add @composio/llamaindex
# or
pnpm add @composio/llamaindex

Quick Start

import { Composio } from '@composio/core';
import { LlamaindexProvider } from '@composio/llamaindex';

// Initialize Composio with Llamaindex provider
const composio = new Composio({
  apiKey: 'your-composio-api-key',
  provider: new LlamaindexProvider(),
});

// Get available tools
const tools = await composio.tools.get('user123', {
  toolkits: ['gmail', 'googlecalendar'],
  limit: 10,
});

Prerequisites

Before using the LlamaIndex provider, make sure you have:

  1. Composio API Key: Get your API key from Composio Dashboard
  2. Environment Setup: Set up your environment variables
  3. LlamaIndex Dependencies: Install required LlamaIndex packages
# Install LlamaIndex dependencies
npm install @llamaindex/openai @llamaindex/workflow
# Set up environment variables
export COMPOSIO_API_KEY="your-composio-api-key"
export OPENAI_API_KEY="your-openai-api-key"  # For LlamaIndex OpenAI integration

Usage Examples

Basic Example

import { Composio } from '@composio/core';
import { LlamaindexProvider } from '@composio/llamaindex';

// Initialize Composio
const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new LlamaindexProvider(),
});

// Get tools
const tools = await composio.tools.get('default', {
  toolkits: ['gmail'],
  limit: 10,
});

console.log(`Found ${tools.length} tools`);

Complete Agent Example with HackerNews

import { Composio } from '@composio/core';
import { LlamaindexProvider } from '@composio/llamaindex';
import { openai } from '@llamaindex/openai';
import { agent, agentStreamEvent } from '@llamaindex/workflow';
import 'dotenv/config';

// Initialize Composio with LlamaIndex provider
const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new LlamaindexProvider(),
});

async function main() {
  try {
    console.log('🚀 Starting LlamaIndex Example...');

    // Get available tools with modifiers
    const tools = await composio.tools.get(
      'default',
      {
        toolkits: ['hackernews'],
        limit: 10,
      },
      {
        beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
          console.log(`🔄 Executing tool ${toolSlug}/${toolkitSlug} with params:`, { params });
          return params;
        },
        afterExecute: ({ toolSlug, toolkitSlug, result }) => {
          console.log(`✅ Executed tool ${toolSlug}/${toolkitSlug} with result:`, { result });
          return result;
        },
      }
    );

    console.log(`✅ Found ${tools.length} tools`);

    // Create LlamaIndex agent with Composio tools
    const hackernewsAgent = agent({
      name: 'Hackernews Agent',
      description: 'A helpful hackernews assistant',
      llm: openai({ model: 'gpt-4o-mini' }),
      systemPrompt:
        'You are a helpful hackernews assistant that helps users with their queries related to hackernews',
      tools, // Composio tools are automatically compatible with LlamaIndex
    });

    // Run the agent with streaming
    const stream = await hackernewsAgent.runStream('Summarize the front page of hackernews');

    for await (const event of stream) {
      if (agentStreamEvent.include(event)) {
        process.stdout.write(event.data.delta);
      }
    }
  } catch (error) {
    console.error('❌ Error running example:', error);
  }
}

main().catch(console.error);

Using Tools with Different Toolkits

import { Composio } from '@composio/core';
import { LlamaindexProvider } from '@composio/llamaindex';
import { openai } from '@llamaindex/openai';
import { agent } from '@llamaindex/workflow';

const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new LlamaindexProvider(),
});

// Get tools from multiple toolkits
const tools = await composio.tools.get('default', {
  toolkits: ['gmail', 'googlecalendar', 'slack'],
  limit: 20,
});

// Create a multi-purpose agent
const assistantAgent = agent({
  name: 'Personal Assistant',
  description: 'A helpful personal assistant',
  llm: openai({ model: 'gpt-4' }),
  systemPrompt:
    'You are a helpful personal assistant that can manage emails, calendar events, and slack messages.',
  tools,
});

// Use the agent
const response = await assistantAgent.run(
  'Schedule a meeting for tomorrow at 2 PM and send a slack message about it'
);
console.log(response);

API Reference

LlamaindexProvider Class

The LlamaindexProvider class extends BaseAgenticProvider and provides llamaindex-specific functionality.

Methods

wrapTool(tool: Tool, executeTool: ExecuteToolFn): LlamaindexTool

Wraps a single Composio tool in the LlamaIndex format with proper Zod schema conversion.

const llamaindexTool = provider.wrapTool(composioTool, executeTool);

// The wrapped tool has LlamaIndex-compatible structure:
// - metadata.name: Tool slug
// - metadata.description: Tool description
// - metadata.parameters: Zod schema for parameters
// - call(): Function to execute the tool
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): LlamaindexTool[]

Wraps multiple Composio tools for use with LlamaIndex agents.

const llamaindexTools = provider.wrapTools(composioTools, executeTool);

// Use directly with LlamaIndex agents
const agent = agent({
  name: 'My Agent',
  llm: openai({ model: 'gpt-4' }),
  tools: llamaindexTools, // Ready to use!
});
wrapMcpServerResponse(data: McpUrlResponse): McpServerGetResponse

Transforms MCP URL responses into the standard format with URL objects.

const mcpServers = provider.wrapMcpServerResponse(urlResponse);
// Returns: [{ url: URL, name: string }, ...]

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

License

ISC License

Support

For support, please visit our Documentation or join our Discord Community.