@configcat/mcp-server 0.1.2

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,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { HttpClient } from "../http";
3
+ export declare function registerConfigCatDocsTools(server: McpServer, http: HttpClient): Promise<void>;
4
+ //# sourceMappingURL=configcat-docs.d.ts.map
@@ -0,0 +1,73 @@
1
+ import { z } from "zod";
2
+ const LLMS_TXT_URL = "https://configcat.com/docs/llms.txt";
3
+ function extractMarkdownSection(content, sectionHeader) {
4
+ const sectionIndex = content.indexOf(sectionHeader);
5
+ if (sectionIndex !== -1) {
6
+ const rest = content.substring(sectionIndex + sectionHeader.length);
7
+ const nextHeadingIndex = rest.search(/\n###\s+/); // looks for "\n### ..."
8
+ let endIndex;
9
+ if (nextHeadingIndex !== -1) {
10
+ endIndex = sectionIndex + sectionHeader.length + nextHeadingIndex;
11
+ }
12
+ else {
13
+ endIndex = content.length;
14
+ }
15
+ // Extract just that section
16
+ return content.substring(sectionIndex, endIndex).trim();
17
+ }
18
+ return "";
19
+ }
20
+ export async function registerConfigCatDocsTools(server, http) {
21
+ const response = await http.fetch(LLMS_TXT_URL);
22
+ if (!response.ok) {
23
+ console.error(`Failed to fetch ${LLMS_TXT_URL} - HTTP ${response.status}: ${response.statusText}`);
24
+ return;
25
+ }
26
+ const sdkDocs = extractMarkdownSection(await response.text(), "### SDK Reference");
27
+ if (!sdkDocs) {
28
+ console.error(`Failed to extract SDK Reference section from ${LLMS_TXT_URL}`);
29
+ return;
30
+ }
31
+ server.tool("update-sdk-documentation", `If the user asks for coding related to a feature flag (such as integrating the ConfigCat SDK, adding a feature flag, or removing a feature flag),
32
+ always call the tool "update-sdk-documentation" first to download the latest ConfigCat SDK documentation.
33
+
34
+ 1. Analyze the SDK URLs listed in the following SDK Reference list.
35
+ 2. Then call the tool "update-sdk-documentation" with specific URL from the SDK Reference list to fetch relevant documentation page.
36
+
37
+ ${sdkDocs}`, {
38
+ url: z.string().url().describe("The URL to fetch SDK documentation from."),
39
+ }, async ({ url }) => {
40
+ try {
41
+ console.error(`Fetching documentation from: ${url}`);
42
+ const response = await http.fetch(url);
43
+ if (!response.ok) {
44
+ return {
45
+ content: [{
46
+ type: "text",
47
+ text: `Error: Failed to fetch ${url} - HTTP ${response.status}: ${response.statusText}`,
48
+ }],
49
+ isError: true,
50
+ };
51
+ }
52
+ const content = await response.text();
53
+ console.error(`Successfully fetched ${content.length} characters from ${url}`);
54
+ return {
55
+ content: [{
56
+ type: "text",
57
+ text: content,
58
+ }],
59
+ };
60
+ }
61
+ catch (error) {
62
+ console.error("Error fetching documentation:", error);
63
+ return {
64
+ content: [{
65
+ type: "text",
66
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
67
+ }],
68
+ isError: true,
69
+ };
70
+ }
71
+ });
72
+ }
73
+ //# sourceMappingURL=configcat-docs.js.map
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@configcat/mcp-server",
3
+ "version": "0.1.2",
4
+ "type": "module",
5
+ "description": "MCP server exposing ConfigCat Public Management API (products, configs, environments, values v1/v2).",
6
+ "engines": {
7
+ "node": ">=20.0.0"
8
+ },
9
+ "bin": {
10
+ "mcp-server": "build/index.js"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc -p .",
14
+ "start": "node build/index.js",
15
+ "dev": "npm run build -- --watch",
16
+ "lint": "eslint .",
17
+ "lint:fix": "eslint . --fix",
18
+ "lint:check": "eslint . --max-warnings 0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/configcat/configcat-mcp.git"
23
+ },
24
+ "keywords": [
25
+ "configcat",
26
+ "featureflags",
27
+ "feature flags",
28
+ "feature toggle",
29
+ "feature switch",
30
+ "mcp",
31
+ "modelcontextprotocol"
32
+ ],
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.17.4",
35
+ "json-schema-to-zod": "^2.6.1",
36
+ "zod": "^3.23.8",
37
+ "zod-to-json-schema": "^3.24.6"
38
+ },
39
+ "author": "ConfigCat",
40
+ "license": "MIT",
41
+ "homepage": "https://configcat.com",
42
+ "sideEffects": false,
43
+ "devDependencies": {
44
+ "@eslint/js": "^9.33.0",
45
+ "@stylistic/eslint-plugin": "^5.2.3",
46
+ "@types/node": "^22.7.4",
47
+ "eslint": "^9.33.0",
48
+ "eslint-plugin-import": "^2.32.0",
49
+ "globals": "^16.3.0",
50
+ "typescript": "^5.5.4",
51
+ "typescript-eslint": "^8.40.0"
52
+ }
53
+ }