@mcp-z/client 2.2.1 ā 2.2.2
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 +8 -0
- package/package.json +2 -3
- package/AGENTS.md +0 -159
package/README.md
CHANGED
|
@@ -16,6 +16,14 @@ npm install --save-dev @mcp-z/client
|
|
|
16
16
|
|
|
17
17
|
Requires Node.js >= 22.
|
|
18
18
|
|
|
19
|
+
## Agent skill
|
|
20
|
+
|
|
21
|
+
Install the repository's `mcp-z-client` skill globally when an agent will write code that consumes this package:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx skills add https://github.com/mcp-z/client.git -g -s mcp-z-client
|
|
25
|
+
```
|
|
26
|
+
|
|
19
27
|
## Quick start
|
|
20
28
|
|
|
21
29
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-z/client",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
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",
|
|
@@ -45,8 +45,7 @@
|
|
|
45
45
|
"types": "./dist/esm/index.d.ts",
|
|
46
46
|
"files": [
|
|
47
47
|
"dist",
|
|
48
|
-
"schemas"
|
|
49
|
-
"AGENTS.md"
|
|
48
|
+
"schemas"
|
|
50
49
|
],
|
|
51
50
|
"scripts": {
|
|
52
51
|
"build": "tsds validate",
|
package/AGENTS.md
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# MCP Examples for AI Agents
|
|
2
|
-
|
|
3
|
-
Quick-start examples for building scripts with MCP servers using `@mcp-z/client`.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @mcp-z/client
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Peek
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { createServerRegistry } from '@mcp-z/client';
|
|
15
|
-
|
|
16
|
-
const registry = createServerRegistry({ todoist: { url: 'https://ai.todoist.net/mcp' } });
|
|
17
|
-
const client = await registry.connect('todoist');
|
|
18
|
-
await client.callTool('add-tasks', { tasks: [{ content: 'My task', priority: 4 }] });
|
|
19
|
-
await registry.close();
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Full Example: Todoist Task Management
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
/**
|
|
26
|
-
* This example shows how to use @mcp-z/client to manage tasks via Todoist.
|
|
27
|
-
* Copy this and modify it for your needs!
|
|
28
|
-
*
|
|
29
|
-
* PREREQUISITES:
|
|
30
|
-
* npm install @mcp-z/client # the client library for typescript / javascript
|
|
31
|
-
* npm install @mcp-z/cli # the cli command is "mcpz". Run "mcpz --help" for a full list of commands
|
|
32
|
-
*
|
|
33
|
-
* DISCOVERY (find tools before writing code):
|
|
34
|
-
* npx @mcp-z/cli search "add task" # Find the tool you need
|
|
35
|
-
* npx @mcp-z/cli inspect --servers todoist # See all available tools
|
|
36
|
-
* npx @mcp-z/cli call-tool todoist add-tasks '{}' # Test it works
|
|
37
|
-
*
|
|
38
|
-
* TIP: Or load your own .mcp.json file instead of inline config:
|
|
39
|
-
* const config = JSON.parse(fs.readFileSync('.mcp.json', 'utf-8'));
|
|
40
|
-
* const registry = createServerRegistry(config.mcpServers);
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
import { createServerRegistry } from '@mcp-z/client';
|
|
44
|
-
|
|
45
|
-
// Configure your MCP servers (inline, or load from .mcp.json file)
|
|
46
|
-
const servers = {
|
|
47
|
-
todoist: {
|
|
48
|
-
url: 'https://ai.todoist.net/mcp'
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
async function main() {
|
|
53
|
-
const registry = createServerRegistry(servers);
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
console.log('š Connecting to Todoist...');
|
|
57
|
-
const client = await registry.connect('todoist');
|
|
58
|
-
|
|
59
|
-
console.log('ā
Connected! Adding task...');
|
|
60
|
-
|
|
61
|
-
// Add a task to Todoist
|
|
62
|
-
// See available tools: npx @mcp-z/cli inspect --servers todoist
|
|
63
|
-
await client.callTool('add-tasks', {
|
|
64
|
-
tasks: [
|
|
65
|
-
{
|
|
66
|
-
content: 'Learn MCP with @mcp-z/client',
|
|
67
|
-
projectId: undefined, // Optional: add to specific project
|
|
68
|
-
priority: 4 // 1-4, where 4 is highest
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
console.log('ā
Task added successfully!');
|
|
74
|
-
|
|
75
|
-
// List tasks (discovery first: npx @mcp-z/cli inspect --servers todoist)
|
|
76
|
-
console.log('\nš Fetching tasks...');
|
|
77
|
-
const findResponse = await client.callTool('find-tasks', {
|
|
78
|
-
searchText: 'Learn MCP'
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
console.log('ā
Tasks found:', findResponse.json());
|
|
82
|
-
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.error('ā Error:', error.message);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
} finally {
|
|
87
|
-
console.log('š Closing connection...');
|
|
88
|
-
await registry.close();
|
|
89
|
-
console.log('ā
Done!');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
main();
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## The Pattern
|
|
97
|
-
|
|
98
|
-
Once you understand this example, you understand them all:
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
import { createServerRegistry } from '@mcp-z/client';
|
|
102
|
-
|
|
103
|
-
const registry = createServerRegistry(servers); // Configure servers
|
|
104
|
-
try {
|
|
105
|
-
const client = await registry.connect('server-name'); // Connect
|
|
106
|
-
await client.callTool('tool-name', { /* args */ }); // Use tools
|
|
107
|
-
} finally {
|
|
108
|
-
await registry.close(); // Always cleanup
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**Configure servers inline or from `.mcp.json`:**
|
|
113
|
-
```javascript
|
|
114
|
-
// Inline config
|
|
115
|
-
const servers = { todoist: { url: '...' } };
|
|
116
|
-
|
|
117
|
-
// Or load from file
|
|
118
|
-
const config = JSON.parse(fs.readFileSync('.mcp.json', 'utf-8'));
|
|
119
|
-
const servers = config.mcpServers;
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Discovery Workflow
|
|
123
|
-
|
|
124
|
-
**Before writing code, discover what's available:**
|
|
125
|
-
|
|
126
|
-
1. **Search for tools:**
|
|
127
|
-
```bash
|
|
128
|
-
npx @mcp-z/cli search "add task"
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
2. **Inspect a server:**
|
|
132
|
-
```bash
|
|
133
|
-
npx @mcp-z/cli inspect --servers todoist
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
3. **Test a tool:**
|
|
137
|
-
```bash
|
|
138
|
-
npx @mcp-z/cli call-tool todoist add-tasks '{"tasks":[{"content":"Test"}]}'
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
4. **Write your script** using `@mcp-z/client`
|
|
142
|
-
|
|
143
|
-
## Available Public Servers
|
|
144
|
-
|
|
145
|
-
These servers don't need special setup - just use their URLs:
|
|
146
|
-
|
|
147
|
-
- **Todoist**: `https://ai.todoist.net/mcp`
|
|
148
|
-
- **Notion**: `https://mcp.notion.com/mcp`
|
|
149
|
-
|
|
150
|
-
Private servers (require authentication):
|
|
151
|
-
- Google Sheets, Drive, Gmail, Outlook, PDF (contact us for access)
|
|
152
|
-
|
|
153
|
-
## Need Help?
|
|
154
|
-
|
|
155
|
-
1. **Discover tools**: `npx @mcp-z/cli search <query>`
|
|
156
|
-
2. **See all tools**: `npx @mcp-z/cli inspect --servers <server>`
|
|
157
|
-
3. **Test first**: `npx @mcp-z/cli call-tool <server> <tool> '{}'`
|
|
158
|
-
|
|
159
|
-
Once you know a tool works via CLI, use it in your script with `@mcp-z/client`!
|