open-index/open-npm huggingface dataset:
npm package: @nest-mcp/client
Description: NestJS MCP Client - Connect to and consume MCP servers from NestJS
Latest version: 0.2.5

# @nest-mcp/client

[![npm version](https://img.shields.io/npm/v/@nest-mcp/client.svg)](https://www.npmjs.com/package/@nest-mcp/client)
[![npm downloads](https://img.shields.io/npm/dm/@nest-mcp/client.svg)](https://www.npmjs.com/package/@nest-mcp/client)
[![License](https://img.shields.io/npm/l/@nest-mcp/client)](https://github.com/btwld/nest-mcp/blob/main/LICENSE)
[![CI](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml)

NestJS module for connecting to and consuming [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers with typed injection, notifications, health checks, and reconnection support.

## Installation

```bash
npm install @nest-mcp/client @modelcontextprotocol/sdk zod@^4
npm install @nestjs/common @nestjs/core reflect-metadata rxjs
```

## Quick start

```typescript
// app.module.ts
import { Module } from '@nestjs/common';
import { McpClientModule } from '@nest-mcp/client';
import { McpTransportType } from '@nest-mcp/client';

@Module({
  imports: [
    McpClientModule.forRoot({
      connections: [
        {
          name: 'my-server',
          transport: {
            type: McpTransportType.STREAMABLE_HTTP,
            url: 'http://localhost:3000/mcp',
          },
        },
      ],
    }),
  ],
})
export class AppModule {}
```

```typescript
// my.service.ts
import { Injectable } from '@nestjs/common';
import { InjectMcpClient, McpClient } from '@nest-mcp/client';

@Injectable()
export class MyService {
  constructor(@InjectMcpClient('my-server') private client: McpClient) {}

  async greet(name: string) {
    return this.client.callTool({ name: 'greet', arguments: { name } });
  }
}
```

## Features

- **`@InjectMcpClient(name)`** — inject a named client into any service
- **`McpClientsService`** — programmatic access to all clients by name
- **`@OnMcpNotification(method)`** — subscribe to server-sent notifications
- **`McpClientHealthIndicator`** — health check integration (NestJS Terminus)
- **Automatic reconnection** with configurable backoff
- **OAuth** support for authenticated servers

## Transports

- Streamable HTTP (`McpTransportType.STREAMABLE_HTTP`)
- SSE (`McpTransportType.SSE`)
- STDIO (`McpTransportType.STDIO`)

## Documentation

Full documentation: [github.com/btwld/nest-mcp/docs/client](https://github.com/btwld/nest-mcp/blob/main/docs/client/README.md)

## License

BSD-3-Clause
npm package: @nest-mcp/common
Description: Shared types, interfaces, constants, utilities, and decorators for @nest-mcp
Latest version: 0.2.0

# @nest-mcp/common

[![npm version](https://img.shields.io/npm/v/@nest-mcp/common.svg)](https://www.npmjs.com/package/@nest-mcp/common)
[![License](https://img.shields.io/npm/l/@nest-mcp/common)](https://github.com/btwld/nest-mcp/blob/main/LICENSE)
[![CI](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml)

Shared types, utilities, and constants for the `nest-mcp` toolkit. This package is a peer dependency of `@nest-mcp/server`, `@nest-mcp/client`, and `@nest-mcp/gateway` — you rarely need to install it directly.

## Installation

```bash
npm install @nest-mcp/common
```

## Contents

- **Types** — `McpExecutionContext`, `McpModuleOptions`, `ToolCallResult`, `ResourceReadResult`, `PromptGetResult`, and more
- **Enums** — `McpTransportType` (STREAMABLE_HTTP, SSE, STDIO)
- **Errors** — `ToolExecutionError`, `ValidationError`
- **Utilities** — `zodToJsonSchema`, `matchUriTemplate`, `paginate`, `extractZodDescriptions`
- **Tokens** — `MCP_OPTIONS`, `MCP_CLIENT_OPTIONS`

## Usage

```typescript
import { McpTransportType, McpExecutionContext } from '@nest-mcp/common';
```

Most users interact with this package indirectly through `@nest-mcp/server`, `@nest-mcp/client`, or `@nest-mcp/gateway`.

## Documentation

Full documentation: [github.com/btwld/nest-mcp](https://github.com/btwld/nest-mcp)

## License

BSD-3-Clause
npm package: @nest-mcp/gateway
Description: NestJS MCP Gateway - Proxy, route, and aggregate multiple MCP servers
Latest version: 0.2.6

# @nest-mcp/gateway

[![npm version](https://img.shields.io/npm/v/@nest-mcp/gateway.svg)](https://www.npmjs.com/package/@nest-mcp/gateway)
[![npm downloads](https://img.shields.io/npm/dm/@nest-mcp/gateway.svg)](https://www.npmjs.com/package/@nest-mcp/gateway)
[![License](https://img.shields.io/npm/l/@nest-mcp/gateway)](https://github.com/btwld/nest-mcp/blob/main/LICENSE)
[![CI](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml)

NestJS module for aggregating multiple upstream [MCP](https://modelcontextprotocol.io/) servers behind a single unified endpoint, with routing, caching, policies, and transforms.

## Installation

```bash
npm install @nest-mcp/gateway @modelcontextprotocol/sdk zod@^4
npm install @nestjs/common @nestjs/core reflect-metadata rxjs
```

## Quick start

```typescript
// app.module.ts
import { Module } from '@nestjs/common';
import { McpGatewayModule } from '@nest-mcp/gateway';
import { McpTransportType } from '@nest-mcp/gateway';

@Module({
  imports: [
    McpGatewayModule.forRoot({
      name: 'my-gateway',
      version: '1.0.0',
      upstreams: [
        {
          name: 'weather',
          transport: {
            type: McpTransportType.STREAMABLE_HTTP,
            url: 'http://weather-service/mcp',
          },
        },
        {
          name: 'search',
          transport: {
            type: McpTransportType.STREAMABLE_HTTP,
            url: 'http://search-service/mcp',
          },
        },
      ],
    }),
  ],
})
export class AppModule {}
```

Tools from upstream servers are exposed with a prefix (`weather_forecast`, `search_query`). Downstream clients see one unified MCP server.

## Features

- **Automatic prefixing** — tools, resources, and prompts are namespaced by upstream name
- **Policy engine** — allow/deny/require-approval rules per tool or upstream
- **Response caching** — TTL-based cache for tool results
- **Request/response transforms** — custom hooks to rewrite calls
- **Health monitoring** — periodic ping per upstream
- **Task proxying** — long-running tasks forwarded with upstream prefix
- **Sampling & elicitation** — forwarded transparently to the correct upstream

## Documentation

Full documentation: [github.com/btwld/nest-mcp/docs/gateway](https://github.com/btwld/nest-mcp/blob/main/docs/gateway/README.md)

## License

BSD-3-Clause
npm package: @nest-mcp/server
Description: NestJS MCP Server - Build Model Context Protocol servers with NestJS
Latest version: 0.4.0

# @nest-mcp/server

[![npm version](https://img.shields.io/npm/v/@nest-mcp/server.svg)](https://www.npmjs.com/package/@nest-mcp/server)
[![npm downloads](https://img.shields.io/npm/dm/@nest-mcp/server.svg)](https://www.npmjs.com/package/@nest-mcp/server)
[![License](https://img.shields.io/npm/l/@nest-mcp/server)](https://github.com/btwld/nest-mcp/blob/main/LICENSE)
[![CI](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/btwld/nest-mcp/actions/workflows/ci.yml)

NestJS module for building [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers with decorators, auth, resilience, and multi-transport support.

## Installation

```bash
npm install @nest-mcp/server @modelcontextprotocol/sdk zod@^4
npm install @nestjs/common @nestjs/core reflect-metadata rxjs
```

## Quick start

```typescript
// tools.service.ts
import { Injectable } from '@nestjs/common';
import { Tool } from '@nest-mcp/server';
import { z } from 'zod';

@Injectable()
export class ToolsService {
  @Tool({
    name: 'greet',
    description: 'Greet a user by name',
    schema: z.object({ name: z.string() }),
  })
  async greet({ name }: { name: string }) {
    return `Hello, ${name}!`;
  }
}
```

```typescript
// app.module.ts
import { Module } from '@nestjs/common';
import { McpModule } from '@nest-mcp/server';
import { McpTransportType } from '@nest-mcp/server';

@Module({
  imports: [
    McpModule.forRoot({
      name: 'my-server',
      version: '1.0.0',
      transports: [{ type: McpTransportType.STREAMABLE_HTTP }],
    }),
  ],
  providers: [ToolsService],
})
export class AppModule {}
```

## Decorators

| Decorator | Description |
|-----------|-------------|
| `@Tool` | Expose a method as an MCP tool |
| `@Resource` | Expose a method as a static MCP resource |
| `@ResourceTemplate` | Expose a method as a URI-template resource |
| `@Prompt` | Expose a method as an MCP prompt |
| `@Completion` | Provide argument completions for a prompt or resource |

## Transports

- **Streamable HTTP** (`McpTransportType.STREAMABLE_HTTP`) — recommended, supports stateful and stateless modes
- **SSE** (`McpTransportType.SSE`) — Server-Sent Events (legacy)
- **STDIO** (`McpTransportType.STDIO`) — for CLI/subprocess use

## Documentation

Full documentation: [github.com/btwld/nest-mcp/docs/server](https://github.com/btwld/nest-mcp/blob/main/docs/server/README.md)

## License

BSD-3-Clause