@ebowwa/crm 0.1.0
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 +174 -0
- package/dist/cli/commands/activities.d.ts +11 -0
- package/dist/cli/commands/activities.d.ts.map +1 -0
- package/dist/cli/commands/activities.js +427 -0
- package/dist/cli/commands/activities.js.map +1 -0
- package/dist/cli/commands/contacts.d.ts +11 -0
- package/dist/cli/commands/contacts.d.ts.map +1 -0
- package/dist/cli/commands/contacts.js +458 -0
- package/dist/cli/commands/contacts.js.map +1 -0
- package/dist/cli/commands/deals.d.ts +11 -0
- package/dist/cli/commands/deals.d.ts.map +1 -0
- package/dist/cli/commands/deals.js +498 -0
- package/dist/cli/commands/deals.js.map +1 -0
- package/dist/cli/commands/media.d.ts +11 -0
- package/dist/cli/commands/media.d.ts.map +1 -0
- package/dist/cli/commands/media.js +417 -0
- package/dist/cli/commands/media.js.map +1 -0
- package/dist/cli/commands/search.d.ts +11 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +346 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +173 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/repl.d.ts +15 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +318 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/utils/config.d.ts +91 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +212 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/output.d.ts +136 -0
- package/dist/cli/utils/output.d.ts.map +1 -0
- package/dist/cli/utils/output.js +323 -0
- package/dist/cli/utils/output.js.map +1 -0
- package/dist/cli/utils/prompt.d.ts +81 -0
- package/dist/cli/utils/prompt.d.ts.map +1 -0
- package/dist/cli/utils/prompt.js +341 -0
- package/dist/cli/utils/prompt.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +32 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/schemas.d.ts +3050 -0
- package/dist/core/schemas.d.ts.map +1 -0
- package/dist/core/schemas.js +667 -0
- package/dist/core/schemas.js.map +1 -0
- package/dist/core/types.d.ts +597 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +13 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +18 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/storage/client.d.ts +109 -0
- package/dist/mcp/storage/client.d.ts.map +1 -0
- package/dist/mcp/storage/client.js +355 -0
- package/dist/mcp/storage/client.js.map +1 -0
- package/dist/mcp/storage/index.d.ts +7 -0
- package/dist/mcp/storage/index.d.ts.map +1 -0
- package/dist/mcp/storage/index.js +6 -0
- package/dist/mcp/storage/index.js.map +1 -0
- package/dist/mcp/storage/types.d.ts +44 -0
- package/dist/mcp/storage/types.d.ts.map +1 -0
- package/dist/mcp/storage/types.js +35 -0
- package/dist/mcp/storage/types.js.map +1 -0
- package/dist/mcp/tools/definitions.d.ts +16 -0
- package/dist/mcp/tools/definitions.d.ts.map +1 -0
- package/dist/mcp/tools/definitions.js +914 -0
- package/dist/mcp/tools/definitions.js.map +1 -0
- package/dist/mcp/tools/handlers.d.ts +50 -0
- package/dist/mcp/tools/handlers.d.ts.map +1 -0
- package/dist/mcp/tools/handlers.js +760 -0
- package/dist/mcp/tools/handlers.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +7 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +6 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/types.d.ts +314 -0
- package/dist/mcp/tools/types.d.ts.map +1 -0
- package/dist/mcp/tools/types.js +5 -0
- package/dist/mcp/tools/types.js.map +1 -0
- package/dist/mcp/transports/stdio.d.ts +27 -0
- package/dist/mcp/transports/stdio.d.ts.map +1 -0
- package/dist/mcp/transports/stdio.js +237 -0
- package/dist/mcp/transports/stdio.js.map +1 -0
- package/dist/telemetry/index.d.ts +58 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +109 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/logger.d.ts +116 -0
- package/dist/telemetry/logger.d.ts.map +1 -0
- package/dist/telemetry/logger.js +256 -0
- package/dist/telemetry/logger.js.map +1 -0
- package/dist/telemetry/metrics.d.ts +115 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +292 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/telemetry/tracer.d.ts +227 -0
- package/dist/telemetry/tracer.d.ts.map +1 -0
- package/dist/telemetry/tracer.js +355 -0
- package/dist/telemetry/tracer.js.map +1 -0
- package/dist/web/app.d.ts +2 -0
- package/dist/web/app.d.ts.map +1 -0
- package/dist/web/app.js +115 -0
- package/dist/web/app.js.map +1 -0
- package/dist/web/components/ContactList.d.ts +3 -0
- package/dist/web/components/ContactList.d.ts.map +1 -0
- package/dist/web/components/ContactList.js +262 -0
- package/dist/web/components/ContactList.js.map +1 -0
- package/dist/web/components/Dashboard.d.ts +3 -0
- package/dist/web/components/Dashboard.d.ts.map +1 -0
- package/dist/web/components/Dashboard.js +158 -0
- package/dist/web/components/Dashboard.js.map +1 -0
- package/dist/web/components/DealPipeline.d.ts +3 -0
- package/dist/web/components/DealPipeline.d.ts.map +1 -0
- package/dist/web/components/DealPipeline.js +306 -0
- package/dist/web/components/DealPipeline.js.map +1 -0
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +269 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/types.d.ts +75 -0
- package/dist/web/types.d.ts.map +1 -0
- package/dist/web/types.js +3 -0
- package/dist/web/types.js.map +1 -0
- package/native/index.d.ts +571 -0
- package/native/index.js +687 -0
- package/package.json +105 -0
- package/src/cli/commands/activities.ts +543 -0
- package/src/cli/commands/contacts.ts +563 -0
- package/src/cli/commands/deals.ts +637 -0
- package/src/cli/commands/media.ts +521 -0
- package/src/cli/commands/search.ts +426 -0
- package/src/cli/index.ts +203 -0
- package/src/cli/repl.ts +379 -0
- package/src/cli/utils/config.ts +299 -0
- package/src/cli/utils/output.ts +386 -0
- package/src/cli/utils/prompt.ts +444 -0
- package/src/cli.ts +11 -0
- package/src/core/index.ts +184 -0
- package/src/core/schemas.ts +770 -0
- package/src/core/types.ts +969 -0
- package/src/index.ts +8 -0
- package/src/mcp/index.ts +17 -0
- package/src/mcp/server.ts +26 -0
- package/src/mcp/storage/client.ts +408 -0
- package/src/mcp/storage/index.ts +7 -0
- package/src/mcp/storage/types.ts +72 -0
- package/src/mcp/tools/definitions.ts +961 -0
- package/src/mcp/tools/handlers.ts +805 -0
- package/src/mcp/tools/index.ts +7 -0
- package/src/mcp/tools/types.ts +390 -0
- package/src/mcp/transports/stdio.ts +225 -0
- package/src/telemetry/index.ts +131 -0
- package/src/telemetry/logger.ts +318 -0
- package/src/telemetry/metrics.ts +393 -0
- package/src/telemetry/tracer.ts +487 -0
- package/src/web/api/activities.ts +41 -0
- package/src/web/api/contacts.ts +114 -0
- package/src/web/api/deals.ts +108 -0
- package/src/web/api/media.ts +98 -0
- package/src/web/app.tsx +143 -0
- package/src/web/components/ActivityFeed.tsx +195 -0
- package/src/web/components/ContactList.tsx +340 -0
- package/src/web/components/Dashboard.tsx +214 -0
- package/src/web/components/DealPipeline.tsx +405 -0
- package/src/web/components/MediaGallery.tsx +334 -0
- package/src/web/index.html +14 -0
- package/src/web/index.ts +326 -0
- package/src/web/styles/main.css +180 -0
- package/src/web/types.ts +311 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool type definitions for CRM
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
Contact,
|
|
7
|
+
Deal,
|
|
8
|
+
Activity,
|
|
9
|
+
Media,
|
|
10
|
+
Note,
|
|
11
|
+
Tag,
|
|
12
|
+
Company,
|
|
13
|
+
ContactFilter,
|
|
14
|
+
DealFilter,
|
|
15
|
+
ActivityFilter,
|
|
16
|
+
PaginationOptions,
|
|
17
|
+
} from '../../core/types.js';
|
|
18
|
+
|
|
19
|
+
/** Tool input types */
|
|
20
|
+
export interface ToolInput {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Tool output response */
|
|
25
|
+
export interface ToolOutput<T = unknown> {
|
|
26
|
+
success: boolean;
|
|
27
|
+
data?: T;
|
|
28
|
+
error?: string;
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Contact Tool Types
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
export interface CreateContactInput {
|
|
37
|
+
name: string;
|
|
38
|
+
firstName?: string;
|
|
39
|
+
lastName?: string;
|
|
40
|
+
emails?: Array<{ email: string; type: string; primary: boolean }>;
|
|
41
|
+
phones?: Array<{ number: string; type: string; primary: boolean }>;
|
|
42
|
+
company?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
tags?: string[];
|
|
45
|
+
source?: string;
|
|
46
|
+
status?: string;
|
|
47
|
+
customFields?: Array<{ key: string; value: unknown; type: string }>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface UpdateContactInput {
|
|
51
|
+
id: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
firstName?: string;
|
|
54
|
+
lastName?: string;
|
|
55
|
+
emails?: Array<{ email: string; type: string; primary: boolean }>;
|
|
56
|
+
phones?: Array<{ number: string; type: string; primary: boolean }>;
|
|
57
|
+
company?: string;
|
|
58
|
+
title?: string;
|
|
59
|
+
tags?: string[];
|
|
60
|
+
status?: string;
|
|
61
|
+
customFields?: Array<{ key: string; value: unknown; type: string }>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface GetContactInput {
|
|
65
|
+
id: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ListContactsInput extends PaginationOptions, Partial<ContactFilter> {}
|
|
69
|
+
|
|
70
|
+
export interface DeleteContactInput {
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SearchContactsInput {
|
|
75
|
+
query: string;
|
|
76
|
+
limit?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Deal Tool Types
|
|
81
|
+
// ============================================================================
|
|
82
|
+
|
|
83
|
+
export interface CreateDealInput {
|
|
84
|
+
title: string;
|
|
85
|
+
contactId: string;
|
|
86
|
+
value: number;
|
|
87
|
+
currency?: string;
|
|
88
|
+
stage?: string;
|
|
89
|
+
probability?: number;
|
|
90
|
+
expectedClose: string;
|
|
91
|
+
notes?: string;
|
|
92
|
+
tags?: string[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface UpdateDealInput {
|
|
96
|
+
id: string;
|
|
97
|
+
title?: string;
|
|
98
|
+
value?: number;
|
|
99
|
+
stage?: string;
|
|
100
|
+
probability?: number;
|
|
101
|
+
expectedClose?: string;
|
|
102
|
+
notes?: string;
|
|
103
|
+
tags?: string[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface GetDealInput {
|
|
107
|
+
id: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ListDealsInput extends PaginationOptions, Partial<DealFilter> {}
|
|
111
|
+
|
|
112
|
+
export interface DeleteDealInput {
|
|
113
|
+
id: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface GetDealsByStageInput {
|
|
117
|
+
stage: string;
|
|
118
|
+
limit?: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Activity Tool Types
|
|
123
|
+
// ============================================================================
|
|
124
|
+
|
|
125
|
+
export interface CreateActivityInput {
|
|
126
|
+
contactId?: string;
|
|
127
|
+
dealId?: string;
|
|
128
|
+
type: string;
|
|
129
|
+
title: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
timestamp?: string;
|
|
132
|
+
duration?: number;
|
|
133
|
+
metadata?: Record<string, unknown>;
|
|
134
|
+
tags?: string[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface UpdateActivityInput {
|
|
138
|
+
id: string;
|
|
139
|
+
title?: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
metadata?: Record<string, unknown>;
|
|
142
|
+
tags?: string[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface GetActivityInput {
|
|
146
|
+
id: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface ListActivitiesInput extends PaginationOptions, Partial<ActivityFilter> {}
|
|
150
|
+
|
|
151
|
+
export interface DeleteActivityInput {
|
|
152
|
+
id: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Media Tool Types
|
|
157
|
+
// ============================================================================
|
|
158
|
+
|
|
159
|
+
export interface CreateMediaInput {
|
|
160
|
+
entityType: string;
|
|
161
|
+
entityId: string;
|
|
162
|
+
type: string;
|
|
163
|
+
filename: string;
|
|
164
|
+
mimeType: string;
|
|
165
|
+
size: number;
|
|
166
|
+
url: string;
|
|
167
|
+
metadata?: Record<string, unknown>;
|
|
168
|
+
altText?: string;
|
|
169
|
+
caption?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface GetMediaInput {
|
|
173
|
+
id: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface ListMediaInput {
|
|
177
|
+
entityType?: string;
|
|
178
|
+
entityId?: string;
|
|
179
|
+
limit?: number;
|
|
180
|
+
offset?: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface DeleteMediaInput {
|
|
184
|
+
id: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ============================================================================
|
|
188
|
+
// Note Tool Types
|
|
189
|
+
// ============================================================================
|
|
190
|
+
|
|
191
|
+
export interface CreateNoteInput {
|
|
192
|
+
contactId?: string;
|
|
193
|
+
dealId?: string;
|
|
194
|
+
content: string;
|
|
195
|
+
format?: string;
|
|
196
|
+
title?: string;
|
|
197
|
+
visibility?: string;
|
|
198
|
+
tags?: string[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface UpdateNoteInput {
|
|
202
|
+
id: string;
|
|
203
|
+
content?: string;
|
|
204
|
+
title?: string;
|
|
205
|
+
visibility?: string;
|
|
206
|
+
tags?: string[];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface GetNoteInput {
|
|
210
|
+
id: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ListNotesInput {
|
|
214
|
+
contactId?: string;
|
|
215
|
+
dealId?: string;
|
|
216
|
+
limit?: number;
|
|
217
|
+
offset?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface DeleteNoteInput {
|
|
221
|
+
id: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ============================================================================
|
|
225
|
+
// Tag Tool Types
|
|
226
|
+
// ============================================================================
|
|
227
|
+
|
|
228
|
+
export interface CreateTagInput {
|
|
229
|
+
name: string;
|
|
230
|
+
label: string;
|
|
231
|
+
color: string;
|
|
232
|
+
category?: string;
|
|
233
|
+
description?: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface UpdateTagInput {
|
|
237
|
+
id: string;
|
|
238
|
+
label?: string;
|
|
239
|
+
color?: string;
|
|
240
|
+
description?: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface GetTagInput {
|
|
244
|
+
id: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface ListTagsInput {
|
|
248
|
+
category?: string;
|
|
249
|
+
limit?: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface DeleteTagInput {
|
|
253
|
+
id: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ============================================================================
|
|
257
|
+
// Company Tool Types
|
|
258
|
+
// ============================================================================
|
|
259
|
+
|
|
260
|
+
export interface CreateCompanyInput {
|
|
261
|
+
name: string;
|
|
262
|
+
website?: string;
|
|
263
|
+
industry?: string;
|
|
264
|
+
size?: string;
|
|
265
|
+
tags?: string[];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface UpdateCompanyInput {
|
|
269
|
+
id: string;
|
|
270
|
+
name?: string;
|
|
271
|
+
website?: string;
|
|
272
|
+
industry?: string;
|
|
273
|
+
size?: string;
|
|
274
|
+
tags?: string[];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface GetCompanyInput {
|
|
278
|
+
id: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface ListCompaniesInput extends PaginationOptions {
|
|
282
|
+
industry?: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface DeleteCompanyInput {
|
|
286
|
+
id: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// ============================================================================
|
|
290
|
+
// Stats Tool Types
|
|
291
|
+
// ============================================================================
|
|
292
|
+
|
|
293
|
+
export interface GetStatsInput {}
|
|
294
|
+
|
|
295
|
+
export interface GetDashboardInput {
|
|
296
|
+
period?: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ============================================================================
|
|
300
|
+
// Tool Output Types
|
|
301
|
+
// ============================================================================
|
|
302
|
+
|
|
303
|
+
export interface ContactOutput {
|
|
304
|
+
contact: Contact;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface ContactListOutput {
|
|
308
|
+
contacts: Contact[];
|
|
309
|
+
total: number;
|
|
310
|
+
page: number;
|
|
311
|
+
limit: number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface DealOutput {
|
|
315
|
+
deal: Deal;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface DealListOutput {
|
|
319
|
+
deals: Deal[];
|
|
320
|
+
total: number;
|
|
321
|
+
page: number;
|
|
322
|
+
limit: number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface ActivityOutput {
|
|
326
|
+
activity: Activity;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface ActivityListOutput {
|
|
330
|
+
activities: Activity[];
|
|
331
|
+
total: number;
|
|
332
|
+
page: number;
|
|
333
|
+
limit: number;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface MediaOutput {
|
|
337
|
+
media: Media;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface MediaListOutput {
|
|
341
|
+
media: Media[];
|
|
342
|
+
total: number;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface NoteOutput {
|
|
346
|
+
note: Note;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface NoteListOutput {
|
|
350
|
+
notes: Note[];
|
|
351
|
+
total: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface TagOutput {
|
|
355
|
+
tag: Tag;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface TagListOutput {
|
|
359
|
+
tags: Tag[];
|
|
360
|
+
total: number;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface CompanyOutput {
|
|
364
|
+
company: Company;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface CompanyListOutput {
|
|
368
|
+
companies: Company[];
|
|
369
|
+
total: number;
|
|
370
|
+
page: number;
|
|
371
|
+
limit: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface StatsOutput {
|
|
375
|
+
contacts: number;
|
|
376
|
+
deals: number;
|
|
377
|
+
activities: number;
|
|
378
|
+
media: number;
|
|
379
|
+
notes: number;
|
|
380
|
+
tags: number;
|
|
381
|
+
companies: number;
|
|
382
|
+
pipelines: number;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export interface DashboardOutput {
|
|
386
|
+
stats: StatsOutput;
|
|
387
|
+
dealsByStage: Record<string, number>;
|
|
388
|
+
recentActivities: Activity[];
|
|
389
|
+
upcomingFollowUps: Contact[];
|
|
390
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STDIO transport for CRM MCP
|
|
3
|
+
* Handles communication over standard input/output
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import { CRMStorageClient } from '../storage/client.js';
|
|
10
|
+
import { ToolHandlers } from '../tools/handlers.js';
|
|
11
|
+
import { TOOL_DEFINITIONS } from '../tools/definitions.js';
|
|
12
|
+
import { CRMError } from '../storage/types.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* STDIO Server implementation for CRM
|
|
16
|
+
*/
|
|
17
|
+
export class StdioServer {
|
|
18
|
+
private server: Server;
|
|
19
|
+
private handlers: ToolHandlers;
|
|
20
|
+
|
|
21
|
+
constructor(private storage: CRMStorageClient) {
|
|
22
|
+
this.server = new Server(
|
|
23
|
+
{
|
|
24
|
+
name: 'crm-mcp-server',
|
|
25
|
+
version: '0.1.0',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
capabilities: {
|
|
29
|
+
tools: {},
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
this.handlers = new ToolHandlers(storage);
|
|
35
|
+
this.setupHandlers();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set up MCP request handlers
|
|
40
|
+
*/
|
|
41
|
+
private setupHandlers(): void {
|
|
42
|
+
// List available tools
|
|
43
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
44
|
+
return {
|
|
45
|
+
tools: TOOL_DEFINITIONS,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Handle tool calls
|
|
50
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
51
|
+
const { name, arguments: args } = request.params;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
let result;
|
|
55
|
+
|
|
56
|
+
// Contact tools
|
|
57
|
+
if (name === 'crm_create_contact') {
|
|
58
|
+
result = await this.handlers.createContact(args ?? {});
|
|
59
|
+
} else if (name === 'crm_get_contact') {
|
|
60
|
+
result = await this.handlers.getContact(args ?? {});
|
|
61
|
+
} else if (name === 'crm_update_contact') {
|
|
62
|
+
result = await this.handlers.updateContact(args ?? {});
|
|
63
|
+
} else if (name === 'crm_delete_contact') {
|
|
64
|
+
result = await this.handlers.deleteContact(args ?? {});
|
|
65
|
+
} else if (name === 'crm_list_contacts') {
|
|
66
|
+
result = await this.handlers.listContacts(args ?? {});
|
|
67
|
+
} else if (name === 'crm_search_contacts') {
|
|
68
|
+
result = await this.handlers.searchContacts(args ?? {});
|
|
69
|
+
}
|
|
70
|
+
// Deal tools
|
|
71
|
+
else if (name === 'crm_create_deal') {
|
|
72
|
+
result = await this.handlers.createDeal(args ?? {});
|
|
73
|
+
} else if (name === 'crm_get_deal') {
|
|
74
|
+
result = await this.handlers.getDeal(args ?? {});
|
|
75
|
+
} else if (name === 'crm_update_deal') {
|
|
76
|
+
result = await this.handlers.updateDeal(args ?? {});
|
|
77
|
+
} else if (name === 'crm_delete_deal') {
|
|
78
|
+
result = await this.handlers.deleteDeal(args ?? {});
|
|
79
|
+
} else if (name === 'crm_list_deals') {
|
|
80
|
+
result = await this.handlers.listDeals(args ?? {});
|
|
81
|
+
} else if (name === 'crm_get_deals_by_stage') {
|
|
82
|
+
result = await this.handlers.getDealsByStage(args ?? {});
|
|
83
|
+
}
|
|
84
|
+
// Activity tools
|
|
85
|
+
else if (name === 'crm_create_activity') {
|
|
86
|
+
result = await this.handlers.createActivity(args ?? {});
|
|
87
|
+
} else if (name === 'crm_get_activity') {
|
|
88
|
+
result = await this.handlers.getActivity(args ?? {});
|
|
89
|
+
} else if (name === 'crm_list_activities') {
|
|
90
|
+
result = await this.handlers.listActivities(args ?? {});
|
|
91
|
+
} else if (name === 'crm_delete_activity') {
|
|
92
|
+
result = await this.handlers.deleteActivity(args ?? {});
|
|
93
|
+
}
|
|
94
|
+
// Media tools
|
|
95
|
+
else if (name === 'crm_upload_media') {
|
|
96
|
+
result = await this.handlers.uploadMedia(args ?? {});
|
|
97
|
+
} else if (name === 'crm_get_media') {
|
|
98
|
+
result = await this.handlers.getMedia(args ?? {});
|
|
99
|
+
} else if (name === 'crm_list_media') {
|
|
100
|
+
result = await this.handlers.listMedia(args ?? {});
|
|
101
|
+
} else if (name === 'crm_delete_media') {
|
|
102
|
+
result = await this.handlers.deleteMedia(args ?? {});
|
|
103
|
+
}
|
|
104
|
+
// Note tools
|
|
105
|
+
else if (name === 'crm_create_note') {
|
|
106
|
+
result = await this.handlers.createNote(args ?? {});
|
|
107
|
+
} else if (name === 'crm_get_note') {
|
|
108
|
+
result = await this.handlers.getNote(args ?? {});
|
|
109
|
+
} else if (name === 'crm_update_note') {
|
|
110
|
+
result = await this.handlers.updateNote(args ?? {});
|
|
111
|
+
} else if (name === 'crm_delete_note') {
|
|
112
|
+
result = await this.handlers.deleteNote(args ?? {});
|
|
113
|
+
} else if (name === 'crm_list_notes') {
|
|
114
|
+
result = await this.handlers.listNotes(args ?? {});
|
|
115
|
+
}
|
|
116
|
+
// Tag tools
|
|
117
|
+
else if (name === 'crm_create_tag') {
|
|
118
|
+
result = await this.handlers.createTag(args ?? {});
|
|
119
|
+
} else if (name === 'crm_get_tag') {
|
|
120
|
+
result = await this.handlers.getTag(args ?? {});
|
|
121
|
+
} else if (name === 'crm_list_tags') {
|
|
122
|
+
result = await this.handlers.listTags(args ?? {});
|
|
123
|
+
} else if (name === 'crm_delete_tag') {
|
|
124
|
+
result = await this.handlers.deleteTag(args ?? {});
|
|
125
|
+
}
|
|
126
|
+
// Company tools
|
|
127
|
+
else if (name === 'crm_create_company') {
|
|
128
|
+
result = await this.handlers.createCompany(args ?? {});
|
|
129
|
+
} else if (name === 'crm_get_company') {
|
|
130
|
+
result = await this.handlers.getCompany(args ?? {});
|
|
131
|
+
} else if (name === 'crm_update_company') {
|
|
132
|
+
result = await this.handlers.updateCompany(args ?? {});
|
|
133
|
+
} else if (name === 'crm_delete_company') {
|
|
134
|
+
result = await this.handlers.deleteCompany(args ?? {});
|
|
135
|
+
} else if (name === 'crm_list_companies') {
|
|
136
|
+
result = await this.handlers.listCompanies(args ?? {});
|
|
137
|
+
}
|
|
138
|
+
// Stats & Dashboard
|
|
139
|
+
else if (name === 'crm_get_stats') {
|
|
140
|
+
result = await this.handlers.getStats();
|
|
141
|
+
} else if (name === 'crm_get_dashboard') {
|
|
142
|
+
result = await this.handlers.getDashboard(args ?? {});
|
|
143
|
+
}
|
|
144
|
+
// Unknown tool
|
|
145
|
+
else {
|
|
146
|
+
return {
|
|
147
|
+
content: [
|
|
148
|
+
{
|
|
149
|
+
type: 'text',
|
|
150
|
+
text: JSON.stringify({
|
|
151
|
+
success: false,
|
|
152
|
+
error: `Unknown tool: ${name}`,
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
content: [
|
|
161
|
+
{
|
|
162
|
+
type: 'text',
|
|
163
|
+
text: JSON.stringify(result, null, 2),
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const errorMessage = error instanceof CRMError ? error.message : String(error);
|
|
169
|
+
return {
|
|
170
|
+
content: [
|
|
171
|
+
{
|
|
172
|
+
type: 'text',
|
|
173
|
+
text: JSON.stringify({
|
|
174
|
+
success: false,
|
|
175
|
+
error: errorMessage,
|
|
176
|
+
}),
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
isError: true,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Start the STDIO server
|
|
187
|
+
*/
|
|
188
|
+
async start(): Promise<void> {
|
|
189
|
+
// Set up error handling
|
|
190
|
+
this.server.onerror = (error) => console.error('[CRM MCP Error]', error);
|
|
191
|
+
|
|
192
|
+
// Set up signal handlers for graceful shutdown
|
|
193
|
+
process.on('SIGINT', async () => {
|
|
194
|
+
console.error('[CRM MCP] Received SIGINT, shutting down...');
|
|
195
|
+
await this.server.close();
|
|
196
|
+
await this.storage.close();
|
|
197
|
+
process.exit(0);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
process.on('SIGTERM', async () => {
|
|
201
|
+
console.error('[CRM MCP] Received SIGTERM, shutting down...');
|
|
202
|
+
await this.server.close();
|
|
203
|
+
await this.storage.close();
|
|
204
|
+
process.exit(0);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Connect the transport
|
|
208
|
+
const transport = new StdioServerTransport();
|
|
209
|
+
await this.server.connect(transport);
|
|
210
|
+
|
|
211
|
+
// Log startup confirmation to stderr (doesn't interfere with JSON-RPC)
|
|
212
|
+
console.error('[CRM MCP] Server running on stdio');
|
|
213
|
+
|
|
214
|
+
// Keep stdin open to receive requests
|
|
215
|
+
process.stdin.resume();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Stop the server
|
|
220
|
+
*/
|
|
221
|
+
async stop(): Promise<void> {
|
|
222
|
+
await this.server.close();
|
|
223
|
+
await this.storage.close();
|
|
224
|
+
}
|
|
225
|
+
}
|