@cyanheads/mcp-ts-core 0.12.5 → 0.12.6
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/AGENTS.md +25 -14
- package/CLAUDE.md +25 -14
- package/README.md +1 -1
- package/changelog/0.12.x/0.12.6.md +44 -0
- package/dist/core/app.d.ts +2 -2
- package/dist/core/app.js +2 -2
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +2 -2
- package/dist/core/worker.d.ts +1 -1
- package/dist/core/worker.js +1 -1
- package/dist/mcp-server/apps/appBuilders.d.ts +2 -2
- package/dist/mcp-server/apps/appBuilders.js +2 -2
- package/dist/mcp-server/cacheHints.d.ts +1 -1
- package/dist/mcp-server/prompts/prompt-registration.d.ts +1 -1
- package/dist/mcp-server/prompts/prompt-registration.js +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
- package/dist/mcp-server/resources/resource-registration.js +1 -1
- package/dist/mcp-server/resources/resourceSubscriptions.d.ts +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +2 -2
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +4 -4
- package/dist/mcp-server/server.d.ts +4 -4
- package/dist/mcp-server/server.js +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +3 -3
- package/dist/mcp-server/tools/tool-registration.js +2 -2
- package/dist/mcp-server/tools/utils/disabled-tool.d.ts +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +4 -4
- package/dist/mcp-server/transports/auth/authFactory.d.ts +1 -1
- package/dist/mcp-server/transports/auth/authFactory.js +2 -2
- package/dist/mcp-server/transports/auth/authMiddleware.d.ts +1 -1
- package/dist/mcp-server/transports/auth/authMiddleware.js +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.js +1 -1
- package/dist/mcp-server/transports/auth/lib/claimParser.d.ts +1 -1
- package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts +1 -1
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts +2 -2
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts +2 -2
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts +1 -1
- package/dist/mcp-server/transports/http/httpServer.d.ts +1 -1
- package/dist/mcp-server/transports/http/httpServer.js +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +3 -3
- package/dist/mcp-server/transports/http/httpTransport.js +12 -12
- package/dist/mcp-server/transports/http/landing-page/handler.d.ts +1 -1
- package/dist/mcp-server/transports/http/sessionStore.js +1 -1
- package/dist/mcp-server/transports/manager.d.ts +2 -2
- package/dist/mcp-server/transports/manager.js +3 -3
- package/dist/services/llm/providers/openrouter.provider.d.ts +1 -1
- package/dist/storage/core/StorageService.d.ts +1 -1
- package/dist/storage/core/StorageService.js +1 -1
- package/dist/storage/core/storageFactory.d.ts +2 -2
- package/dist/storage/core/storageFactory.js +6 -6
- package/dist/storage/core/storageValidation.d.ts.map +1 -1
- package/dist/storage/core/storageValidation.js +5 -3
- package/dist/storage/core/storageValidation.js.map +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.js +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.js +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.js +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.js +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +3 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.js +11 -7
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
- package/dist/storage/providers/supabase/supabaseProvider.d.ts +2 -2
- package/dist/storage/providers/supabase/supabaseProvider.js +1 -1
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +92 -53
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/utils/formatting/diffFormatter.d.ts +2 -2
- package/dist/utils/formatting/diffFormatter.js +4 -4
- package/dist/utils/formatting/tableFormatter.d.ts +2 -2
- package/dist/utils/formatting/tableFormatter.js +3 -3
- package/dist/utils/formatting/treeFormatter.d.ts +3 -3
- package/dist/utils/formatting/treeFormatter.js +4 -4
- package/dist/utils/internal/error-handler/errorHandler.js +6 -6
- package/dist/utils/internal/error-handler/helpers.js +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +1 -1
- package/dist/utils/internal/health.js +2 -2
- package/dist/utils/internal/lazyImport.js +1 -1
- package/dist/utils/internal/logger.d.ts +3 -3
- package/dist/utils/internal/logger.js +4 -4
- package/dist/utils/internal/performance.d.ts +1 -1
- package/dist/utils/internal/performance.js +6 -6
- package/dist/utils/internal/requestContext.d.ts +1 -1
- package/dist/utils/internal/requestContext.js +2 -2
- package/dist/utils/metrics/tokenCounter.d.ts +1 -1
- package/dist/utils/metrics/tokenCounter.js +2 -2
- package/dist/utils/network/fetchWithTimeout.d.ts +1 -1
- package/dist/utils/network/fetchWithTimeout.js +6 -6
- package/dist/utils/network/httpError.js +1 -1
- package/dist/utils/network/retry.d.ts +1 -1
- package/dist/utils/network/retry.js +1 -1
- package/dist/utils/pagination/pagination.d.ts +2 -2
- package/dist/utils/pagination/pagination.js +4 -4
- package/dist/utils/parsing/csvParser.d.ts +4 -4
- package/dist/utils/parsing/csvParser.js +6 -6
- package/dist/utils/parsing/dateParser.d.ts +3 -3
- package/dist/utils/parsing/dateParser.js +6 -6
- package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
- package/dist/utils/parsing/frontmatterParser.js +3 -3
- package/dist/utils/parsing/htmlExtractor.d.ts +3 -3
- package/dist/utils/parsing/htmlExtractor.js +5 -5
- package/dist/utils/parsing/jsonParser.d.ts +4 -4
- package/dist/utils/parsing/jsonParser.js +6 -6
- package/dist/utils/parsing/pdfParser.d.ts +2 -2
- package/dist/utils/parsing/pdfParser.js +4 -4
- package/dist/utils/parsing/xmlParser.d.ts +4 -4
- package/dist/utils/parsing/xmlParser.js +5 -5
- package/dist/utils/parsing/yamlParser.d.ts +4 -4
- package/dist/utils/parsing/yamlParser.js +6 -6
- package/dist/utils/scheduling/scheduler.d.ts +3 -3
- package/dist/utils/scheduling/scheduler.js +5 -5
- package/dist/utils/security/rateLimiter.d.ts +2 -2
- package/dist/utils/security/rateLimiter.js +3 -3
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/security/sanitization.d.ts +3 -3
- package/dist/utils/security/sanitization.js +7 -7
- package/dist/utils/telemetry/instrumentation.d.ts.map +1 -1
- package/dist/utils/telemetry/instrumentation.js +7 -8
- package/dist/utils/telemetry/instrumentation.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +1 -1
- package/dist/utils/telemetry/trace.js +1 -1
- package/package.json +13 -7
- package/scripts/devcheck.ts +6 -4
- package/skills/api-workers/SKILL.md +3 -3
- package/templates/AGENTS.md +2 -2
- package/templates/CLAUDE.md +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
3
3
|
/**
|
|
4
4
|
* Utility class for parsing YAML strings.
|
|
@@ -26,7 +26,7 @@ export declare class YamlParser {
|
|
|
26
26
|
* the `<think>` block, or if `js-yaml` fails to parse the content.
|
|
27
27
|
* @example
|
|
28
28
|
* ```typescript
|
|
29
|
-
* import { yamlParser } from '
|
|
29
|
+
* import { yamlParser } from './yamlParser.js';
|
|
30
30
|
*
|
|
31
31
|
* const result = await yamlParser.parse<{ key: string }>('key: value');
|
|
32
32
|
* console.log(result.key); // 'value'
|
|
@@ -46,14 +46,14 @@ export declare class YamlParser {
|
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```typescript
|
|
49
|
-
* import { yamlParser } from '
|
|
49
|
+
* import { yamlParser } from './yamlParser.js';
|
|
50
50
|
*
|
|
51
51
|
* // Basic parse
|
|
52
52
|
* const result = await yamlParser.parse<{ name: string }>('name: Claude');
|
|
53
53
|
* console.log(result.name); // 'Claude'
|
|
54
54
|
*
|
|
55
55
|
* // With request context for correlated logging
|
|
56
|
-
* import { requestContextService } from '
|
|
56
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
57
57
|
* const ctx = requestContextService.createRequestContext({ operation: 'parseConfig' });
|
|
58
58
|
* const config = await yamlParser.parse<AppConfig>(rawYaml, ctx);
|
|
59
59
|
*
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* @module src/utils/parsing/yamlParser
|
|
9
9
|
*/
|
|
10
10
|
import { validationError } from '../../types-global/errors.js';
|
|
11
|
-
import { lazyImport } from '
|
|
12
|
-
import { logger } from '
|
|
13
|
-
import { requestContextService, withExtra, } from '
|
|
11
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
12
|
+
import { logger } from '../internal/logger.js';
|
|
13
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
14
14
|
import { assertTextInputBudget } from './inputBudget.js';
|
|
15
15
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
16
16
|
const getYaml = lazyImport(() => import('js-yaml'), 'Install "js-yaml" to use YAML parsing: bun add js-yaml');
|
|
@@ -40,7 +40,7 @@ export class YamlParser {
|
|
|
40
40
|
* the `<think>` block, or if `js-yaml` fails to parse the content.
|
|
41
41
|
* @example
|
|
42
42
|
* ```typescript
|
|
43
|
-
* import { yamlParser } from '
|
|
43
|
+
* import { yamlParser } from './yamlParser.js';
|
|
44
44
|
*
|
|
45
45
|
* const result = await yamlParser.parse<{ key: string }>('key: value');
|
|
46
46
|
* console.log(result.key); // 'value'
|
|
@@ -102,14 +102,14 @@ export class YamlParser {
|
|
|
102
102
|
*
|
|
103
103
|
* @example
|
|
104
104
|
* ```typescript
|
|
105
|
-
* import { yamlParser } from '
|
|
105
|
+
* import { yamlParser } from './yamlParser.js';
|
|
106
106
|
*
|
|
107
107
|
* // Basic parse
|
|
108
108
|
* const result = await yamlParser.parse<{ name: string }>('name: Claude');
|
|
109
109
|
* console.log(result.name); // 'Claude'
|
|
110
110
|
*
|
|
111
111
|
* // With request context for correlated logging
|
|
112
|
-
* import { requestContextService } from '
|
|
112
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
113
113
|
* const ctx = requestContextService.createRequestContext({ operation: 'parseConfig' });
|
|
114
114
|
* const config = await yamlParser.parse<AppConfig>(rawYaml, ctx);
|
|
115
115
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @module src/utils/scheduling/scheduler
|
|
14
14
|
*/
|
|
15
15
|
import type { ScheduledTask } from 'node-cron';
|
|
16
|
-
import type { RequestContext } from '
|
|
16
|
+
import type { RequestContext } from '../internal/requestContext.js';
|
|
17
17
|
/**
|
|
18
18
|
* Represents a scheduled job managed by the {@link SchedulerService}.
|
|
19
19
|
*
|
|
@@ -51,7 +51,7 @@ export interface Job {
|
|
|
51
51
|
* instantiating this class directly.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
|
-
* import { schedulerService } from '
|
|
54
|
+
* import { schedulerService } from './scheduler.js';
|
|
55
55
|
*
|
|
56
56
|
* await schedulerService.schedule(
|
|
57
57
|
* 'cleanup',
|
|
@@ -182,7 +182,7 @@ export declare class SchedulerService {
|
|
|
182
182
|
* `SchedulerService.getInstance()` directly.
|
|
183
183
|
*
|
|
184
184
|
* @example
|
|
185
|
-
* import { schedulerService } from '
|
|
185
|
+
* import { schedulerService } from './scheduler.js';
|
|
186
186
|
*
|
|
187
187
|
* await schedulerService.schedule('heartbeat', '* * * * *', heartbeatFn, 'Heartbeat');
|
|
188
188
|
* schedulerService.start('heartbeat');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { configurationError, conflict, invalidParams, notFound } from '../../types-global/errors.js';
|
|
2
|
-
import { logger } from '
|
|
3
|
-
import { requestContextService } from '
|
|
4
|
-
import { runtimeCaps } from '
|
|
2
|
+
import { logger } from '../internal/logger.js';
|
|
3
|
+
import { requestContextService } from '../internal/requestContext.js';
|
|
4
|
+
import { runtimeCaps } from '../internal/runtime.js';
|
|
5
5
|
/**
|
|
6
6
|
* Lazily loads the `node-cron` module on first call and caches the resulting
|
|
7
7
|
* promise so subsequent calls resolve from the same import. Throws
|
|
@@ -35,7 +35,7 @@ async function loadCron() {
|
|
|
35
35
|
* instantiating this class directly.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
|
-
* import { schedulerService } from '
|
|
38
|
+
* import { schedulerService } from './scheduler.js';
|
|
39
39
|
*
|
|
40
40
|
* await schedulerService.schedule(
|
|
41
41
|
* 'cleanup',
|
|
@@ -268,7 +268,7 @@ export class SchedulerService {
|
|
|
268
268
|
* `SchedulerService.getInstance()` directly.
|
|
269
269
|
*
|
|
270
270
|
* @example
|
|
271
|
-
* import { schedulerService } from '
|
|
271
|
+
* import { schedulerService } from './scheduler.js';
|
|
272
272
|
*
|
|
273
273
|
* await schedulerService.schedule('heartbeat', '* * * * *', heartbeatFn, 'Heartbeat');
|
|
274
274
|
* schedulerService.start('heartbeat');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { config as ConfigType } from '../../config/index.js';
|
|
2
|
-
import type { logger as LoggerType } from '
|
|
3
|
-
import { type RequestContext } from '
|
|
2
|
+
import type { logger as LoggerType } from '../internal/logger.js';
|
|
3
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
4
4
|
/** Eagerly creates the rate limit rejection counter so the series exists from startup. */
|
|
5
5
|
export declare function initRateLimitMetrics(): void;
|
|
6
6
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { trace } from '@opentelemetry/api';
|
|
7
7
|
import { rateLimited } from '../../types-global/errors.js';
|
|
8
|
-
import { requestContextService } from '
|
|
9
|
-
import { createCounter } from '
|
|
8
|
+
import { requestContextService } from '../internal/requestContext.js';
|
|
9
|
+
import { createCounter } from '../telemetry/metrics.js';
|
|
10
10
|
let rejectionCounter;
|
|
11
11
|
function getRateLimitMetrics() {
|
|
12
12
|
rejectionCounter ??= createCounter('mcp.ratelimit.rejections', 'Rate limit rejections', '{rejections}');
|
|
@@ -82,7 +82,7 @@ export class RateLimiter {
|
|
|
82
82
|
oldestKey = key;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
if (oldestKey) {
|
|
85
|
+
if (oldestKey !== null) {
|
|
86
86
|
this.limits.delete(oldestKey);
|
|
87
87
|
const logContext = requestContextService.createRequestContext({
|
|
88
88
|
operation: 'RateLimiter.evictLRUEntry',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../../../src/utils/security/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAuB,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,IAAI,gBAA8D,CAAC;AAEnE,SAAS,mBAAmB;IAC1B,gBAAgB,KAAK,aAAa,CAChC,0BAA0B,EAC1B,uBAAuB,EACvB,cAAc,CACf,CAAC;IACF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC9B,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,oBAAoB;IAClC,mBAAmB,EAAE,CAAC;AACxB,CAAC;AAkCD;;;;;;;;;;;;;;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AAC,CAAC,CAAC,CAAC;YAE9C,MAAM,WAAW,CAAC,YAAY,EAAE;gBAC9B,eAAe,EAAE,QAAQ;gBACzB,GAAG,EAAE,QAAQ;gBACb,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW;gBACvC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;aACxC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,SAAS,CAAC,GAAW;QAM1B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,KAAK;YACpB,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW;YACvC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;YACtE,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,OAAO;QACZ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -104,7 +104,7 @@ export interface HtmlSanitizeConfig {
|
|
|
104
104
|
*
|
|
105
105
|
* @example
|
|
106
106
|
* ```ts
|
|
107
|
-
* import { sanitization } from '
|
|
107
|
+
* import { sanitization } from './sanitization.js';
|
|
108
108
|
*
|
|
109
109
|
* const clean = await sanitization.sanitizeHtml('<script>alert(1)</script><b>hi</b>');
|
|
110
110
|
* // => '<b>hi</b>'
|
|
@@ -407,7 +407,7 @@ export declare class Sanitization {
|
|
|
407
407
|
*
|
|
408
408
|
* @example
|
|
409
409
|
* ```ts
|
|
410
|
-
* import { sanitization } from '
|
|
410
|
+
* import { sanitization } from './sanitization.js';
|
|
411
411
|
* const safe = await sanitization.sanitizeHtml(userHtml);
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
@@ -421,7 +421,7 @@ export declare const sanitization: Sanitization;
|
|
|
421
421
|
* or `'[Log Sanitization Failed]'` on clone error.
|
|
422
422
|
* @example
|
|
423
423
|
* ```ts
|
|
424
|
-
* import { sanitizeInputForLogging } from '
|
|
424
|
+
* import { sanitizeInputForLogging } from './sanitization.js';
|
|
425
425
|
* logger.info('Request', sanitizeInputForLogging({ user: 'alice', token: 'secret' }));
|
|
426
426
|
* // logs: { user: 'alice', token: '[REDACTED]' }
|
|
427
427
|
* ```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { configurationError, JsonRpcErrorCode, McpError, validationError, } from '../../types-global/errors.js';
|
|
2
|
-
import { logger } from '
|
|
3
|
-
import { requestContextService } from '
|
|
4
|
-
import { runtimeCaps } from '
|
|
5
|
-
import { isRecord } from '
|
|
2
|
+
import { logger } from '../internal/logger.js';
|
|
3
|
+
import { requestContextService } from '../internal/requestContext.js';
|
|
4
|
+
import { runtimeCaps } from '../internal/runtime.js';
|
|
5
|
+
import { isRecord } from '../types/guards.js';
|
|
6
6
|
let _sanitizeHtmlFn;
|
|
7
7
|
async function loadSanitizeHtml() {
|
|
8
8
|
_sanitizeHtmlFn ??= (await import('sanitize-html').catch(() => {
|
|
@@ -38,7 +38,7 @@ if (runtimeCaps.isNode) {
|
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```ts
|
|
41
|
-
* import { sanitization } from '
|
|
41
|
+
* import { sanitization } from './sanitization.js';
|
|
42
42
|
*
|
|
43
43
|
* const clean = await sanitization.sanitizeHtml('<script>alert(1)</script><b>hi</b>');
|
|
44
44
|
* // => '<b>hi</b>'
|
|
@@ -741,7 +741,7 @@ export class Sanitization {
|
|
|
741
741
|
*
|
|
742
742
|
* @example
|
|
743
743
|
* ```ts
|
|
744
|
-
* import { sanitization } from '
|
|
744
|
+
* import { sanitization } from './sanitization.js';
|
|
745
745
|
* const safe = await sanitization.sanitizeHtml(userHtml);
|
|
746
746
|
* ```
|
|
747
747
|
*/
|
|
@@ -755,7 +755,7 @@ export const sanitization = Sanitization.getInstance();
|
|
|
755
755
|
* or `'[Log Sanitization Failed]'` on clone error.
|
|
756
756
|
* @example
|
|
757
757
|
* ```ts
|
|
758
|
-
* import { sanitizeInputForLogging } from '
|
|
758
|
+
* import { sanitizeInputForLogging } from './sanitization.js';
|
|
759
759
|
* logger.info('Request', sanitizeInputForLogging({ user: 'alice', token: 'secret' }));
|
|
760
760
|
* // logs: { user: 'alice', token: '[REDACTED]' }
|
|
761
761
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKvD;;;;;GAKG;AACH,eAAO,IAAI,GAAG,EAAE,OAAO,GAAG,IAAW,CAAC;AAmEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsH7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKvD;;;;;GAKG;AACH,eAAO,IAAI,GAAG,EAAE,OAAO,GAAG,IAAW,CAAC;AAmEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsH7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB3E"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';
|
|
8
8
|
import { config } from '../../config/index.js';
|
|
9
|
-
import { runtimeCaps } from '
|
|
9
|
+
import { runtimeCaps } from '../internal/runtime.js';
|
|
10
10
|
/**
|
|
11
11
|
* The active OpenTelemetry `NodeSDK` instance, or `null` when telemetry is disabled,
|
|
12
12
|
* the runtime is not Node/Bun, or the SDK has been shut down.
|
|
@@ -211,15 +211,13 @@ export async function shutdownOpenTelemetry(timeoutMs = 5000) {
|
|
|
211
211
|
if (!sdk) {
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
+
let timer;
|
|
214
215
|
try {
|
|
215
216
|
const shutdownPromise = sdk.shutdown();
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const timer = setTimeout(() => reject(new Error('OpenTelemetry SDK shutdown timeout')), timeoutMs);
|
|
221
|
-
await Promise.race([shutdownPromise, timeoutPromise]);
|
|
222
|
-
clearTimeout(timer);
|
|
217
|
+
await new Promise((resolve, reject) => {
|
|
218
|
+
timer = setTimeout(() => reject(new Error('OpenTelemetry SDK shutdown timeout')), timeoutMs);
|
|
219
|
+
shutdownPromise.then(resolve, reject);
|
|
220
|
+
});
|
|
223
221
|
diag.info('OpenTelemetry SDK terminated successfully.');
|
|
224
222
|
}
|
|
225
223
|
catch (error) {
|
|
@@ -227,6 +225,7 @@ export async function shutdownOpenTelemetry(timeoutMs = 5000) {
|
|
|
227
225
|
throw error; // Propagate for caller handling
|
|
228
226
|
}
|
|
229
227
|
finally {
|
|
228
|
+
clearTimeout(timer);
|
|
230
229
|
sdk = null;
|
|
231
230
|
isOtelInitialized = false;
|
|
232
231
|
initializationPromise = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../src/utils/telemetry/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,IAAI,GAAG,GAAmB,IAAI,CAAC;AAEtC,kCAAkC;AAClC,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAC9B,IAAI,qBAAqB,GAAyB,IAAI,CAAC;AAEvD;;;;;;;;GAQG;AACH,SAAS,aAAa;IACpB,OAAO,CACL,WAAW,CAAC,MAAM;QAClB,CAAC,WAAW,CAAC,YAAY;QACzB,OAAO,OAAO,EAAE,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAC3C,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB;IAC1B,6EAA6E;IAC7E,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,cAAc,GAAG,gBAAgB,CAAC;IACxC,MAAM,cAAc,GAAG,gBAAgB,CAAC;IACxC,MAAM,YAAY,GAAG,cAAc,CAAC;IAEpC,MAAM,KAAK,GAA2B,EAAE,CAAC;IAEzC,qBAAqB;IACrB,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;QAC7B,KAAK,CAAC,cAAc,CAAC,GAA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AAe,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QACzD,MAAM,KAAK,CAAC,CAAC,gCAAgC;IAC/C,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,GAAG,GAAG,IAAI,CAAC;QACX,iBAAiB,GAAG,KAAK,CAAC;QAC1B,qBAAqB,GAAG,IAAI,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module src/utils/telemetry/trace
|
|
6
6
|
*/
|
|
7
7
|
import { type Span } from '@opentelemetry/api';
|
|
8
|
-
import type { RequestContext } from '
|
|
8
|
+
import type { RequestContext } from '../internal/requestContext.js';
|
|
9
9
|
/**
|
|
10
10
|
* Parsed fields from a W3C `traceparent` header (`00-<traceId>-<spanId>-<flags>`).
|
|
11
11
|
* Used to propagate distributed trace context across service boundaries.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { context as otContext, propagation, ROOT_CONTEXT, SpanStatusCode, trace, } from '@opentelemetry/api';
|
|
8
8
|
import { config } from '../../config/index.js';
|
|
9
|
-
import { requestContextService } from '
|
|
9
|
+
import { requestContextService } from '../internal/requestContext.js';
|
|
10
10
|
/**
|
|
11
11
|
* Builds a W3C `traceparent` header value from a `RequestContext` or the currently active span.
|
|
12
12
|
* Uses `ctx.traceId`/`ctx.spanId` when provided; falls back to the active OTel span context.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyanheads/mcp-ts-core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"mcpName": "io.github.cyanheads/mcp-ts-core",
|
|
5
5
|
"description": "Agent-native TypeScript framework for building MCP servers. Build tools, not infrastructure. Declarative definitions with auth, multi-backend storage, OpenTelemetry, and first-class support for Bun/Node/Cloudflare Workers.",
|
|
6
6
|
"files": [
|
|
@@ -164,21 +164,27 @@
|
|
|
164
164
|
"format:unsafe": "biome check --write --unsafe .",
|
|
165
165
|
"typecheck": "bunx tsc --noEmit",
|
|
166
166
|
"typecheck:scripts": "bunx tsc --project tsconfig.scripts.json --noEmit",
|
|
167
|
+
"list-skills": "bun run scripts/list-skills.ts",
|
|
167
168
|
"tree": "bun run scripts/tree.ts",
|
|
168
169
|
"fetch-spec": "bun run scripts/fetch-openapi-spec.ts",
|
|
170
|
+
"bench": "bunx vitest bench --run --config tests/config/vitest.benchmark.ts",
|
|
171
|
+
"bench:node": "bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs bench --run --config tests/config/vitest.benchmark.ts",
|
|
172
|
+
"bench:io": "bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run --config tests/config/vitest.performance.ts",
|
|
173
|
+
"bench:io:bun": "bunx vitest run --config tests/config/vitest.performance.ts --project http --project native",
|
|
169
174
|
"test": "bunx vitest run",
|
|
170
175
|
"test:all": "bun run rebuild && bun run test:coverage && bun run test:node && bun run test:worker && bun run test:integration",
|
|
171
|
-
"test:integration": "bunx vitest run --config vitest.integration.ts",
|
|
172
|
-
"test:leaks": "
|
|
173
|
-
"test:node": "
|
|
174
|
-
"test:order": "
|
|
175
|
-
"test:package": "bun run rebuild && bunx vitest run --config vitest.package.ts",
|
|
176
|
+
"test:integration": "bunx vitest run --config tests/config/vitest.integration.ts",
|
|
177
|
+
"test:leaks": "bun run tests/leaks/run.ts",
|
|
178
|
+
"test:node": "bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run && bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run --config tests/config/vitest.integration.ts",
|
|
179
|
+
"test:order": "bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run --sequence.shuffle --sequence.seed=20260809 --expect.requireAssertions",
|
|
180
|
+
"test:package": "bun run rebuild && bunx vitest run --config tests/config/vitest.package.ts",
|
|
176
181
|
"test:unit": "bunx vitest run --project unit",
|
|
177
182
|
"test:smoke": "bunx vitest run --project smoke",
|
|
178
183
|
"test:fuzz": "bunx vitest run --project fuzz",
|
|
179
184
|
"test:typecheck": "bunx vitest run --project typecheck",
|
|
180
185
|
"test:compliance": "bunx vitest run --project compliance",
|
|
181
|
-
"test:
|
|
186
|
+
"test:leak-gate": "bunx vitest run --project leak-gate",
|
|
187
|
+
"test:worker": "bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run --config tests/config/vitest.worker.ts && bun run scripts/with-node.ts ./node_modules/vitest/vitest.mjs run --config tests/config/vitest.worker-bundle.ts",
|
|
182
188
|
"test:ui": "bunx vitest --ui",
|
|
183
189
|
"test:coverage": "bunx vitest run --coverage",
|
|
184
190
|
"audit": "bun audit",
|
package/scripts/devcheck.ts
CHANGED
|
@@ -437,16 +437,18 @@ const ALL_CHECKS: Check[] = [
|
|
|
437
437
|
flag: '--no-packaging',
|
|
438
438
|
canFix: false,
|
|
439
439
|
// Validates env var alignment between manifest.json (MCPB bundle) and
|
|
440
|
-
// server.json (MCP Registry), plus plugin marketplace manifests (#240)
|
|
441
|
-
//
|
|
442
|
-
// when none exist — consumers on an
|
|
440
|
+
// server.json (MCP Registry), plus plugin marketplace manifests (#240), and
|
|
441
|
+
// the bundle-content guards on .mcpbignore (#343). Runs when any of those
|
|
442
|
+
// inputs is present; skipped cleanly when none exist — consumers on an
|
|
443
|
+
// HTTP-only deploy are unaffected.
|
|
443
444
|
getCommand: () => {
|
|
444
445
|
const hasManifest = existsSync(path.join(ROOT_DIR, 'manifest.json'));
|
|
445
446
|
const hasPluginManifest =
|
|
446
447
|
existsSync(path.join(ROOT_DIR, '.claude-plugin/plugin.json')) ||
|
|
447
448
|
existsSync(path.join(ROOT_DIR, '.codex-plugin/plugin.json')) ||
|
|
448
449
|
existsSync(path.join(ROOT_DIR, '.codex-plugin/mcp.json'));
|
|
449
|
-
|
|
450
|
+
const hasMcpbIgnore = existsSync(path.join(ROOT_DIR, '.mcpbignore'));
|
|
451
|
+
if (!hasManifest && !hasPluginManifest && !hasMcpbIgnore) return null;
|
|
450
452
|
return ['bun', 'run', 'scripts/lint-packaging.ts'];
|
|
451
453
|
},
|
|
452
454
|
tip: (c) =>
|
|
@@ -4,7 +4,7 @@ description: >
|
|
|
4
4
|
Cloudflare Workers deployment using `createWorkerHandler` from `@cyanheads/mcp-ts-core/worker`. Covers the full handler signature, binding types, CloudflareBindings extensibility, runtime compatibility guards, and wrangler.toml requirements.
|
|
5
5
|
metadata:
|
|
6
6
|
author: cyanheads
|
|
7
|
-
version: "1.
|
|
7
|
+
version: "1.8"
|
|
8
8
|
audience: external
|
|
9
9
|
type: reference
|
|
10
10
|
---
|
|
@@ -224,9 +224,9 @@ The interface is the SDK's `ServerEventBus` — `publish(event)` and `subscribe(
|
|
|
224
224
|
|
|
225
225
|
## Testing Workers with miniflare
|
|
226
226
|
|
|
227
|
-
`bun run test:worker` runs the worker suite under `vitest.worker.ts` (using `@cloudflare/vitest-pool-workers` + miniflare). Each test **file** gets its own fresh V8 isolate — module scope (including `createWorkerHandler`'s `appPromise` singleton) is reset between files.
|
|
227
|
+
`bun run test:worker` runs the worker suite under `tests/config/vitest.worker.ts` (using `@cloudflare/vitest-pool-workers` + miniflare). Each test **file** gets its own fresh V8 isolate — module scope (including `createWorkerHandler`'s `appPromise` singleton) is reset between files.
|
|
228
228
|
|
|
229
|
-
### vitest.worker.ts miniflare bindings
|
|
229
|
+
### tests/config/vitest.worker.ts miniflare bindings
|
|
230
230
|
|
|
231
231
|
Declare all storage bindings used in the suite:
|
|
232
232
|
|
package/templates/AGENTS.md
CHANGED
|
@@ -197,7 +197,7 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
197
197
|
|
|
198
198
|
Handlers throw — the framework catches, classifies, and formats.
|
|
199
199
|
|
|
200
|
-
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
|
|
200
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
201
201
|
|
|
202
202
|
```ts
|
|
203
203
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -376,7 +376,7 @@ security: false # optional — true ONLY for a source
|
|
|
376
376
|
|
|
377
377
|
`agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
|
|
378
378
|
|
|
379
|
-
**Section order
|
|
379
|
+
**Section order:** the Keep a Changelog sequence — Added, Changed, Deprecated, Removed, Fixed, Security — then `Dependencies` last. Include only sections with entries — don't ship empty headers.
|
|
380
380
|
|
|
381
381
|
**Tag annotations** render as GitHub Release bodies via `--notes-from-tag`. They must be structured markdown — never a flat comma-separated string. Subject omits the version number (GitHub prepends it). See `changelog/template.md` for the full format reference.
|
|
382
382
|
|
package/templates/CLAUDE.md
CHANGED
|
@@ -197,7 +197,7 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
197
197
|
|
|
198
198
|
Handlers throw — the framework catches, classifies, and formats.
|
|
199
199
|
|
|
200
|
-
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
|
|
200
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required (≥ 5 words, lint-validated) — the single source of truth for the agent's next move. Pass `ctx.recoveryFor('reason')` as the throw's data to put it on the wire (`data.recovery.hint`, mirrored into `content[]` text); override with an explicit `{ recovery: { hint: '...' } }` when dynamic runtime context matters. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely and don't need declaring.
|
|
201
201
|
|
|
202
202
|
```ts
|
|
203
203
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
@@ -376,7 +376,7 @@ security: false # optional — true ONLY for a source
|
|
|
376
376
|
|
|
377
377
|
`agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
|
|
378
378
|
|
|
379
|
-
**Section order
|
|
379
|
+
**Section order:** the Keep a Changelog sequence — Added, Changed, Deprecated, Removed, Fixed, Security — then `Dependencies` last. Include only sections with entries — don't ship empty headers.
|
|
380
380
|
|
|
381
381
|
**Tag annotations** render as GitHub Release bodies via `--notes-from-tag`. They must be structured markdown — never a flat comma-separated string. Subject omits the version number (GitHub prepends it). See `changelog/template.md` for the full format reference.
|
|
382
382
|
|