@nest-mcp/client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @nest-mcp/client
|
|
2
|
+
|
|
3
|
+
NestJS module for connecting to and consuming [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers with typed injection, notifications, health checks, and reconnection support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nest-mcp/client @modelcontextprotocol/sdk
|
|
9
|
+
npm install @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// app.module.ts
|
|
16
|
+
import { Module } from '@nestjs/common';
|
|
17
|
+
import { McpClientModule } from '@nest-mcp/client';
|
|
18
|
+
import { McpTransportType } from '@nest-mcp/common';
|
|
19
|
+
|
|
20
|
+
@Module({
|
|
21
|
+
imports: [
|
|
22
|
+
McpClientModule.forRoot({
|
|
23
|
+
connections: [
|
|
24
|
+
{
|
|
25
|
+
name: 'my-server',
|
|
26
|
+
transport: {
|
|
27
|
+
type: McpTransportType.STREAMABLE_HTTP,
|
|
28
|
+
url: 'http://localhost:3000/mcp',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
export class AppModule {}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// my.service.ts
|
|
40
|
+
import { Injectable } from '@nestjs/common';
|
|
41
|
+
import { InjectMcpClient, McpClient } from '@nest-mcp/client';
|
|
42
|
+
|
|
43
|
+
@Injectable()
|
|
44
|
+
export class MyService {
|
|
45
|
+
constructor(@InjectMcpClient('my-server') private client: McpClient) {}
|
|
46
|
+
|
|
47
|
+
async greet(name: string) {
|
|
48
|
+
return this.client.callTool({ name: 'greet', arguments: { name } });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- **`@InjectMcpClient(name)`** — inject a named client into any service
|
|
56
|
+
- **`McpClientsService`** — programmatic access to all clients by name
|
|
57
|
+
- **`@OnMcpNotification(method)`** — subscribe to server-sent notifications
|
|
58
|
+
- **`McpClientHealthIndicator`** — health check integration (NestJS Terminus)
|
|
59
|
+
- **Automatic reconnection** with configurable backoff
|
|
60
|
+
- **OAuth** support for authenticated servers
|
|
61
|
+
|
|
62
|
+
## Transports
|
|
63
|
+
|
|
64
|
+
- Streamable HTTP (`McpTransportType.STREAMABLE_HTTP`)
|
|
65
|
+
- SSE (`McpTransportType.SSE`)
|
|
66
|
+
- STDIO (`McpTransportType.STDIO`)
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
Full documentation: [github.com/btwld/nest-mcp/docs/client](https://github.com/btwld/nest-mcp/blob/main/docs/client/README.md)
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-mcp/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "NestJS MCP Client - Connect to and consume MCP servers from NestJS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@nest-mcp/common": "0.1.
|
|
22
|
+
"@nest-mcp/common": "0.1.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.10.0",
|