@id3-clarity/mcp-server 1.5.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/dist/config.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadConfig = loadConfig;
4
+ function loadConfig() {
5
+ const apiUrl = process.env.CLARITY_API_URL;
6
+ const apiToken = process.env.CLARITY_API_TOKEN;
7
+ if (!apiUrl)
8
+ throw new Error('CLARITY_API_URL env var required');
9
+ if (!apiToken)
10
+ throw new Error('CLARITY_API_TOKEN env var required');
11
+ if (!/^clr_[a-z0-9]{32}$/.test(apiToken)) {
12
+ throw new Error('CLARITY_API_TOKEN format invalid (expected: clr_<32 alphanumeric>)');
13
+ }
14
+ const lang = process.env.CLARITY_LANG === 'tr' ? 'tr' : 'en';
15
+ return { apiUrl: apiUrl.replace(/\/$/, ''), apiToken, lang };
16
+ }
17
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAMA,gCAUC;AAVD,SAAgB,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC/C,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACjE,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACrE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ ready: string;
3
+ configError: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = { ready: 'CLARITY MCP Server ready', configError: 'Configuration error' };
4
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":";;AAAA,kBAAe,EAAE,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ ready: string;
3
+ configError: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = { ready: 'CLARITY MCP Server hazır', configError: 'Yapılandırma hatası' };
4
+ //# sourceMappingURL=tr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tr.js","sourceRoot":"","sources":["../../src/i18n/tr.ts"],"names":[],"mappings":";;AAAA,kBAAe,EAAE,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
5
+ const config_1 = require("./config");
6
+ const server_1 = require("./server");
7
+ async function main() {
8
+ const config = (0, config_1.loadConfig)();
9
+ const server = (0, server_1.createServer)(config);
10
+ const transport = new stdio_js_1.StdioServerTransport();
11
+ await server.connect(transport);
12
+ console.error(`@id3-clarity/mcp-server ready (lang=${config.lang})`);
13
+ }
14
+ main().catch((err) => {
15
+ console.error('Fatal:', err.message);
16
+ process.exit(1);
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,qCAAsC;AACtC,qCAAwC;AAExC,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,uCAAuC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;AACvE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { ServerConfig } from './config';
3
+ export declare function createServer(config: ServerConfig): Server;
package/dist/server.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createServer = createServer;
4
+ /*
5
+ * ARCHITECTURAL DECISION: low-level `Server` API is intentional. DO NOT migrate
6
+ * to the high-level `McpServer` without re-validating the tool contract.
7
+ * --------------------------------------------------------------------------
8
+ * We use the low-level `Server` API (JSDoc-`@deprecated` in MCP SDK ≥1.x, but
9
+ * still fully exported and explicitly supported "for advanced use cases").
10
+ * Our 68 tool definitions in `src/tools/index.ts` are RAW JSON Schema objects
11
+ * derived from CLARITY's OpenAPI. The low-level ListTools handler advertises
12
+ * those schemas to clients VERBATIM, and CallTool forwards `arguments`
13
+ * untouched (CLARITY validates server-side).
14
+ *
15
+ * Why NOT `McpServer.registerTool` (verified against installed SDK 1.29.0):
16
+ * 1. `registerTool`'s `inputSchema` type is `ZodRawShapeCompat | AnySchema`
17
+ * where `AnySchema = z3.ZodTypeAny | z4.$ZodType` — i.e. ZOD ONLY. There
18
+ * is no raw-JSON-Schema escape hatch; passing our objects throws
19
+ * "inputSchema must be a Zod schema or raw shape" (mcp.js:869).
20
+ * 2. McpServer builds `tools/list` by running each Zod schema through
21
+ * `toJsonSchemaCompat` (zod→JSON-Schema). That output is NOT byte-equal
22
+ * to our raw schemas: it injects `$schema`, and `z.string().uuid()`
23
+ * expands to a `format:"uuid"` PLUS a `pattern` regex — diverging on all
24
+ * 63 uuid-typed params. MCP clients depend on this exact JSON, so it is a
25
+ * breaking contract change.
26
+ * 3. McpServer additionally validates input client-side: Zod objects STRIP
27
+ * unknown keys (or `.strict()` REJECTS) before the call — changing
28
+ * today's pass-through semantics.
29
+ *
30
+ * The contract is locked by `server.contract.test.ts` (snapshot of all 68
31
+ * tools' tools/list output + verbatim-pass-through assertions). Run `npm test`.
32
+ *
33
+ * REVISIT TRIGGER: only migrate if a future SDK adds raw-JSON-Schema tool
34
+ * registration that preserves `tools/list` byte-for-byte AND keeps unknown-key
35
+ * pass-through — verify by running the contract test against the new path
36
+ * before deleting these eslint-disables.
37
+ */
38
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- see header comment
39
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js"); // NOSONAR
40
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
41
+ const clarity_api_client_1 = require("./client/clarity-api-client");
42
+ const tools_1 = require("./tools");
43
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- see header comment
44
+ function createServer(config) {
45
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- see header comment
46
+ const server = new index_js_1.Server(// NOSONAR
47
+ { name: '@id3-clarity/mcp-server', version: '1.5.0' }, { capabilities: { tools: {} } });
48
+ const client = new clarity_api_client_1.ClarityApiClient(config);
49
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
50
+ tools: tools_1.TOOLS.map((t) => ({
51
+ name: t.name,
52
+ description: t.description[config.lang] ?? t.description.en,
53
+ inputSchema: t.inputSchema,
54
+ })),
55
+ }));
56
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
57
+ // The CallToolRequestSchema infers `arguments` as
58
+ // Record<string, unknown> | undefined, so the previous `as` cast
59
+ // was a no-op (S4325). Default to {} and let the inferred type flow.
60
+ const args = req.params.arguments ?? {};
61
+ const result = await client.invokeTool(req.params.name, args);
62
+ return {
63
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
64
+ isError: result.success === false && !result.requiresConfirmation,
65
+ };
66
+ });
67
+ return server;
68
+ }
69
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AA0CA,oCA6BC;AAvED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,kFAAkF;AAClF,wEAAmE,CAAC,UAAU;AAC9E,iEAAmG;AAEnG,oEAA+D;AAC/D,mCAAgC;AAEhC,kFAAkF;AAClF,SAAgB,YAAY,CAAC,MAAoB;IAC/C,kFAAkF;IAClF,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAE,UAAU;IACnC,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,OAAO,EAAE,EACrD,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,qCAAgB,CAAC,MAAM,CAAC,CAAC;IAE5C,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC5D,KAAK,EAAE,aAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACvB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE;YAC3D,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;IAEJ,MAAM,CAAC,iBAAiB,CAAC,gCAAqB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC5D,kDAAkD;QAClD,iEAAiE;QACjE,qEAAqE;QACrE,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,oBAAoB;SAClE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface ToolDefinition {
2
+ name: string;
3
+ description: {
4
+ tr: string;
5
+ en: string;
6
+ };
7
+ inputSchema: Record<string, unknown>;
8
+ }
9
+ export declare const TOOLS: ToolDefinition[];