@kerabie/mcp 0.0.0-stage → 1.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.
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createHttpHandler
4
+ } from "./chunk-4MMO737J.js";
5
+ import "./chunk-72BI6YMN.js";
6
+
7
+ // src/cli-http.ts
8
+ import { createServer as createHttpServer } from "http";
9
+ var port = Number(process.env.PORT) || 3333;
10
+ var server = createHttpServer(createHttpHandler({ baseUrl: process.env.KERABIE_BASE_URL }));
11
+ server.requestTimeout = 6e4;
12
+ server.listen(port, () => console.error(`kerabie-mcp-http listening on :${port} (POST /mcp, GET /health)`));
13
+ for (const sig of ["SIGINT", "SIGTERM"]) process.on(sig, () => server.close(() => process.exit(0)));
package/dist/cli.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createServer
4
+ } from "./chunk-72BI6YMN.js";
5
+
6
+ // src/cli.ts
7
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ import { KerAbieClient } from "@kerabie/sdk";
9
+ var apiKey = process.env.KERABIE_API_KEY;
10
+ var client = apiKey ? new KerAbieClient({ apiKey, baseUrl: process.env.KERABIE_BASE_URL, orgId: process.env.KERABIE_ORG_ID }) : null;
11
+ if (!client) console.error("kerabie-mcp: no KERABIE_API_KEY set, so only the documentation tools are available. Add a key (Settings > API) to work with your account.");
12
+ var readOnly = process.env.KERABIE_MCP_READ_ONLY === "true" || process.argv.includes("--read-only");
13
+ await createServer(client, { readOnly }).connect(new StdioServerTransport());
14
+ console.error(`kerabie-mcp running${client ? "" : " (docs only)"}${readOnly ? " (read-only)" : ""}`);
@@ -0,0 +1,105 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { KerAbieClient } from '@kerabie/sdk';
3
+ import { z } from 'zod';
4
+ import { IncomingMessage, ServerResponse } from 'node:http';
5
+
6
+ /**
7
+ * Every tool the server offers, as data: name, description, input schema and what it calls on the Kerabie SDK.
8
+ * Only API routes that exist are exposed. Tools that change anything are `write: true` (and `destructive`
9
+ * when they delete), so a read-only server simply leaves them out.
10
+ */
11
+ interface ToolDef {
12
+ name: string;
13
+ title: string;
14
+ description: string;
15
+ input: z.ZodRawShape;
16
+ write?: boolean;
17
+ destructive?: boolean;
18
+ /** Answers from bundled knowledge, so it needs no API key. */
19
+ local?: boolean;
20
+ run: (c: KerAbieClient, a: any) => Promise<unknown>;
21
+ }
22
+ declare const TOOLS: ToolDef[];
23
+
24
+ /** The most text one tool answer carries. Past it the answer says so and points at pagination. */
25
+ declare const MAX_RESULT_CHARS = 60000;
26
+ interface ServerOptions {
27
+ /** Leave out every tool that changes something. */
28
+ readOnly?: boolean;
29
+ version?: string;
30
+ }
31
+ /** The tools a server with these options offers. */
32
+ declare const ALL_TOOLS: ToolDef[];
33
+ /** The tools a server offers: with no client (no API key) only the documentation tools; read-only drops every tool that changes something. */
34
+ declare const toolsFor: (readOnly: boolean, hasClient?: boolean) => ToolDef[];
35
+ declare function formatResult(value: unknown): string;
36
+ /** An API error as something the model can act on: what failed, and why. */
37
+ declare function formatError(e: unknown): string;
38
+ declare function createServer(client: KerAbieClient | null, opts?: ServerOptions): McpServer;
39
+
40
+ /** `Authorization: Bearer ker_live_...` → the key, or null. */
41
+ declare function bearerKey(header: string | undefined | null): string | null;
42
+
43
+ interface HttpOptions {
44
+ /** The Kerabie API the tools call. Defaults to the SDK's own default (https://api.kerabie.com). */
45
+ baseUrl?: string;
46
+ version?: string;
47
+ }
48
+ /**
49
+ * A hosted MCP endpoint: `POST /mcp` over Streamable HTTP, one stateless server per request.
50
+ *
51
+ * The caller's own API key (`Authorization: Bearer ker_live_...`) is used for every tool call, so a person
52
+ * can only ever do what their key allows, and nothing is stored here. With no key only the documentation
53
+ * tools are offered. `?readOnly=true` leaves out every tool that changes something.
54
+ */
55
+ declare function createHttpHandler(opts?: HttpOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
56
+
57
+ /**
58
+ * Tools for developers building on Kerabie: the docs, the API endpoint list, the TypeScript and React Native
59
+ * SDK types, and integration guides. They answer from knowledge bundled into the package, so they work without
60
+ * an API key and match the SDK versions that ship with it.
61
+ */
62
+ declare const DEV_TOOLS: ToolDef[];
63
+
64
+ interface Doc {
65
+ id: string;
66
+ url: string;
67
+ title: string;
68
+ description: string;
69
+ section: string;
70
+ body: string;
71
+ headings: {
72
+ level: number;
73
+ text: string;
74
+ }[];
75
+ }
76
+ interface Endpoint {
77
+ method: string;
78
+ path: string;
79
+ title: string;
80
+ doc: string;
81
+ sdk: string;
82
+ }
83
+ interface SearchHit {
84
+ id: string;
85
+ title: string;
86
+ section: string;
87
+ url: string;
88
+ snippet: string;
89
+ score: number;
90
+ }
91
+ /** Scores a doc by how many query words appear in its title (heavily), headings and text. */
92
+ declare function searchDocs(query: string, opts?: {
93
+ section?: string;
94
+ limit?: number;
95
+ }, docs?: Doc[]): SearchHit[];
96
+ /** One doc, or only the part under `heading` (up to the next heading of the same or higher level). */
97
+ declare function getDocText(doc: Doc, heading?: string): string | null;
98
+ declare function findDoc(id: string, docs?: Doc[]): Doc | undefined;
99
+ declare function searchEndpoints(query: string | undefined, endpoints?: Endpoint[]): Endpoint[];
100
+ /** Names declared in a type source. */
101
+ declare function listDeclarations(source: string): string[];
102
+ /** The text of one declaration (with the doc comment above it), found by name. */
103
+ declare function extractDeclaration(source: string, name: string): string | null;
104
+
105
+ export { ALL_TOOLS, DEV_TOOLS, type HttpOptions, MAX_RESULT_CHARS, type ServerOptions, TOOLS, type ToolDef, bearerKey, createHttpHandler, createServer, extractDeclaration, findDoc, formatError, formatResult, getDocText, listDeclarations, searchDocs, searchEndpoints, toolsFor };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ import {
2
+ bearerKey,
3
+ createHttpHandler
4
+ } from "./chunk-4MMO737J.js";
5
+ import {
6
+ ALL_TOOLS,
7
+ DEV_TOOLS,
8
+ MAX_RESULT_CHARS,
9
+ TOOLS,
10
+ createServer,
11
+ extractDeclaration,
12
+ findDoc,
13
+ formatError,
14
+ formatResult,
15
+ getDocText,
16
+ listDeclarations,
17
+ searchDocs,
18
+ searchEndpoints,
19
+ toolsFor
20
+ } from "./chunk-72BI6YMN.js";
21
+ export {
22
+ ALL_TOOLS,
23
+ DEV_TOOLS,
24
+ MAX_RESULT_CHARS,
25
+ TOOLS,
26
+ bearerKey,
27
+ createHttpHandler,
28
+ createServer,
29
+ extractDeclaration,
30
+ findDoc,
31
+ formatError,
32
+ formatResult,
33
+ getDocText,
34
+ listDeclarations,
35
+ searchDocs,
36
+ searchEndpoints,
37
+ toolsFor
38
+ };
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@kerabie/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "MCP server for Kerabie: lets Claude, Cursor and other MCP clients work with your conversations, tickets, contacts, campaigns, knowledge base, analytics and AI tools",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "kerabie-mcp": "dist/cli.js",
9
+ "kerabie-mcp-http": "dist/cli-http.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "keywords": [
16
+ "kerabie",
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "helpdesk",
20
+ "customer-support"
21
+ ],
22
+ "license": "MIT",
23
+ "scripts": {
24
+ "knowledge": "node scripts/build-knowledge.mjs",
25
+ "build": "node scripts/build-knowledge.mjs && tsup",
26
+ "typecheck": "tsc --noEmit",
27
+ "test": "vitest run",
28
+ "sync": "node scripts/build-knowledge.mjs",
29
+ "dev:worker": "wrangler dev",
30
+ "deploy": "wrangler deploy"
31
+ },
32
+ "dependencies": {
33
+ "@kerabie/sdk": "^1.0.1",
34
+ "@modelcontextprotocol/sdk": "^1.32.1",
35
+ "zod": "^3.25.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^20.0.0",
39
+ "tsup": "^8.0.0",
40
+ "typescript": "^5.3.0",
41
+ "vitest": "^3.0.0",
42
+ "wrangler": "^4.0.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ }
47
+ }