@mcp-z/client 2.2.2 → 2.2.3
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 +35 -18
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -11,33 +11,42 @@ Programmatic MCP client library for Node.js - connect, discover, and call tools
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install
|
|
14
|
+
npm install @mcp-z/client
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Requires Node.js >=
|
|
17
|
+
Requires Node.js >= 20.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Quick start
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Create a local stdio server that exposes an `echo` tool:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
npm install @modelcontextprotocol/sdk zod
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Save this as `echo-server.mjs`:
|
|
28
28
|
|
|
29
|
-
```
|
|
30
|
-
import {
|
|
29
|
+
```js
|
|
30
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
31
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
32
|
+
import { z } from 'zod';
|
|
31
33
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
}
|
|
34
|
+
const server = new McpServer({ name: 'echo', version: '1.0.0' });
|
|
35
|
+
server.registerTool('echo', { inputSchema: { message: z.string() } }, async ({ message }) => ({
|
|
36
|
+
content: [{ type: 'text', text: message }]
|
|
37
|
+
}));
|
|
38
|
+
await server.connect(new StdioServerTransport());
|
|
39
|
+
```
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
await client.callTool('add-tasks', {
|
|
38
|
-
tasks: [{ content: 'Learn MCP', priority: 4 }]
|
|
39
|
-
});
|
|
41
|
+
Connect to it and print the returned text:
|
|
40
42
|
|
|
43
|
+
```ts
|
|
44
|
+
import { createServerRegistry } from '@mcp-z/client';
|
|
45
|
+
|
|
46
|
+
const registry = createServerRegistry({ echo: { command: 'node', args: ['echo-server.mjs'] } });
|
|
47
|
+
const client = await registry.connect('echo');
|
|
48
|
+
const response = await client.callTool('echo', { message: 'hello MCP' });
|
|
49
|
+
console.log(response.text()); // hello MCP
|
|
41
50
|
await registry.close();
|
|
42
51
|
```
|
|
43
52
|
|
|
@@ -184,12 +193,20 @@ const pinned = await registry.connect('strict-server', {
|
|
|
184
193
|
|
|
185
194
|
After connecting, `client.getProtocolEra()` returns `'modern'` or `'legacy'` and `client.getNegotiatedProtocolVersion()` the revision the server settled on.
|
|
186
195
|
|
|
187
|
-
|
|
196
|
+
With `mode: 'auto'` against a stdio server, a legacy server that never answers the `server/discover` probe costs the full 60-second request timeout before the client falls back to the 2025 sequence. Any reply, including a "method not found" error, ends the probe.
|
|
188
197
|
|
|
189
198
|
## Requirements
|
|
190
199
|
|
|
191
|
-
- Node.js >=
|
|
200
|
+
- Node.js >= 20
|
|
201
|
+
|
|
202
|
+
## Agent skill
|
|
203
|
+
|
|
204
|
+
If a coding agent will use this package, install its agent guidance globally:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npx skills add https://github.com/mcp-z/client.git -g -s mcp-z-client
|
|
208
|
+
```
|
|
192
209
|
|
|
193
|
-
|
|
210
|
+
## Documentation
|
|
194
211
|
|
|
195
212
|
[API Docs](https://mcp-z.github.io/client)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-z/client",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Programmatic MCP client library for Node.js - connect, discover, and call tools on Model Context Protocol servers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
72
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
72
73
|
"@types/express": "^5.0.6",
|
|
73
74
|
"@types/mocha": "^10.0.10",
|
|
74
75
|
"@types/node": "^26.2.0",
|