@channlize/mcp 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 ADDED
@@ -0,0 +1,394 @@
1
+ # @channlize/mcp
2
+
3
+ Model Context Protocol (MCP) server for Channlize - enables AI agents to understand and interact with the Channlize platform.
4
+
5
+ ## Overview
6
+
7
+ The Channlize MCP server provides AI agents (like Claude) with:
8
+
9
+ - **Resources**: Documentation, API schemas, and integration guides
10
+ - **Tools**: Ability to submit forms, create chat sessions, and send messages
11
+ - **Prompts**: Templates for common integration patterns
12
+
13
+ This package can be used both as a standalone MCP server (for Claude Desktop and other MCP clients) or as a library to build custom MCP integrations.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @channlize/mcp
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Standalone Server (Claude Desktop)
24
+
25
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "channlize": {
31
+ "command": "npx",
32
+ "args": [
33
+ "@channlize/mcp",
34
+ "--api-key",
35
+ "your-widget-key-here",
36
+ "--project-id",
37
+ "your-project-id-here"
38
+ ]
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ Or using environment variables:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "channlize": {
50
+ "command": "npx",
51
+ "args": ["@channlize/mcp"],
52
+ "env": {
53
+ "CHANNLIZE_API_KEY": "your-widget-key-here",
54
+ "CHANNLIZE_PROJECT_ID": "your-project-id-here",
55
+ "CHANNLIZE_BASE_URL": "https://api.channlize.com"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ### Library Usage
63
+
64
+ ```typescript
65
+ import { ChannlizeMCPServer } from '@channlize/mcp';
66
+
67
+ const server = new ChannlizeMCPServer({
68
+ name: 'my-channlize-server',
69
+ version: '1.0.0',
70
+ config: {
71
+ apiKey: process.env.CHANNLIZE_API_KEY!,
72
+ projectId: process.env.CHANNLIZE_PROJECT_ID,
73
+ baseUrl: process.env.CHANNLIZE_BASE_URL,
74
+ },
75
+ });
76
+
77
+ // Run with stdio transport (for MCP clients)
78
+ await server.runStdio();
79
+
80
+ // Or get the underlying Server instance for custom transports
81
+ const mcpServer = server.getServer();
82
+ ```
83
+
84
+ ## Available Resources
85
+
86
+ Resources provide read-only context about Channlize:
87
+
88
+ | URI | Description |
89
+ |-----|-------------|
90
+ | `channlize://schema/contact-form` | JSON schema for contact form data structure |
91
+ | `channlize://schema/chat-session` | JSON schema for chat session data structure |
92
+ | `channlize://docs/api-reference` | Complete Channlize API reference documentation |
93
+ | `channlize://docs/quick-start` | Quick start guide for using Channlize SDK |
94
+ | `channlize://docs/react-components` | Documentation for React components and hooks |
95
+
96
+ ### Example Usage in Claude
97
+
98
+ ```
99
+ Can you show me the contact form schema?
100
+ ```
101
+
102
+ Claude will read the `channlize://schema/contact-form` resource to understand the data structure.
103
+
104
+ ## Available Tools
105
+
106
+ Tools allow AI agents to interact with Channlize:
107
+
108
+ ### submit_contact_form
109
+
110
+ Submit a contact form inquiry to Channlize.
111
+
112
+ **Parameters:**
113
+ - `name` (string, required): Contact's full name
114
+ - `email` (string, required): Contact's email address
115
+ - `message` (string, required): The message content
116
+ - `subject` (string, optional): Subject line
117
+ - `customFields` (object, optional): Additional custom fields
118
+ - `pageUrl` (string, optional): URL where form was submitted
119
+ - `userAgent` (string, optional): User agent string
120
+
121
+ **Example:**
122
+ ```typescript
123
+ {
124
+ "name": "submit_contact_form",
125
+ "arguments": {
126
+ "name": "John Doe",
127
+ "email": "john@example.com",
128
+ "message": "I need help with my account",
129
+ "subject": "Account Support"
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### create_chat_session
135
+
136
+ Create a new real-time chat session.
137
+
138
+ **Parameters:**
139
+ - `metadata` (object, optional): Custom session metadata
140
+
141
+ **Returns:** Session ID and SSE endpoint for real-time updates
142
+
143
+ ### send_message
144
+
145
+ Send a message in an existing chat session.
146
+
147
+ **Parameters:**
148
+ - `sessionId` (string, required): The chat session ID
149
+ - `content` (string, required): Message content
150
+
151
+ ### get_chat_messages
152
+
153
+ Retrieve messages from a chat session.
154
+
155
+ **Parameters:**
156
+ - `sessionId` (string, required): The chat session ID
157
+ - `limit` (number, optional): Max messages to retrieve (default: 50)
158
+ - `offset` (number, optional): Number of messages to skip (default: 0)
159
+
160
+ ### close_chat_session
161
+
162
+ Close an active chat session.
163
+
164
+ **Parameters:**
165
+ - `sessionId` (string, required): The chat session ID to close
166
+
167
+ ## Available Prompts
168
+
169
+ Prompts provide templates for common integration scenarios:
170
+
171
+ ### integrate-contact-form
172
+
173
+ Guide for adding a Channlize contact form to a React application.
174
+
175
+ **Arguments:**
176
+ - `framework` (optional): React framework being used (e.g., Next.js, Vite)
177
+ - `styling` (optional): Styling approach (e.g., Tailwind, CSS Modules)
178
+
179
+ ### setup-live-chat
180
+
181
+ Guide for implementing the Channlize live chat widget.
182
+
183
+ **Arguments:**
184
+ - `placement` (optional): Widget placement (e.g., "page", "popup", "sidebar")
185
+
186
+ ### customize-styling
187
+
188
+ Guide for theming and customizing Channlize components.
189
+
190
+ ### handle-webhooks
191
+
192
+ Guide for integrating Channlize webhooks into custom workflows.
193
+
194
+ ## CLI Usage
195
+
196
+ The standalone server can be run directly from the command line:
197
+
198
+ ```bash
199
+ # Using npx
200
+ npx @channlize/mcp --api-key wk_123abc --project-id proj_456def
201
+
202
+ # Or install globally
203
+ npm install -g @channlize/mcp
204
+ channlize-mcp --api-key wk_123abc --project-id proj_456def
205
+
206
+ # Using environment variables
207
+ export CHANNLIZE_API_KEY=wk_123abc
208
+ export CHANNLIZE_PROJECT_ID=proj_456def
209
+ channlize-mcp
210
+ ```
211
+
212
+ ### CLI Options
213
+
214
+ ```
215
+ --api-key <key> Channlize API key (widget key) [required]
216
+ --project-id <id> Channlize project ID
217
+ --base-url <url> Channlize API base URL (default: https://api.channlize.com)
218
+ --timeout <ms> Request timeout in milliseconds (default: 10000)
219
+ -h, --help Show help message
220
+ ```
221
+
222
+ ### Environment Variables
223
+
224
+ - `CHANNLIZE_API_KEY`: Your Channlize widget key
225
+ - `CHANNLIZE_PROJECT_ID`: Your project ID
226
+ - `CHANNLIZE_BASE_URL`: API base URL (optional)
227
+ - `CHANNLIZE_TIMEOUT`: Request timeout in ms (optional)
228
+
229
+ ## Example Interactions
230
+
231
+ ### With Claude Desktop
232
+
233
+ Once configured, you can ask Claude to:
234
+
235
+ 1. **Learn about Channlize:**
236
+ - "What is Channlize and how does it work?"
237
+ - "Show me how to integrate a contact form"
238
+ - "What's the structure of a chat session?"
239
+
240
+ 2. **Submit forms:**
241
+ - "Submit a contact form with name 'John Doe', email 'john@example.com', and message 'Need help with billing'"
242
+
243
+ 3. **Manage chat sessions:**
244
+ - "Create a new chat session"
245
+ - "Send a message 'Hello!' to session session_123"
246
+ - "Get messages from session session_123"
247
+
248
+ 4. **Get integration help:**
249
+ - "Show me how to add a contact form to my Next.js app with Tailwind CSS"
250
+ - "How do I set up webhooks for Channlize?"
251
+
252
+ ## API Reference
253
+
254
+ ### ChannlizeMCPServer
255
+
256
+ Main server class for creating MCP servers.
257
+
258
+ ```typescript
259
+ class ChannlizeMCPServer {
260
+ constructor(options?: MCPServerOptions);
261
+
262
+ setConfig(config: ChannlizeMCPConfig): void;
263
+ getServer(): Server;
264
+ runStdio(): Promise<void>;
265
+ close(): Promise<void>;
266
+ }
267
+ ```
268
+
269
+ ### Types
270
+
271
+ ```typescript
272
+ interface ChannlizeMCPConfig {
273
+ apiKey: string;
274
+ projectId?: string;
275
+ baseUrl?: string;
276
+ timeout?: number;
277
+ }
278
+
279
+ interface MCPServerOptions {
280
+ name?: string;
281
+ version?: string;
282
+ config?: ChannlizeMCPConfig;
283
+ }
284
+ ```
285
+
286
+ ### Helper Functions
287
+
288
+ ```typescript
289
+ // Resources
290
+ function listResources(): Resource[];
291
+ function getResource(uri: string): Resource | undefined;
292
+
293
+ // Tools
294
+ function listTools(): ToolDefinition[];
295
+ function getTool(name: string): ToolDefinition | undefined;
296
+
297
+ // Prompts
298
+ function listPrompts(): PromptDefinition[];
299
+ function getPrompt(name: string): PromptDefinition | undefined;
300
+
301
+ // Factory
302
+ function createMCPServer(options?: MCPServerOptions): ChannlizeMCPServer;
303
+ ```
304
+
305
+ ## Custom Integrations
306
+
307
+ You can build custom MCP integrations using the library:
308
+
309
+ ```typescript
310
+ import { createMCPServer, listTools, listResources } from '@channlize/mcp';
311
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
312
+
313
+ // Create server with your config
314
+ const server = createMCPServer({
315
+ config: {
316
+ apiKey: process.env.CHANNLIZE_API_KEY!,
317
+ projectId: process.env.CHANNLIZE_PROJECT_ID,
318
+ },
319
+ });
320
+
321
+ // Use custom transport (e.g., HTTP + SSE)
322
+ const transport = new SSEServerTransport('/mcp', response);
323
+ await server.getServer().connect(transport);
324
+
325
+ // List available capabilities
326
+ console.log('Resources:', listResources().map(r => r.uri));
327
+ console.log('Tools:', listTools().map(t => t.name));
328
+ ```
329
+
330
+ ## Security
331
+
332
+ - API keys are required for all tool operations
333
+ - Keys are never exposed in resource responses
334
+ - Webhook signature verification recommended for production
335
+ - Use environment variables for sensitive credentials
336
+
337
+ ## Error Handling
338
+
339
+ The server handles and reports errors gracefully:
340
+
341
+ ```typescript
342
+ try {
343
+ await client.submitContactForm(data);
344
+ } catch (error) {
345
+ // Error details returned to MCP client
346
+ console.error({
347
+ success: false,
348
+ error: error.message,
349
+ code: error.code,
350
+ statusCode: error.statusCode,
351
+ });
352
+ }
353
+ ```
354
+
355
+ ## Requirements
356
+
357
+ - Node.js 18+
358
+ - Valid Channlize API key (widget key)
359
+ - Active Channlize project
360
+
361
+ ## Related Packages
362
+
363
+ - [@channlize/core](../core) - Core TypeScript SDK
364
+ - [@channlize/react](../react) - React components and hooks
365
+
366
+ ## Contributing
367
+
368
+ See the main [SDK repository](https://github.com/channlize/sdk) for contribution guidelines.
369
+
370
+ ## License
371
+
372
+ MIT - see [LICENSE](../../LICENSE) file for details.
373
+
374
+ ## Support
375
+
376
+ - Documentation: https://docs.channlize.com
377
+ - GitHub Issues: https://github.com/channlize/sdk/issues
378
+ - Email: support@channlize.com
379
+
380
+ ## Changelog
381
+
382
+ ### 0.1.0 (Initial Release)
383
+
384
+ - MCP server with stdio transport
385
+ - 5 resources (schemas + docs)
386
+ - 5 tools (form submission, chat management)
387
+ - 4 prompts (integration guides)
388
+ - Library and CLI support
389
+ - Full TypeScript support
390
+
391
+
392
+
393
+
394
+
@@ -0,0 +1,118 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ export { AuthenticationError, ChannlizeConfig, ChannlizeError, ChatMessage, ChatSession, ContactFormData, CreateChatSessionResponse, CreateContactResponse, FileAttachment, RateLimitError, SendMessageResponse, ValidationError } from '@channlize/core';
3
+
4
+ /**
5
+ * MCP-specific types and configuration for Channlize
6
+ */
7
+ interface ChannlizeMCPConfig {
8
+ /** Channlize API key (widget key) */
9
+ apiKey: string;
10
+ /** Channlize project ID */
11
+ projectId?: string;
12
+ /** Base URL for Channlize API */
13
+ baseUrl?: string;
14
+ /** Request timeout in milliseconds */
15
+ timeout?: number;
16
+ }
17
+ interface MCPServerOptions {
18
+ /** Server name */
19
+ name?: string;
20
+ /** Server version */
21
+ version?: string;
22
+ /** Channlize configuration */
23
+ config?: ChannlizeMCPConfig;
24
+ }
25
+ interface ToolContext {
26
+ config: ChannlizeMCPConfig;
27
+ }
28
+ interface ResourceContext {
29
+ config?: ChannlizeMCPConfig;
30
+ }
31
+
32
+ /**
33
+ * MCP Resources for Channlize
34
+ * Provides read-only context about schemas, API docs, and guides
35
+ */
36
+ interface Resource {
37
+ uri: string;
38
+ name: string;
39
+ description: string;
40
+ mimeType: string;
41
+ getText(): string;
42
+ }
43
+ declare function getResource(uri: string): Resource | undefined;
44
+ declare function listResources(): Resource[];
45
+
46
+ /**
47
+ * MCP Tools for Channlize
48
+ * Wraps ChannlizeClient methods for AI agent interaction
49
+ */
50
+
51
+ interface ToolDefinition {
52
+ name: string;
53
+ description: string;
54
+ inputSchema: {
55
+ type: 'object';
56
+ properties: Record<string, any>;
57
+ required?: string[];
58
+ };
59
+ handler: (args: any, context: ToolContext) => Promise<any>;
60
+ }
61
+ declare function getTool(name: string): ToolDefinition | undefined;
62
+ declare function listTools(): ToolDefinition[];
63
+
64
+ /**
65
+ * MCP Prompts for Channlize
66
+ * Templates for common integration patterns and use cases
67
+ */
68
+ interface PromptDefinition {
69
+ name: string;
70
+ description: string;
71
+ arguments?: Array<{
72
+ name: string;
73
+ description: string;
74
+ required?: boolean;
75
+ }>;
76
+ getPrompt: (args?: Record<string, string>) => string;
77
+ }
78
+ declare function getPrompt(name: string): PromptDefinition | undefined;
79
+ declare function listPrompts(): PromptDefinition[];
80
+
81
+ /**
82
+ * @channlize/mcp
83
+ * Model Context Protocol (MCP) server for Channlize
84
+ * Enables AI agents to interact with Channlize platform
85
+ */
86
+
87
+ /**
88
+ * Channlize MCP Server
89
+ * Provides resources, tools, and prompts for AI agents
90
+ */
91
+ declare class ChannlizeMCPServer {
92
+ private server;
93
+ private config?;
94
+ constructor(options?: MCPServerOptions);
95
+ private setupHandlers;
96
+ /**
97
+ * Set or update the Channlize configuration
98
+ */
99
+ setConfig(config: ChannlizeMCPConfig): void;
100
+ /**
101
+ * Get the underlying MCP server instance
102
+ */
103
+ getServer(): Server;
104
+ /**
105
+ * Start the server with stdio transport
106
+ */
107
+ runStdio(): Promise<void>;
108
+ /**
109
+ * Close the server
110
+ */
111
+ close(): Promise<void>;
112
+ }
113
+ /**
114
+ * Create and return a new Channlize MCP Server instance
115
+ */
116
+ declare function createMCPServer(options?: MCPServerOptions): ChannlizeMCPServer;
117
+
118
+ export { type ChannlizeMCPConfig, ChannlizeMCPServer, type MCPServerOptions, type ResourceContext, type ToolContext, createMCPServer, ChannlizeMCPServer as default, getPrompt, getResource, getTool, listPrompts, listResources, listTools };
@@ -0,0 +1,118 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ export { AuthenticationError, ChannlizeConfig, ChannlizeError, ChatMessage, ChatSession, ContactFormData, CreateChatSessionResponse, CreateContactResponse, FileAttachment, RateLimitError, SendMessageResponse, ValidationError } from '@channlize/core';
3
+
4
+ /**
5
+ * MCP-specific types and configuration for Channlize
6
+ */
7
+ interface ChannlizeMCPConfig {
8
+ /** Channlize API key (widget key) */
9
+ apiKey: string;
10
+ /** Channlize project ID */
11
+ projectId?: string;
12
+ /** Base URL for Channlize API */
13
+ baseUrl?: string;
14
+ /** Request timeout in milliseconds */
15
+ timeout?: number;
16
+ }
17
+ interface MCPServerOptions {
18
+ /** Server name */
19
+ name?: string;
20
+ /** Server version */
21
+ version?: string;
22
+ /** Channlize configuration */
23
+ config?: ChannlizeMCPConfig;
24
+ }
25
+ interface ToolContext {
26
+ config: ChannlizeMCPConfig;
27
+ }
28
+ interface ResourceContext {
29
+ config?: ChannlizeMCPConfig;
30
+ }
31
+
32
+ /**
33
+ * MCP Resources for Channlize
34
+ * Provides read-only context about schemas, API docs, and guides
35
+ */
36
+ interface Resource {
37
+ uri: string;
38
+ name: string;
39
+ description: string;
40
+ mimeType: string;
41
+ getText(): string;
42
+ }
43
+ declare function getResource(uri: string): Resource | undefined;
44
+ declare function listResources(): Resource[];
45
+
46
+ /**
47
+ * MCP Tools for Channlize
48
+ * Wraps ChannlizeClient methods for AI agent interaction
49
+ */
50
+
51
+ interface ToolDefinition {
52
+ name: string;
53
+ description: string;
54
+ inputSchema: {
55
+ type: 'object';
56
+ properties: Record<string, any>;
57
+ required?: string[];
58
+ };
59
+ handler: (args: any, context: ToolContext) => Promise<any>;
60
+ }
61
+ declare function getTool(name: string): ToolDefinition | undefined;
62
+ declare function listTools(): ToolDefinition[];
63
+
64
+ /**
65
+ * MCP Prompts for Channlize
66
+ * Templates for common integration patterns and use cases
67
+ */
68
+ interface PromptDefinition {
69
+ name: string;
70
+ description: string;
71
+ arguments?: Array<{
72
+ name: string;
73
+ description: string;
74
+ required?: boolean;
75
+ }>;
76
+ getPrompt: (args?: Record<string, string>) => string;
77
+ }
78
+ declare function getPrompt(name: string): PromptDefinition | undefined;
79
+ declare function listPrompts(): PromptDefinition[];
80
+
81
+ /**
82
+ * @channlize/mcp
83
+ * Model Context Protocol (MCP) server for Channlize
84
+ * Enables AI agents to interact with Channlize platform
85
+ */
86
+
87
+ /**
88
+ * Channlize MCP Server
89
+ * Provides resources, tools, and prompts for AI agents
90
+ */
91
+ declare class ChannlizeMCPServer {
92
+ private server;
93
+ private config?;
94
+ constructor(options?: MCPServerOptions);
95
+ private setupHandlers;
96
+ /**
97
+ * Set or update the Channlize configuration
98
+ */
99
+ setConfig(config: ChannlizeMCPConfig): void;
100
+ /**
101
+ * Get the underlying MCP server instance
102
+ */
103
+ getServer(): Server;
104
+ /**
105
+ * Start the server with stdio transport
106
+ */
107
+ runStdio(): Promise<void>;
108
+ /**
109
+ * Close the server
110
+ */
111
+ close(): Promise<void>;
112
+ }
113
+ /**
114
+ * Create and return a new Channlize MCP Server instance
115
+ */
116
+ declare function createMCPServer(options?: MCPServerOptions): ChannlizeMCPServer;
117
+
118
+ export { type ChannlizeMCPConfig, ChannlizeMCPServer, type MCPServerOptions, type ResourceContext, type ToolContext, createMCPServer, ChannlizeMCPServer as default, getPrompt, getResource, getTool, listPrompts, listResources, listTools };