@contractspec/bundle.library 3.8.4 → 3.8.5

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.
Files changed (90) hide show
  1. package/.turbo/turbo-build.log +126 -112
  2. package/CHANGELOG.md +6 -0
  3. package/dist/application/index.js +806 -131
  4. package/dist/application/mcp/cliMcp.js +21 -2
  5. package/dist/application/mcp/common.js +21 -2
  6. package/dist/application/mcp/common.test.d.ts +1 -0
  7. package/dist/application/mcp/contractsMcp.js +21 -2
  8. package/dist/application/mcp/docsMcp.catalog.d.ts +2 -0
  9. package/dist/application/mcp/docsMcp.catalog.js +382 -0
  10. package/dist/application/mcp/docsMcp.d.ts +5 -1
  11. package/dist/application/mcp/docsMcp.data.d.ts +85 -0
  12. package/dist/application/mcp/docsMcp.data.js +148 -0
  13. package/dist/application/mcp/docsMcp.js +776 -101
  14. package/dist/application/mcp/docsMcp.prompts.d.ts +3 -0
  15. package/dist/application/mcp/docsMcp.prompts.js +522 -0
  16. package/dist/application/mcp/docsMcp.reference.d.ts +24 -0
  17. package/dist/application/mcp/docsMcp.reference.js +236 -0
  18. package/dist/application/mcp/docsMcp.resources.d.ts +3 -0
  19. package/dist/application/mcp/docsMcp.resources.js +520 -0
  20. package/dist/application/mcp/docsMcp.test.d.ts +1 -0
  21. package/dist/application/mcp/docsMcp.tools.d.ts +3 -0
  22. package/dist/application/mcp/docsMcp.tools.js +519 -0
  23. package/dist/application/mcp/index.js +806 -131
  24. package/dist/application/mcp/internalMcp.js +21 -2
  25. package/dist/application/mcp/normalizeMcpRequest.d.ts +1 -0
  26. package/dist/application/mcp/normalizeMcpRequest.js +22 -0
  27. package/dist/application/mcp/providerRankingMcp.js +21 -2
  28. package/dist/features/index.js +15 -15
  29. package/dist/index.js +171 -171
  30. package/dist/node/application/index.js +806 -131
  31. package/dist/node/application/mcp/cliMcp.js +21 -2
  32. package/dist/node/application/mcp/common.js +21 -2
  33. package/dist/node/application/mcp/contractsMcp.js +21 -2
  34. package/dist/node/application/mcp/docsMcp.catalog.js +381 -0
  35. package/dist/node/application/mcp/docsMcp.data.js +147 -0
  36. package/dist/node/application/mcp/docsMcp.js +776 -101
  37. package/dist/node/application/mcp/docsMcp.prompts.js +521 -0
  38. package/dist/node/application/mcp/docsMcp.reference.js +235 -0
  39. package/dist/node/application/mcp/docsMcp.resources.js +519 -0
  40. package/dist/node/application/mcp/docsMcp.tools.js +518 -0
  41. package/dist/node/application/mcp/index.js +806 -131
  42. package/dist/node/application/mcp/internalMcp.js +21 -2
  43. package/dist/node/application/mcp/normalizeMcpRequest.js +21 -0
  44. package/dist/node/application/mcp/providerRankingMcp.js +21 -2
  45. package/dist/node/features/index.js +15 -15
  46. package/dist/node/index.js +171 -171
  47. package/dist/node/presentation/features/hooks/index.js +12 -12
  48. package/dist/node/presentation/features/hooks/useContractsRegistry.js +12 -12
  49. package/dist/node/presentation/features/index.js +12 -12
  50. package/dist/node/presentation/features/organisms/FeatureDataViewsList.js +12 -12
  51. package/dist/node/presentation/features/organisms/FeatureEventsList.js +12 -12
  52. package/dist/node/presentation/features/organisms/FeatureFormsList.js +12 -12
  53. package/dist/node/presentation/features/organisms/FeaturePresentationsList.js +12 -12
  54. package/dist/node/presentation/features/organisms/index.js +12 -12
  55. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
  56. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
  57. package/dist/node/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
  58. package/dist/node/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
  59. package/dist/node/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
  60. package/dist/node/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
  61. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
  62. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
  63. package/dist/presentation/features/hooks/index.js +12 -12
  64. package/dist/presentation/features/hooks/useContractsRegistry.js +12 -12
  65. package/dist/presentation/features/index.js +12 -12
  66. package/dist/presentation/features/organisms/FeatureDataViewsList.js +12 -12
  67. package/dist/presentation/features/organisms/FeatureEventsList.js +12 -12
  68. package/dist/presentation/features/organisms/FeatureFormsList.js +12 -12
  69. package/dist/presentation/features/organisms/FeaturePresentationsList.js +12 -12
  70. package/dist/presentation/features/organisms/index.js +12 -12
  71. package/dist/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
  72. package/dist/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
  73. package/dist/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
  74. package/dist/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
  75. package/dist/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
  76. package/dist/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
  77. package/dist/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
  78. package/dist/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
  79. package/package.json +85 -1
  80. package/src/application/mcp/common.test.ts +64 -0
  81. package/src/application/mcp/common.ts +5 -2
  82. package/src/application/mcp/docsMcp.catalog.ts +2 -0
  83. package/src/application/mcp/docsMcp.data.ts +196 -0
  84. package/src/application/mcp/docsMcp.prompts.ts +165 -0
  85. package/src/application/mcp/docsMcp.reference.ts +152 -0
  86. package/src/application/mcp/docsMcp.resources.ts +194 -0
  87. package/src/application/mcp/docsMcp.test.ts +148 -0
  88. package/src/application/mcp/docsMcp.tools.ts +183 -0
  89. package/src/application/mcp/docsMcp.ts +13 -177
  90. package/src/application/mcp/normalizeMcpRequest.ts +30 -0
@@ -1,13 +1,4 @@
1
1
  // @bun
2
- // src/features/docs/docs.contracts.ts
3
- import {
4
- ContractReferenceQuery,
5
- DocSummaryModel,
6
- DocsIndexInput,
7
- DocsIndexOutput,
8
- DocsIndexQuery,
9
- DocsIndexQuery as DocsIndexQuery2
10
- } from "@contractspec/lib.contracts-spec/docs";
11
2
  // src/features/contracts-registry.ts
12
3
  import {
13
4
  EventRegistry,
@@ -18,11 +9,11 @@ import {
18
9
  } from "@contractspec/lib.contracts-spec/data-views";
19
10
  import {
20
11
  ContractReferenceDataView,
21
- ContractReferenceQuery as ContractReferenceQuery2,
12
+ ContractReferenceQuery,
22
13
  DocsGenerateCommand,
23
14
  DocsGeneratedEvent,
24
15
  DocsIndexDataView,
25
- DocsIndexQuery as DocsIndexQuery3,
16
+ DocsIndexQuery,
26
17
  DocsLayoutPresentation,
27
18
  DocsPublishCommand,
28
19
  DocsPublishedEvent,
@@ -44,7 +35,7 @@ import {
44
35
  var operationRegistry = null;
45
36
  function createContractSpecOperationRegistry() {
46
37
  const registry = new OperationSpecRegistry;
47
- registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
38
+ registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
48
39
  return registry;
49
40
  }
50
41
  function getContractSpecOperationRegistry() {
@@ -190,6 +181,15 @@ var DocsFeature = {
190
181
  }
191
182
  };
192
183
 
184
+ // src/features/docs/docs.contracts.ts
185
+ import {
186
+ ContractReferenceQuery as ContractReferenceQuery2,
187
+ DocSummaryModel,
188
+ DocsIndexInput,
189
+ DocsIndexOutput,
190
+ DocsIndexQuery as DocsIndexQuery2,
191
+ DocsIndexQuery as DocsIndexQuery3
192
+ } from "@contractspec/lib.contracts-spec/docs";
193
193
  // src/features/mcp.feature.ts
194
194
  var MCPFeature = {
195
195
  meta: {
@@ -1,13 +1,4 @@
1
1
  // @bun
2
- // src/features/docs/docs.contracts.ts
3
- import {
4
- ContractReferenceQuery,
5
- DocSummaryModel,
6
- DocsIndexInput,
7
- DocsIndexOutput,
8
- DocsIndexQuery,
9
- DocsIndexQuery as DocsIndexQuery2
10
- } from "@contractspec/lib.contracts-spec/docs";
11
2
  // src/features/contracts-registry.ts
12
3
  import {
13
4
  EventRegistry,
@@ -18,11 +9,11 @@ import {
18
9
  } from "@contractspec/lib.contracts-spec/data-views";
19
10
  import {
20
11
  ContractReferenceDataView,
21
- ContractReferenceQuery as ContractReferenceQuery2,
12
+ ContractReferenceQuery,
22
13
  DocsGenerateCommand,
23
14
  DocsGeneratedEvent,
24
15
  DocsIndexDataView,
25
- DocsIndexQuery as DocsIndexQuery3,
16
+ DocsIndexQuery,
26
17
  DocsLayoutPresentation,
27
18
  DocsPublishCommand,
28
19
  DocsPublishedEvent,
@@ -44,7 +35,7 @@ import {
44
35
  var operationRegistry = null;
45
36
  function createContractSpecOperationRegistry() {
46
37
  const registry = new OperationSpecRegistry;
47
- registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
38
+ registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
48
39
  return registry;
49
40
  }
50
41
  function getContractSpecOperationRegistry() {
@@ -190,6 +181,15 @@ var DocsFeature = {
190
181
  }
191
182
  };
192
183
 
184
+ // src/features/docs/docs.contracts.ts
185
+ import {
186
+ ContractReferenceQuery as ContractReferenceQuery2,
187
+ DocSummaryModel,
188
+ DocsIndexInput,
189
+ DocsIndexOutput,
190
+ DocsIndexQuery as DocsIndexQuery2,
191
+ DocsIndexQuery as DocsIndexQuery3
192
+ } from "@contractspec/lib.contracts-spec/docs";
193
193
  // src/features/mcp.feature.ts
194
194
  var MCPFeature = {
195
195
  meta: {
@@ -1,13 +1,4 @@
1
1
  // @bun
2
- // src/features/docs/docs.contracts.ts
3
- import {
4
- ContractReferenceQuery,
5
- DocSummaryModel,
6
- DocsIndexInput,
7
- DocsIndexOutput,
8
- DocsIndexQuery,
9
- DocsIndexQuery as DocsIndexQuery2
10
- } from "@contractspec/lib.contracts-spec/docs";
11
2
  // src/features/contracts-registry.ts
12
3
  import {
13
4
  EventRegistry,
@@ -18,11 +9,11 @@ import {
18
9
  } from "@contractspec/lib.contracts-spec/data-views";
19
10
  import {
20
11
  ContractReferenceDataView,
21
- ContractReferenceQuery as ContractReferenceQuery2,
12
+ ContractReferenceQuery,
22
13
  DocsGenerateCommand,
23
14
  DocsGeneratedEvent,
24
15
  DocsIndexDataView,
25
- DocsIndexQuery as DocsIndexQuery3,
16
+ DocsIndexQuery,
26
17
  DocsLayoutPresentation,
27
18
  DocsPublishCommand,
28
19
  DocsPublishedEvent,
@@ -44,7 +35,7 @@ import {
44
35
  var operationRegistry = null;
45
36
  function createContractSpecOperationRegistry() {
46
37
  const registry = new OperationSpecRegistry;
47
- registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
38
+ registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
48
39
  return registry;
49
40
  }
50
41
  function getContractSpecOperationRegistry() {
@@ -190,6 +181,15 @@ var DocsFeature = {
190
181
  }
191
182
  };
192
183
 
184
+ // src/features/docs/docs.contracts.ts
185
+ import {
186
+ ContractReferenceQuery as ContractReferenceQuery2,
187
+ DocSummaryModel,
188
+ DocsIndexInput,
189
+ DocsIndexOutput,
190
+ DocsIndexQuery as DocsIndexQuery2,
191
+ DocsIndexQuery as DocsIndexQuery3
192
+ } from "@contractspec/lib.contracts-spec/docs";
193
193
  // src/features/mcp.feature.ts
194
194
  var MCPFeature = {
195
195
  meta: {
@@ -1,13 +1,4 @@
1
1
  // @bun
2
- // src/features/docs/docs.contracts.ts
3
- import {
4
- ContractReferenceQuery,
5
- DocSummaryModel,
6
- DocsIndexInput,
7
- DocsIndexOutput,
8
- DocsIndexQuery,
9
- DocsIndexQuery as DocsIndexQuery2
10
- } from "@contractspec/lib.contracts-spec/docs";
11
2
  // src/features/contracts-registry.ts
12
3
  import {
13
4
  EventRegistry,
@@ -18,11 +9,11 @@ import {
18
9
  } from "@contractspec/lib.contracts-spec/data-views";
19
10
  import {
20
11
  ContractReferenceDataView,
21
- ContractReferenceQuery as ContractReferenceQuery2,
12
+ ContractReferenceQuery,
22
13
  DocsGenerateCommand,
23
14
  DocsGeneratedEvent,
24
15
  DocsIndexDataView,
25
- DocsIndexQuery as DocsIndexQuery3,
16
+ DocsIndexQuery,
26
17
  DocsLayoutPresentation,
27
18
  DocsPublishCommand,
28
19
  DocsPublishedEvent,
@@ -44,7 +35,7 @@ import {
44
35
  var operationRegistry = null;
45
36
  function createContractSpecOperationRegistry() {
46
37
  const registry = new OperationSpecRegistry;
47
- registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
38
+ registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
48
39
  return registry;
49
40
  }
50
41
  function getContractSpecOperationRegistry() {
@@ -190,6 +181,15 @@ var DocsFeature = {
190
181
  }
191
182
  };
192
183
 
184
+ // src/features/docs/docs.contracts.ts
185
+ import {
186
+ ContractReferenceQuery as ContractReferenceQuery2,
187
+ DocSummaryModel,
188
+ DocsIndexInput,
189
+ DocsIndexOutput,
190
+ DocsIndexQuery as DocsIndexQuery2,
191
+ DocsIndexQuery as DocsIndexQuery3
192
+ } from "@contractspec/lib.contracts-spec/docs";
193
193
  // src/features/mcp.feature.ts
194
194
  var MCPFeature = {
195
195
  meta: {
@@ -1,13 +1,4 @@
1
1
  // @bun
2
- // src/features/docs/docs.contracts.ts
3
- import {
4
- ContractReferenceQuery,
5
- DocSummaryModel,
6
- DocsIndexInput,
7
- DocsIndexOutput,
8
- DocsIndexQuery,
9
- DocsIndexQuery as DocsIndexQuery2
10
- } from "@contractspec/lib.contracts-spec/docs";
11
2
  // src/features/contracts-registry.ts
12
3
  import {
13
4
  EventRegistry,
@@ -18,11 +9,11 @@ import {
18
9
  } from "@contractspec/lib.contracts-spec/data-views";
19
10
  import {
20
11
  ContractReferenceDataView,
21
- ContractReferenceQuery as ContractReferenceQuery2,
12
+ ContractReferenceQuery,
22
13
  DocsGenerateCommand,
23
14
  DocsGeneratedEvent,
24
15
  DocsIndexDataView,
25
- DocsIndexQuery as DocsIndexQuery3,
16
+ DocsIndexQuery,
26
17
  DocsLayoutPresentation,
27
18
  DocsPublishCommand,
28
19
  DocsPublishedEvent,
@@ -44,7 +35,7 @@ import {
44
35
  var operationRegistry = null;
45
36
  function createContractSpecOperationRegistry() {
46
37
  const registry = new OperationSpecRegistry;
47
- registry.register(DocsIndexQuery3).register(ContractReferenceQuery2).register(DocsGenerateCommand).register(DocsPublishCommand);
38
+ registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
48
39
  return registry;
49
40
  }
50
41
  function getContractSpecOperationRegistry() {
@@ -190,6 +181,15 @@ var DocsFeature = {
190
181
  }
191
182
  };
192
183
 
184
+ // src/features/docs/docs.contracts.ts
185
+ import {
186
+ ContractReferenceQuery as ContractReferenceQuery2,
187
+ DocSummaryModel,
188
+ DocsIndexInput,
189
+ DocsIndexOutput,
190
+ DocsIndexQuery as DocsIndexQuery2,
191
+ DocsIndexQuery as DocsIndexQuery3
192
+ } from "@contractspec/lib.contracts-spec/docs";
193
193
  // src/features/mcp.feature.ts
194
194
  var MCPFeature = {
195
195
  meta: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/bundle.library",
3
- "version": "3.8.4",
3
+ "version": "3.8.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -84,12 +84,54 @@
84
84
  "node": "./dist/node/application/mcp/docsMcp.js",
85
85
  "default": "./dist/application/mcp/docsMcp.js"
86
86
  },
87
+ "./application/mcp/docsMcp.catalog": {
88
+ "types": "./dist/application/mcp/docsMcp.catalog.d.ts",
89
+ "bun": "./dist/application/mcp/docsMcp.catalog.js",
90
+ "node": "./dist/node/application/mcp/docsMcp.catalog.js",
91
+ "default": "./dist/application/mcp/docsMcp.catalog.js"
92
+ },
93
+ "./application/mcp/docsMcp.data": {
94
+ "types": "./dist/application/mcp/docsMcp.data.d.ts",
95
+ "bun": "./dist/application/mcp/docsMcp.data.js",
96
+ "node": "./dist/node/application/mcp/docsMcp.data.js",
97
+ "default": "./dist/application/mcp/docsMcp.data.js"
98
+ },
99
+ "./application/mcp/docsMcp.prompts": {
100
+ "types": "./dist/application/mcp/docsMcp.prompts.d.ts",
101
+ "bun": "./dist/application/mcp/docsMcp.prompts.js",
102
+ "node": "./dist/node/application/mcp/docsMcp.prompts.js",
103
+ "default": "./dist/application/mcp/docsMcp.prompts.js"
104
+ },
105
+ "./application/mcp/docsMcp.reference": {
106
+ "types": "./dist/application/mcp/docsMcp.reference.d.ts",
107
+ "bun": "./dist/application/mcp/docsMcp.reference.js",
108
+ "node": "./dist/node/application/mcp/docsMcp.reference.js",
109
+ "default": "./dist/application/mcp/docsMcp.reference.js"
110
+ },
111
+ "./application/mcp/docsMcp.resources": {
112
+ "types": "./dist/application/mcp/docsMcp.resources.d.ts",
113
+ "bun": "./dist/application/mcp/docsMcp.resources.js",
114
+ "node": "./dist/node/application/mcp/docsMcp.resources.js",
115
+ "default": "./dist/application/mcp/docsMcp.resources.js"
116
+ },
117
+ "./application/mcp/docsMcp.tools": {
118
+ "types": "./dist/application/mcp/docsMcp.tools.d.ts",
119
+ "bun": "./dist/application/mcp/docsMcp.tools.js",
120
+ "node": "./dist/node/application/mcp/docsMcp.tools.js",
121
+ "default": "./dist/application/mcp/docsMcp.tools.js"
122
+ },
87
123
  "./application/mcp/internalMcp": {
88
124
  "types": "./dist/application/mcp/internalMcp.d.ts",
89
125
  "bun": "./dist/application/mcp/internalMcp.js",
90
126
  "node": "./dist/node/application/mcp/internalMcp.js",
91
127
  "default": "./dist/application/mcp/internalMcp.js"
92
128
  },
129
+ "./application/mcp/normalizeMcpRequest": {
130
+ "types": "./dist/application/mcp/normalizeMcpRequest.d.ts",
131
+ "bun": "./dist/application/mcp/normalizeMcpRequest.js",
132
+ "node": "./dist/node/application/mcp/normalizeMcpRequest.js",
133
+ "default": "./dist/application/mcp/normalizeMcpRequest.js"
134
+ },
93
135
  "./application/mcp/providerRankingMcp": {
94
136
  "types": "./dist/application/mcp/providerRankingMcp.d.ts",
95
137
  "bun": "./dist/application/mcp/providerRankingMcp.js",
@@ -1945,12 +1987,54 @@
1945
1987
  "node": "./dist/node/application/mcp/docsMcp.js",
1946
1988
  "default": "./dist/application/mcp/docsMcp.js"
1947
1989
  },
1990
+ "./application/mcp/docsMcp.catalog": {
1991
+ "types": "./dist/application/mcp/docsMcp.catalog.d.ts",
1992
+ "bun": "./dist/application/mcp/docsMcp.catalog.js",
1993
+ "node": "./dist/node/application/mcp/docsMcp.catalog.js",
1994
+ "default": "./dist/application/mcp/docsMcp.catalog.js"
1995
+ },
1996
+ "./application/mcp/docsMcp.data": {
1997
+ "types": "./dist/application/mcp/docsMcp.data.d.ts",
1998
+ "bun": "./dist/application/mcp/docsMcp.data.js",
1999
+ "node": "./dist/node/application/mcp/docsMcp.data.js",
2000
+ "default": "./dist/application/mcp/docsMcp.data.js"
2001
+ },
2002
+ "./application/mcp/docsMcp.prompts": {
2003
+ "types": "./dist/application/mcp/docsMcp.prompts.d.ts",
2004
+ "bun": "./dist/application/mcp/docsMcp.prompts.js",
2005
+ "node": "./dist/node/application/mcp/docsMcp.prompts.js",
2006
+ "default": "./dist/application/mcp/docsMcp.prompts.js"
2007
+ },
2008
+ "./application/mcp/docsMcp.reference": {
2009
+ "types": "./dist/application/mcp/docsMcp.reference.d.ts",
2010
+ "bun": "./dist/application/mcp/docsMcp.reference.js",
2011
+ "node": "./dist/node/application/mcp/docsMcp.reference.js",
2012
+ "default": "./dist/application/mcp/docsMcp.reference.js"
2013
+ },
2014
+ "./application/mcp/docsMcp.resources": {
2015
+ "types": "./dist/application/mcp/docsMcp.resources.d.ts",
2016
+ "bun": "./dist/application/mcp/docsMcp.resources.js",
2017
+ "node": "./dist/node/application/mcp/docsMcp.resources.js",
2018
+ "default": "./dist/application/mcp/docsMcp.resources.js"
2019
+ },
2020
+ "./application/mcp/docsMcp.tools": {
2021
+ "types": "./dist/application/mcp/docsMcp.tools.d.ts",
2022
+ "bun": "./dist/application/mcp/docsMcp.tools.js",
2023
+ "node": "./dist/node/application/mcp/docsMcp.tools.js",
2024
+ "default": "./dist/application/mcp/docsMcp.tools.js"
2025
+ },
1948
2026
  "./application/mcp/internalMcp": {
1949
2027
  "types": "./dist/application/mcp/internalMcp.d.ts",
1950
2028
  "bun": "./dist/application/mcp/internalMcp.js",
1951
2029
  "node": "./dist/node/application/mcp/internalMcp.js",
1952
2030
  "default": "./dist/application/mcp/internalMcp.js"
1953
2031
  },
2032
+ "./application/mcp/normalizeMcpRequest": {
2033
+ "types": "./dist/application/mcp/normalizeMcpRequest.d.ts",
2034
+ "bun": "./dist/application/mcp/normalizeMcpRequest.js",
2035
+ "node": "./dist/node/application/mcp/normalizeMcpRequest.js",
2036
+ "default": "./dist/application/mcp/normalizeMcpRequest.js"
2037
+ },
1954
2038
  "./application/mcp/providerRankingMcp": {
1955
2039
  "types": "./dist/application/mcp/providerRankingMcp.d.ts",
1956
2040
  "bun": "./dist/application/mcp/providerRankingMcp.js",
@@ -0,0 +1,64 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import {
3
+ OperationSpecRegistry,
4
+ PromptRegistry,
5
+ ResourceRegistry,
6
+ } from '@contractspec/lib.contracts-spec';
7
+ import { Elysia } from 'elysia';
8
+ import { appLogger } from '../../infrastructure/elysia/logger';
9
+ import { createMcpElysiaHandler } from './common';
10
+
11
+ function createTestApp() {
12
+ return new Elysia().use(
13
+ createMcpElysiaHandler({
14
+ logger: appLogger,
15
+ path: '/mcp/test',
16
+ serverName: 'test-mcp',
17
+ ops: new OperationSpecRegistry(),
18
+ resources: new ResourceRegistry(),
19
+ prompts: new PromptRegistry(),
20
+ })
21
+ );
22
+ }
23
+
24
+ function createInitializeRequest(accept: string) {
25
+ return new Request('http://localhost/mcp/test', {
26
+ method: 'POST',
27
+ headers: {
28
+ accept,
29
+ 'content-type': 'application/json',
30
+ },
31
+ body: JSON.stringify({
32
+ jsonrpc: '2.0',
33
+ id: 1,
34
+ method: 'initialize',
35
+ params: {
36
+ protocolVersion: '2024-11-05',
37
+ capabilities: {},
38
+ clientInfo: { name: 'test-client', version: '1.0.0' },
39
+ },
40
+ }),
41
+ });
42
+ }
43
+
44
+ describe('createMcpElysiaHandler', () => {
45
+ it('accepts JSON-only clients for POST MCP requests', async () => {
46
+ const response = await createTestApp().handle(
47
+ createInitializeRequest('application/json')
48
+ );
49
+
50
+ expect(response.status).toBe(200);
51
+ const body = await response.json();
52
+ expect(body.result.serverInfo.name).toBe('test-mcp');
53
+ });
54
+
55
+ it('keeps rejecting incompatible Accept headers', async () => {
56
+ const response = await createTestApp().handle(
57
+ createInitializeRequest('text/html')
58
+ );
59
+
60
+ expect(response.status).toBe(406);
61
+ const body = await response.json();
62
+ expect(body.error.message).toContain('Not Acceptable');
63
+ });
64
+ });
@@ -12,6 +12,7 @@ import { Logger } from '@contractspec/lib.logger';
12
12
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
13
  import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
14
14
  import { Elysia } from 'elysia';
15
+ import { normalizeMcpRequest } from './normalizeMcpRequest';
15
16
 
16
17
  export interface McpAuthValidationResult {
17
18
  valid: boolean;
@@ -150,7 +151,7 @@ export function createMcpElysiaHandler({
150
151
  });
151
152
 
152
153
  try {
153
- return await state.transport.handleRequest(request);
154
+ return await state.transport.handleRequest(normalizeMcpRequest(request));
154
155
  } finally {
155
156
  await closeSessionState(state);
156
157
  }
@@ -189,7 +190,9 @@ export function createMcpElysiaHandler({
189
190
  }
190
191
 
191
192
  try {
192
- const response = await state.transport.handleRequest(request);
193
+ const response = await state.transport.handleRequest(
194
+ normalizeMcpRequest(request)
195
+ );
193
196
  const activeSessionId = state.transport.sessionId;
194
197
 
195
198
  if (activeSessionId && !sessions.has(activeSessionId)) {
@@ -0,0 +1,2 @@
1
+ export * from './docsMcp.data';
2
+ export * from './docsMcp.reference';
@@ -0,0 +1,196 @@
1
+ import type { DocPresentationRoute } from '@contractspec/lib.contracts-spec/docs';
2
+ import { defaultDocRegistry } from '@contractspec/lib.contracts-spec/docs';
3
+
4
+ const DEFAULT_LIMIT = 20;
5
+ const MAX_LIMIT = 100;
6
+
7
+ type DocsSearchArgs = {
8
+ query?: string;
9
+ tag?: string | string[];
10
+ visibility?: string;
11
+ kind?: string;
12
+ limit?: number;
13
+ offset?: number;
14
+ };
15
+
16
+ function normalizeText(value: string | undefined | null) {
17
+ return value?.trim().toLowerCase() ?? '';
18
+ }
19
+
20
+ function normalizeRoute(route: string) {
21
+ const decoded = decodeURIComponent(route).trim();
22
+ if (!decoded) return '/';
23
+ return decoded.startsWith('/') ? decoded : `/${decoded}`;
24
+ }
25
+
26
+ function normalizeTags(value: string | string[] | undefined) {
27
+ const tags = Array.isArray(value) ? value : value ? [value] : [];
28
+ return tags.map((tag) => normalizeText(tag)).filter(Boolean);
29
+ }
30
+
31
+ function clampLimit(limit: number | undefined) {
32
+ if (!limit || Number.isNaN(limit)) return DEFAULT_LIMIT;
33
+ return Math.min(Math.max(limit, 1), MAX_LIMIT);
34
+ }
35
+
36
+ function clampOffset(offset: number | undefined) {
37
+ if (!offset || Number.isNaN(offset)) return 0;
38
+ return Math.max(offset, 0);
39
+ }
40
+
41
+ export function toDocSummary({ block, route }: DocPresentationRoute) {
42
+ return {
43
+ id: block.id,
44
+ title: block.title,
45
+ summary: block.summary ?? '',
46
+ route,
47
+ visibility: block.visibility ?? 'public',
48
+ kind: block.kind ?? 'reference',
49
+ version: block.version ?? '1.0.0',
50
+ tags: block.tags ?? [],
51
+ };
52
+ }
53
+
54
+ function scoreDoc(route: DocPresentationRoute, query: string) {
55
+ if (!query) return 1;
56
+
57
+ const tokens = query.split(/\s+/).filter(Boolean);
58
+ const title = normalizeText(route.block.title);
59
+ const id = normalizeText(route.block.id);
60
+ const summary = normalizeText(route.block.summary);
61
+ const body = normalizeText(route.block.body);
62
+ const path = normalizeText(route.route);
63
+ const tags = (route.block.tags ?? []).map((tag) => normalizeText(tag));
64
+ const haystack = [title, id, summary, body, path, ...tags].join(' ');
65
+
66
+ if (tokens.some((token) => !haystack.includes(token))) return 0;
67
+
68
+ let score = 0;
69
+ for (const token of tokens) {
70
+ if (id.includes(token)) score += 8;
71
+ if (title.includes(token)) score += 7;
72
+ if (tags.some((tag) => tag.includes(token))) score += 5;
73
+ if (summary.includes(token)) score += 4;
74
+ if (path.includes(token)) score += 3;
75
+ if (body.includes(token)) score += 2;
76
+ }
77
+
78
+ return score;
79
+ }
80
+
81
+ export function searchDocs(
82
+ routes: DocPresentationRoute[],
83
+ args: DocsSearchArgs
84
+ ) {
85
+ const query = normalizeText(
86
+ typeof args.query === 'string' ? args.query : undefined
87
+ );
88
+ const tags = normalizeTags(args.tag as string | string[] | undefined);
89
+ const visibility = normalizeText(
90
+ typeof args.visibility === 'string' ? args.visibility : undefined
91
+ );
92
+ const kind = normalizeText(
93
+ typeof args.kind === 'string' ? args.kind : undefined
94
+ );
95
+ const limit = clampLimit(
96
+ typeof args.limit === 'number' ? args.limit : undefined
97
+ );
98
+ const offset = clampOffset(
99
+ typeof args.offset === 'number' ? args.offset : undefined
100
+ );
101
+
102
+ const ranked = routes
103
+ .map((route) => ({
104
+ doc: toDocSummary(route),
105
+ score: scoreDoc(route, query),
106
+ }))
107
+ .filter(({ doc, score }) => {
108
+ const matchesQuery = query ? score > 0 : true;
109
+ const matchesTags = tags.length
110
+ ? tags.every((tag) =>
111
+ doc.tags.some((docTag) => normalizeText(docTag).includes(tag))
112
+ )
113
+ : true;
114
+ const matchesVisibility = visibility
115
+ ? normalizeText(doc.visibility) === visibility
116
+ : true;
117
+ const matchesKind = kind ? normalizeText(doc.kind) === kind : true;
118
+ return matchesQuery && matchesTags && matchesVisibility && matchesKind;
119
+ })
120
+ .sort((left, right) => {
121
+ if (right.score !== left.score) return right.score - left.score;
122
+ return left.doc.title.localeCompare(right.doc.title);
123
+ });
124
+
125
+ const docs = ranked.slice(offset, offset + limit).map(({ doc }) => doc);
126
+ const nextOffset =
127
+ offset + docs.length < ranked.length ? offset + docs.length : undefined;
128
+
129
+ return {
130
+ docs,
131
+ items: docs,
132
+ total: ranked.length,
133
+ ...(nextOffset != null ? { nextOffset } : {}),
134
+ };
135
+ }
136
+
137
+ export function getDocById(id: string) {
138
+ const normalizedId = decodeURIComponent(id);
139
+ const found = defaultDocRegistry.get(normalizedId);
140
+ if (!found) return undefined;
141
+
142
+ return {
143
+ doc: toDocSummary(found),
144
+ content: String(found.block.body ?? ''),
145
+ };
146
+ }
147
+
148
+ export function getDocByRoute(
149
+ routes: DocPresentationRoute[],
150
+ routePath: string
151
+ ) {
152
+ const normalizedPath = normalizeRoute(routePath);
153
+ const found = routes.find(
154
+ (route) => normalizeRoute(route.route) === normalizedPath
155
+ );
156
+ if (!found) return undefined;
157
+
158
+ return {
159
+ doc: toDocSummary(found),
160
+ content: String(found.block.body ?? ''),
161
+ };
162
+ }
163
+
164
+ export function listDocFacets(routes: DocPresentationRoute[]) {
165
+ const tags = new Map<string, number>();
166
+ const kinds = new Map<string, number>();
167
+ const visibilities = new Map<string, number>();
168
+
169
+ for (const route of routes) {
170
+ const kind = route.block.kind ?? 'reference';
171
+ const visibility = route.block.visibility ?? 'public';
172
+ kinds.set(kind, (kinds.get(kind) ?? 0) + 1);
173
+ visibilities.set(visibility, (visibilities.get(visibility) ?? 0) + 1);
174
+
175
+ for (const tag of route.block.tags ?? []) {
176
+ tags.set(tag, (tags.get(tag) ?? 0) + 1);
177
+ }
178
+ }
179
+
180
+ const toEntries = (
181
+ values: Map<string, number>,
182
+ key: 'tag' | 'kind' | 'visibility'
183
+ ) =>
184
+ [...values.entries()]
185
+ .sort(
186
+ (left, right) => right[1] - left[1] || left[0].localeCompare(right[0])
187
+ )
188
+ .map(([value, count]) => ({ [key]: value, count }));
189
+
190
+ return {
191
+ totalDocs: routes.length,
192
+ tags: toEntries(tags, 'tag'),
193
+ kinds: toEntries(kinds, 'kind'),
194
+ visibilities: toEntries(visibilities, 'visibility'),
195
+ };
196
+ }