matimo 0.1.0-alpha.1 → 0.1.0-alpha.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 +83 -28
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +8 -3
- package/dist/core/schema.js.map +1 -1
- package/dist/core/tool-loader.d.ts.map +1 -1
- package/dist/core/tool-loader.js +15 -4
- package/dist/core/tool-loader.js.map +1 -1
- package/dist/core/tool-registry.d.ts.map +1 -1
- package/dist/core/tool-registry.js +5 -1
- package/dist/core/tool-registry.js.map +1 -1
- package/dist/decorators/tool-decorator.d.ts.map +1 -1
- package/dist/decorators/tool-decorator.js +7 -4
- package/dist/decorators/tool-decorator.js.map +1 -1
- package/dist/encodings/parameter-encoding.d.ts.map +1 -1
- package/dist/encodings/parameter-encoding.js +9 -2
- package/dist/encodings/parameter-encoding.js.map +1 -1
- package/dist/executors/command-executor.d.ts.map +1 -1
- package/dist/executors/command-executor.js +5 -1
- package/dist/executors/command-executor.js.map +1 -1
- package/dist/executors/http-executor.d.ts.map +1 -1
- package/dist/executors/http-executor.js +5 -1
- package/dist/executors/http-executor.js.map +1 -1
- package/package.json +4 -4
- package/tools/calculator/calculator.ts +78 -0
- package/tools/calculator/definition.yaml +71 -0
- package/tools/echo-tool/definition.yaml +35 -0
- package/tools/examples/calculator.yaml +54 -0
- package/tools/examples/echo-tool.yaml +35 -0
- package/tools/examples/http-client.yaml +66 -0
- package/tools/github/definition.yaml +41 -0
- package/tools/gmail/README.md +1189 -0
- package/tools/gmail/create-draft/definition.yaml +99 -0
- package/tools/gmail/definition.yaml +49 -0
- package/tools/gmail/delete-message/definition.yaml +42 -0
- package/tools/gmail/get-message/definition.yaml +89 -0
- package/tools/gmail/list-messages/definition.yaml +84 -0
- package/tools/gmail/send-email/definition.yaml +95 -0
- package/tools/http-client/definition.yaml +73 -0
- package/tools/slack/README.md +200 -0
- package/tools/slack/assets/icon.svg +9 -0
- package/tools/slack/assets/logo-dark.svg +14 -0
- package/tools/slack/assets/logo-light.svg +14 -0
- package/tools/slack/assets/logo.svg +14 -0
- package/tools/slack/definition.yaml +54 -0
- package/tools/slack/get-user/definition.yaml +31 -0
- package/tools/slack/list-channels/definition.yaml +46 -0
- package/tools/slack/send-message/definition.yaml +30 -0
- package/tools/slack/slack_add_reaction/definition.yaml +45 -0
- package/tools/slack/slack_create_channel/definition.yaml +41 -0
- package/tools/slack/slack_get_channel_history/definition.yaml +58 -0
- package/tools/slack/slack_get_reactions/definition.yaml +36 -0
- package/tools/slack/slack_get_thread_replies/definition.yaml +45 -0
- package/tools/slack/slack_get_user_info/definition.yaml +32 -0
- package/tools/slack/slack_join_channel/definition.yaml +35 -0
- package/tools/slack/slack_reply_to_message/definition.yaml +49 -0
- package/tools/slack/slack_search_messages/definition.yaml +46 -0
- package/tools/slack/slack_send_channel_message/definition.yaml +34 -0
- package/tools/slack/slack_send_dm/definition.yaml +37 -0
- package/tools/slack/slack_set_channel_topic/definition.yaml +40 -0
- package/tools/slack/slack_upload_file/definition.yaml +152 -0
- package/docs/Gemfile +0 -5
- package/docs/RELEASES.md +0 -69
- package/docs/ROADMAP.md +0 -138
- package/docs/_config.yml +0 -27
- package/docs/api-reference/ERRORS.md +0 -445
- package/docs/api-reference/SDK.md +0 -582
- package/docs/api-reference/TYPES.md +0 -415
- package/docs/architecture/OAUTH.md +0 -1366
- package/docs/architecture/OVERVIEW.md +0 -564
- package/docs/assets/logo.png +0 -0
- package/docs/community/COMMIT_GUIDELINES.md +0 -552
- package/docs/framework-integrations/LANGCHAIN.md +0 -286
- package/docs/getting-started/QUICK_START.md +0 -211
- package/docs/getting-started/YOUR_FIRST_TOOL.md +0 -217
- package/docs/getting-started/installation.md +0 -124
- package/docs/index.md +0 -288
- package/docs/tool-development/DECORATOR_GUIDE.md +0 -633
- package/docs/tool-development/OAUTH_LINK.md +0 -5
- package/docs/tool-development/PROVIDER_CONFIGURATION.md +0 -458
- package/docs/tool-development/TESTING.md +0 -412
- package/docs/tool-development/TOOL_SPECIFICATION.md +0 -793
- package/docs/tool-development/YAML_TOOLS.md +0 -65
- package/docs/troubleshooting/FAQ.md +0 -391
- package/docs/user-guide/AUTHENTICATION.md +0 -255
- package/docs/user-guide/DEVELOPMENT_STANDARDS.md +0 -698
- package/docs/user-guide/SDK_PATTERNS.md +0 -316
- package/docs/user-guide/TOOL_DISCOVERY.md +0 -209
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
# SDK Usage Patterns
|
|
2
|
-
|
|
3
|
-
Learn the two main ways to use Matimo SDK in v0.1.0-alpha.1.
|
|
4
|
-
|
|
5
|
-
## Pattern 1: Factory Pattern (Recommended for Simple Use Cases)
|
|
6
|
-
|
|
7
|
-
The factory pattern is the simplest and most ergonomic way to use Matimo.
|
|
8
|
-
|
|
9
|
-
### Basic Setup
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { matimo } from 'matimo';
|
|
13
|
-
|
|
14
|
-
// Initialize once
|
|
15
|
-
const m = await matimo.init('./tools');
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
### Execute a Tool
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
const result = await m.execute('calculator', {
|
|
22
|
-
operation: 'add',
|
|
23
|
-
a: 5,
|
|
24
|
-
b: 3
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
console.log(result); // { result: 8 }
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Discover Tools
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
// List all tools
|
|
34
|
-
const allTools = m.listTools();
|
|
35
|
-
console.log(`Loaded ${allTools.length} tools`);
|
|
36
|
-
|
|
37
|
-
// Get specific tool
|
|
38
|
-
const tool = m.getTool('calculator');
|
|
39
|
-
console.log(`Tool: ${tool.name} - ${tool.description}`);
|
|
40
|
-
|
|
41
|
-
// Filter by tags
|
|
42
|
-
const mathTools = m.getToolsByTag('math');
|
|
43
|
-
mathTools.forEach(t => console.log(`- ${t.name}`));
|
|
44
|
-
|
|
45
|
-
// Search tools
|
|
46
|
-
const results = m.searchTools('email');
|
|
47
|
-
results.forEach(t => console.log(`Found: ${t.name}`));
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Handle Errors
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
try {
|
|
54
|
-
const result = await m.execute('calculator', {
|
|
55
|
-
operation: 'divide',
|
|
56
|
-
a: 10,
|
|
57
|
-
b: 0 // ⚠️ Will fail
|
|
58
|
-
});
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (error.code === 'TOOL_NOT_FOUND') {
|
|
61
|
-
console.error('Tool not available:', error.message);
|
|
62
|
-
} else if (error.code === 'INVALID_PARAMETERS') {
|
|
63
|
-
console.error('Bad parameters:', error.details);
|
|
64
|
-
} else if (error.code === 'EXECUTION_FAILED') {
|
|
65
|
-
console.error('Tool error:', error.details);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Complete Example
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { matimo } from 'matimo';
|
|
74
|
-
|
|
75
|
-
async function main() {
|
|
76
|
-
try {
|
|
77
|
-
// 1. Initialize
|
|
78
|
-
const m = await matimo.init('./tools');
|
|
79
|
-
|
|
80
|
-
// 2. List available tools
|
|
81
|
-
const tools = m.listTools();
|
|
82
|
-
console.log(`📦 Loaded ${tools.length} tools`);
|
|
83
|
-
|
|
84
|
-
// 3. Execute tool
|
|
85
|
-
const result = await m.execute('gmail-send-email', {
|
|
86
|
-
to: 'recipient@example.com',
|
|
87
|
-
subject: 'Hello',
|
|
88
|
-
body: 'Message from Matimo'
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
console.log('✅ Email sent:', result);
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error('❌ Error:', error.message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
main();
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Pattern 2: Decorator Pattern (Recommended for Class-Based Code)
|
|
103
|
-
|
|
104
|
-
The decorator pattern is ideal for class-based agents and applications.
|
|
105
|
-
|
|
106
|
-
### Basic Setup
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
import { tool, matimo } from 'matimo';
|
|
110
|
-
|
|
111
|
-
// Initialize Matimo
|
|
112
|
-
const matimoInstance = await matimo.init('./tools');
|
|
113
|
-
|
|
114
|
-
// Create agent class
|
|
115
|
-
class EmailAgent {
|
|
116
|
-
constructor(private matimoInstance: any) {}
|
|
117
|
-
|
|
118
|
-
@tool('gmail-send-email')
|
|
119
|
-
async sendEmail(to: string, subject: string, body: string) {
|
|
120
|
-
// Decorator handles execution
|
|
121
|
-
// Method body is optional - decorator does the work
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@tool('gmail-list-messages')
|
|
125
|
-
async listEmails(maxResults?: number) {
|
|
126
|
-
// Executed by decorator
|
|
127
|
-
// Return type inferred from tool definition
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Use it
|
|
132
|
-
const agent = new EmailAgent(matimoInstance);
|
|
133
|
-
|
|
134
|
-
// Call decorated methods
|
|
135
|
-
await agent.sendEmail(
|
|
136
|
-
'john@example.com',
|
|
137
|
-
'Hello John',
|
|
138
|
-
'This is a test email'
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const emails = await agent.listEmails(10);
|
|
142
|
-
console.log(`Found ${emails.length} emails`);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Advanced: Custom Agent with Multiple Tools
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
import { tool, matimo } from 'matimo';
|
|
149
|
-
|
|
150
|
-
class AIAssistant {
|
|
151
|
-
constructor(private matimo: any) {}
|
|
152
|
-
|
|
153
|
-
@tool('calculator')
|
|
154
|
-
async calculate(operation: string, a: number, b: number) {
|
|
155
|
-
// Decorator auto-executes the calculator tool
|
|
156
|
-
// Argument order matches tool parameters
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
@tool('gmail-send-email')
|
|
160
|
-
async sendEmail(to: string, subject: string, body: string) {
|
|
161
|
-
// Send emails as part of workflow
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
@tool('gmail-list-messages')
|
|
165
|
-
async checkEmails(maxResults?: number) {
|
|
166
|
-
// List emails
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Custom methods that use tools
|
|
170
|
-
async runWorkflow(userEmail: string) {
|
|
171
|
-
// Orchestrate tool calls
|
|
172
|
-
const emails = await this.checkEmails(5);
|
|
173
|
-
console.log(`Checking ${emails.length} latest emails`);
|
|
174
|
-
|
|
175
|
-
if (emails.length > 0) {
|
|
176
|
-
await this.sendEmail(
|
|
177
|
-
userEmail,
|
|
178
|
-
'Daily Summary',
|
|
179
|
-
`You have ${emails.length} unread emails`
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Usage
|
|
186
|
-
const matimo = await matimo.init('./tools');
|
|
187
|
-
const assistant = new AIAssistant(matimo);
|
|
188
|
-
|
|
189
|
-
await assistant.runWorkflow('user@example.com');
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## Comparison: Factory vs Decorator
|
|
195
|
-
|
|
196
|
-
| Feature | Factory | Decorator |
|
|
197
|
-
|---------|---------|-----------|
|
|
198
|
-
| **Simplicity** | Simple | Requires classes |
|
|
199
|
-
| **Best For** | Scripts, backends | Agents, complex apps |
|
|
200
|
-
| **Syntax** | `m.execute()` | `@tool()` |
|
|
201
|
-
| **Type Safety** | Good | Excellent |
|
|
202
|
-
| **Framework Fit** | Any | Class-based |
|
|
203
|
-
| **Async/Await** | Required | Required |
|
|
204
|
-
| **Error Handling** | Try/catch | Try/catch |
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## Using Matimo with AI Frameworks
|
|
209
|
-
|
|
210
|
-
For intelligent tool orchestration with LangChain, CrewAI, Claude SDK, or other AI frameworks where the LLM automatically decides which tool to use, see:
|
|
211
|
-
|
|
212
|
-
- **[LangChain Integration Guide](../framework-integrations/LANGCHAIN.md)** — Complete patterns with LangChain
|
|
213
|
-
- Official API pattern (recommended)
|
|
214
|
-
- Decorator pattern with LangChain
|
|
215
|
-
- Factory pattern with LangChain
|
|
216
|
-
- Working examples with GPT-4
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## Patterns in Different Contexts
|
|
221
|
-
|
|
222
|
-
### Backend API
|
|
223
|
-
|
|
224
|
-
```typescript
|
|
225
|
-
// Express.js route handler
|
|
226
|
-
import { matimo } from 'matimo';
|
|
227
|
-
|
|
228
|
-
const m = await matimo.init('./tools');
|
|
229
|
-
|
|
230
|
-
app.post('/api/send-email', async (req, res) => {
|
|
231
|
-
try {
|
|
232
|
-
const result = await m.execute('gmail-send-email', {
|
|
233
|
-
to: req.body.to,
|
|
234
|
-
subject: req.body.subject,
|
|
235
|
-
body: req.body.body
|
|
236
|
-
});
|
|
237
|
-
res.json({ success: true, result });
|
|
238
|
-
} catch (error) {
|
|
239
|
-
res.status(400).json({ error: error.message });
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### LangChain Agent
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
// See LANGCHAIN.md for full integration
|
|
248
|
-
const m = await matimo.init('./tools');
|
|
249
|
-
|
|
250
|
-
const langchainTools = m.listTools().map(tool => ({
|
|
251
|
-
name: tool.name,
|
|
252
|
-
description: tool.description,
|
|
253
|
-
run: async (input) => {
|
|
254
|
-
const result = await m.execute(tool.name, JSON.parse(input));
|
|
255
|
-
return JSON.stringify(result);
|
|
256
|
-
}
|
|
257
|
-
}));
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### CLI Tool
|
|
261
|
-
|
|
262
|
-
```typescript
|
|
263
|
-
// Command-line interface
|
|
264
|
-
import { matimo } from 'matimo';
|
|
265
|
-
|
|
266
|
-
const m = await matimo.init('./tools');
|
|
267
|
-
|
|
268
|
-
const toolName = process.argv[2];
|
|
269
|
-
const params = JSON.parse(process.argv[3] || '{}');
|
|
270
|
-
|
|
271
|
-
const result = await m.execute(toolName, params);
|
|
272
|
-
console.log(JSON.stringify(result, null, 2));
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## Error Handling Best Practices
|
|
278
|
-
|
|
279
|
-
```typescript
|
|
280
|
-
import { MatimoError } from 'matimo';
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
const result = await m.execute('calculator', params);
|
|
284
|
-
} catch (error) {
|
|
285
|
-
if (error instanceof MatimoError) {
|
|
286
|
-
// Handle Matimo-specific errors
|
|
287
|
-
switch (error.code) {
|
|
288
|
-
case 'TOOL_NOT_FOUND':
|
|
289
|
-
console.error(`Tool not available: ${error.message}`);
|
|
290
|
-
break;
|
|
291
|
-
case 'INVALID_PARAMETERS':
|
|
292
|
-
console.error(`Bad parameters: ${JSON.stringify(error.details)}`);
|
|
293
|
-
break;
|
|
294
|
-
case 'EXECUTION_FAILED':
|
|
295
|
-
console.error(`Execution failed: ${error.details}`);
|
|
296
|
-
break;
|
|
297
|
-
default:
|
|
298
|
-
console.error(`Unknown error: ${error.message}`);
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
// Handle other errors
|
|
302
|
-
console.error('Unexpected error:', error);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
---
|
|
308
|
-
|
|
309
|
-
## Next Steps
|
|
310
|
-
|
|
311
|
-
- **[Tool Discovery Guide](./TOOL_DISCOVERY.md)** — More on finding tools
|
|
312
|
-
- **[LangChain Integration](../framework-integrations/LANGCHAIN.md)** — Using with LangChain
|
|
313
|
-
- **[Decorator Pattern Guide](../tool-development/DECORATOR_GUIDE.md)** — Deep dive on decorators
|
|
314
|
-
- **[API Reference](../api-reference/SDK.md)** — Complete API docs
|
|
315
|
-
|
|
316
|
-
See [examples/](../../examples/) for working code.
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# Tool Discovery & Filtering
|
|
2
|
-
|
|
3
|
-
Find and filter tools by name, description, and tags.
|
|
4
|
-
|
|
5
|
-
## List All Tools
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { matimo } from 'matimo';
|
|
9
|
-
|
|
10
|
-
const m = await matimo.init('./tools');
|
|
11
|
-
|
|
12
|
-
// List all loaded tools
|
|
13
|
-
const allTools = m.listTools();
|
|
14
|
-
console.log(`Loaded ${allTools.length} tools`);
|
|
15
|
-
|
|
16
|
-
allTools.forEach(tool => {
|
|
17
|
-
console.log(`• ${tool.name} - ${tool.description}`);
|
|
18
|
-
});
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
**Output:**
|
|
22
|
-
```
|
|
23
|
-
Loaded 8 tools
|
|
24
|
-
• calculator - Perform basic math operations
|
|
25
|
-
• gmail-send-email - Send an email via Gmail API
|
|
26
|
-
• gmail-list-messages - List emails from Gmail
|
|
27
|
-
• github-create-issue - Create a GitHub issue
|
|
28
|
-
... (more tools)
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Get Specific Tool
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
const tool = m.getTool('calculator');
|
|
37
|
-
|
|
38
|
-
console.log(`Name: ${tool.name}`);
|
|
39
|
-
console.log(`Description: ${tool.description}`);
|
|
40
|
-
console.log(`Version: ${tool.version}`);
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## Filter by Tags
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// Get tools with specific tags
|
|
49
|
-
const mathTools = m.getToolsByTag('math');
|
|
50
|
-
console.log(`Math tools: ${mathTools.map(t => t.name).join(', ')}`);
|
|
51
|
-
|
|
52
|
-
const emailTools = m.getToolsByTag('email');
|
|
53
|
-
console.log(`Email tools: ${emailTools.map(t => t.name).join(', ')}`);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Search Tools
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
// Search by name or description
|
|
62
|
-
const results = m.searchTools('email');
|
|
63
|
-
|
|
64
|
-
results.forEach(tool => {
|
|
65
|
-
console.log(`Found: ${tool.name}`);
|
|
66
|
-
console.log(` Description: ${tool.description}`);
|
|
67
|
-
console.log(` Tags: ${tool.tags?.join(', ') || 'none'}`);
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**Output:**
|
|
72
|
-
```
|
|
73
|
-
Found: gmail-send-email
|
|
74
|
-
Description: Send an email via Gmail API
|
|
75
|
-
Tags: email, gmail, http
|
|
76
|
-
|
|
77
|
-
Found: gmail-list-messages
|
|
78
|
-
Description: List emails from Gmail
|
|
79
|
-
Tags: email, gmail, http
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Filter Criteria
|
|
85
|
-
|
|
86
|
-
### By Type
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
// Filter by execution type
|
|
90
|
-
const httpTools = m.listTools().filter(t => t.execution?.type === 'http');
|
|
91
|
-
console.log(`HTTP tools: ${httpTools.length}`);
|
|
92
|
-
|
|
93
|
-
const cmdTools = m.listTools().filter(t => t.execution?.type === 'command');
|
|
94
|
-
console.log(`Command tools: ${cmdTools.length}`);
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### By Authentication
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
// Tools requiring OAuth2
|
|
101
|
-
const oauth2Tools = m.listTools().filter(t => t.authentication?.type === 'oauth2');
|
|
102
|
-
console.log(`OAuth2 tools: ${oauth2Tools.map(t => t.name).join(', ')}`);
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### By Provider
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
// Gmail tools
|
|
109
|
-
const gmailTools = m.listTools().filter(t => t.name.startsWith('gmail-'));
|
|
110
|
-
console.log(`Gmail tools: ${gmailTools.map(t => t.name).join(', ')}`);
|
|
111
|
-
|
|
112
|
-
// GitHub tools
|
|
113
|
-
const githubTools = m.listTools().filter(t => t.name.startsWith('github-'));
|
|
114
|
-
console.log(`GitHub tools: ${githubTools.map(t => t.name).join(', ')}`);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Tool Metadata
|
|
120
|
-
|
|
121
|
-
Each tool has:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
const tool = m.getTool('calculator');
|
|
125
|
-
|
|
126
|
-
// Basic info
|
|
127
|
-
tool.name // 'calculator'
|
|
128
|
-
tool.description // 'Perform basic math operations'
|
|
129
|
-
tool.version // '1.0.0'
|
|
130
|
-
|
|
131
|
-
// Parameters
|
|
132
|
-
tool.parameters // { operation: {...}, a: {...}, b: {...} }
|
|
133
|
-
Object.keys(tool.parameters) // ['operation', 'a', 'b']
|
|
134
|
-
|
|
135
|
-
// Execution config
|
|
136
|
-
tool.execution.type // 'command' | 'http'
|
|
137
|
-
tool.execution.command // shell command (if type === 'command')
|
|
138
|
-
tool.execution.url // API endpoint (if type === 'http')
|
|
139
|
-
|
|
140
|
-
// Authentication
|
|
141
|
-
tool.authentication?.type // 'oauth2' | 'api_key' | etc.
|
|
142
|
-
tool.authentication?.provider // 'google' | 'github' | 'slack'
|
|
143
|
-
|
|
144
|
-
// Output
|
|
145
|
-
tool.output_schema // { type: 'object', properties: {...} }
|
|
146
|
-
|
|
147
|
-
// Metadata
|
|
148
|
-
tool.tags // ['math', 'calculator']
|
|
149
|
-
tool.author // 'Matimo'
|
|
150
|
-
tool.license // 'MIT'
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## Common Use Cases
|
|
156
|
-
|
|
157
|
-
### Find All Email Tools
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
const emailTools = m.listTools()
|
|
161
|
-
.filter(t => t.tags?.includes('email'));
|
|
162
|
-
|
|
163
|
-
emailTools.forEach(tool => {
|
|
164
|
-
console.log(`- ${tool.name}: ${tool.description}`);
|
|
165
|
-
});
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Find Tools Without Authentication
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
const publicTools = m.listTools()
|
|
172
|
-
.filter(t => !t.authentication);
|
|
173
|
-
|
|
174
|
-
console.log(`Public tools (no auth required):`);
|
|
175
|
-
publicTools.forEach(t => console.log(` - ${t.name}`));
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Find Tools Requiring OAuth2
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
const oauth2Tools = m.listTools()
|
|
182
|
-
.filter(t => t.authentication?.type === 'oauth2');
|
|
183
|
-
|
|
184
|
-
console.log(`Tools requiring OAuth2:`);
|
|
185
|
-
oauth2Tools.forEach(t => {
|
|
186
|
-
console.log(` - ${t.name} (${t.authentication?.provider})`);
|
|
187
|
-
});
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### List All Providers
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
const providers = new Set(
|
|
194
|
-
m.listTools()
|
|
195
|
-
.filter(t => t.authentication?.provider)
|
|
196
|
-
.map(t => t.authentication?.provider)
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
console.log(`Available providers: ${Array.from(providers).join(', ')}`);
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## Next Steps
|
|
205
|
-
|
|
206
|
-
- **Execute Tools**: [Your First Tool](../getting-started/YOUR_FIRST_TOOL.md)
|
|
207
|
-
- **Learn Patterns**: [SDK Usage Patterns](./SDK_PATTERNS.md)
|
|
208
|
-
- **Setup OAuth2**: [Authentication Guide](./AUTHENTICATION.md)
|
|
209
|
-
|