@regle/mcp-server 1.14.6 → 1.14.7-beta.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.
- package/dist/regle-mcp-server.d.ts +1 -1
- package/dist/regle-mcp-server.js +118 -23
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "dotenv/config";
|
package/dist/regle-mcp-server.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import "dotenv/config";
|
|
2
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
5
|
import { z } from "zod";
|
|
6
|
+
import "posthog-node";
|
|
5
7
|
|
|
6
8
|
var docs_data_default = {
|
|
7
9
|
docs: [
|
|
@@ -1663,7 +1665,15 @@ function searchApi(query) {
|
|
|
1663
1665
|
return results;
|
|
1664
1666
|
}
|
|
1665
1667
|
|
|
1666
|
-
var version = "1.14.
|
|
1668
|
+
var version = "1.14.7-beta.2";
|
|
1669
|
+
|
|
1670
|
+
function trackServerConnected(params) {}
|
|
1671
|
+
function trackToolCall(params) {}
|
|
1672
|
+
function trackSearchQuery(params) {}
|
|
1673
|
+
function trackDocAccessed(params) {}
|
|
1674
|
+
function trackRuleLookup(params) {}
|
|
1675
|
+
function trackHelperLookup(params) {}
|
|
1676
|
+
async function shutdown() {}
|
|
1667
1677
|
|
|
1668
1678
|
function jsonResponse(data$1) {
|
|
1669
1679
|
return { content: [{
|
|
@@ -1687,7 +1697,38 @@ const server = new McpServer({
|
|
|
1687
1697
|
title: "Regle MCP Server",
|
|
1688
1698
|
websiteUrl: "https://reglejs.dev"
|
|
1689
1699
|
});
|
|
1690
|
-
|
|
1700
|
+
function getClientInfo() {
|
|
1701
|
+
const clientInfo = server.server.getClientVersion();
|
|
1702
|
+
return {
|
|
1703
|
+
clientName: clientInfo?.name,
|
|
1704
|
+
clientVersion: clientInfo?.version
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
function registerTrackedTool(name, config, handler) {
|
|
1708
|
+
server.registerTool(name, config, async (args) => {
|
|
1709
|
+
const clientInfo = getClientInfo();
|
|
1710
|
+
try {
|
|
1711
|
+
const result = await handler(args, clientInfo);
|
|
1712
|
+
const isError = "isError" in result && result.isError === true;
|
|
1713
|
+
/* @__PURE__ */ trackToolCall({
|
|
1714
|
+
toolName: name,
|
|
1715
|
+
success: !isError,
|
|
1716
|
+
...clientInfo,
|
|
1717
|
+
...isError && { errorMessage: JSON.stringify(result.content) }
|
|
1718
|
+
});
|
|
1719
|
+
return result;
|
|
1720
|
+
} catch (error) {
|
|
1721
|
+
/* @__PURE__ */ trackToolCall({
|
|
1722
|
+
toolName: name,
|
|
1723
|
+
success: false,
|
|
1724
|
+
...clientInfo,
|
|
1725
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
1726
|
+
});
|
|
1727
|
+
return Promise.reject(error);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
registerTrackedTool("regle-list-documentation", {
|
|
1691
1732
|
title: "List all available Regle documentation pages",
|
|
1692
1733
|
inputSchema: z.object({ category: z.string().optional().describe("Filter by category (e.g., \"rules\", \"core-concepts\", \"introduction\")") })
|
|
1693
1734
|
}, async ({ category }) => {
|
|
@@ -1702,15 +1743,20 @@ server.registerTool("regle-list-documentation", {
|
|
|
1702
1743
|
}))
|
|
1703
1744
|
});
|
|
1704
1745
|
});
|
|
1705
|
-
|
|
1746
|
+
registerTrackedTool("regle-get-documentation", {
|
|
1706
1747
|
title: "Get the full content of a specific Regle documentation page",
|
|
1707
1748
|
inputSchema: z.object({ id: z.string().describe("The documentation page ID (e.g., \"core-concepts-rules-built-in-rules\")") })
|
|
1708
|
-
}, async ({ id }) => {
|
|
1749
|
+
}, async ({ id }, clientInfo) => {
|
|
1709
1750
|
const doc = getDocById(id);
|
|
1710
1751
|
if (!doc) return errorResponse("Documentation page not found", {
|
|
1711
1752
|
requestedId: id,
|
|
1712
1753
|
availableIds: docs.map((d) => d.id)
|
|
1713
1754
|
});
|
|
1755
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
1756
|
+
...clientInfo,
|
|
1757
|
+
docId: doc.id,
|
|
1758
|
+
docCategory: doc.category
|
|
1759
|
+
});
|
|
1714
1760
|
return jsonResponse({
|
|
1715
1761
|
id: doc.id,
|
|
1716
1762
|
title: doc.title,
|
|
@@ -1719,12 +1765,17 @@ server.registerTool("regle-get-documentation", {
|
|
|
1719
1765
|
content: doc.content
|
|
1720
1766
|
});
|
|
1721
1767
|
});
|
|
1722
|
-
|
|
1768
|
+
registerTrackedTool("regle-get-usage-guide", {
|
|
1723
1769
|
title: "Get a comprehensive guide on how to use the useRegle composable",
|
|
1724
1770
|
inputSchema: z.object({})
|
|
1725
|
-
}, async () => {
|
|
1771
|
+
}, async (_args, clientInfo) => {
|
|
1726
1772
|
const doc = getDocById("core-concepts-index");
|
|
1727
1773
|
if (!doc) return errorResponse("useRegle guide not found");
|
|
1774
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
1775
|
+
...clientInfo,
|
|
1776
|
+
docId: doc.id,
|
|
1777
|
+
docCategory: doc.category
|
|
1778
|
+
});
|
|
1728
1779
|
return jsonResponse({
|
|
1729
1780
|
id: doc.id,
|
|
1730
1781
|
title: doc.title,
|
|
@@ -1732,12 +1783,17 @@ server.registerTool("regle-get-usage-guide", {
|
|
|
1732
1783
|
content: doc.content
|
|
1733
1784
|
});
|
|
1734
1785
|
});
|
|
1735
|
-
|
|
1786
|
+
registerTrackedTool("regle-get-vuelidate-migration-guide", {
|
|
1736
1787
|
title: "Get a guide on how to migrate from Vuelidate to Regle",
|
|
1737
1788
|
inputSchema: z.object({})
|
|
1738
|
-
}, async () => {
|
|
1789
|
+
}, async (_args, clientInfo) => {
|
|
1739
1790
|
const doc = getDocById("introduction-migrate-from-vuelidate");
|
|
1740
1791
|
if (!doc) return errorResponse("Vuelidate migration guide not found");
|
|
1792
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
1793
|
+
...clientInfo,
|
|
1794
|
+
docId: doc.id,
|
|
1795
|
+
docCategory: doc.category
|
|
1796
|
+
});
|
|
1741
1797
|
return jsonResponse({
|
|
1742
1798
|
id: doc.id,
|
|
1743
1799
|
title: doc.title,
|
|
@@ -1746,14 +1802,20 @@ server.registerTool("regle-get-vuelidate-migration-guide", {
|
|
|
1746
1802
|
});
|
|
1747
1803
|
});
|
|
1748
1804
|
const categories = getCategories();
|
|
1749
|
-
|
|
1805
|
+
registerTrackedTool("regle-search-documentation", {
|
|
1750
1806
|
title: "Search Regle documentation for specific topics, rules, or concepts",
|
|
1751
1807
|
inputSchema: z.object({
|
|
1752
1808
|
query: z.string().describe("Search query (e.g., \"required\", \"async validation\", \"useRegle\")"),
|
|
1753
1809
|
limit: z.number().optional().default(5).describe("Maximum number of results to return")
|
|
1754
1810
|
})
|
|
1755
|
-
}, async ({ query, limit }) => {
|
|
1811
|
+
}, async ({ query, limit }, clientInfo) => {
|
|
1756
1812
|
const results = searchDocs(query).slice(0, limit);
|
|
1813
|
+
/* @__PURE__ */ trackSearchQuery({
|
|
1814
|
+
...clientInfo,
|
|
1815
|
+
query,
|
|
1816
|
+
resultCount: results.length,
|
|
1817
|
+
toolName: "regle-search-documentation"
|
|
1818
|
+
});
|
|
1757
1819
|
if (results.length === 0) return jsonResponse({
|
|
1758
1820
|
query,
|
|
1759
1821
|
resultCount: 0,
|
|
@@ -1772,10 +1834,10 @@ server.registerTool("regle-search-documentation", {
|
|
|
1772
1834
|
results: formattedResults
|
|
1773
1835
|
});
|
|
1774
1836
|
});
|
|
1775
|
-
|
|
1837
|
+
registerTrackedTool("regle-list-rules", {
|
|
1776
1838
|
title: "Get a quick reference of all built-in validation rules in Regle",
|
|
1777
1839
|
inputSchema: z.object({})
|
|
1778
|
-
}, async () => {
|
|
1840
|
+
}, async (_args, _clientInfo) => {
|
|
1779
1841
|
const rules = getRulesFromDocs();
|
|
1780
1842
|
if (rules.length === 0) return errorResponse("Built-in rules documentation not found");
|
|
1781
1843
|
return jsonResponse({
|
|
@@ -1799,11 +1861,16 @@ const { r$ } = useRegle(
|
|
|
1799
1861
|
fullDocId: "core-concepts-rules-built-in-rules"
|
|
1800
1862
|
});
|
|
1801
1863
|
});
|
|
1802
|
-
|
|
1864
|
+
registerTrackedTool("regle-get-rule-reference", {
|
|
1803
1865
|
title: "Get details about a specific built-in validation rule",
|
|
1804
1866
|
inputSchema: z.object({ name: z.string().describe("The rule name (e.g., \"required\", \"email\", \"minLength\")") })
|
|
1805
|
-
}, async ({ name }) => {
|
|
1867
|
+
}, async ({ name }, clientInfo) => {
|
|
1806
1868
|
const rule = getApiByName(name);
|
|
1869
|
+
/* @__PURE__ */ trackRuleLookup({
|
|
1870
|
+
...clientInfo,
|
|
1871
|
+
ruleName: name,
|
|
1872
|
+
found: !!rule
|
|
1873
|
+
});
|
|
1807
1874
|
if (!rule) {
|
|
1808
1875
|
const allRules = getRulesFromDocs();
|
|
1809
1876
|
return errorResponse(`Rule "${name}" not found`, { availableRules: allRules.map((r) => r.name) });
|
|
@@ -1816,12 +1883,17 @@ server.registerTool("regle-get-rule-reference", {
|
|
|
1816
1883
|
fullDocId: "core-concepts-rules-built-in-rules"
|
|
1817
1884
|
});
|
|
1818
1885
|
});
|
|
1819
|
-
|
|
1886
|
+
registerTrackedTool("regle-list-validation-properties", {
|
|
1820
1887
|
title: "Get documentation on all validation properties available on r$ and field objects",
|
|
1821
1888
|
inputSchema: z.object({})
|
|
1822
|
-
}, async () => {
|
|
1889
|
+
}, async (_args, clientInfo) => {
|
|
1823
1890
|
const doc = getDocById("core-concepts-validation-properties");
|
|
1824
1891
|
if (!doc) return errorResponse("Validation properties documentation not found");
|
|
1892
|
+
/* @__PURE__ */ trackDocAccessed({
|
|
1893
|
+
...clientInfo,
|
|
1894
|
+
docId: doc.id,
|
|
1895
|
+
docCategory: doc.category
|
|
1896
|
+
});
|
|
1825
1897
|
return jsonResponse({
|
|
1826
1898
|
id: doc.id,
|
|
1827
1899
|
title: doc.title,
|
|
@@ -1829,10 +1901,10 @@ server.registerTool("regle-list-validation-properties", {
|
|
|
1829
1901
|
content: doc.content
|
|
1830
1902
|
});
|
|
1831
1903
|
});
|
|
1832
|
-
|
|
1904
|
+
registerTrackedTool("regle-list-helpers", {
|
|
1833
1905
|
title: "Get a reference of all validation helper utilities available in Regle",
|
|
1834
1906
|
inputSchema: z.object({})
|
|
1835
|
-
}, async () => {
|
|
1907
|
+
}, async (_args, _clientInfo) => {
|
|
1836
1908
|
const helpers = getHelpersFromDocs();
|
|
1837
1909
|
if (helpers.length === 0) return errorResponse("Validation helpers documentation not found");
|
|
1838
1910
|
const guards = helpers.filter((h) => h.category === "guard");
|
|
@@ -1875,11 +1947,16 @@ const rule = createRule({
|
|
|
1875
1947
|
fullDocId: "core-concepts-rules-validations-helpers"
|
|
1876
1948
|
});
|
|
1877
1949
|
});
|
|
1878
|
-
|
|
1950
|
+
registerTrackedTool("regle-get-helper-reference", {
|
|
1879
1951
|
title: "Get details about a specific validation helper utility",
|
|
1880
1952
|
inputSchema: z.object({ name: z.string().describe("The helper name (e.g., \"isFilled\", \"getSize\", \"toNumber\")") })
|
|
1881
|
-
}, async ({ name }) => {
|
|
1953
|
+
}, async ({ name }, clientInfo) => {
|
|
1882
1954
|
const helper = getApiByName(name);
|
|
1955
|
+
/* @__PURE__ */ trackHelperLookup({
|
|
1956
|
+
...clientInfo,
|
|
1957
|
+
helperName: name,
|
|
1958
|
+
found: !!helper
|
|
1959
|
+
});
|
|
1883
1960
|
if (!helper) {
|
|
1884
1961
|
const allHelpers = getHelpersFromDocs();
|
|
1885
1962
|
return errorResponse(`Helper "${name}" not found`, { availableHelpers: allHelpers.map((h) => h.name) });
|
|
@@ -1894,14 +1971,14 @@ server.registerTool("regle-get-helper-reference", {
|
|
|
1894
1971
|
});
|
|
1895
1972
|
});
|
|
1896
1973
|
const apiPackages = getApiPackages();
|
|
1897
|
-
|
|
1974
|
+
registerTrackedTool("regle-get-api-reference", {
|
|
1898
1975
|
title: "Get API reference for Regle packages with full metadata (parameters, return types, examples)",
|
|
1899
1976
|
inputSchema: z.object({
|
|
1900
1977
|
package: z.string().optional().describe("Package name (e.g., \"@regle/core\", \"@regle/rules\", \"@regle/schemas\", \"@regle/nuxt\")"),
|
|
1901
1978
|
name: z.string().optional().describe("Specific function/export name to look up (e.g., \"useRegle\", \"required\")"),
|
|
1902
1979
|
search: z.string().optional().describe("Search query to find exports by name or description")
|
|
1903
1980
|
})
|
|
1904
|
-
}, async ({ package: packageName, name, search }) => {
|
|
1981
|
+
}, async ({ package: packageName, name, search }, clientInfo) => {
|
|
1905
1982
|
if (name) {
|
|
1906
1983
|
const apiItem = getApiByName(name, packageName);
|
|
1907
1984
|
if (!apiItem) return errorResponse(`API export "${name}" not found`, { availablePackages: apiPackages });
|
|
@@ -1917,6 +1994,12 @@ server.registerTool("regle-get-api-reference", {
|
|
|
1917
1994
|
}
|
|
1918
1995
|
if (search) {
|
|
1919
1996
|
const results = searchApi(search);
|
|
1997
|
+
/* @__PURE__ */ trackSearchQuery({
|
|
1998
|
+
...clientInfo,
|
|
1999
|
+
query: search,
|
|
2000
|
+
resultCount: results.length,
|
|
2001
|
+
toolName: "regle-get-api-reference"
|
|
2002
|
+
});
|
|
1920
2003
|
return jsonResponse({
|
|
1921
2004
|
query: search,
|
|
1922
2005
|
resultCount: results.length,
|
|
@@ -1955,10 +2038,22 @@ server.registerTool("regle-get-api-reference", {
|
|
|
1955
2038
|
async function main() {
|
|
1956
2039
|
const transport = new StdioServerTransport();
|
|
1957
2040
|
await server.connect(transport);
|
|
2041
|
+
const clientInfo = server.server.getClientVersion();
|
|
2042
|
+
/* @__PURE__ */ trackServerConnected({
|
|
2043
|
+
clientName: clientInfo?.name,
|
|
2044
|
+
clientVersion: clientInfo?.version
|
|
2045
|
+
});
|
|
1958
2046
|
console.error("Regle MCP Server running on stdio");
|
|
1959
2047
|
}
|
|
1960
|
-
|
|
2048
|
+
async function gracefulShutdown() {
|
|
2049
|
+
await /* @__PURE__ */ shutdown();
|
|
2050
|
+
process.exit(0);
|
|
2051
|
+
}
|
|
2052
|
+
process.on("SIGINT", gracefulShutdown);
|
|
2053
|
+
process.on("SIGTERM", gracefulShutdown);
|
|
2054
|
+
main().catch(async (error) => {
|
|
1961
2055
|
console.error("Failed to start server:", error);
|
|
2056
|
+
await /* @__PURE__ */ shutdown();
|
|
1962
2057
|
process.exit(1);
|
|
1963
2058
|
});
|
|
1964
2059
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/mcp-server",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.7-beta.2",
|
|
4
4
|
"description": "MCP Server for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@modelcontextprotocol/sdk": "1.24.3",
|
|
7
|
+
"dotenv": "17.2.3",
|
|
8
|
+
"posthog-node": "5.17.4",
|
|
7
9
|
"zod": "4.1.13"
|
|
8
10
|
},
|
|
9
11
|
"devDependencies": {
|