Plugin SDK

Build powerful plugins for Adverant Nexus with our comprehensive SDK

Installation

TypeScript/JavaScript

npm install @adverant-nexus/sdk

The SDK is compatible with Node.js 18+ and includes TypeScript definitions.

Python

pip install adverant-nexus-sdk

Python SDK requires Python 3.9 or higher.

Core Concepts

Plugin Architecture

Plugins extend Nexus through the Model Context Protocol (MCP), providing tools, resources, and prompts that AI agents can discover and use.

  • Tools: Functions that perform actions (e.g., analyze data, send emails)
  • Resources: Data sources that plugins expose (e.g., databases, APIs)
  • Prompts: Pre-configured prompts for common workflows

Nexus Client

The Nexus Client provides access to core platform services:

import { NexusClient } from '@adverant-nexus/sdk'

const nexus = new NexusClient({
  apiKey: process.env.BRAIN_API_KEY
})

// Access GraphRAG memory
await nexus.graphrag.storeMemory({
  content: 'Important information',
  tags: ['customer', 'analysis']
})

// Orchestrate sub-agents
await nexus.agents.orchestrate({
  task: 'Analyze customer feedback',
  agents: ['sentiment', 'summarization']
})

API Reference

Creating a Plugin Server

import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'

const server = new NexusPluginServer({
  name: 'my-plugin',
  version: '1.0.0',
  description: 'My awesome plugin'
})

// Define a tool
server.tool(new Tool({
  name: 'analyze_data',
  description: 'Analyzes data and returns insights',
  inputSchema: {
    type: 'object',
    properties: {
      data: { type: 'array' },
      options: { type: 'object' }
    },
    required: ['data']
  },
  execute: async (input) => {
    // Your implementation
    return { insights: [...] }
  }
}))

// Start the server
await server.start()

Accessing Nexus Services

// GraphRAG Memory
await nexus.graphrag.storeMemory({ content, tags })
await nexus.graphrag.query({ query, limit: 10 })

// Agent Orchestration
await nexus.agents.orchestrate({ task, agents })

// Learning System
await nexus.learning.recordPattern({ pattern, feedback })

Examples

Simple Plugin Example

A basic plugin that provides a greeting tool:

import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'

const server = new NexusPluginServer({
  name: 'greeter',
  version: '1.0.0'
})

server.tool(new Tool({
  name: 'greet',
  description: 'Greets a user by name',
  inputSchema: {
    type: 'object',
    properties: {
      name: { type: 'string' }
    },
    required: ['name']
  },
  execute: async ({ name }) => {
    return { message: `Hello, ${name}!` }
  }
}))

await server.start()

Next Steps