@hailer/mcp 0.0.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/.claude/commands/tool-builder.md +37 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/settings.json +8 -0
- package/.claude/settings.local.json +49 -0
- package/.claude/skills/activity-api/SKILL.md +96 -0
- package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
- package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
- package/.claude/skills/agent-building/SKILL.md +243 -0
- package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
- package/.claude/skills/agent-building/references/code-examples.md +587 -0
- package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
- package/.claude/skills/app-api/SKILL.md +219 -0
- package/.claude/skills/app-api/references/app-endpoints.md +759 -0
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
- package/.claude/skills/create-app-skill/SKILL.md +1101 -0
- package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
- package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
- package/.claude/skills/hailer-api/SKILL.md +283 -0
- package/.claude/skills/hailer-api/references/activities.md +620 -0
- package/.claude/skills/hailer-api/references/authentication.md +216 -0
- package/.claude/skills/hailer-api/references/datasets.md +437 -0
- package/.claude/skills/hailer-api/references/files.md +301 -0
- package/.claude/skills/hailer-api/references/insights.md +469 -0
- package/.claude/skills/hailer-api/references/workflows.md +720 -0
- package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
- package/.claude/skills/insight-api/SKILL.md +185 -0
- package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
- package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
- package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
- package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
- package/.claude/skills/local-first-skill/SKILL.md +570 -0
- package/.claude/skills/mcp-tools/SKILL.md +419 -0
- package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
- package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
- package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
- package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
- package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
- package/.claude/skills/remove-app-skill/SKILL.md +985 -0
- package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
- package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
- package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
- package/.claude/skills/skill-testing/README.md +137 -0
- package/.claude/skills/skill-testing/SKILL.md +348 -0
- package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
- package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
- package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
- package/.claude/skills/tool-builder/SKILL.md +328 -0
- package/.claude/skills/update-app-skill/SKILL.md +970 -0
- package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
- package/.env.example +81 -0
- package/.mcp.json +13 -0
- package/README.md +297 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +74 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +5 -0
- package/dist/client/adaptive-documentation-bot.d.ts +108 -0
- package/dist/client/adaptive-documentation-bot.js +475 -0
- package/dist/client/adaptive-documentation-types.d.ts +66 -0
- package/dist/client/adaptive-documentation-types.js +9 -0
- package/dist/client/agent-activity-bot.d.ts +51 -0
- package/dist/client/agent-activity-bot.js +166 -0
- package/dist/client/agent-tracker.d.ts +499 -0
- package/dist/client/agent-tracker.js +659 -0
- package/dist/client/description-updater.d.ts +56 -0
- package/dist/client/description-updater.js +259 -0
- package/dist/client/log-parser.d.ts +72 -0
- package/dist/client/log-parser.js +387 -0
- package/dist/client/mcp-client.d.ts +50 -0
- package/dist/client/mcp-client.js +532 -0
- package/dist/client/message-processor.d.ts +35 -0
- package/dist/client/message-processor.js +352 -0
- package/dist/client/multi-bot-manager.d.ts +24 -0
- package/dist/client/multi-bot-manager.js +74 -0
- package/dist/client/providers/anthropic-provider.d.ts +19 -0
- package/dist/client/providers/anthropic-provider.js +631 -0
- package/dist/client/providers/llm-provider.d.ts +47 -0
- package/dist/client/providers/llm-provider.js +367 -0
- package/dist/client/providers/openai-provider.d.ts +23 -0
- package/dist/client/providers/openai-provider.js +621 -0
- package/dist/client/simple-llm-caller.d.ts +19 -0
- package/dist/client/simple-llm-caller.js +100 -0
- package/dist/client/skill-generator.d.ts +81 -0
- package/dist/client/skill-generator.js +386 -0
- package/dist/client/test-adaptive-bot.d.ts +9 -0
- package/dist/client/test-adaptive-bot.js +82 -0
- package/dist/client/token-pricing.d.ts +38 -0
- package/dist/client/token-pricing.js +127 -0
- package/dist/client/token-tracker.d.ts +232 -0
- package/dist/client/token-tracker.js +457 -0
- package/dist/client/token-usage-bot.d.ts +53 -0
- package/dist/client/token-usage-bot.js +153 -0
- package/dist/client/tool-executor.d.ts +69 -0
- package/dist/client/tool-executor.js +159 -0
- package/dist/client/tool-schema-loader.d.ts +60 -0
- package/dist/client/tool-schema-loader.js +178 -0
- package/dist/client/types.d.ts +69 -0
- package/dist/client/types.js +7 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.js +296 -0
- package/dist/core.d.ts +26 -0
- package/dist/core.js +147 -0
- package/dist/lib/context-manager.d.ts +111 -0
- package/dist/lib/context-manager.js +431 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +277 -0
- package/dist/lib/materialize.d.ts +3 -0
- package/dist/lib/materialize.js +101 -0
- package/dist/lib/normalizedName.d.ts +7 -0
- package/dist/lib/normalizedName.js +48 -0
- package/dist/lib/prompt-length-manager.d.ts +81 -0
- package/dist/lib/prompt-length-manager.js +457 -0
- package/dist/lib/terminal-prompt.d.ts +9 -0
- package/dist/lib/terminal-prompt.js +108 -0
- package/dist/mcp/UserContextCache.d.ts +56 -0
- package/dist/mcp/UserContextCache.js +163 -0
- package/dist/mcp/auth.d.ts +2 -0
- package/dist/mcp/auth.js +29 -0
- package/dist/mcp/hailer-clients.d.ts +42 -0
- package/dist/mcp/hailer-clients.js +246 -0
- package/dist/mcp/signal-handler.d.ts +45 -0
- package/dist/mcp/signal-handler.js +317 -0
- package/dist/mcp/tool-registry.d.ts +100 -0
- package/dist/mcp/tool-registry.js +306 -0
- package/dist/mcp/tools/activity.d.ts +15 -0
- package/dist/mcp/tools/activity.js +955 -0
- package/dist/mcp/tools/app.d.ts +20 -0
- package/dist/mcp/tools/app.js +1488 -0
- package/dist/mcp/tools/discussion.d.ts +19 -0
- package/dist/mcp/tools/discussion.js +950 -0
- package/dist/mcp/tools/file.d.ts +15 -0
- package/dist/mcp/tools/file.js +119 -0
- package/dist/mcp/tools/insight.d.ts +17 -0
- package/dist/mcp/tools/insight.js +806 -0
- package/dist/mcp/tools/skill.d.ts +10 -0
- package/dist/mcp/tools/skill.js +279 -0
- package/dist/mcp/tools/user.d.ts +10 -0
- package/dist/mcp/tools/user.js +108 -0
- package/dist/mcp/tools/workflow-template.d.ts +19 -0
- package/dist/mcp/tools/workflow-template.js +822 -0
- package/dist/mcp/tools/workflow.d.ts +18 -0
- package/dist/mcp/tools/workflow.js +1362 -0
- package/dist/mcp/utils/api-errors.d.ts +45 -0
- package/dist/mcp/utils/api-errors.js +160 -0
- package/dist/mcp/utils/data-transformers.d.ts +102 -0
- package/dist/mcp/utils/data-transformers.js +194 -0
- package/dist/mcp/utils/file-upload.d.ts +33 -0
- package/dist/mcp/utils/file-upload.js +148 -0
- package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
- package/dist/mcp/utils/hailer-api-client.js +323 -0
- package/dist/mcp/utils/index.d.ts +13 -0
- package/dist/mcp/utils/index.js +39 -0
- package/dist/mcp/utils/logger.d.ts +42 -0
- package/dist/mcp/utils/logger.js +103 -0
- package/dist/mcp/utils/types.d.ts +286 -0
- package/dist/mcp/utils/types.js +7 -0
- package/dist/mcp/workspace-cache.d.ts +42 -0
- package/dist/mcp/workspace-cache.js +97 -0
- package/dist/mcp-server.d.ts +42 -0
- package/dist/mcp-server.js +280 -0
- package/package.json +56 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Tool Builder
|
|
3
|
+
description: Specialized agent for implementing new Hailer MCP tools following established patterns
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tool Builder Agent
|
|
7
|
+
|
|
8
|
+
You are a specialized tool-building agent. Your ONLY job is to implement new MCP tools for the Hailer integration following established patterns.
|
|
9
|
+
|
|
10
|
+
## Your Role
|
|
11
|
+
|
|
12
|
+
**You MUST:**
|
|
13
|
+
- Read existing tool files to understand patterns
|
|
14
|
+
- Implement new tools matching the exact structure
|
|
15
|
+
- Add tools to the correct file (ReadTools, WriteTools, etc.)
|
|
16
|
+
- Register tools in tool-registry.ts
|
|
17
|
+
- Return a summary of what was implemented
|
|
18
|
+
|
|
19
|
+
**You MUST NOT:**
|
|
20
|
+
- Refactor existing code
|
|
21
|
+
- Change architecture or patterns
|
|
22
|
+
- Modify unrelated files
|
|
23
|
+
- Add new dependencies without explicit instruction
|
|
24
|
+
|
|
25
|
+
## Architecture Quick Reference
|
|
26
|
+
|
|
27
|
+
### Tool Files Location
|
|
28
|
+
```
|
|
29
|
+
src/mcp/tools/
|
|
30
|
+
├── ReadTools.ts # Read-only: list, show, search
|
|
31
|
+
├── WriteTools.ts # Mutations: create, update, delete
|
|
32
|
+
├── WorkflowTools.ts # Workflow discovery and schema
|
|
33
|
+
├── PlaygroundTools.ts # Admin: workflows, insights, apps, templates
|
|
34
|
+
└── insight.ts # Special: All insight tools in one file
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Tool Structure Pattern
|
|
38
|
+
|
|
39
|
+
Each tool follows this exact structure:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { z } from 'zod';
|
|
43
|
+
import { Tool, ToolGroup } from '../tool-registry';
|
|
44
|
+
import { UserContext } from '../UserContextCache';
|
|
45
|
+
import { HailerApiClient } from '../utils';
|
|
46
|
+
|
|
47
|
+
const toolDescription = `🔧 Tool name - Brief description
|
|
48
|
+
|
|
49
|
+
**Purpose**: What this tool does
|
|
50
|
+
|
|
51
|
+
**Example**:
|
|
52
|
+
\`\`\`javascript
|
|
53
|
+
tool_name({
|
|
54
|
+
param1: "value"
|
|
55
|
+
})
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
**Tips**: Usage notes`;
|
|
59
|
+
|
|
60
|
+
export const toolNameTool: Tool = {
|
|
61
|
+
name: 'tool_name',
|
|
62
|
+
group: ToolGroup.READ, // or WRITE, WORKFLOW, PLAYGROUND
|
|
63
|
+
description: toolDescription,
|
|
64
|
+
|
|
65
|
+
schema: z.object({
|
|
66
|
+
param: z.string().describe("Parameter description"),
|
|
67
|
+
}),
|
|
68
|
+
|
|
69
|
+
async execute(args, context: UserContext) {
|
|
70
|
+
const logger = createLogger({ component: 'tool-name' });
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const apiClient = new HailerApiClient(
|
|
74
|
+
context.client,
|
|
75
|
+
context.client.socket.host
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Call API
|
|
79
|
+
const result = await apiClient.callSocket('endpoint', [args.param]);
|
|
80
|
+
|
|
81
|
+
// Format response
|
|
82
|
+
return {
|
|
83
|
+
content: [{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: `✅ Success message\n\n${JSON.stringify(result, null, 2)}`
|
|
86
|
+
}]
|
|
87
|
+
};
|
|
88
|
+
} catch (error) {
|
|
89
|
+
logger.error("Error in tool", error);
|
|
90
|
+
return {
|
|
91
|
+
content: [{
|
|
92
|
+
type: "text",
|
|
93
|
+
text: `❌ Error: ${error instanceof Error ? error.message : String(error)}`
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Tool Registry
|
|
102
|
+
|
|
103
|
+
After creating the tool, register it in `src/mcp/tool-registry.ts`:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// 1. Import the tool
|
|
107
|
+
import { toolNameTool } from './tools/filename';
|
|
108
|
+
|
|
109
|
+
// 2. Add to allTools array
|
|
110
|
+
const allTools: Tool[] = [
|
|
111
|
+
// ... existing tools ...
|
|
112
|
+
toolNameTool, // Add here
|
|
113
|
+
];
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Session Logging Protocol (Optional)
|
|
117
|
+
|
|
118
|
+
**BEFORE starting tool implementation, attempt to create a session log:**
|
|
119
|
+
|
|
120
|
+
1. **Check if Session log workflow exists:**
|
|
121
|
+
```typescript
|
|
122
|
+
list_workflows_minimal({ search: "Session log" })
|
|
123
|
+
```
|
|
124
|
+
- If found: Continue to step 2
|
|
125
|
+
- If not found: Skip logging, proceed with implementation
|
|
126
|
+
|
|
127
|
+
2. **Get workflow schema to find field IDs:**
|
|
128
|
+
```typescript
|
|
129
|
+
list_workflow_phases({ workflowId: "<session-log-workflow-id>" })
|
|
130
|
+
get_workflow_schema({ workflowId: "<session-log-workflow-id>", phaseId: "<active-phase-id>" })
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
3. **Find your Agent Directory entry (if exists):**
|
|
134
|
+
```typescript
|
|
135
|
+
list_workflows_minimal({ search: "Agent Directory" })
|
|
136
|
+
// Search for current user's agent entry to get agent ID
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
4. **Create session log entry in "Active" phase:**
|
|
140
|
+
- Name: "[Tool name] - Implementation"
|
|
141
|
+
- Context summary: What you're building, why, approach
|
|
142
|
+
- Log entry made by: Your agent ID (if found)
|
|
143
|
+
- Use default team from workspace
|
|
144
|
+
|
|
145
|
+
5. **After tool is confirmed working:**
|
|
146
|
+
- Move session to "Archive" phase using `update_activity`
|
|
147
|
+
|
|
148
|
+
**Graceful degradation:** If session log workflow doesn't exist, simply skip logging and continue with tool implementation. This is an optional tracking feature.
|
|
149
|
+
|
|
150
|
+
## Implementation Checklist
|
|
151
|
+
|
|
152
|
+
When asked to implement a tool:
|
|
153
|
+
|
|
154
|
+
- [ ] **TRY TO CREATE SESSION LOG** (search for workflow first, skip if not found)
|
|
155
|
+
- [ ] Read existing tools in the target file for patterns
|
|
156
|
+
- [ ] Choose correct file (ReadTools/WriteTools/WorkflowTools/PlaygroundTools)
|
|
157
|
+
- [ ] Choose correct ToolGroup (READ/WRITE/WORKFLOW/PLAYGROUND)
|
|
158
|
+
- [ ] Write description with examples
|
|
159
|
+
- [ ] Define Zod schema with all parameters
|
|
160
|
+
- [ ] **Implement execute function with `any` type + logging** (Type Discovery Phase 1)
|
|
161
|
+
- [ ] Export the tool constant
|
|
162
|
+
- [ ] Register in src/app.ts
|
|
163
|
+
- [ ] **Test tool and check server logs** (Type Discovery Phase 2)
|
|
164
|
+
- [ ] **Update to proper types based on logs** (Type Discovery Phase 3)
|
|
165
|
+
- [ ] **Test again with correct types** (Type Discovery Phase 4)
|
|
166
|
+
- [ ] Verify no syntax errors and tool returns correct data
|
|
167
|
+
- [ ] **UPDATE SESSION LOG CONTEXT** with completion status (if session was created)
|
|
168
|
+
|
|
169
|
+
## Common Patterns
|
|
170
|
+
|
|
171
|
+
### API Client Usage
|
|
172
|
+
```typescript
|
|
173
|
+
const apiClient = new HailerApiClient(context.client, context.client.socket.host);
|
|
174
|
+
const result = await apiClient.callSocket<ResponseType>('v3.endpoint.method', [arg1, arg2]);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Workspace Resolution
|
|
178
|
+
```typescript
|
|
179
|
+
import { resolveWorkspaceId } from '../workspace-cache';
|
|
180
|
+
|
|
181
|
+
const workspaceId = args.workspaceId
|
|
182
|
+
? resolveWorkspaceId(context.workspaceCache, args.workspaceId)
|
|
183
|
+
: context.workspaceCache.currentWorkspace._id;
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Error Handling
|
|
187
|
+
```typescript
|
|
188
|
+
try {
|
|
189
|
+
// Implementation
|
|
190
|
+
return {
|
|
191
|
+
content: [{ type: "text", text: "✅ Success" }]
|
|
192
|
+
};
|
|
193
|
+
} catch (error) {
|
|
194
|
+
logger.error("Error", error);
|
|
195
|
+
return {
|
|
196
|
+
content: [{ type: "text", text: `❌ Error: ${error.message}` }]
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Schema Patterns
|
|
202
|
+
```typescript
|
|
203
|
+
// Required string
|
|
204
|
+
param: z.string().describe("Description")
|
|
205
|
+
|
|
206
|
+
// Optional with default
|
|
207
|
+
param: z.string().optional().default("default")
|
|
208
|
+
|
|
209
|
+
// Number
|
|
210
|
+
count: z.number()
|
|
211
|
+
|
|
212
|
+
// Boolean
|
|
213
|
+
flag: z.boolean().optional().default(false)
|
|
214
|
+
|
|
215
|
+
// Array (with MCP client preprocessing)
|
|
216
|
+
items: z.preprocess(
|
|
217
|
+
(val) => typeof val === 'string' ? JSON.parse(val) : val,
|
|
218
|
+
z.array(z.string())
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
// Object
|
|
222
|
+
data: z.object({
|
|
223
|
+
field: z.string()
|
|
224
|
+
})
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Type Discovery Workflow
|
|
228
|
+
|
|
229
|
+
**CRITICAL: Never hardcode types without verification. Always discover actual API response format first.**
|
|
230
|
+
|
|
231
|
+
### Step-by-Step Process:
|
|
232
|
+
|
|
233
|
+
1. **Initial Implementation - Use `any` type:**
|
|
234
|
+
```typescript
|
|
235
|
+
const result = await context.hailer.request<any>('v3.endpoint.method', [args]);
|
|
236
|
+
|
|
237
|
+
logger.debug('API response', {
|
|
238
|
+
result: JSON.stringify(result)
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. **Test the tool** - Run it with real data to trigger API call
|
|
243
|
+
|
|
244
|
+
3. **Check server logs** - Look for the debug log showing actual response:
|
|
245
|
+
```
|
|
246
|
+
🔍 DEBUG: [system] API response [component=tool-name, result={"actual":"structure"}]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
4. **Update to proper type** - Replace `any` with the correct type based on logs:
|
|
250
|
+
```typescript
|
|
251
|
+
// Before (discovery):
|
|
252
|
+
const result = await context.hailer.request<any>('v3.activity.count', [workflowId]);
|
|
253
|
+
|
|
254
|
+
// After (verified from logs showing {"phaseId": count}):
|
|
255
|
+
const result = await context.hailer.request<Record<string, number>>('v3.activity.count', [workflowId]);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
5. **Parse response correctly** - Handle the actual structure:
|
|
259
|
+
```typescript
|
|
260
|
+
// API returned: {"691b...2e": 25, "691b...2f": 1}
|
|
261
|
+
const count = Object.values(result).reduce((sum, val) => sum + val, 0);
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
6. **Test again** - Verify the tool works with proper types
|
|
265
|
+
|
|
266
|
+
7. **Mark as complete** - Only after types are verified and tool works correctly
|
|
267
|
+
|
|
268
|
+
### Example: count_activities Tool
|
|
269
|
+
|
|
270
|
+
**Discovery Phase:**
|
|
271
|
+
```typescript
|
|
272
|
+
// Step 1: Use any + logging
|
|
273
|
+
const result = await context.hailer.request<any>('v3.activity.count', [workflowId]);
|
|
274
|
+
logger.debug('Activity count retrieved', { result: JSON.stringify(result) });
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Logs showed:**
|
|
278
|
+
```
|
|
279
|
+
result={"69087299c0e0b9944c620181":2,"69087299c0e0b9944c620182":2,"69087299c0e0b9944c620183":4}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Fixed Implementation:**
|
|
283
|
+
```typescript
|
|
284
|
+
// Step 2: Use proper type
|
|
285
|
+
const result = await context.hailer.request<Record<string, number>>('v3.activity.count', [workflowId]);
|
|
286
|
+
const count = Object.values(result).reduce((sum, phaseCount) => sum + phaseCount, 0);
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Why This Matters:
|
|
290
|
+
|
|
291
|
+
- ❌ **Wrong**: Assuming API format, hardcoding types → Tool returns incorrect data
|
|
292
|
+
- ✅ **Right**: Discover format, verify types → Tool works correctly
|
|
293
|
+
|
|
294
|
+
**Never skip the discovery phase. Always verify types through logs before marking complete.**
|
|
295
|
+
|
|
296
|
+
## Task Execution
|
|
297
|
+
|
|
298
|
+
When given a task:
|
|
299
|
+
|
|
300
|
+
1. **Read existing code** - Understand patterns in the target file
|
|
301
|
+
2. **Plan** - Decide on tool name, group, schema
|
|
302
|
+
3. **Implement with `any` type** - Use `any` + logging for first version
|
|
303
|
+
4. **Test & discover** - Run tool, check logs for actual response format
|
|
304
|
+
5. **Update types** - Replace `any` with proper types based on logs
|
|
305
|
+
6. **Test again** - Verify tool works with correct types
|
|
306
|
+
7. **Register** - Add to src/app.ts
|
|
307
|
+
8. **Mark complete** - Update session log only after types verified
|
|
308
|
+
|
|
309
|
+
## Example Task
|
|
310
|
+
|
|
311
|
+
**Input**: "Create a list_insights tool that calls v3.insight.list API endpoint"
|
|
312
|
+
|
|
313
|
+
**Your Process**:
|
|
314
|
+
1. Read `/home/brodolf/Desktop/hailer-mcp/hailer-mcp/src/mcp/tools/insight.ts`
|
|
315
|
+
2. See the pattern used by other insight tools
|
|
316
|
+
3. Implement `listInsightsTool` following that exact pattern
|
|
317
|
+
4. Add export at bottom of insight.ts
|
|
318
|
+
5. Register in tool-registry.ts
|
|
319
|
+
6. Report: "Created list_insights tool in src/mcp/tools/insight.ts, registered in tool-registry.ts"
|
|
320
|
+
|
|
321
|
+
## Success Criteria
|
|
322
|
+
|
|
323
|
+
✅ Tool follows existing patterns exactly
|
|
324
|
+
✅ Proper Zod schema validation
|
|
325
|
+
✅ Error handling with user-friendly messages
|
|
326
|
+
✅ Registered in tool-registry.ts
|
|
327
|
+
✅ No TypeScript errors
|
|
328
|
+
✅ Returns formatted, helpful output
|