matimo 0.1.0-alpha.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.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +651 -0
  3. package/dist/auth/oauth2-config.d.ts +104 -0
  4. package/dist/auth/oauth2-config.d.ts.map +1 -0
  5. package/dist/auth/oauth2-config.js +38 -0
  6. package/dist/auth/oauth2-config.js.map +1 -0
  7. package/dist/auth/oauth2-handler.d.ts +130 -0
  8. package/dist/auth/oauth2-handler.d.ts.map +1 -0
  9. package/dist/auth/oauth2-handler.js +265 -0
  10. package/dist/auth/oauth2-handler.js.map +1 -0
  11. package/dist/auth/oauth2-provider-loader.d.ts +68 -0
  12. package/dist/auth/oauth2-provider-loader.d.ts.map +1 -0
  13. package/dist/auth/oauth2-provider-loader.js +120 -0
  14. package/dist/auth/oauth2-provider-loader.js.map +1 -0
  15. package/dist/core/schema.d.ts +238 -0
  16. package/dist/core/schema.d.ts.map +1 -0
  17. package/dist/core/schema.js +168 -0
  18. package/dist/core/schema.js.map +1 -0
  19. package/dist/core/tool-loader.d.ts +29 -0
  20. package/dist/core/tool-loader.d.ts.map +1 -0
  21. package/dist/core/tool-loader.js +98 -0
  22. package/dist/core/tool-loader.js.map +1 -0
  23. package/dist/core/tool-registry.d.ts +48 -0
  24. package/dist/core/tool-registry.d.ts.map +1 -0
  25. package/dist/core/tool-registry.js +89 -0
  26. package/dist/core/tool-registry.js.map +1 -0
  27. package/dist/core/types.d.ts +143 -0
  28. package/dist/core/types.d.ts.map +1 -0
  29. package/dist/core/types.js +5 -0
  30. package/dist/core/types.js.map +1 -0
  31. package/dist/decorators/index.d.ts +2 -0
  32. package/dist/decorators/index.d.ts.map +1 -0
  33. package/dist/decorators/index.js +2 -0
  34. package/dist/decorators/index.js.map +1 -0
  35. package/dist/decorators/tool-decorator.d.ts +97 -0
  36. package/dist/decorators/tool-decorator.d.ts.map +1 -0
  37. package/dist/decorators/tool-decorator.js +154 -0
  38. package/dist/decorators/tool-decorator.js.map +1 -0
  39. package/dist/encodings/parameter-encoding.d.ts +51 -0
  40. package/dist/encodings/parameter-encoding.d.ts.map +1 -0
  41. package/dist/encodings/parameter-encoding.js +116 -0
  42. package/dist/encodings/parameter-encoding.js.map +1 -0
  43. package/dist/errors/matimo-error.d.ts +34 -0
  44. package/dist/errors/matimo-error.d.ts.map +1 -0
  45. package/dist/errors/matimo-error.js +49 -0
  46. package/dist/errors/matimo-error.js.map +1 -0
  47. package/dist/executors/command-executor.d.ts +19 -0
  48. package/dist/executors/command-executor.d.ts.map +1 -0
  49. package/dist/executors/command-executor.js +94 -0
  50. package/dist/executors/command-executor.js.map +1 -0
  51. package/dist/executors/http-executor.d.ts +26 -0
  52. package/dist/executors/http-executor.d.ts.map +1 -0
  53. package/dist/executors/http-executor.js +133 -0
  54. package/dist/executors/http-executor.js.map +1 -0
  55. package/dist/index.d.ts +22 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +23 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/matimo-instance.d.ts +98 -0
  60. package/dist/matimo-instance.d.ts.map +1 -0
  61. package/dist/matimo-instance.js +260 -0
  62. package/dist/matimo-instance.js.map +1 -0
  63. package/docs/Gemfile +5 -0
  64. package/docs/RELEASES.md +69 -0
  65. package/docs/ROADMAP.md +138 -0
  66. package/docs/_config.yml +27 -0
  67. package/docs/api-reference/ERRORS.md +445 -0
  68. package/docs/api-reference/SDK.md +582 -0
  69. package/docs/api-reference/TYPES.md +415 -0
  70. package/docs/architecture/OAUTH.md +1366 -0
  71. package/docs/architecture/OVERVIEW.md +564 -0
  72. package/docs/assets/logo.png +0 -0
  73. package/docs/community/COMMIT_GUIDELINES.md +552 -0
  74. package/docs/framework-integrations/LANGCHAIN.md +286 -0
  75. package/docs/getting-started/QUICK_START.md +211 -0
  76. package/docs/getting-started/YOUR_FIRST_TOOL.md +217 -0
  77. package/docs/getting-started/installation.md +124 -0
  78. package/docs/index.md +288 -0
  79. package/docs/tool-development/DECORATOR_GUIDE.md +633 -0
  80. package/docs/tool-development/OAUTH_LINK.md +5 -0
  81. package/docs/tool-development/PROVIDER_CONFIGURATION.md +458 -0
  82. package/docs/tool-development/TESTING.md +412 -0
  83. package/docs/tool-development/TOOL_SPECIFICATION.md +793 -0
  84. package/docs/tool-development/YAML_TOOLS.md +65 -0
  85. package/docs/troubleshooting/FAQ.md +391 -0
  86. package/docs/user-guide/AUTHENTICATION.md +255 -0
  87. package/docs/user-guide/DEVELOPMENT_STANDARDS.md +698 -0
  88. package/docs/user-guide/SDK_PATTERNS.md +316 -0
  89. package/docs/user-guide/TOOL_DISCOVERY.md +209 -0
  90. package/package.json +96 -0
@@ -0,0 +1,138 @@
1
+ # Matimo Roadmap
2
+
3
+ ## v0.1.0-alpha.1 (Current Release)
4
+
5
+ ### ✅ Core Features Implemented
6
+
7
+ **OAuth2 Authentication**
8
+ - OAuth2 handler with token management
9
+ - Provider-agnostic configuration via YAML
10
+ - Multi-provider support (Google, GitHub, Slack)
11
+ - Token injection system for tools
12
+
13
+ **Tool System**
14
+ - YAML-based tool definitions with Zod validation
15
+ - Tool loader and registry
16
+ - Command executor (shell commands + templating)
17
+ - HTTP executor (REST APIs with OAuth2 support)
18
+ - Parameter encoding utilities
19
+
20
+ **SDK Patterns**
21
+ - Factory pattern (recommended for simple use cases)
22
+ - Decorator pattern (@tool decorators for class-based code)
23
+ - Tool discovery and filtering
24
+ - Full TypeScript type safety (zero `any` types)
25
+
26
+ **Tool Examples**
27
+ - Gmail tools (list, get, send, create-draft, delete)
28
+ - GitHub provider configuration
29
+ - Slack provider configuration
30
+ - Calculator and echo tools (reference implementations)
31
+
32
+ **Quality Assurance**
33
+ - 100% test passing
34
+ - Full TypeScript strict mode enforcement
35
+ - ESLint clean with zero warnings
36
+ - Prettier formatting
37
+ - Zod schema validation for all definitions
38
+
39
+ **Documentation**
40
+ - Quick start guide
41
+ - API reference
42
+ - Tool specification
43
+ - OAuth2 implementation guide
44
+ - Decorator pattern guide
45
+ - Contributing guide
46
+ - Security guidelines
47
+
48
+ ---
49
+
50
+ ## Future Release (not in specific order)
51
+
52
+ ### 🔜 Planned Features
53
+
54
+ **CLI Tool**
55
+ - `matimo list` - List all tools
56
+ - `matimo execute` - Execute tools from command line
57
+ - `matimo validate` - Validate tool YAML files
58
+ - `matimo test` - Test tool execution locally
59
+
60
+ **MCP (Model Context Protocol) Server**
61
+ - Native MCP server
62
+ - Tool discovery via MCP
63
+ - Automatic tool calling
64
+ - Session management
65
+
66
+ **Framework Integrations**
67
+ - CrewAI integration examples
68
+ - Vercel AI SDK integration
69
+ - Custom framework patterns
70
+ - Framework-specific documentation
71
+
72
+ **Advanced Features**
73
+ - Rate limiting (token bucket algorithm)
74
+ - Health monitoring (API schema drift detection)
75
+ - Token refresh automation
76
+ - Error recovery strategies
77
+
78
+ **REST API Server**
79
+ - HTTP endpoints for tool execution
80
+ - Async job execution
81
+ - Webhook support
82
+ - OpenAPI documentation
83
+
84
+ **Python SDK**
85
+ - Python implementation with same YAML definitions
86
+ - LangChain Python integration
87
+ - CrewAI Python support
88
+ - Feature parity with Node.js SDK
89
+
90
+ **Tool Marketplace**
91
+ - Distributed tool registry
92
+ - Tool publishing and versioning
93
+ - Community tool submissions
94
+ - Tool ratings and reviews
95
+
96
+ **Deployment**
97
+ - Docker images and Dockerfile examples
98
+ - Kubernetes deployment guides
99
+ - CI/CD integration examples
100
+ - Production deployment patterns
101
+
102
+ **Ecosystem Maturity**
103
+ - Automated schema translation (OpenAPI → Matimo YAML)
104
+ - Performance optimizations
105
+ - Enterprise features (audit logs, rate limiting)
106
+
107
+ **Skills/Workflows**
108
+ - Tool composition/chaining
109
+ - Conditional execution
110
+ - Error handling workflows
111
+ - Advanced orchestration
112
+
113
+
114
+ ## How to Use This Roadmap
115
+
116
+ - **v0.1.0-alpha.1**: Use current implementation for OAuth2, tool execution, and SDK patterns
117
+ - **Future Releases**: These are planned but not yet implemented. Contributions welcome!
118
+ - **Contributing**: See [CONTRIBUTING.md](../CONTRIBUTING.md) for how to help
119
+
120
+ ---
121
+
122
+ ## Release Thoughts
123
+
124
+ ```
125
+ v0.1.0-alpha.1 Feb 2026 (Current)
126
+
127
+ v0.1.0-alpha.2 3rd week Feb 2026.
128
+
129
+ v0.1.0-alpha.3 1st week Mar 2026.
130
+
131
+ v0.1.0 End of March 2026.
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Contributing to the Roadmap
137
+
138
+ Have ideas? [Open a GitHub Discussion](https://github.com/tallclub/matimo/discussions) to propose features for future releases.
@@ -0,0 +1,27 @@
1
+ theme: jekyll-theme-slate
2
+ title: Matimo - AI Tools Ecosystem
3
+ description: Define tools once in YAML, use them everywhere
4
+ show_downloads: true
5
+ google_analytics: false
6
+
7
+ # Matimo Documentation
8
+ url: "https://tallclub.github.io"
9
+ baseurl: "/matimo"
10
+ repository: "tallclub/matimo"
11
+
12
+ # Build settings
13
+ markdown: kramdown
14
+ highlighter: rouge
15
+
16
+ # Navigation
17
+ nav:
18
+ - text: "Home"
19
+ url: "/"
20
+ - text: "Getting Started"
21
+ url: "/getting-started/"
22
+ - text: "Documentation"
23
+ url: "/"
24
+ - text: "GitHub"
25
+ url: "https://github.com/tallclub/matimo"
26
+ - text: "npm"
27
+ url: "https://www.npmjs.com/package/matimo"
@@ -0,0 +1,445 @@
1
+ # API Error Codes Reference
2
+
3
+ Complete reference of error codes returned by Matimo SDK.
4
+
5
+ ## Central Error Management
6
+
7
+ Matimo uses a centralized error handling system via the `MatimoError` class defined in `src/errors/matimo-error.ts`. This ensures consistent error handling across all SDK operations.
8
+
9
+ ### MatimoError Class
10
+
11
+ All Matimo errors extend the native `Error` class and include:
12
+
13
+ ```typescript
14
+ import { MatimoError, ErrorCode } from 'matimo';
15
+
16
+ class MatimoError extends Error {
17
+ code: ErrorCode; // Machine-readable error code
18
+ details?: Record<string, unknown>; // Additional context
19
+
20
+ toJSON(): Record<string, unknown>; // Serialize to JSON
21
+ }
22
+ ```
23
+
24
+ **Key Benefits:**
25
+ - **Centralized Definition**: All error codes defined in one place (`ErrorCode` enum)
26
+ - **Type-Safe**: TypeScript enum ensures only valid error codes can be thrown
27
+ - **Serializable**: `toJSON()` method for logging and API responses
28
+ - **Extensible**: Details object captures context-specific information
29
+ - **Consistent**: Same error structure across all SDK methods
30
+
31
+ ### Error Codes Enum
32
+
33
+ All 11 error codes are defined in the `ErrorCode` enum:
34
+
35
+ ```typescript
36
+ export enum ErrorCode {
37
+ INVALID_SCHEMA = 'INVALID_SCHEMA', // Tool definition validation failed
38
+ EXECUTION_FAILED = 'EXECUTION_FAILED', // Tool execution error
39
+ AUTH_FAILED = 'AUTH_FAILED', // Authentication/token error
40
+ TOOL_NOT_FOUND = 'TOOL_NOT_FOUND', // Tool not in registry
41
+ FILE_NOT_FOUND = 'FILE_NOT_FOUND', // File/directory missing
42
+ VALIDATION_FAILED = 'VALIDATION_FAILED', // Parameter validation error
43
+ RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED', // API rate limit hit
44
+ TIMEOUT = 'TIMEOUT', // Operation timeout
45
+ NETWORK_ERROR = 'NETWORK_ERROR', // Network/connection error
46
+ INVALID_PARAMETER = 'INVALID_PARAMETER', // Invalid parameter value
47
+ UNKNOWN_ERROR = 'UNKNOWN_ERROR', // Unknown error
48
+ }
49
+ ```
50
+
51
+ ### Creating Errors
52
+
53
+ Matimo provides helper functions for common error types:
54
+
55
+ ```typescript
56
+ import {
57
+ createValidationError,
58
+ createExecutionError,
59
+ MatimoError,
60
+ ErrorCode
61
+ } from 'matimo';
62
+
63
+ // Using helpers
64
+ const validationErr = createValidationError(
65
+ 'Missing required parameter',
66
+ { param: 'email' }
67
+ );
68
+
69
+ const executionErr = createExecutionError(
70
+ 'Tool returned error 500',
71
+ { statusCode: 500, tool: 'gmail-send' }
72
+ );
73
+
74
+ // Direct instantiation
75
+ const authErr = new MatimoError(
76
+ 'Missing API token',
77
+ ErrorCode.AUTH_FAILED,
78
+ { env: 'GMAIL_ACCESS_TOKEN' }
79
+ );
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Error Structure
85
+
86
+ All Matimo errors follow this structure (via `MatimoError`):
87
+
88
+ ```typescript
89
+ {
90
+ name: 'MatimoError'; // Error class name
91
+ message: string; // Human-readable message
92
+ code: ErrorCode; // Error code enum value
93
+ details?: object; // Additional context
94
+ }
95
+ ```
96
+
97
+ **Example:**
98
+ ```typescript
99
+ import { MatimoError, ErrorCode } from 'matimo';
100
+
101
+ try {
102
+ await m.execute('unknown-tool', {});
103
+ } catch (error) {
104
+ if (error instanceof MatimoError) {
105
+ console.log(error.code); // ErrorCode.TOOL_NOT_FOUND
106
+ console.log(error.message); // 'Tool "unknown-tool" not found'
107
+ console.log(error.details); // { toolName: 'unknown-tool' }
108
+ console.log(error.toJSON()); // Full error object for logging
109
+ }
110
+ }
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Error Codes
116
+
117
+ ### TOOL_NOT_FOUND
118
+
119
+ Tool name doesn't exist in registry.
120
+
121
+ ```typescript
122
+ if (error.code === 'TOOL_NOT_FOUND') {
123
+ // Tool doesn't exist
124
+ // Check tool name spelling
125
+ // Use m.listTools() to see available tools
126
+ }
127
+ ```
128
+
129
+ **Common causes:**
130
+ - Typo in tool name
131
+ - Tool file not loaded
132
+ - Tool definition invalid
133
+
134
+ **Resolution:**
135
+ ```typescript
136
+ // List available tools
137
+ const tools = m.listTools();
138
+ console.log(tools.map(t => t.name));
139
+
140
+ // Use correct tool name
141
+ const result = await m.execute('calculator', params);
142
+ ```
143
+
144
+ ---
145
+
146
+ ### INVALID_PARAMETERS
147
+
148
+ Required parameters missing or wrong type.
149
+
150
+ ```typescript
151
+ if (error.code === 'INVALID_PARAMETERS') {
152
+ console.log('Missing or invalid:', error.details.invalidFields);
153
+ // e.g., { invalidFields: ['operation', 'a'] }
154
+ }
155
+ ```
156
+
157
+ **Common causes:**
158
+ - Missing required parameter
159
+ - Wrong parameter type (string vs number)
160
+ - Parameter value outside allowed range
161
+
162
+ **Resolution:**
163
+ ```typescript
164
+ // Get tool definition
165
+ const tool = m.getTool('calculator');
166
+
167
+ // Check required parameters
168
+ Object.entries(tool.parameters).forEach(([name, param]) => {
169
+ if (param.required) {
170
+ console.log(`Required: ${name}`);
171
+ }
172
+ });
173
+
174
+ // Execute with all required params
175
+ const result = await m.execute('calculator', {
176
+ operation: 'add', // required
177
+ a: 5, // required
178
+ b: 3 // required
179
+ });
180
+ ```
181
+
182
+ ---
183
+
184
+ ### EXECUTION_FAILED
185
+
186
+ Tool execution encountered an error.
187
+
188
+ ```typescript
189
+ if (error.code === 'EXECUTION_FAILED') {
190
+ console.log('Tool error:', error.details);
191
+ // Details vary by tool type
192
+ }
193
+ ```
194
+
195
+ **Common causes:**
196
+ - Tool returned error (e.g., API returned 500)
197
+ - Command execution failed
198
+ - Network error
199
+ - Authentication failed
200
+
201
+ **Resolution:**
202
+ ```typescript
203
+ try {
204
+ const result = await m.execute('gmail-send-email', {
205
+ to: 'user@example.com',
206
+ subject: 'Test',
207
+ body: 'Test'
208
+ });
209
+ } catch (error) {
210
+ if (error.code === 'EXECUTION_FAILED') {
211
+ if (error.details.statusCode === 401) {
212
+ console.error('❌ Authentication failed - check token');
213
+ } else if (error.details.statusCode === 429) {
214
+ console.error('⏱️ Rate limited - retry later');
215
+ } else {
216
+ console.error('Tool error:', error.message);
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ ---
223
+
224
+ ### INVALID_SCHEMA
225
+
226
+ Tool definition doesn't match schema.
227
+
228
+ ```typescript
229
+ if (error.code === 'INVALID_SCHEMA') {
230
+ console.log('Tool definition invalid:', error.details.errors);
231
+ }
232
+ ```
233
+
234
+ **Common causes:**
235
+ - Required field missing in tool YAML
236
+ - Wrong parameter type in YAML
237
+ - Invalid execution configuration
238
+
239
+ **Resolution:**
240
+ ```bash
241
+ # Validate all tools
242
+ pnpm validate-tools
243
+
244
+ # This will show which tools have schema errors
245
+ ```
246
+
247
+ See [Tool Specification](../tool-development/YAML_TOOLS.md) for correct YAML format.
248
+
249
+ ---
250
+
251
+ ### VALIDATION_FAILED
252
+
253
+ Parameter validation failed (e.g., not in enum, wrong regex pattern).
254
+
255
+ ```typescript
256
+ if (error.code === 'VALIDATION_FAILED') {
257
+ console.log('Validation errors:', error.details.errors);
258
+ }
259
+ ```
260
+
261
+ **Common causes:**
262
+ - Parameter value not in enum list
263
+ - String doesn't match regex pattern
264
+ - Number outside min/max range
265
+
266
+ **Resolution:**
267
+ ```typescript
268
+ // Get tool definition
269
+ const tool = m.getTool('calculator');
270
+
271
+ // Check parameter constraints
272
+ const operation = tool.parameters.operation;
273
+ console.log('Allowed operations:', operation.enum);
274
+ // ['add', 'subtract', 'multiply', 'divide']
275
+
276
+ // Use allowed value
277
+ const result = await m.execute('calculator', {
278
+ operation: 'add', // Must be in enum
279
+ a: 5,
280
+ b: 3
281
+ });
282
+ ```
283
+
284
+ ---
285
+
286
+ ### AUTH_FAILED
287
+
288
+ Authentication error (missing or invalid token).
289
+
290
+ ```typescript
291
+ if (error.code === 'AUTH_FAILED') {
292
+ console.log('Auth error:', error.message);
293
+ // e.g., "Missing GMAIL_ACCESS_TOKEN environment variable"
294
+ }
295
+ ```
296
+
297
+ **Common causes:**
298
+ - OAuth2 token not set in environment variable
299
+ - Token expired
300
+ - Token invalid or revoked
301
+
302
+ **Resolution:**
303
+ ```bash
304
+ # Check token is set
305
+ echo $GMAIL_ACCESS_TOKEN
306
+
307
+ # If empty, set it
308
+ export GMAIL_ACCESS_TOKEN="ya29.a0AfH6SMBx..."
309
+
310
+ # Test execution
311
+ npx tsx -e "import {matimo} from 'matimo'; const m = await matimo.init('./tools'); console.log(await m.execute('gmail-send-email', {to: 'test@example.com', subject: 'Test', body: 'Test'}));"
312
+ ```
313
+
314
+ See [Authentication Guide](../user-guide/AUTHENTICATION.md) for token setup.
315
+
316
+ ---
317
+
318
+ ### FILE_NOT_FOUND
319
+
320
+ Tool file or directory doesn't exist.
321
+
322
+ ```typescript
323
+ if (error.code === 'FILE_NOT_FOUND') {
324
+ console.log('Missing file:', error.details.path);
325
+ }
326
+ ```
327
+
328
+ **Common causes:**
329
+ - Tools directory path is wrong
330
+ - Tool YAML file deleted
331
+ - Incorrect file path in code
332
+
333
+ **Resolution:**
334
+ ```bash
335
+ # Verify tools directory exists
336
+ ls -la ./tools
337
+
338
+ # Verify tool file exists
339
+ ls -la ./tools/calculator/definition.yaml
340
+
341
+ # Use correct path when initializing
342
+ const m = await matimo.init('./tools');
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Handling Errors
348
+
349
+ ### Pattern 1: Type Check and Handle Specific Codes
350
+
351
+ ```typescript
352
+ import { MatimoError, ErrorCode } from 'matimo';
353
+
354
+ try {
355
+ const result = await m.execute('calculator', params);
356
+ } catch (error) {
357
+ if (error instanceof MatimoError) {
358
+ switch (error.code) {
359
+ case ErrorCode.TOOL_NOT_FOUND:
360
+ console.error('Tool not available');
361
+ break;
362
+ case ErrorCode.VALIDATION_FAILED:
363
+ console.error('Bad parameters:', error.details);
364
+ break;
365
+ case ErrorCode.EXECUTION_FAILED:
366
+ console.error('Tool execution failed:', error.details);
367
+ break;
368
+ default:
369
+ console.error('Unknown error:', error.message);
370
+ }
371
+ } else {
372
+ // Handle non-Matimo errors
373
+ throw error;
374
+ }
375
+ }
376
+ ```
377
+
378
+ ### Pattern 2: Check Specific Error Code
379
+
380
+ ```typescript
381
+ import { MatimoError, ErrorCode } from 'matimo';
382
+
383
+ try {
384
+ await m.execute('gmail-send-email', params);
385
+ } catch (error) {
386
+ if (error instanceof MatimoError) {
387
+ if (error.code === ErrorCode.AUTH_FAILED) {
388
+ // Handle auth separately
389
+ return redirectToLogin();
390
+ }
391
+
392
+ if (error.code === ErrorCode.EXECUTION_FAILED) {
393
+ // Handle tool error
394
+ return retryWithBackoff();
395
+ }
396
+ }
397
+
398
+ // Handle others
399
+ throw error;
400
+ }
401
+ ```
402
+
403
+ ### Pattern 3: Serialize for Logging
404
+
405
+ ```typescript
406
+ import { MatimoError } from 'matimo';
407
+
408
+ try {
409
+ await m.execute(toolName, params);
410
+ } catch (error) {
411
+ if (error instanceof MatimoError) {
412
+ // Use toJSON() for structured logging
413
+ logger.error('tool_execution_failed', error.toJSON());
414
+ } else {
415
+ throw error;
416
+ }
417
+ }
418
+ ```
419
+
420
+ ---
421
+
422
+ ## Error Codes Reference
423
+
424
+ | Code | ErrorCode Enum | Cause | Resolution |
425
+ |------|---|-------|-----------|
426
+ | `TOOL_NOT_FOUND` | `ErrorCode.TOOL_NOT_FOUND` | Tool doesn't exist | Check tool name, use `listTools()` |
427
+ | `INVALID_PARAMETERS` | `ErrorCode.INVALID_PARAMETER` | Missing/wrong params | Check tool definition |
428
+ | `EXECUTION_FAILED` | `ErrorCode.EXECUTION_FAILED` | Tool execution error | Check tool error details |
429
+ | `INVALID_SCHEMA` | `ErrorCode.INVALID_SCHEMA` | Bad tool definition | Fix tool YAML, run `validate-tools` |
430
+ | `VALIDATION_FAILED` | `ErrorCode.VALIDATION_FAILED` | Param validation failed | Check constraints (enum, regex, range) |
431
+ | `AUTH_FAILED` | `ErrorCode.AUTH_FAILED` | Missing/invalid token | Set OAuth2 env var |
432
+ | `FILE_NOT_FOUND` | `ErrorCode.FILE_NOT_FOUND` | File/dir missing | Verify paths exist |
433
+ | `RATE_LIMIT_EXCEEDED` | `ErrorCode.RATE_LIMIT_EXCEEDED` | API rate limit hit | Wait and retry |
434
+ | `TIMEOUT` | `ErrorCode.TIMEOUT` | Operation timeout | Increase timeout or check network |
435
+ | `NETWORK_ERROR` | `ErrorCode.NETWORK_ERROR` | Network/connection error | Check connectivity |
436
+ | `UNKNOWN_ERROR` | `ErrorCode.UNKNOWN_ERROR` | Unknown error | Check error details |
437
+
438
+ ---
439
+
440
+ ## Next Steps
441
+
442
+ - **Handle Errors**: [Error Handling Patterns](#handling-errors)
443
+ - **Setup Auth**: [Authentication Guide](../user-guide/AUTHENTICATION.md)
444
+ - **Type Definitions**: [Type Reference](./TYPES.md)
445
+