@frontmcp/testing 0.6.1 → 0.6.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.
Files changed (142) hide show
  1. package/esm/fixtures/index.mjs +2377 -0
  2. package/esm/index.mjs +4768 -0
  3. package/esm/matchers/index.mjs +646 -0
  4. package/esm/package.json +122 -0
  5. package/esm/playwright/index.mjs +19 -0
  6. package/esm/setup.mjs +680 -0
  7. package/fixtures/index.js +2418 -0
  8. package/index.js +4866 -0
  9. package/jest-preset.js +3 -3
  10. package/matchers/index.js +673 -0
  11. package/package.json +51 -23
  12. package/playwright/index.js +46 -0
  13. package/setup.js +651 -0
  14. package/src/assertions/index.js +0 -18
  15. package/src/assertions/index.js.map +0 -1
  16. package/src/assertions/mcp-assertions.js +0 -220
  17. package/src/assertions/mcp-assertions.js.map +0 -1
  18. package/src/auth/auth-headers.js +0 -62
  19. package/src/auth/auth-headers.js.map +0 -1
  20. package/src/auth/index.js +0 -15
  21. package/src/auth/index.js.map +0 -1
  22. package/src/auth/mock-api-server.js +0 -200
  23. package/src/auth/mock-api-server.js.map +0 -1
  24. package/src/auth/mock-oauth-server.js +0 -253
  25. package/src/auth/mock-oauth-server.js.map +0 -1
  26. package/src/auth/token-factory.js +0 -181
  27. package/src/auth/token-factory.js.map +0 -1
  28. package/src/auth/user-fixtures.js +0 -92
  29. package/src/auth/user-fixtures.js.map +0 -1
  30. package/src/client/index.js +0 -12
  31. package/src/client/index.js.map +0 -1
  32. package/src/client/mcp-test-client.builder.js +0 -163
  33. package/src/client/mcp-test-client.builder.js.map +0 -1
  34. package/src/client/mcp-test-client.js +0 -937
  35. package/src/client/mcp-test-client.js.map +0 -1
  36. package/src/client/mcp-test-client.types.js +0 -16
  37. package/src/client/mcp-test-client.types.js.map +0 -1
  38. package/src/errors/index.js +0 -85
  39. package/src/errors/index.js.map +0 -1
  40. package/src/example-tools/index.js +0 -40
  41. package/src/example-tools/index.js.map +0 -1
  42. package/src/example-tools/tool-configs.js +0 -222
  43. package/src/example-tools/tool-configs.js.map +0 -1
  44. package/src/expect.js +0 -31
  45. package/src/expect.js.map +0 -1
  46. package/src/fixtures/fixture-types.js +0 -7
  47. package/src/fixtures/fixture-types.js.map +0 -1
  48. package/src/fixtures/index.js +0 -16
  49. package/src/fixtures/index.js.map +0 -1
  50. package/src/fixtures/test-fixture.js +0 -311
  51. package/src/fixtures/test-fixture.js.map +0 -1
  52. package/src/http-mock/http-mock.js +0 -544
  53. package/src/http-mock/http-mock.js.map +0 -1
  54. package/src/http-mock/http-mock.types.js +0 -10
  55. package/src/http-mock/http-mock.types.js.map +0 -1
  56. package/src/http-mock/index.js +0 -11
  57. package/src/http-mock/index.js.map +0 -1
  58. package/src/index.js +0 -167
  59. package/src/index.js.map +0 -1
  60. package/src/interceptor/index.js +0 -15
  61. package/src/interceptor/index.js.map +0 -1
  62. package/src/interceptor/interceptor-chain.js +0 -207
  63. package/src/interceptor/interceptor-chain.js.map +0 -1
  64. package/src/interceptor/interceptor.types.js +0 -7
  65. package/src/interceptor/interceptor.types.js.map +0 -1
  66. package/src/interceptor/mock-registry.js +0 -189
  67. package/src/interceptor/mock-registry.js.map +0 -1
  68. package/src/matchers/index.js +0 -12
  69. package/src/matchers/index.js.map +0 -1
  70. package/src/matchers/matcher-types.js +0 -10
  71. package/src/matchers/matcher-types.js.map +0 -1
  72. package/src/matchers/mcp-matchers.js +0 -395
  73. package/src/matchers/mcp-matchers.js.map +0 -1
  74. package/src/platform/index.js +0 -47
  75. package/src/platform/index.js.map +0 -1
  76. package/src/platform/platform-client-info.js +0 -155
  77. package/src/platform/platform-client-info.js.map +0 -1
  78. package/src/platform/platform-types.js +0 -110
  79. package/src/platform/platform-types.js.map +0 -1
  80. package/src/playwright/index.js +0 -49
  81. package/src/playwright/index.js.map +0 -1
  82. package/src/server/index.js +0 -10
  83. package/src/server/index.js.map +0 -1
  84. package/src/server/test-server.js +0 -341
  85. package/src/server/test-server.js.map +0 -1
  86. package/src/setup.js +0 -30
  87. package/src/setup.js.map +0 -1
  88. package/src/transport/index.js +0 -10
  89. package/src/transport/index.js.map +0 -1
  90. package/src/transport/streamable-http.transport.js +0 -438
  91. package/src/transport/streamable-http.transport.js.map +0 -1
  92. package/src/transport/transport.interface.js +0 -7
  93. package/src/transport/transport.interface.js.map +0 -1
  94. package/src/ui/index.js +0 -23
  95. package/src/ui/index.js.map +0 -1
  96. package/src/ui/ui-assertions.js +0 -367
  97. package/src/ui/ui-assertions.js.map +0 -1
  98. package/src/ui/ui-matchers.js +0 -493
  99. package/src/ui/ui-matchers.js.map +0 -1
  100. /package/{src/assertions → assertions}/index.d.ts +0 -0
  101. /package/{src/assertions → assertions}/mcp-assertions.d.ts +0 -0
  102. /package/{src/auth → auth}/auth-headers.d.ts +0 -0
  103. /package/{src/auth → auth}/index.d.ts +0 -0
  104. /package/{src/auth → auth}/mock-api-server.d.ts +0 -0
  105. /package/{src/auth → auth}/mock-oauth-server.d.ts +0 -0
  106. /package/{src/auth → auth}/token-factory.d.ts +0 -0
  107. /package/{src/auth → auth}/user-fixtures.d.ts +0 -0
  108. /package/{src/client → client}/index.d.ts +0 -0
  109. /package/{src/client → client}/mcp-test-client.builder.d.ts +0 -0
  110. /package/{src/client → client}/mcp-test-client.d.ts +0 -0
  111. /package/{src/client → client}/mcp-test-client.types.d.ts +0 -0
  112. /package/{src/errors → errors}/index.d.ts +0 -0
  113. /package/{src/example-tools → example-tools}/index.d.ts +0 -0
  114. /package/{src/example-tools → example-tools}/tool-configs.d.ts +0 -0
  115. /package/{src/expect.d.ts → expect.d.ts} +0 -0
  116. /package/{src/fixtures → fixtures}/fixture-types.d.ts +0 -0
  117. /package/{src/fixtures → fixtures}/index.d.ts +0 -0
  118. /package/{src/fixtures → fixtures}/test-fixture.d.ts +0 -0
  119. /package/{src/http-mock → http-mock}/http-mock.d.ts +0 -0
  120. /package/{src/http-mock → http-mock}/http-mock.types.d.ts +0 -0
  121. /package/{src/http-mock → http-mock}/index.d.ts +0 -0
  122. /package/{src/index.d.ts → index.d.ts} +0 -0
  123. /package/{src/interceptor → interceptor}/index.d.ts +0 -0
  124. /package/{src/interceptor → interceptor}/interceptor-chain.d.ts +0 -0
  125. /package/{src/interceptor → interceptor}/interceptor.types.d.ts +0 -0
  126. /package/{src/interceptor → interceptor}/mock-registry.d.ts +0 -0
  127. /package/{src/matchers → matchers}/index.d.ts +0 -0
  128. /package/{src/matchers → matchers}/matcher-types.d.ts +0 -0
  129. /package/{src/matchers → matchers}/mcp-matchers.d.ts +0 -0
  130. /package/{src/platform → platform}/index.d.ts +0 -0
  131. /package/{src/platform → platform}/platform-client-info.d.ts +0 -0
  132. /package/{src/platform → platform}/platform-types.d.ts +0 -0
  133. /package/{src/playwright → playwright}/index.d.ts +0 -0
  134. /package/{src/server → server}/index.d.ts +0 -0
  135. /package/{src/server → server}/test-server.d.ts +0 -0
  136. /package/{src/setup.d.ts → setup.d.ts} +0 -0
  137. /package/{src/transport → transport}/index.d.ts +0 -0
  138. /package/{src/transport → transport}/streamable-http.transport.d.ts +0 -0
  139. /package/{src/transport → transport}/transport.interface.d.ts +0 -0
  140. /package/{src/ui → ui}/index.d.ts +0 -0
  141. /package/{src/ui → ui}/ui-assertions.d.ts +0 -0
  142. /package/{src/ui → ui}/ui-matchers.d.ts +0 -0
@@ -1,163 +0,0 @@
1
- "use strict";
2
- /**
3
- * @file mcp-test-client.builder.ts
4
- * @description Builder pattern for creating McpTestClient instances
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.McpTestClientBuilder = void 0;
8
- const mcp_test_client_1 = require("./mcp-test-client");
9
- const platform_client_info_1 = require("../platform/platform-client-info");
10
- /**
11
- * Builder for creating McpTestClient instances with fluent API
12
- *
13
- * @example
14
- * ```typescript
15
- * const client = await McpTestClient.create({ baseUrl: 'http://localhost:3003' })
16
- * .withTransport('streamable-http')
17
- * .withToken('my-jwt-token')
18
- * .withTimeout(5000)
19
- * .withDebug()
20
- * .buildAndConnect();
21
- * ```
22
- */
23
- class McpTestClientBuilder {
24
- config;
25
- constructor(config) {
26
- this.config = { ...config };
27
- }
28
- /**
29
- * Set the authentication configuration
30
- */
31
- withAuth(auth) {
32
- this.config.auth = { ...this.config.auth, ...auth };
33
- return this;
34
- }
35
- /**
36
- * Set the bearer token for authentication
37
- */
38
- withToken(token) {
39
- this.config.auth = { ...this.config.auth, token };
40
- return this;
41
- }
42
- /**
43
- * Add custom headers to all requests
44
- */
45
- withHeaders(headers) {
46
- this.config.auth = {
47
- ...this.config.auth,
48
- headers: { ...this.config.auth?.headers, ...headers },
49
- };
50
- return this;
51
- }
52
- /**
53
- * Set the transport type
54
- */
55
- withTransport(transport) {
56
- this.config.transport = transport;
57
- return this;
58
- }
59
- /**
60
- * Set the request timeout in milliseconds
61
- */
62
- withTimeout(timeoutMs) {
63
- this.config.timeout = timeoutMs;
64
- return this;
65
- }
66
- /**
67
- * Enable debug logging
68
- */
69
- withDebug(enabled = true) {
70
- this.config.debug = enabled;
71
- return this;
72
- }
73
- /**
74
- * Enable public mode - skip authentication entirely.
75
- * When true, no Authorization header is sent and anonymous token is not requested.
76
- * Use this for testing public/unauthenticated endpoints in CI/CD pipelines.
77
- */
78
- withPublicMode(enabled = true) {
79
- this.config.publicMode = enabled;
80
- return this;
81
- }
82
- /**
83
- * Set the MCP protocol version to request
84
- */
85
- withProtocolVersion(version) {
86
- this.config.protocolVersion = version;
87
- return this;
88
- }
89
- /**
90
- * Set the client info sent during initialization
91
- */
92
- withClientInfo(info) {
93
- this.config.clientInfo = info;
94
- return this;
95
- }
96
- /**
97
- * Set the platform type for testing platform-specific meta keys.
98
- * Automatically configures clientInfo and capabilities for platform detection.
99
- *
100
- * Platform-specific behavior:
101
- * - `openai`: Uses openai/* meta keys, sets User-Agent to "ChatGPT/1.0"
102
- * - `ext-apps`: Uses ui/* meta keys per SEP-1865, sets io.modelcontextprotocol/ui capability
103
- * - `claude`: Uses frontmcp/* + ui/* keys, sets User-Agent to "claude-desktop/1.0"
104
- * - `cursor`: Uses frontmcp/* + ui/* keys, sets User-Agent to "cursor/1.0"
105
- * - Other platforms follow similar patterns
106
- *
107
- * @example
108
- * ```typescript
109
- * const client = await McpTestClient.create({ baseUrl })
110
- * .withPlatform('openai')
111
- * .buildAndConnect();
112
- *
113
- * // ext-apps automatically sets the io.modelcontextprotocol/ui capability
114
- * const extAppsClient = await McpTestClient.create({ baseUrl })
115
- * .withPlatform('ext-apps')
116
- * .buildAndConnect();
117
- * ```
118
- */
119
- withPlatform(platform) {
120
- this.config.platform = platform;
121
- // Auto-set clientInfo based on platform for User-Agent detection
122
- this.config.clientInfo = (0, platform_client_info_1.getPlatformClientInfo)(platform);
123
- // Auto-set capabilities based on platform (ext-apps requires io.modelcontextprotocol/ui)
124
- this.config.capabilities = (0, platform_client_info_1.getPlatformCapabilities)(platform);
125
- return this;
126
- }
127
- /**
128
- * Set custom client capabilities for MCP initialization.
129
- * Use this for fine-grained control over capabilities sent during initialization.
130
- *
131
- * @example
132
- * ```typescript
133
- * const client = await McpTestClient.create({ baseUrl })
134
- * .withCapabilities({
135
- * sampling: {},
136
- * experimental: {
137
- * 'io.modelcontextprotocol/ui': { mimeTypes: ['text/html+mcp'] }
138
- * }
139
- * })
140
- * .buildAndConnect();
141
- * ```
142
- */
143
- withCapabilities(capabilities) {
144
- this.config.capabilities = capabilities;
145
- return this;
146
- }
147
- /**
148
- * Build the McpTestClient instance (does not connect)
149
- */
150
- build() {
151
- return new mcp_test_client_1.McpTestClient(this.config);
152
- }
153
- /**
154
- * Build the McpTestClient and connect to the server
155
- */
156
- async buildAndConnect() {
157
- const client = this.build();
158
- await client.connect();
159
- return client;
160
- }
161
- }
162
- exports.McpTestClientBuilder = McpTestClientBuilder;
163
- //# sourceMappingURL=mcp-test-client.builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-test-client.builder.js","sourceRoot":"","sources":["../../../src/client/mcp-test-client.builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;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C,OAAO,GAAG,IAAI;QAC3B,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,OAAe;QACjC,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,IAAuC;QACpD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,CAAC,QAA0B;QACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAChC,iEAAiE;QACjE,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAA,4CAAqB,EAAC,QAAQ,CAAC,CAAC;QACzD,yFAAyF;QACzF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAA,8CAAuB,EAAC,QAAQ,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,YAAoC;QACnD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,+BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5B,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxJD,oDAwJC","sourcesContent":["/**\n * @file mcp-test-client.builder.ts\n * @description Builder pattern for creating McpTestClient instances\n */\n\nimport type {\n McpTestClientConfig,\n TestTransportType,\n TestAuthConfig,\n TestClientCapabilities,\n} from './mcp-test-client.types';\nimport { McpTestClient } from './mcp-test-client';\nimport type { TestPlatformType } from '../platform/platform-types';\nimport { getPlatformClientInfo, getPlatformCapabilities } from '../platform/platform-client-info';\n\n/**\n * Builder for creating McpTestClient instances with fluent API\n *\n * @example\n * ```typescript\n * const client = await McpTestClient.create({ baseUrl: 'http://localhost:3003' })\n * .withTransport('streamable-http')\n * .withToken('my-jwt-token')\n * .withTimeout(5000)\n * .withDebug()\n * .buildAndConnect();\n * ```\n */\nexport class McpTestClientBuilder {\n private config: McpTestClientConfig;\n\n constructor(config: McpTestClientConfig) {\n this.config = { ...config };\n }\n\n /**\n * Set the authentication configuration\n */\n withAuth(auth: TestAuthConfig): this {\n this.config.auth = { ...this.config.auth, ...auth };\n return this;\n }\n\n /**\n * Set the bearer token for authentication\n */\n withToken(token: string): this {\n this.config.auth = { ...this.config.auth, token };\n return this;\n }\n\n /**\n * Add custom headers to all requests\n */\n withHeaders(headers: Record<string, string>): this {\n this.config.auth = {\n ...this.config.auth,\n headers: { ...this.config.auth?.headers, ...headers },\n };\n return this;\n }\n\n /**\n * Set the transport type\n */\n withTransport(transport: TestTransportType): this {\n this.config.transport = transport;\n return this;\n }\n\n /**\n * Set the request timeout in milliseconds\n */\n withTimeout(timeoutMs: number): this {\n this.config.timeout = timeoutMs;\n return this;\n }\n\n /**\n * Enable debug logging\n */\n withDebug(enabled = true): this {\n this.config.debug = enabled;\n return this;\n }\n\n /**\n * Enable public mode - skip authentication entirely.\n * When true, no Authorization header is sent and anonymous token is not requested.\n * Use this for testing public/unauthenticated endpoints in CI/CD pipelines.\n */\n withPublicMode(enabled = true): this {\n this.config.publicMode = enabled;\n return this;\n }\n\n /**\n * Set the MCP protocol version to request\n */\n withProtocolVersion(version: string): this {\n this.config.protocolVersion = version;\n return this;\n }\n\n /**\n * Set the client info sent during initialization\n */\n withClientInfo(info: { name: string; version: string }): this {\n this.config.clientInfo = info;\n return this;\n }\n\n /**\n * Set the platform type for testing platform-specific meta keys.\n * Automatically configures clientInfo and capabilities for platform detection.\n *\n * Platform-specific behavior:\n * - `openai`: Uses openai/* meta keys, sets User-Agent to \"ChatGPT/1.0\"\n * - `ext-apps`: Uses ui/* meta keys per SEP-1865, sets io.modelcontextprotocol/ui capability\n * - `claude`: Uses frontmcp/* + ui/* keys, sets User-Agent to \"claude-desktop/1.0\"\n * - `cursor`: Uses frontmcp/* + ui/* keys, sets User-Agent to \"cursor/1.0\"\n * - Other platforms follow similar patterns\n *\n * @example\n * ```typescript\n * const client = await McpTestClient.create({ baseUrl })\n * .withPlatform('openai')\n * .buildAndConnect();\n *\n * // ext-apps automatically sets the io.modelcontextprotocol/ui capability\n * const extAppsClient = await McpTestClient.create({ baseUrl })\n * .withPlatform('ext-apps')\n * .buildAndConnect();\n * ```\n */\n withPlatform(platform: TestPlatformType): this {\n this.config.platform = platform;\n // Auto-set clientInfo based on platform for User-Agent detection\n this.config.clientInfo = getPlatformClientInfo(platform);\n // Auto-set capabilities based on platform (ext-apps requires io.modelcontextprotocol/ui)\n this.config.capabilities = getPlatformCapabilities(platform);\n return this;\n }\n\n /**\n * Set custom client capabilities for MCP initialization.\n * Use this for fine-grained control over capabilities sent during initialization.\n *\n * @example\n * ```typescript\n * const client = await McpTestClient.create({ baseUrl })\n * .withCapabilities({\n * sampling: {},\n * experimental: {\n * 'io.modelcontextprotocol/ui': { mimeTypes: ['text/html+mcp'] }\n * }\n * })\n * .buildAndConnect();\n * ```\n */\n withCapabilities(capabilities: TestClientCapabilities): this {\n this.config.capabilities = capabilities;\n return this;\n }\n\n /**\n * Build the McpTestClient instance (does not connect)\n */\n build(): McpTestClient {\n return new McpTestClient(this.config);\n }\n\n /**\n * Build the McpTestClient and connect to the server\n */\n async buildAndConnect(): Promise<McpTestClient> {\n const client = this.build();\n await client.connect();\n return client;\n }\n}\n"]}