Skip to content

feat(mcp): add MCP extension for exposing APIs as MCP tools#11564

Draft
akshatdubeysf wants to merge 1 commit intoloopbackio:masterfrom
akshatdubeysf:extensions/mcp
Draft

feat(mcp): add MCP extension for exposing APIs as MCP tools#11564
akshatdubeysf wants to merge 1 commit intoloopbackio:masterfrom
akshatdubeysf:extensions/mcp

Conversation

@akshatdubeysf
Copy link
Copy Markdown

@akshatdubeysf akshatdubeysf commented Apr 13, 2026

  • Adds @loopback/mcp extension that integrates LoopBack 4 applications with the Model Context Protocol (MCP)
    specification
  • Enables exposing LoopBack controller methods as MCP tools via the @mcptool() decorator, making them discoverable and
    callable by MCP clients (LLMs, agents, etc.)
  • Provides automatic tool discovery at boot time, schema generation from LoopBack @param decorators, and pre/post hook
    support via the provider pattern
  • It implements -
    • McpComponent — drop-in component that registers all services, controllers, and lifecycle observers
    • @mcpTool() decorator — marks controller methods as MCP tools with name, description, optional Zod schema, and
      hook bindings
    • McpToolRegistry — service that discovers and stores all decorated tool metadata at boot
    • McpServerFactory — creates MCP server instances with registered tools
    • McpSchemaGeneratorService — generates MCP-compatible schemas from LoopBack parameter metadata
    • McpController — exposes a POST /mcp endpoint using StreamableHTTP transport
    • McpToolRegistryBootObserver — lifecycle observer that triggers tool registration after app boot
    • Unit, integration, and acceptance tests

Checklist

  • DCO (Developer Certificate of Origin) signed in all commits
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@akshatdubeysf akshatdubeysf marked this pull request as draft April 13, 2026 08:05
  Add @loopback/mcp extension that enables LoopBack applications to expose
  their API endpoints as Model Context Protocol (MCP) tools. Includes
  decorator-based tool registration, schema generation, and server factory.

Signed-off-by: Akshat Dubey <akshat.dubey@sourcefuse.com>
as shown below.

```ts
import {McpComponent} from 'loopback4-mcp';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the naming here

@@ -0,0 +1,5 @@
# Repositories
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove these empty folders ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants