{"id":42268564,"url":"https://github.com/sourcefuse/loopback4-mcp","last_synced_at":"2026-03-02T08:14:22.986Z","repository":{"id":325042439,"uuid":"1095647845","full_name":"sourcefuse/loopback4-mcp","owner":"sourcefuse","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-27T05:19:09.000Z","size":330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-27T18:35:07.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcefuse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-13T10:30:58.000Z","updated_at":"2026-01-27T05:19:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sourcefuse/loopback4-mcp","commit_stats":null,"previous_names":["sourcefuse/loopback4-mcp"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sourcefuse/loopback4-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcefuse","download_url":"https://codeload.github.com/sourcefuse/loopback4-mcp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29995910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-27T07:05:56.439Z","updated_at":"2026-03-02T08:14:22.965Z","avatar_url":"https://github.com/sourcefuse.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://sourcefuse.github.io/arc-docs/arc-api-docs\" target=\"_blank\"\u003e\u003cimg src=\"https://github.com/sourcefuse/loopback4-microservice-catalog/blob/master/docs/assets/logo-dark-bg.png?raw=true\" alt=\"ARC By SourceFuse logo\" title=\"ARC By SourceFuse\" align=\"right\" width=\"150\" /\u003e\u003c/a\u003e\n\n# [loopback4-mcp](https://github.com/sourcefuse/loopback4-mcp)\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/loopback4-mcp\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/loopback4-mcp.svg\" alt=\"npm version\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://sonarcloud.io/summary/new_code?id=sourcefuse_loopback4-mcp\" target=\"_blank\"\u003e\n\u003cimg alt=\"Sonar Quality Gate\" src=\"https://img.shields.io/sonar/quality_gate/sourcefuse_loopback4-mcp?server=https%3A%2F%2Fsonarcloud.io\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/sourcefuse/loopback4-mcp/graphs/contributors\" target=\"_blank\"\u003e\n\u003cimg alt=\"GitHub contributors\" src=\"https://img.shields.io/github/contributors/sourcefuse/loopback4-mcp?\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/loopback4-mcp\" target=\"_blank\"\u003e\n\u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dw/loopback4-mcp.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"./LICENSE\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/sourcefuse/loopback4-mcp.svg\" alt=\"License\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://loopback.io/\" target=\"_blank\"\u003e\n\u003cimg alt=\"Powered By LoopBack 4\" src=\"https://img.shields.io/badge/Powered%20by-LoopBack 4-brightgreen\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis extension provides a plug-and-play integration between LoopBack4 applications and the Model Context Protocol (MCP) specification.\n\nIts 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.\n\n### Key Features\n\n- Automatic MCP Tool Discovery :-\n  The extension scans your application at boot time and automatically registers all methods decorated with the custom @mcpTool() decorator.\n\n  This allows you to define MCP tools anywhere in your LoopBack project without manually wiring metadata.\n\n- Lifecycle-managed Tool Registry :-\n  A dedicated `McpToolRegistry` service maintains all discovered tool metadata,their handlers and execution context.\n\n  A `McpToolRegistryBootObserver` ensures that registration happens only after the application has fully booted.\n\n## Installation\n\n```sh\nnpm install loopback4-mcp\n```\n\n## Basic Usage\n\nConfigure and load `McpComponent` in the application constructor\nas shown below.\n\n```ts\nimport {McpComponent} from 'loopback4-mcp';\n\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    super();\n    this.component(McpComponent);\n  }\n}\n```\n\nAdd the `@mcpTool()` decorator to any controller in your application.\n\nAll MCP tool methods must use LoopBack `@param` decorators to define their input parameters.If `@param` decorators are missing, the MCP tool will fail.\n\n```ts\n@mcpTool({\n  name: 'create-user',\n  description: 'Creates a new user in the system',\n  schema?: {\n    email: z.string().email(),\n    name: z.string(),\n  },\n})\nasync createUser(\n  @param.query.string('email') email: string,\n  @param.query.string('name') name: string,\n) {\n  return {message: `User ${name} created`};\n}\n```\n\nThis decorator accepts a total of five fields, out of which `name` and `description` are mandatory and `schema`,`preHook` and `postHook` are optional enhancements.\n\nThe 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.\n\n## Mcp Hook Usage Details\n\nTo use hooks with MCP tools, follow the provider-based approach:\n\nStep 1: Create a hook provider:\n\n```ts\n// src/providers/my-hook.provider.ts\nexport class MyHookProvider implements Provider\u003cMcpHookFunction\u003e {\n  constructor(@inject(LOGGER.LOGGER_INJECT) private logger: ILogger) {}\n  value(): McpHookFunction {\n    return async (context: McpHookContext) =\u003e {\n      this.logger.info(`Hook executed for tool: ${context.toolName}`);\n    };\n  }\n}\n```\n\nStep 2: Add binding key to McpHookBindings:\n\n```ts\n// src/keys.ts\nexport namespace McpHookBindings {\n  export const MY_HOOK = BindingKey.create\u003cMcpHookFunction\u003e('hooks.mcp.myHook');\n}\n```\n\nStep 3: Bind provider in `application.ts`:\n\n```typescript\nthis.bind(McpHookBindings.MY_HOOK).toProvider(MyHookProvider);\n```\n\nStep 4: Use in decorator:\n\n```ts\n@mcpTool({\n name: 'my-tool',\n description: 'my-description'\n preHookBinding: McpHookBindings.MY_HOOK,\n  postHookBinding: 'hooks.mcp.myOtherHook' // or string binding key\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcefuse%2Floopback4-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcefuse%2Floopback4-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcefuse%2Floopback4-mcp/lists"}