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

@romatech/ai-extensions

v2.0.0

Published

Plug-and-play AI enablement framework for Node.js APIs. Transforms Express/Fastify/Koa endpoints into MCP tools and RAG-enabled knowledge sources automatically.

Downloads

330

Readme

@romatech/ai-extensions

npm License: MIT

Plug-and-play AI enablement framework for Node.js APIs. Transforms your endpoints into MCP tools and RAG-enabled knowledge sources — identical to the .NET version.

Works with Express, Fastify, Koa, and Hono.

Features

  • Decorator-based@AiTool, @AiHidden, @AiDescription (like .NET attributes)
  • Multi-framework — Express, Fastify, Koa, Hono, NestJS, Next.js, tRPC, AWS Lambda
  • MCP Server — Full Model Context Protocol implementation
  • RAG Search — Semantic search across API documentation
  • Swagger Discovery — Auto-discovers endpoints from OpenAPI spec
  • Custom Handlers — Bypass HTTP with in-process tool handlers
  • Tool Versioning — v1/v2 with deprecation support
  • Dry-run Mode — Validate without executing
  • Auth & CORS — Built-in API key auth and CORS headers
  • Circuit Breaker — Auto-disable failing tools
  • Multi-tenant — Different tools per API key
  • Metrics + Audit — Tool usage tracking + execution history
  • SSE + WebSocket — Persistent transports with heartbeat
  • Embedding Providers — Local (zero deps), OpenAI, Ollama

Installation

npm install @romatech/ai-extensions reflect-metadata

Add to tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Quick Start

import 'reflect-metadata';
import express from 'express';
import { Controller, Get, Post, Delete, AiTool, AiHidden, AiDescription, AiCategory, useController, useAi } from '@romatech/ai-extensions';

@Controller('/api/orders')
class OrdersController {
    @Get('/')
    @AiDescription('Lists all orders')
    @AiCategory('Orders')
    static getAll(req, res) {
        res.json([{ id: 1, status: 'Pending' }]);
    }

    @Post('/')
    @AiTool('create_order')
    @AiDescription('Creates a new customer order')
    @AiCategory('Orders')
    static create(req, res) {
        res.status(201).json({ id: 2, ...req.body });
    }

    @Delete('/:id')
    @AiHidden()
    static delete(req, res) {
        res.sendStatus(204);
    }
}

const app = express();
app.use(express.json());

useController(app, OrdersController);
useAi(app, { baseUrl: 'http://localhost:3000' });

app.listen(3000);

That's it. Your API is now MCP-enabled with RAG search.

Works With Any Framework

// Express
useController(app, OrdersController);
useAi(app);

// Fastify
useController(fastify, OrdersController);
useAi(fastify);

// Koa (via @koa/router)
useController(router, OrdersController);
useAi(router);

// Hono
useController(app, OrdersController);
useAi(app);

useAi() auto-detects the framework and registers the MCP endpoint accordingly.

Decorators

| Decorator | Equivalent .NET | Effect | |-----------|----------------|--------| | @Controller('/path') | [Route("/path")] | Base path for all methods | | @Get('/') | [HttpGet] | Registers GET route | | @Post('/') | [HttpPost] | Registers POST route | | @Put('/') | [HttpPut] | Registers PUT route | | @Delete('/') | [HttpDelete] | Registers DELETE route | | @AiTool('name') | [AiTool("name")] | Marks as executable MCP tool | | @AiHidden() | [AiHidden] | Hides from AI completely | | @AiDescription('...') | [AiDescription("...")] | AI-facing description | | @AiCategory('...') | [AiCategory("...")] | Semantic grouping | | @AiRole('...') | [AiRole("...")] | Required role | | @AiRateLimit(n) | [AiRateLimit(n)] | Max requests/minute | | @AiContextPriority(n) | [AiContextPriority(n)] | RAG ranking priority |

MCP Protocol

Once enabled, your app responds at POST /mcp:

# List tools
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# Call a tool
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"create_order","arguments":{"product":"Widget"}}}'

# Search API docs (RAG)
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"rag_search","arguments":{"query":"how to create orders"}}}'

Exposure Rules

| State | MCP Tool | RAG Search | Resources | |-------|----------|------------|-----------| | @AiTool() | ✅ Executable | ✅ Indexed | ❌ | | @AiHidden() | ❌ | ❌ | ❌ | | No decorator | ❌ | ✅ Indexed | ✅ (GET only) |

Configuration

useAi(app, {
    baseUrl: 'http://localhost:3000',
    mcp: {
        route: '/mcp',
        serverName: 'my-api',
        serverVersion: '1.0.0',
        apiKey: process.env.MCP_API_KEY,      // auth
        cors: '*',                             // CORS
        enableRateLimiting: true,
        globalRateLimitPerMinute: 60,
        toolTimeoutMs: 30000,
    },
    rag: {
        maxSearchResults: 10,
        minimumSimilarity: 0.3,
        indexTtlMs: 300000,                    // 5min cache
    },
});

.NET Equivalent

This package is the Node.js equivalent of Romatech.Extensions.Ai. Both produce identical MCP responses from the client perspective.

License

MIT