@channlize/mcp 0.1.0 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # @channlize/mcp
2
+
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7e72a95: Rebuild the MCP server on the official MCP TypeScript SDK v2 (`@modelcontextprotocol/server`, `McpServer.registerTool`), with zod input and output schemas, structured content, tool annotations and clear tool errors.
8
+
9
+ - New server-key tools: `get_project`, `get_analytics`, `list_conversations`, `get_conversation`, `create_conversation`, `list_contacts`, `get_contact`, `create_contact`, `list_event_definitions`, `list_event_deliveries`, `query_logs`, `track_log`. `notify_event` now resolves the project from the key when `CHANNLIZE_PROJECT_ID` is unset.
10
+ - Keys: `CHANNLIZE_SERVER_API_KEY` enables the server tools and `CHANNLIZE_WIDGET_KEY` the visitor tools (contact form, chat). `CHANNLIZE_API_KEY` accepts either key and detects it by prefix. A widget key passed as the server key fails at startup with a clear message. Only tools for the configured keys are listed.
11
+ - New Streamable HTTP transport (`--transport http`, localhost-only by default, with Host/Origin checks). stdio stays the default.
12
+ - Rewritten resources (`channlize://project` plus quick-start, React and Events docs) and prompts (`triage-conversations`, `summarize-conversation`, `check-events`, `setup-events`, `setup-live-chat`, `integrate-contact-form`). The `customize-styling` and `handle-webhooks` prompts and the old schema/API-reference resources are removed, since they described APIs that don't exist.
13
+ - Breaking: requires Node.js 20+. `listTools` / `getTool` / `listResources` / `getPrompt` and `setConfig` are no longer exported; use `buildServer(config)` to get a configured `McpServer`.
14
+
15
+ ## 0.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - c113208: Add Events: post a Slack message from your server when something happens.
20
+
21
+ - `@channlize/core`: `client.notify(event, data?, { idempotencyKey?, channel? })` and a standalone `createNotifier()` that reads `CHANNLIZE_SERVER_API_KEY` / `CHANNLIZE_API_KEY` and `CHANNLIZE_PROJECT_ID`. Both call `POST /v1/notify` with the server API key (write scope). Event keys and data can be typed with `createNotifier<AppEvents>()` or by augmenting `ChannlizeEvents`. `trackEvent` / `trackServerEvent` are unchanged and now documented as log tracking. Fix: an explicit `baseUrl: undefined` or `timeout: undefined` no longer overrides the defaults.
22
+ - `@channlize/mcp`: new `notify_event` tool, enabled with `--server-api-key` / `CHANNLIZE_SERVER_API_KEY`.
23
+ - `@channlize/react`: docs only. `useChannlizeAnalytics().track` is documented as log tracking.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [c113208]
28
+ - @channlize/core@0.2.0
29
+
30
+ ## 0.1.1
31
+
32
+ ### Patch Changes
33
+
34
+ - 9ddf630: Errors thrown by the client now carry the API's human-readable `message`
35
+ (field messages joined for validation failures) instead of the error code,
36
+ and `ChannlizeError.code` is set from the API's `error` code.
37
+
38
+ `CreateContactResponse` gains the fields the API actually returns:
39
+ `success`, `conversationId` and `message`. The old `id`, `status` and
40
+ `slackThreadUrl` fields were never returned and are deprecated. The MCP
41
+ `submit_contact_form` tool now reports `conversationId`.
42
+
43
+ - Updated dependencies [9ddf630]
44
+ - @channlize/core@0.1.0
package/README.md CHANGED
@@ -1,394 +1,178 @@
1
1
  # @channlize/mcp
2
2
 
3
- Model Context Protocol (MCP) server for Channlize - enables AI agents to understand and interact with the Channlize platform.
3
+ [Model Context Protocol](https://modelcontextprotocol.io) server for [Channlize](https://channlize.com). It lets an AI assistant (Claude, Cursor, VS Code Copilot, Windsurf…) read your support inbox, contacts, logs and Events, and send Events to Slack.
4
4
 
5
- ## Overview
5
+ - Built on the official MCP TypeScript SDK v2 (`@modelcontextprotocol/server` 2.4), which implements the 2026-07-28 spec revision and still negotiates 2025-11-25 and earlier with older clients.
6
+ - Transports: **stdio** (default) and **Streamable HTTP** (`--transport http`). The deprecated HTTP+SSE transport isn't offered.
7
+ - Requires Node.js 20 or later.
6
8
 
7
- The Channlize MCP server provides AI agents (like Claude) with:
9
+ ## Keys
8
10
 
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
11
+ | Key | Where | Enables |
12
+ | --- | --- | --- |
13
+ | Server API key `ch_live_…` (secret) | `CHANNLIZE_SERVER_API_KEY` | Inbox, contacts, Events and log tools. `read` scope for the read tools, `write` scope to send Events and logs and open conversations or contacts. |
14
+ | Widget key `wk_…` (public, optional) | `CHANNLIZE_WIDGET_KEY` | Visitor-side tools (contact form, chat session), for testing your setup. |
12
15
 
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.
16
+ Create both in the dashboard under **SDK & Integration → API keys**. A read-only key is enough to explore and triage; use a `write` key only if the assistant should post to Slack.
14
17
 
15
- ## Installation
18
+ Other settings:
19
+
20
+ - `CHANNLIZE_PROJECT_ID`: the project for Events and logs. It defaults to the first project of the key's organization.
21
+ - `CHANNLIZE_API_KEY`: either kind of key, detected by its prefix.
22
+ - `CHANNLIZE_BASE_URL`: default `https://api.channlize.com`.
23
+ - `CHANNLIZE_TIMEOUT`: in ms, default 10000.
24
+
25
+ Each one has a matching flag (`--server-api-key`, `--widget-key`, `--project-id`, …); run `npx -y @channlize/mcp --help` to list them.
26
+
27
+ ## Setup
28
+
29
+ ### Claude Code
16
30
 
17
31
  ```bash
18
- npm install @channlize/mcp
32
+ claude mcp add channlize \
33
+ --env CHANNLIZE_SERVER_API_KEY=ch_live_… \
34
+ --env CHANNLIZE_PROJECT_ID=<project-id> \
35
+ -- npx -y @channlize/mcp
19
36
  ```
20
37
 
21
- ## Quick Start
38
+ Add `--scope user` to use it in every project. Check it with `claude mcp list`, or `/mcp` inside Claude Code.
22
39
 
23
- ### Standalone Server (Claude Desktop)
40
+ ### Claude Desktop
24
41
 
25
- Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
42
+ Edit `claude_desktop_config.json`:
26
43
 
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
- ```
44
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
45
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
43
46
 
44
- Or using environment variables:
47
+ Then restart Claude.
45
48
 
46
49
  ```json
47
50
  {
48
51
  "mcpServers": {
49
52
  "channlize": {
50
53
  "command": "npx",
51
- "args": ["@channlize/mcp"],
54
+ "args": ["-y", "@channlize/mcp"],
52
55
  "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
+ "CHANNLIZE_SERVER_API_KEY": "ch_live_…",
57
+ "CHANNLIZE_PROJECT_ID": "<project-id>"
56
58
  }
57
59
  }
58
60
  }
59
61
  }
60
62
  ```
61
63
 
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
- ```
64
+ ### Cursor
101
65
 
102
- Claude will read the `channlize://schema/contact-form` resource to understand the data structure.
66
+ Use `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project), with the same `mcpServers` block as Claude Desktop.
103
67
 
104
- ## Available Tools
68
+ ### VS Code (GitHub Copilot agent mode)
105
69
 
106
- Tools allow AI agents to interact with Channlize:
70
+ In `.vscode/mcp.json`, VS Code prompts for the key once and stores it securely:
107
71
 
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
72
+ ```json
123
73
  {
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"
74
+ "inputs": [
75
+ {
76
+ "type": "promptString",
77
+ "id": "channlize-key",
78
+ "description": "Channlize server API key (ch_live_…)",
79
+ "password": true
80
+ }
81
+ ],
82
+ "servers": {
83
+ "channlize": {
84
+ "type": "stdio",
85
+ "command": "npx",
86
+ "args": ["-y", "@channlize/mcp"],
87
+ "env": {
88
+ "CHANNLIZE_SERVER_API_KEY": "${input:channlize-key}",
89
+ "CHANNLIZE_PROJECT_ID": "<project-id>"
90
+ }
91
+ }
130
92
  }
131
93
  }
132
94
  ```
133
95
 
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.
96
+ ### Windsurf
174
97
 
175
- **Arguments:**
176
- - `framework` (optional): React framework being used (e.g., Next.js, Vite)
177
- - `styling` (optional): Styling approach (e.g., Tailwind, CSS Modules)
98
+ Use `~/.codeium/windsurf/mcp_config.json`, with the same `mcpServers` block as Claude Desktop.
178
99
 
179
- ### setup-live-chat
100
+ ### Streamable HTTP
180
101
 
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:
102
+ For clients that connect over HTTP:
197
103
 
198
104
  ```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
105
+ CHANNLIZE_SERVER_API_KEY=ch_live_… npx -y @channlize/mcp --transport http --port 3333
106
+ # → http://127.0.0.1:3333/mcp
220
107
  ```
221
108
 
222
- ### Environment Variables
109
+ It binds to `127.0.0.1` by default and rejects requests whose `Host` or `Origin` isn't localhost, which guards against DNS rebinding. Anyone who can reach the port acts with your key, so don't expose it on a public interface.
223
110
 
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)
111
+ ## Tools
228
112
 
229
- ## Example Interactions
113
+ Server API key:
230
114
 
231
- ### With Claude Desktop
115
+ | Tool | Scope | What it does |
116
+ | --- | --- | --- |
117
+ | `get_project` | any | Project name and ID, totals, the key's permissions, Slack connection |
118
+ | `get_analytics` | any | Daily conversations and messages for the last 30 days |
119
+ | `list_conversations` | read | Recent conversations, filtered by status or priority |
120
+ | `get_conversation` | read | One conversation with its message thread |
121
+ | `create_conversation` | write | Open a conversation for a customer (posted to Slack) |
122
+ | `list_contacts` | read | Customers, paginated |
123
+ | `get_contact` | read | One customer |
124
+ | `create_contact` | write | Find or create a customer by email |
125
+ | `notify_event` | write | Post an Event to Slack (`user.subscribed`…), idempotent with a key |
126
+ | `list_event_definitions` | read | Events set up on the project, including drafts |
127
+ | `list_event_deliveries` | read | Recent Event deliveries with status and skip/fail reason |
128
+ | `query_logs` | read | Search log tracking by severity, source, text and time |
129
+ | `track_log` | write | Record a log line |
232
130
 
233
- Once configured, you can ask Claude to:
131
+ Widget key (visitor side): `submit_contact_form`, `create_chat_session`, `send_message`, `get_chat_messages` and `close_chat_session`.
234
132
 
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?"
133
+ Each tool declares input and output schemas and annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`), and returns `structuredContent`. Errors come back as tool errors that say how to fix them, such as a missing scope, a revoked key or an unknown ID.
239
134
 
240
- 2. **Submit forms:**
241
- - "Submit a contact form with name 'John Doe', email 'john@example.com', and message 'Need help with billing'"
135
+ You can't reply to a conversation or change its status or priority through the API yet. The team does that in the Slack thread or the dashboard.
242
136
 
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
- ```
137
+ ## Resources and prompts
285
138
 
286
- ### Helper Functions
139
+ Resources:
287
140
 
288
- ```typescript
289
- // Resources
290
- function listResources(): Resource[];
291
- function getResource(uri: string): Resource | undefined;
141
+ - `channlize://project`: the live project, as JSON.
142
+ - `channlize://docs/quick-start`
143
+ - `channlize://docs/react-components`
144
+ - `channlize://docs/events`
292
145
 
293
- // Tools
294
- function listTools(): ToolDefinition[];
295
- function getTool(name: string): ToolDefinition | undefined;
146
+ Prompts:
296
147
 
297
- // Prompts
298
- function listPrompts(): PromptDefinition[];
299
- function getPrompt(name: string): PromptDefinition | undefined;
148
+ - `triage-conversations`: rank open conversations and draft replies.
149
+ - `summarize-conversation`
150
+ - `check-events`: explain skipped or failed deliveries.
151
+ - `setup-events`, `setup-live-chat`, `integrate-contact-form`: add Channlize to the codebase you're working in.
300
152
 
301
- // Factory
302
- function createMCPServer(options?: MCPServerOptions): ChannlizeMCPServer;
303
- ```
153
+ ## Troubleshooting
304
154
 
305
- ## Custom Integrations
155
+ - **"A Channlize key is required"**: set `CHANNLIZE_SERVER_API_KEY` in the client's `env` block, then restart the client.
156
+ - **"holds a widget key (wk_…)"**: you passed the public widget key as the server key. Create a server API key, or pass the widget key as `CHANNLIZE_WIDGET_KEY`.
157
+ - **401 invalid key**: the key was revoked, has expired or was mistyped. Create a new one.
158
+ - **403 lacks required permission**: the key is read-only. Create a key with the `write` scope for `notify_event`, `track_log`, `create_conversation` and `create_contact`.
159
+ - **404 project not found**: `CHANNLIZE_PROJECT_ID` is wrong, or belongs to another organization.
160
+ - **The server doesn't start**: check `node --version` (20+) and run `npx -y @channlize/mcp --help`. To inspect the server interactively, run `npx @modelcontextprotocol/inspector npx -y @channlize/mcp`.
306
161
 
307
- You can build custom MCP integrations using the library:
162
+ ## Programmatic use
308
163
 
309
- ```typescript
310
- import { createMCPServer, listTools, listResources } from '@channlize/mcp';
311
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
164
+ ```ts
165
+ import { ChannlizeMCPServer, buildServer } from '@channlize/mcp';
312
166
 
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
- },
167
+ const server = new ChannlizeMCPServer({
168
+ config: { serverApiKey: process.env.CHANNLIZE_SERVER_API_KEY },
319
169
  });
170
+ await server.runStdio(); // or: await server.runHttp({ port: 3333 })
320
171
 
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));
172
+ // Or get a configured McpServer for your own transport:
173
+ const mcp = buildServer({ serverApiKey: '…' });
328
174
  ```
329
175
 
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
176
  ## License
371
177
 
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
-
178
+ MIT