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

@moss-tools/mastra

v0.1.0

Published

Moss semantic search tools for Mastra agents

Readme

@moss-tools/mastra

Moss semantic search tools for Mastra agents.

Wraps Moss into createTool() primitives that drop straight into any Mastra agent. Sub-10ms lookups, no external embedder, no vector database to run.

Installation

npm install @moss-tools/mastra @moss-dev/moss @mastra/core zod

Prerequisites

  • Moss project ID and project key — get them from the Moss Portal
  • Node.js 18+

Quickstart

import { Agent } from '@mastra/core/agent';
import { MossClient } from '@moss-dev/moss';
import { mossSearchTool } from '@moss-tools/mastra';

const client = new MossClient(
  process.env.MOSS_PROJECT_ID!,
  process.env.MOSS_PROJECT_KEY!
);

// Load the index once at startup for sub-10ms queries
await client.loadIndex('my-index');

const agent = new Agent({
  id: 'support-agent',
  name: 'Knowledge Support Copilot',
  instructions: 'Use moss_search to find relevant information before answering.',
  model: 'openai/gpt-4.1-mini',
  tools: {
    search: mossSearchTool({ client, indexName: 'my-index' }),
  },
});

const response = await agent.generate('What is your refund policy?');
console.log(response.text);

Available tools

mossSearchTool

Searches a Moss index and returns ranked documents.

import { mossSearchTool } from '@moss-tools/mastra';

// Pre-bound to an index — LLM only needs to supply { query }
const searchBound = mossSearchTool({ client, indexName: 'my-index' });

// Dynamic — LLM supplies { indexName, query }
const searchDynamic = mossSearchTool({ client });

Options:

| Option | Default | Description | |---|---|---| | client | (required) | MossClient instance | | indexName | — | Pre-bind to an index; when omitted the LLM must provide it | | topK | 5 | Number of results to return | | alpha | 0.8 | Search blend: 1.0 = semantic only, 0.0 = keyword only | | id | "moss_search" | Mastra tool ID | | description | (auto) | Tool description shown to the LLM |

mossAddDocsTool

Adds or upserts documents into a Moss index. Useful for agents that learn and store information during a conversation.

import { mossAddDocsTool } from '@moss-tools/mastra';

const addDocs = mossAddDocsTool({ client, indexName: 'my-index' });

Options:

| Option | Default | Description | |---|---|---| | client | (required) | MossClient instance | | indexName | — | Pre-bind to an index | | id | "moss_add_docs" | Mastra tool ID | | description | (auto) | Tool description shown to the LLM |

Agent with both tools

const agent = new Agent({
  id: 'learning-agent',
  instructions:
    'You are a support assistant. Search the knowledge base with moss_search. ' +
    'If you learn something new that should be remembered, store it with moss_add_docs.',
  model: 'openai/gpt-4.1-mini',
  tools: {
    search: mossSearchTool({ client, indexName: 'support-kb' }),
    addDocs: mossAddDocsTool({ client, indexName: 'support-kb' }),
  },
});

License

BSD 2-Clause — see LICENSE.

Support