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

loopback4-mcp

v1.0.0

Published

A loopback extension that exposes API to MCP Tools.

Readme

loopback4-mcp

Overview

This extension provides a plug-and-play integration between LoopBack4 applications and the Model Context Protocol (MCP) specification.

Its purpose is to enable LoopBack APIs, services, and business logic to be exposed as MCP Tools, allowing external MCP clients (such as LLMs, agents, or MCP-compatible apps) to discover and execute server-defined operations.

Key Features

  • Automatic MCP Tool Discovery :- The extension scans your application at boot time and automatically registers all methods decorated with the custom @mcpTool() decorator.

    This allows you to define MCP tools anywhere in your LoopBack project without manually wiring metadata.

  • Lifecycle-managed Tool Registry :- A dedicated McpToolRegistry service maintains all discovered tool metadata,their handlers and execution context.

    A McpToolRegistryBootObserver ensures that registration happens only after the application has fully booted.

Installation

npm install loopback4-mcp

Then register the component inside your application.ts.

this.component(McpComponent);

Usage

Add the @mcpTool() decorator to any controller in your application.

@mcpTool({
  name: 'create-user',
  description: 'Creates a new user in the system',
  schema?: {
    email: z.string().email(),
    name: z.string(),
  },
})
async createUser(args: {email: string; name: string}) {
  return {message: `User ${args.name} created`};
}

This decorator accepts a total of five fields, out of which name and description are mandatory and schema,preHook and postHook are optional enhancements.

The schema field allows defining a Zod-based validation schema for tool input parameters, while preHook and postHook enable execution of custom logic before and after the tool handler runs.

Mcp Hook Usage Details

To use hooks with MCP tools, follow the provider-based approach:

Step 1: Create a hook provider:

// src/providers/my-hook.provider.ts
export class MyHookProvider implements Provider<McpHookFunction> {
  constructor(@inject(LOGGER.LOGGER_INJECT) private logger: ILogger) {}
  value(): McpHookFunction {
    return async (context: McpHookContext) => {
      this.logger.info(`Hook executed for tool: ${context.toolName}`);
    };
  }
}

Step 2: Add binding key to McpHookBindings:

// src/keys.ts
export namespace McpHookBindings {
  export const MY_HOOK = BindingKey.create<McpHookFunction>('hooks.mcp.myHook');
}

Step 3: Bind provider in application.ts:

this.bind(McpHookBindings.MY_HOOK).toProvider(MyHookProvider);

Step 4: Use in decorator:

@mcpTool({
 name: 'my-tool',
 description: 'my-description'
 preHookBinding: McpHookBindings.MY_HOOK,
  postHookBinding: 'hooks.mcp.myOtherHook' // or string binding key
})