@regle/mcp-server 1.14.1 → 1.14.3

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.
@@ -241,7 +241,7 @@ var docs_data_default = {
241
241
  "title": "Regle MCP server",
242
242
  "category": "integrations",
243
243
  "path": "integrations/mcp-server.md",
244
- "content": "# MCP Server\n\nRegle offers an MCP server that can be used to get documentation and autocomplete for Regle.\n\n## Features\n\nThe MCP server provides the following features:\n\n- Create form validation rules\n- Search documentation\n- Get precise information on any rule\n- Create custom rules\n- API information on every Regle helper\n\n## Cursor\n\n<a href=\"https://cursor.com/en-US/install-mcp?name=regle&config=eyJjb21tYW5kIjoibnB4IEByZWdsZS9tY3Atc2VydmVyIn0%3D\">\n <div class=\"light-only\">\n <img src=\"https://cursor.com/deeplink/mcp-install-dark.svg\" alt=\"Install MCP Server\" />\n </div>\n <div class=\"dark-only\">\n <img src=\"https://cursor.com/deeplink/mcp-install-light.svg\" alt=\"Install MCP Server\" />\n </div>\n</a>\n\nOr add to your `.cursor/mcp.json`\n```json\n{\n \"mcpServers\": {\n \"regle\": {\n \"command\": \"npx\",\n \"args\": [\"@regle/mcp-server\"]\n }\n }\n}\n```\n\n## Claude Desktop\n\nAdd to your `claude_desktop_config.json`:\n\n```json\n{\n \"mcpServers\": {\n \"regle\": {\n \"command\": \"npx\",\n \"args\": [\"@regle/mcp-server\"]\n }\n }\n}\n```"
244
+ "content": "# MCP Server\n\nRegle offers an MCP server that can be used to get documentation and autocomplete in your favorite AI assistant editor.\n\nThe MCP server provides the following features:\n\n- Create form validation rules\n- Search documentation\n- Get precise information on any rule\n- Create custom rules\n- API information on every Regle helper\n\n## Cursor\n\n<a href=\"https://cursor.com/en-US/install-mcp?name=regle&config=eyJjb21tYW5kIjoibnB4IEByZWdsZS9tY3Atc2VydmVyIn0%3D\">\n <div class=\"light-only\">\n <img src=\"https://cursor.com/deeplink/mcp-install-dark.svg\" alt=\"Install MCP Server\" />\n </div>\n <div class=\"dark-only\">\n <img src=\"https://cursor.com/deeplink/mcp-install-light.svg\" alt=\"Install MCP Server\" />\n </div>\n</a>\n\nOr add to your `.cursor/mcp.json`\n```json\n{\n \"mcpServers\": {\n \"regle\": {\n \"command\": \"npx\",\n \"args\": [\"@regle/mcp-server\"]\n }\n }\n}\n```\n\n## Claude Desktop\n\nAdd to your `claude_desktop_config.json`:\n\n```json\n{\n \"mcpServers\": {\n \"regle\": {\n \"command\": \"npx\",\n \"args\": [\"@regle/mcp-server\"]\n }\n }\n}\n```"
245
245
  },
246
246
  {
247
247
  "id": "integrations-nuxt",
@@ -419,21 +419,21 @@ var docs_data_default = {
419
419
  {
420
420
  "name": "flatErrors",
421
421
  "kind": "function",
422
- "description": "Converts a nested $errors object to a flat array of string errors\n\nCan also flatten to an array containing the path of each error with the options.includePath",
422
+ "description": "Converts a nested `$errors` object to a flat array of error strings.\nUseful for displaying a complete list of form errors or counting total errors.\n\nWith the `includePath` option, returns errors in Standard Schema Issue format\nincluding the path to each error field.",
423
423
  "parameters": [{
424
424
  "name": "errors",
425
425
  "type": "$InternalRegleErrors",
426
- "description": "",
426
+ "description": "- The `$errors` object from a Regle instance (e.g., `r$.$errors`)",
427
427
  "optional": false
428
428
  }, {
429
429
  "name": "options",
430
430
  "type": "{ includePath: true; }",
431
- "description": "",
431
+ "description": "- Configuration options",
432
432
  "optional": false
433
433
  }],
434
434
  "returnType": "StandardSchemaV1.Issue[]",
435
- "example": "",
436
- "tags": {}
435
+ "example": "import { flatErrors, useRegle } from '@regle/core';\nimport { required, email, minLength } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { name: '', email: 'invalid' },\n { name: { required, minLength: minLength(3) }, email: { email } }\n);\n\nawait r$.$validate();\n\n// Get flat array of error messages\nconst errors = flatErrors(r$.$errors);\n// ['This field is required', 'Value must be a valid email address']\n\n// Get errors with paths (Standard Schema format)\nconst issues = flatErrors(r$.$errors, { includePath: true });\n// [{ message: 'This field is required', path: ['name'] }, ...]",
436
+ "tags": { "see": "://reglejs.dev/core-concepts/displaying-errors#display-flat-errors Documentation" }
437
437
  },
438
438
  {
439
439
  "name": "inferRules",
@@ -546,11 +546,11 @@ var docs_data_default = {
546
546
  {
547
547
  "name": "RegleVuePlugin",
548
548
  "kind": "const",
549
- "description": "",
549
+ "description": "Vue plugin to enable Regle devtools integration with Vue Devtools.\nProvides debugging capabilities for inspecting validation trees, states, and actions.\n\nSupports inspection of: `useRegle`, `useRules`, `useRegleSchema`, `useScopedRegle`, `useScopedRegleSchema`.\n\nNote: If using `@regle/nuxt`, devtools are automatically enabled.",
550
550
  "parameters": [],
551
551
  "returnType": "",
552
- "example": "",
553
- "tags": {}
552
+ "example": "// main.ts\nimport { createApp } from 'vue';\nimport { RegleVuePlugin } from '@regle/core';\nimport App from './App.vue';\n\nconst app = createApp(App);\napp.use(RegleVuePlugin);\napp.mount('#app');",
553
+ "tags": { "see": "://reglejs.dev/introduction/devtools Documentation" }
554
554
  },
555
555
  {
556
556
  "name": "unwrapRuleParameters",
@@ -569,16 +569,16 @@ var docs_data_default = {
569
569
  {
570
570
  "name": "useCollectScope",
571
571
  "kind": "function",
572
- "description": "",
572
+ "description": "Composable to collect and merge all Regle instances created with the default `useScopedRegle` within the same scope.\nReturns a merged `r$` object allowing validation across multiple components simultaneously.\n\nChildren properties like `$value` and `$errors` are converted to arrays instead of objects.\nYou have access to all validation properties like `$error`, `$invalid`, `$validate()`, etc.",
573
573
  "parameters": [{
574
574
  "name": "namespace",
575
575
  "type": "MaybeRefOrGetter<string | string[]>",
576
- "description": "",
576
+ "description": "- Optional namespace or array of namespaces to filter which scoped instances to collect",
577
577
  "optional": true
578
578
  }],
579
- "returnType": "{\n r$: MergedScopedRegles<Record<string, unknown>[]> | MergedRegles<Record<string, SuperCompatibleRegleRoot>>;\n }",
580
- "example": "",
581
- "tags": {}
579
+ "returnType": "{ r$: MergedScopedRegles<TValue>; }",
580
+ "example": "// ParentComponent.vue\nimport { useCollectScope } from '@regle/core';\n\nconst { r$ } = useCollectScope();\n// Or with namespace filtering\nconst { r$ } = useCollectScope('contacts');\n\n// Validate all collected forms\nconst { result, data } = await r$.$validate();\n// Access collected errors\nconsole.log(r$.$errors);",
581
+ "tags": { "see": "://reglejs.dev/advanced-usage/scoped-validation Documentation" }
582
582
  },
583
583
  {
584
584
  "name": "useRegle",
@@ -601,7 +601,7 @@ var docs_data_default = {
601
601
  "parameters": [],
602
602
  "returnType": "{ regle: $InternalRegleStatusType; }",
603
603
  "example": "",
604
- "tags": {}
604
+ "tags": { "internal": "This is the internal function that creates the root storage for the Regle instance.\nThis allows shared logic between all `useRegle` like composables" }
605
605
  },
606
606
  {
607
607
  "name": "useRules",
@@ -624,17 +624,17 @@ var docs_data_default = {
624
624
  },
625
625
  {
626
626
  "name": "useScopedRegle",
627
- "kind": "const",
628
- "description": "",
627
+ "kind": "function",
628
+ "description": "Clone of `useRegle` that automatically registers its instance for collection by `useCollectScope`.\nEvery time it's called, a new instance is added for the parent scope to collect.\n\nCan be called multiple times anywhere in your app - not restricted to components or DOM.\nWhen the component is unmounted or scope is disposed, the instance is automatically unregistered.",
629
629
  "parameters": [{
630
630
  "name": "params",
631
631
  "type": "[state: MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TState extends PrimitiveTypes ? MaybeRefOrGetter<TDecl> : TState extends Record<...> ? MaybeRefOrComputedRef<...> | ((...args: any[]...",
632
632
  "description": "",
633
633
  "optional": false
634
634
  }],
635
- "returnType": "NonNullable<TState> extends PrimitiveTypes ? { r$: Raw<RegleFieldStatus<PrimitiveTypes & TState & {}, TDecl, any>>; } : { ...; }",
636
- "example": "",
637
- "tags": {}
635
+ "returnType": "NonNullable<TState> extends PrimitiveTypes ? RegleSingleField<PrimitiveTypes & TState & {}, TDecl, never, { ...; }> : Regle<...>",
636
+ "example": "// ChildComponent.vue\nimport { useScopedRegle } from '@regle/core';\n\nconst { r$ } = useScopedRegle(\n { email: '' },\n { email: { required, email } },\n { namespace: 'contacts' }\n);",
637
+ "tags": { "see": "://reglejs.dev/advanced-usage/scoped-validation Documentation" }
638
638
  },
639
639
  {
640
640
  "name": "variantToRef",
@@ -1663,9 +1663,23 @@ function searchApi(query) {
1663
1663
  return results;
1664
1664
  }
1665
1665
 
1666
- var version = "1.14.1";
1666
+ var version = "1.14.3";
1667
1667
 
1668
- const categories = getCategories();
1668
+ function jsonResponse(data$1) {
1669
+ return { content: [{
1670
+ type: "text",
1671
+ text: JSON.stringify(data$1, null, 2)
1672
+ }] };
1673
+ }
1674
+ function errorResponse(error, extra) {
1675
+ return {
1676
+ ...jsonResponse({
1677
+ error,
1678
+ ...extra
1679
+ }),
1680
+ isError: true
1681
+ };
1682
+ }
1669
1683
  const server = new McpServer({
1670
1684
  name: "regle-mcp-server",
1671
1685
  version,
@@ -1673,55 +1687,66 @@ const server = new McpServer({
1673
1687
  title: "Regle MCP Server",
1674
1688
  websiteUrl: "https://reglejs.dev"
1675
1689
  });
1676
- server.registerTool("regle-list-docs", {
1690
+ server.registerTool("regle-list-documentation", {
1677
1691
  title: "List all available Regle documentation pages",
1678
1692
  inputSchema: z.object({ category: z.string().optional().describe("Filter by category (e.g., \"rules\", \"core-concepts\", \"introduction\")") })
1679
1693
  }, async ({ category }) => {
1680
1694
  const filteredDocs = category ? getDocsByCategory(category) : docs;
1681
- return { content: [{
1682
- type: "text",
1683
- text: JSON.stringify({
1684
- message: "Available Regle documentation pages",
1685
- category: category || "all",
1686
- count: filteredDocs.length,
1687
- docs: filteredDocs.map((doc) => ({
1688
- id: doc.id,
1689
- title: doc.title
1690
- }))
1691
- }, null, 2)
1692
- }] };
1695
+ return jsonResponse({
1696
+ message: "Available Regle documentation pages",
1697
+ category: category || "all",
1698
+ count: filteredDocs.length,
1699
+ docs: filteredDocs.map((doc) => ({
1700
+ id: doc.id,
1701
+ title: doc.title
1702
+ }))
1703
+ });
1693
1704
  });
1694
- server.registerTool("regle-get-doc", {
1705
+ server.registerTool("regle-get-documentation", {
1695
1706
  title: "Get the full content of a specific Regle documentation page",
1696
1707
  inputSchema: z.object({ id: z.string().describe("The documentation page ID (e.g., \"core-concepts-rules-built-in-rules\")") })
1697
1708
  }, async ({ id }) => {
1698
1709
  const doc = getDocById(id);
1699
- if (!doc) {
1700
- const availableIds = docs.map((d) => d.id);
1701
- return {
1702
- content: [{
1703
- type: "text",
1704
- text: JSON.stringify({
1705
- error: "Documentation page not found",
1706
- requestedId: id,
1707
- availableIds
1708
- }, null, 2)
1709
- }],
1710
- isError: true
1711
- };
1712
- }
1713
- return { content: [{
1714
- type: "text",
1715
- text: JSON.stringify({
1716
- id: doc.id,
1717
- title: doc.title,
1718
- category: doc.category,
1719
- path: doc.path,
1720
- content: doc.content
1721
- }, null, 2)
1722
- }] };
1710
+ if (!doc) return errorResponse("Documentation page not found", {
1711
+ requestedId: id,
1712
+ availableIds: docs.map((d) => d.id)
1713
+ });
1714
+ return jsonResponse({
1715
+ id: doc.id,
1716
+ title: doc.title,
1717
+ category: doc.category,
1718
+ path: doc.path,
1719
+ content: doc.content
1720
+ });
1721
+ });
1722
+ server.registerTool("regle-get-usage-guide", {
1723
+ title: "Get a comprehensive guide on how to use the useRegle composable",
1724
+ inputSchema: z.object({})
1725
+ }, async () => {
1726
+ const doc = getDocById("core-concepts-index");
1727
+ if (!doc) return errorResponse("useRegle guide not found");
1728
+ return jsonResponse({
1729
+ id: doc.id,
1730
+ title: doc.title,
1731
+ category: doc.category,
1732
+ content: doc.content
1733
+ });
1734
+ });
1735
+ server.registerTool("regle-get-vuelidate-migration-guide", {
1736
+ title: "Get a guide on how to migrate from Vuelidate to Regle",
1737
+ inputSchema: z.object({})
1738
+ }, async () => {
1739
+ const doc = getDocById("introduction-migrate-from-vuelidate");
1740
+ if (!doc) return errorResponse("Vuelidate migration guide not found");
1741
+ return jsonResponse({
1742
+ id: doc.id,
1743
+ title: doc.title,
1744
+ category: doc.category,
1745
+ content: doc.content
1746
+ });
1723
1747
  });
1724
- server.registerTool("regle-search-docs", {
1748
+ const categories = getCategories();
1749
+ server.registerTool("regle-search-documentation", {
1725
1750
  title: "Search Regle documentation for specific topics, rules, or concepts",
1726
1751
  inputSchema: z.object({
1727
1752
  query: z.string().describe("Search query (e.g., \"required\", \"async validation\", \"useRegle\")"),
@@ -1729,53 +1754,39 @@ server.registerTool("regle-search-docs", {
1729
1754
  })
1730
1755
  }, async ({ query, limit }) => {
1731
1756
  const results = searchDocs(query).slice(0, limit);
1732
- if (results.length === 0) return { content: [{
1733
- type: "text",
1734
- text: JSON.stringify({
1735
- query,
1736
- resultCount: 0,
1737
- results: [],
1738
- suggestions: categories
1739
- }, null, 2)
1740
- }] };
1757
+ if (results.length === 0) return jsonResponse({
1758
+ query,
1759
+ resultCount: 0,
1760
+ results: [],
1761
+ suggestions: categories
1762
+ });
1741
1763
  const formattedResults = results.map((doc) => ({
1742
1764
  id: doc.id,
1743
1765
  title: doc.title,
1744
1766
  category: doc.category,
1745
1767
  preview: doc.content.substring(0, 300) + "..."
1746
1768
  }));
1747
- return { content: [{
1748
- type: "text",
1749
- text: JSON.stringify({
1750
- query,
1751
- resultCount: results.length,
1752
- results: formattedResults
1753
- }, null, 2)
1754
- }] };
1769
+ return jsonResponse({
1770
+ query,
1771
+ resultCount: results.length,
1772
+ results: formattedResults
1773
+ });
1755
1774
  });
1756
- server.registerTool("regle-get-rules-reference", {
1775
+ server.registerTool("regle-list-rules", {
1757
1776
  title: "Get a quick reference of all built-in validation rules in Regle",
1758
1777
  inputSchema: z.object({})
1759
1778
  }, async () => {
1760
1779
  const rules = getRulesFromDocs();
1761
- if (rules.length === 0) return {
1762
- content: [{
1763
- type: "text",
1764
- text: JSON.stringify({ error: "Built-in rules documentation not found" }, null, 2)
1765
- }],
1766
- isError: true
1767
- };
1768
- return { content: [{
1769
- type: "text",
1770
- text: JSON.stringify({
1771
- title: "Built-in Rules",
1772
- package: "@regle/rules",
1773
- count: rules.length,
1774
- rules: rules.map((r) => ({
1775
- name: r.name,
1776
- description: r.description
1777
- })),
1778
- usageExample: `import { useRegle } from '@regle/core';
1780
+ if (rules.length === 0) return errorResponse("Built-in rules documentation not found");
1781
+ return jsonResponse({
1782
+ title: "Built-in Rules",
1783
+ package: "@regle/rules",
1784
+ count: rules.length,
1785
+ rules: rules.map((r) => ({
1786
+ name: r.name,
1787
+ description: r.description
1788
+ })),
1789
+ usageExample: `import { useRegle } from '@regle/core';
1779
1790
  import { required, email, minLength } from '@regle/rules';
1780
1791
 
1781
1792
  const { r$ } = useRegle(
@@ -1785,44 +1796,45 @@ const { r$ } = useRegle(
1785
1796
  password: { required, minLength: minLength(8) }
1786
1797
  }
1787
1798
  );`,
1788
- fullDocId: "core-concepts-rules-built-in-rules"
1789
- }, null, 2)
1790
- }] };
1799
+ fullDocId: "core-concepts-rules-built-in-rules"
1800
+ });
1801
+ });
1802
+ server.registerTool("regle-get-rule-reference", {
1803
+ title: "Get details about a specific built-in validation rule",
1804
+ inputSchema: z.object({ name: z.string().describe("The rule name (e.g., \"required\", \"email\", \"minLength\")") })
1805
+ }, async ({ name }) => {
1806
+ const rule = getApiByName(name);
1807
+ if (!rule) {
1808
+ const allRules = getRulesFromDocs();
1809
+ return errorResponse(`Rule "${name}" not found`, { availableRules: allRules.map((r) => r.name) });
1810
+ }
1811
+ return jsonResponse({
1812
+ name: rule.name,
1813
+ description: rule.description,
1814
+ package: "@regle/rules",
1815
+ usageExample: rule.example,
1816
+ fullDocId: "core-concepts-rules-built-in-rules"
1817
+ });
1791
1818
  });
1792
- server.registerTool("regle-get-validation-properties", {
1819
+ server.registerTool("regle-list-validation-properties", {
1793
1820
  title: "Get documentation on all validation properties available on r$ and field objects",
1794
1821
  inputSchema: z.object({})
1795
1822
  }, async () => {
1796
1823
  const doc = getDocById("core-concepts-validation-properties");
1797
- if (!doc) return {
1798
- content: [{
1799
- type: "text",
1800
- text: JSON.stringify({ error: "Validation properties documentation not found" }, null, 2)
1801
- }],
1802
- isError: true
1803
- };
1804
- return { content: [{
1805
- type: "text",
1806
- text: JSON.stringify({
1807
- id: doc.id,
1808
- title: doc.title,
1809
- category: doc.category,
1810
- content: doc.content
1811
- }, null, 2)
1812
- }] };
1824
+ if (!doc) return errorResponse("Validation properties documentation not found");
1825
+ return jsonResponse({
1826
+ id: doc.id,
1827
+ title: doc.title,
1828
+ category: doc.category,
1829
+ content: doc.content
1830
+ });
1813
1831
  });
1814
- server.registerTool("regle-get-helpers-reference", {
1832
+ server.registerTool("regle-list-helpers", {
1815
1833
  title: "Get a reference of all validation helper utilities available in Regle",
1816
1834
  inputSchema: z.object({})
1817
1835
  }, async () => {
1818
1836
  const helpers = getHelpersFromDocs();
1819
- if (helpers.length === 0) return {
1820
- content: [{
1821
- type: "text",
1822
- text: JSON.stringify({ error: "Validation helpers documentation not found" }, null, 2)
1823
- }],
1824
- isError: true
1825
- };
1837
+ if (helpers.length === 0) return errorResponse("Validation helpers documentation not found");
1826
1838
  const guards = helpers.filter((h) => h.category === "guard");
1827
1839
  const operations = helpers.filter((h) => h.category === "operation");
1828
1840
  const coerces = helpers.filter((h) => h.category === "coerce");
@@ -1830,27 +1842,25 @@ server.registerTool("regle-get-helpers-reference", {
1830
1842
  name: h.name,
1831
1843
  description: h.description
1832
1844
  }));
1833
- return { content: [{
1834
- type: "text",
1835
- text: JSON.stringify({
1836
- title: "Validation Helpers",
1837
- package: "@regle/rules",
1838
- totalCount: helpers.length,
1839
- categories: {
1840
- guards: {
1841
- description: "Runtime and Type Guards",
1842
- helpers: formatHelpers(guards)
1843
- },
1844
- operations: {
1845
- description: "Operations Utils",
1846
- helpers: formatHelpers(operations)
1847
- },
1848
- coerces: {
1849
- description: "Coerce Utils",
1850
- helpers: formatHelpers(coerces)
1851
- }
1852
- },
1853
- usageExample: `import { createRule, type Maybe } from '@regle/core';
1845
+ return jsonResponse({
1846
+ title: "Validation Helpers",
1847
+ package: "@regle/rules",
1848
+ totalCount: helpers.length,
1849
+ categories: {
1850
+ guards: {
1851
+ description: "Runtime and Type Guards",
1852
+ helpers: formatHelpers(guards)
1853
+ },
1854
+ operations: {
1855
+ description: "Operations Utils",
1856
+ helpers: formatHelpers(operations)
1857
+ },
1858
+ coerces: {
1859
+ description: "Coerce Utils",
1860
+ helpers: formatHelpers(coerces)
1861
+ }
1862
+ },
1863
+ usageExample: `import { createRule, type Maybe } from '@regle/core';
1854
1864
  import { isFilled, getSize } from '@regle/rules';
1855
1865
 
1856
1866
  const rule = createRule({
@@ -1862,31 +1872,26 @@ const rule = createRule({
1862
1872
  },
1863
1873
  message: 'Error'
1864
1874
  });`,
1865
- fullDocId: "core-concepts-rules-validations-helpers"
1866
- }, null, 2)
1867
- }] };
1875
+ fullDocId: "core-concepts-rules-validations-helpers"
1876
+ });
1868
1877
  });
1869
- server.registerTool("regle-get-useregle-guide", {
1870
- title: "Get a comprehensive guide on how to use the useRegle composable",
1871
- inputSchema: z.object({})
1872
- }, async () => {
1873
- const doc = getDocById("core-concepts-index");
1874
- if (!doc) return {
1875
- content: [{
1876
- type: "text",
1877
- text: JSON.stringify({ error: "useRegle guide not found" }, null, 2)
1878
- }],
1879
- isError: true
1880
- };
1881
- return { content: [{
1882
- type: "text",
1883
- text: JSON.stringify({
1884
- id: doc.id,
1885
- title: doc.title,
1886
- category: doc.category,
1887
- content: doc.content
1888
- }, null, 2)
1889
- }] };
1878
+ server.registerTool("regle-get-helper-reference", {
1879
+ title: "Get details about a specific validation helper utility",
1880
+ inputSchema: z.object({ name: z.string().describe("The helper name (e.g., \"isFilled\", \"getSize\", \"toNumber\")") })
1881
+ }, async ({ name }) => {
1882
+ const helper = getApiByName(name);
1883
+ if (!helper) {
1884
+ const allHelpers = getHelpersFromDocs();
1885
+ return errorResponse(`Helper "${name}" not found`, { availableHelpers: allHelpers.map((h) => h.name) });
1886
+ }
1887
+ return jsonResponse({
1888
+ name: helper.name,
1889
+ description: helper.description,
1890
+ category: helper.tags,
1891
+ package: "@regle/rules",
1892
+ usageExample: helper.example,
1893
+ fullDocId: "core-concepts-rules-validations-helpers"
1894
+ });
1890
1895
  });
1891
1896
  const apiPackages = getApiPackages();
1892
1897
  server.registerTool("regle-get-api-reference", {
@@ -1899,84 +1904,53 @@ server.registerTool("regle-get-api-reference", {
1899
1904
  }, async ({ package: packageName, name, search }) => {
1900
1905
  if (name) {
1901
1906
  const apiItem = getApiByName(name, packageName);
1902
- if (!apiItem) return {
1903
- content: [{
1904
- type: "text",
1905
- text: JSON.stringify({
1906
- error: `API export "${name}" not found`,
1907
- availablePackages: apiPackages
1908
- }, null, 2)
1909
- }],
1910
- isError: true
1911
- };
1912
- return { content: [{
1913
- type: "text",
1914
- text: JSON.stringify({
1915
- name: apiItem.name,
1916
- kind: apiItem.kind,
1917
- description: apiItem.description,
1918
- parameters: apiItem.parameters,
1919
- returnType: apiItem.returnType,
1920
- example: apiItem.example,
1921
- tags: apiItem.tags
1922
- }, null, 2)
1923
- }] };
1907
+ if (!apiItem) return errorResponse(`API export "${name}" not found`, { availablePackages: apiPackages });
1908
+ return jsonResponse({
1909
+ name: apiItem.name,
1910
+ kind: apiItem.kind,
1911
+ description: apiItem.description,
1912
+ parameters: apiItem.parameters,
1913
+ returnType: apiItem.returnType,
1914
+ example: apiItem.example,
1915
+ tags: apiItem.tags
1916
+ });
1924
1917
  }
1925
1918
  if (search) {
1926
1919
  const results = searchApi(search);
1927
- return { content: [{
1928
- type: "text",
1929
- text: JSON.stringify({
1930
- query: search,
1931
- resultCount: results.length,
1932
- results: results.map((r) => ({
1933
- name: r.name,
1934
- package: r.package,
1935
- kind: r.kind,
1936
- description: r.description.substring(0, 200) + (r.description.length > 200 ? "..." : "")
1937
- }))
1938
- }, null, 2)
1939
- }] };
1920
+ return jsonResponse({
1921
+ query: search,
1922
+ resultCount: results.length,
1923
+ results: results.map((r) => ({
1924
+ name: r.name,
1925
+ package: r.package,
1926
+ kind: r.kind,
1927
+ description: r.description.substring(0, 200) + (r.description.length > 200 ? "..." : "")
1928
+ }))
1929
+ });
1940
1930
  }
1941
1931
  if (packageName) {
1942
1932
  const apis = getApiByPackage(packageName);
1943
- if (apis.length === 0) return {
1944
- content: [{
1945
- type: "text",
1946
- text: JSON.stringify({
1947
- error: `Package "${packageName}" not found or has no exports`,
1948
- availablePackages: apiPackages
1949
- }, null, 2)
1950
- }],
1951
- isError: true
1952
- };
1953
- return { content: [{
1954
- type: "text",
1955
- text: JSON.stringify({
1956
- package: packageName,
1957
- exportCount: apis.length,
1958
- exports: apis.map((a) => ({
1959
- name: a.name,
1960
- kind: a.kind,
1961
- description: a.description.substring(0, 150) + (a.description.length > 150 ? "..." : ""),
1962
- hasExample: !!a.example,
1963
- parameterCount: a.parameters.length
1964
- }))
1965
- }, null, 2)
1966
- }] };
1933
+ if (apis.length === 0) return errorResponse(`Package "${packageName}" not found or has no exports`, { availablePackages: apiPackages });
1934
+ return jsonResponse({
1935
+ package: packageName,
1936
+ exportCount: apis.length,
1937
+ exports: apis.map((a) => ({
1938
+ name: a.name,
1939
+ kind: a.kind,
1940
+ description: a.description.substring(0, 150) + (a.description.length > 150 ? "..." : ""),
1941
+ hasExample: !!a.example,
1942
+ parameterCount: a.parameters.length
1943
+ }))
1944
+ });
1967
1945
  }
1968
- const packageSummary = apiPackages.map((pkg) => ({
1969
- package: pkg,
1970
- exportCount: getApiByPackage(pkg).length
1971
- }));
1972
- return { content: [{
1973
- type: "text",
1974
- text: JSON.stringify({
1975
- message: "Available Regle API packages",
1976
- packages: packageSummary,
1977
- usage: "Use \"package\" to list exports, \"name\" to get specific export details, or \"search\" to find exports"
1978
- }, null, 2)
1979
- }] };
1946
+ return jsonResponse({
1947
+ message: "Available Regle API packages",
1948
+ packages: apiPackages.map((pkg) => ({
1949
+ package: pkg,
1950
+ exportCount: getApiByPackage(pkg).length
1951
+ })),
1952
+ usage: "Use \"package\" to list exports, \"name\" to get specific export details, or \"search\" to find exports"
1953
+ });
1980
1954
  });
1981
1955
  async function main() {
1982
1956
  const transport = new StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/mcp-server",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
4
4
  "description": "MCP Server for Regle",
5
5
  "dependencies": {
6
6
  "@modelcontextprotocol/sdk": "1.24.3",