@cyanheads/mcp-ts-core 0.8.1 → 0.8.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.
- package/CLAUDE.md +8 -2
- package/README.md +1 -1
- package/changelog/0.8.x/0.8.2.md +18 -0
- package/changelog/0.8.x/0.8.3.md +43 -0
- package/dist/logs/combined.log +12 -4
- package/dist/logs/error.log +12 -4
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +2 -3
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +3 -3
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +8 -12
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts +2 -3
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +28 -0
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +64 -23
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/copy-script.d.ts +13 -4
- package/dist/mcp-server/transports/http/landing-page/assets/copy-script.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/copy-script.js +99 -25
- package/dist/mcp-server/transports/http/landing-page/assets/copy-script.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/styles.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/styles.js +318 -8
- package/dist/mcp-server/transports/http/landing-page/assets/styles.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/status-strip.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/status-strip.js +20 -1
- package/dist/mcp-server/transports/http/landing-page/sections/status-strip.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/tools.d.ts +6 -5
- package/dist/mcp-server/transports/http/landing-page/sections/tools.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/tools.js +114 -69
- package/dist/mcp-server/transports/http/landing-page/sections/tools.js.map +1 -1
- package/dist/types-global/errors.d.ts +3 -22
- package/dist/types-global/errors.d.ts.map +1 -1
- package/dist/types-global/errors.js +0 -19
- package/dist/types-global/errors.js.map +1 -1
- package/package.json +1 -1
- package/skills/add-app-tool/SKILL.md +24 -8
- package/skills/add-resource/SKILL.md +1 -1
- package/skills/add-tool/SKILL.md +87 -20
- package/skills/api-errors/SKILL.md +21 -7
- package/skills/api-linter/SKILL.md +1 -1
- package/skills/design-mcp-server/SKILL.md +1 -1
- package/skills/field-test/SKILL.md +15 -6
- package/skills/maintenance/SKILL.md +19 -7
- package/templates/AGENTS.md +3 -2
- package/templates/CLAUDE.md +3 -2
- package/templates/src/mcp-server/tools/definitions/echo.tool.ts +18 -1
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
7
7
|
import type { CallToolResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import type { StorageService } from '../../../storage/core/StorageService.js';
|
|
9
|
+
import { type JsonRpcErrorCode } from '../../../types-global/errors.js';
|
|
9
10
|
import type { Logger } from '../../../utils/internal/logger.js';
|
|
10
11
|
import type { AnyToolDefinition } from './toolDefinition.js';
|
|
11
12
|
type SdkExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
@@ -25,6 +26,33 @@ export interface HandlerNotifiers {
|
|
|
25
26
|
notifyResourceListChanged?: () => void;
|
|
26
27
|
notifyResourceUpdated?: (uri: string) => void;
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Shapes a `CallToolResult` for a tool error response with parity across both
|
|
31
|
+
* surfaces clients forward to the agent:
|
|
32
|
+
* - `content[]` — read by clients like Claude Desktop (markdown)
|
|
33
|
+
* - `structuredContent.error` — read by clients like Claude Code (JSON)
|
|
34
|
+
*
|
|
35
|
+
* Both surfaces carry the same payload. When `data.recovery.hint` is present,
|
|
36
|
+
* it is also mirrored into the `content[]` text so format()-only clients see
|
|
37
|
+
* the recovery guidance.
|
|
38
|
+
*
|
|
39
|
+
* Note: `_meta.error` is intentionally NOT emitted — the error code, message,
|
|
40
|
+
* and data live on `structuredContent.error` instead, mirroring the success
|
|
41
|
+
* path's `structuredContent` surface.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildToolErrorResult(code: JsonRpcErrorCode, message: string, data: Record<string, unknown> | undefined): CallToolResult;
|
|
44
|
+
/**
|
|
45
|
+
* Builds an error `CallToolResult` from a raw thrown value. Classifies via
|
|
46
|
+
* {@link ErrorHandler.classifyOnly} when the value isn't already an
|
|
47
|
+
* `McpError`. Only propagates data from `McpError` (its declared `data`) or
|
|
48
|
+
* `ZodError` (its `issues`) — other thrown values get a `structuredContent.error`
|
|
49
|
+
* with `code` and `message` only, so internal classification context never
|
|
50
|
+
* leaks to clients.
|
|
51
|
+
*
|
|
52
|
+
* Use after invoking {@link ErrorHandler.handleError} for OTel/logging side
|
|
53
|
+
* effects — this helper does not log.
|
|
54
|
+
*/
|
|
55
|
+
export declare function classifyAndBuildToolErrorResult(error: unknown): CallToolResult;
|
|
28
56
|
/**
|
|
29
57
|
* Creates an MCP tool handler from a tool definition.
|
|
30
58
|
* The returned function is compatible with the MCP SDK's ToolCallback type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,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,CAO9E;AAwBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,gBAAgB,GAC1B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,cAAc,CAAC,CAiF9E"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { ZodError } from 'zod';
|
|
7
7
|
import { attachTypedFail, createContext } from '../../../core/context.js';
|
|
8
8
|
import { withRequiredScopes } from '../../../mcp-server/transports/auth/lib/authUtils.js';
|
|
9
|
-
import {
|
|
9
|
+
import { McpError } from '../../../types-global/errors.js';
|
|
10
10
|
import { ErrorHandler } from '../../../utils/internal/error-handler/errorHandler.js';
|
|
11
11
|
import { measureToolExecution } from '../../../utils/internal/performance.js';
|
|
12
12
|
import { requestContextService } from '../../../utils/internal/requestContext.js';
|
|
@@ -17,6 +17,67 @@ const defaultResponseFormatter = (result) => [
|
|
|
17
17
|
{ type: 'text', text: JSON.stringify(result, null, 2) },
|
|
18
18
|
];
|
|
19
19
|
// ---------------------------------------------------------------------------
|
|
20
|
+
// Error response shaping
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* Pulls `data.recovery.hint` from an error data payload when present and
|
|
24
|
+
* non-empty. Returns `undefined` otherwise. Used to mirror the hint into
|
|
25
|
+
* `content[]` text so format()-only clients see the same recovery guidance
|
|
26
|
+
* structuredContent-only clients receive via `error.data.recovery.hint`.
|
|
27
|
+
*/
|
|
28
|
+
function extractRecoveryHint(data) {
|
|
29
|
+
const hint = data?.recovery?.hint;
|
|
30
|
+
return typeof hint === 'string' && hint.length > 0 ? hint : undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Shapes a `CallToolResult` for a tool error response with parity across both
|
|
34
|
+
* surfaces clients forward to the agent:
|
|
35
|
+
* - `content[]` — read by clients like Claude Desktop (markdown)
|
|
36
|
+
* - `structuredContent.error` — read by clients like Claude Code (JSON)
|
|
37
|
+
*
|
|
38
|
+
* Both surfaces carry the same payload. When `data.recovery.hint` is present,
|
|
39
|
+
* it is also mirrored into the `content[]` text so format()-only clients see
|
|
40
|
+
* the recovery guidance.
|
|
41
|
+
*
|
|
42
|
+
* Note: `_meta.error` is intentionally NOT emitted — the error code, message,
|
|
43
|
+
* and data live on `structuredContent.error` instead, mirroring the success
|
|
44
|
+
* path's `structuredContent` surface.
|
|
45
|
+
*/
|
|
46
|
+
export function buildToolErrorResult(code, message, data) {
|
|
47
|
+
const hint = extractRecoveryHint(data);
|
|
48
|
+
const text = hint ? `Error: ${message}\n\nRecovery: ${hint}` : `Error: ${message}`;
|
|
49
|
+
return {
|
|
50
|
+
isError: true,
|
|
51
|
+
content: [{ type: 'text', text }],
|
|
52
|
+
structuredContent: {
|
|
53
|
+
error: {
|
|
54
|
+
code,
|
|
55
|
+
message,
|
|
56
|
+
...(data !== undefined && { data }),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Builds an error `CallToolResult` from a raw thrown value. Classifies via
|
|
63
|
+
* {@link ErrorHandler.classifyOnly} when the value isn't already an
|
|
64
|
+
* `McpError`. Only propagates data from `McpError` (its declared `data`) or
|
|
65
|
+
* `ZodError` (its `issues`) — other thrown values get a `structuredContent.error`
|
|
66
|
+
* with `code` and `message` only, so internal classification context never
|
|
67
|
+
* leaks to clients.
|
|
68
|
+
*
|
|
69
|
+
* Use after invoking {@link ErrorHandler.handleError} for OTel/logging side
|
|
70
|
+
* effects — this helper does not log.
|
|
71
|
+
*/
|
|
72
|
+
export function classifyAndBuildToolErrorResult(error) {
|
|
73
|
+
if (error instanceof McpError) {
|
|
74
|
+
return buildToolErrorResult(error.code, error.message, error.data);
|
|
75
|
+
}
|
|
76
|
+
const { code, message } = ErrorHandler.classifyOnly(error);
|
|
77
|
+
const data = error instanceof ZodError ? { issues: error.issues } : undefined;
|
|
78
|
+
return buildToolErrorResult(code, message, data);
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
20
81
|
// Capability detection helpers
|
|
21
82
|
// ---------------------------------------------------------------------------
|
|
22
83
|
function wrapElicit(sdkContext) {
|
|
@@ -104,31 +165,11 @@ export function createToolHandler(def, services, notifiers) {
|
|
|
104
165
|
};
|
|
105
166
|
}
|
|
106
167
|
catch (error) {
|
|
107
|
-
|
|
168
|
+
ErrorHandler.handleError(error, {
|
|
108
169
|
operation: `tool:${def.name}`,
|
|
109
170
|
context: appContext,
|
|
110
171
|
});
|
|
111
|
-
|
|
112
|
-
? handled
|
|
113
|
-
: new McpError(JsonRpcErrorCode.InternalError, handled.message, {
|
|
114
|
-
originalError: handled.name,
|
|
115
|
-
});
|
|
116
|
-
// Surface error classification via _meta so programmatic clients can distinguish error types (auth, validation, not-found, etc.) without parsing the text message. Only propagate data from explicitly thrown McpError instances and ZodError (structured validation issues) — ErrorHandler enrichment contains internal context (stack traces, operation details) that shouldn't be client-visible.
|
|
117
|
-
const originalData = error instanceof McpError
|
|
118
|
-
? error.data
|
|
119
|
-
: error instanceof ZodError
|
|
120
|
-
? { issues: error.issues }
|
|
121
|
-
: undefined;
|
|
122
|
-
return {
|
|
123
|
-
isError: true,
|
|
124
|
-
content: [{ type: 'text', text: `Error: ${mcpError.message}` }],
|
|
125
|
-
_meta: {
|
|
126
|
-
error: {
|
|
127
|
-
code: mcpError.code,
|
|
128
|
-
...(originalData !== undefined && { data: originalData }),
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
172
|
+
return classifyAndBuildToolErrorResult(error);
|
|
132
173
|
}
|
|
133
174
|
};
|
|
134
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,QAAQ,EAAoC,MAAM,KAAK,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAEnF,OAAO,
|
|
1
|
+
{"version":3,"file":"toolHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,QAAQ,EAAoC,MAAM,KAAK,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAEnF,OAAO,EAAyB,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAgC3E,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,MAAM,wBAAwB,GAAG,CAAC,MAAe,EAAkB,EAAE,CAAC;IACpE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;CACxD,CAAC;AAEF,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,IAAyC;IACpE,MAAM,IAAI,GAAI,IAAI,EAAE,QAA2C,EAAE,IAAI,CAAC;IACtE,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS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MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEjD,gFAAgF;YAChF,IAAI,OAAuB,CAAC;YAC5B,IAAI,CAAC;gBACH,OAAO,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CACb,6BAA6B,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CACxG,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,iBAAiB,EAAE,eAAe;gBAClC,OAAO;aACR,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;gBAC9B,SAAS,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE;gBAC7B,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;YACH,OAAO,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Inlined
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* @fileoverview Inlined client-side scripts for the landing page. Two
|
|
3
|
+
* delegated handlers, both keyed by data attributes:
|
|
4
|
+
*
|
|
5
|
+
* - Copy-to-clipboard: any element carrying `[data-copy]` triggers a copy
|
|
6
|
+
* of the target's `textContent` (CSS selector via `[data-copy-target]`)
|
|
7
|
+
* or the literal `data-copy` value.
|
|
8
|
+
* - Tool filtering: chip clicks toggle a mutability filter, the search
|
|
9
|
+
* input filters by `data-name` + indexed `data-search` substring, and
|
|
10
|
+
* cards/groups update via `hidden`. No framework, no transitions,
|
|
11
|
+
* fully accessible (chips use `aria-pressed`).
|
|
12
|
+
*
|
|
13
|
+
* The whole bundle stays well under 2 KB so it ships inline alongside the
|
|
14
|
+
* page HTML.
|
|
6
15
|
*
|
|
7
16
|
* @module src/mcp-server/transports/http/landing-page/assets/copy-script
|
|
8
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-script.d.ts","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/copy-script.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copy-script.d.ts","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/copy-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,4BAA4B,CAAC;AAEtE,wBAAgB,gBAAgB,IAAI,QAAQ,CA0F3C"}
|
|
@@ -1,36 +1,110 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Inlined
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* @fileoverview Inlined client-side scripts for the landing page. Two
|
|
3
|
+
* delegated handlers, both keyed by data attributes:
|
|
4
|
+
*
|
|
5
|
+
* - Copy-to-clipboard: any element carrying `[data-copy]` triggers a copy
|
|
6
|
+
* of the target's `textContent` (CSS selector via `[data-copy-target]`)
|
|
7
|
+
* or the literal `data-copy` value.
|
|
8
|
+
* - Tool filtering: chip clicks toggle a mutability filter, the search
|
|
9
|
+
* input filters by `data-name` + indexed `data-search` substring, and
|
|
10
|
+
* cards/groups update via `hidden`. No framework, no transitions,
|
|
11
|
+
* fully accessible (chips use `aria-pressed`).
|
|
12
|
+
*
|
|
13
|
+
* The whole bundle stays well under 2 KB so it ships inline alongside the
|
|
14
|
+
* page HTML.
|
|
6
15
|
*
|
|
7
16
|
* @module src/mcp-server/transports/http/landing-page/assets/copy-script
|
|
8
17
|
*/
|
|
9
18
|
import { unsafeRaw } from '../../../../../utils/formatting/html.js';
|
|
10
19
|
export function renderCopyScript() {
|
|
11
20
|
const js = `
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
btn.
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
(function() {
|
|
22
|
+
// ---------- Copy to clipboard ----------
|
|
23
|
+
document.addEventListener('click', function(e) {
|
|
24
|
+
var btn = e.target.closest('[data-copy]');
|
|
25
|
+
if (!btn) return;
|
|
26
|
+
var selector = btn.getAttribute('data-copy-target');
|
|
27
|
+
var text = '';
|
|
28
|
+
if (selector) {
|
|
29
|
+
var node = document.querySelector(selector);
|
|
30
|
+
if (node) text = node.textContent || '';
|
|
31
|
+
} else {
|
|
32
|
+
text = btn.getAttribute('data-copy') || '';
|
|
33
|
+
}
|
|
34
|
+
if (!text || !navigator.clipboard) return;
|
|
35
|
+
navigator.clipboard.writeText(text).then(function() {
|
|
36
|
+
var prev = btn.textContent;
|
|
37
|
+
btn.setAttribute('data-copied', 'true');
|
|
38
|
+
btn.textContent = 'Copied';
|
|
39
|
+
setTimeout(function() {
|
|
40
|
+
btn.removeAttribute('data-copied');
|
|
41
|
+
btn.textContent = prev;
|
|
42
|
+
}, 1500);
|
|
43
|
+
});
|
|
32
44
|
});
|
|
33
|
-
|
|
45
|
+
|
|
46
|
+
// ---------- Tool filter + search ----------
|
|
47
|
+
var section = document.querySelector('[data-tools-section]');
|
|
48
|
+
if (!section) return;
|
|
49
|
+
var cards = Array.prototype.slice.call(section.querySelectorAll('[data-tool-card]'));
|
|
50
|
+
if (cards.length === 0) return;
|
|
51
|
+
var chips = Array.prototype.slice.call(section.querySelectorAll('[data-filter-mutability]'));
|
|
52
|
+
var searchInput = section.querySelector('[data-tool-search]');
|
|
53
|
+
var groups = Array.prototype.slice.call(section.querySelectorAll('[data-group]'));
|
|
54
|
+
var grids = Array.prototype.slice.call(section.querySelectorAll('[data-grid]'));
|
|
55
|
+
var emptyState = section.querySelector('.tools-empty');
|
|
56
|
+
|
|
57
|
+
var activeMutability = 'all';
|
|
58
|
+
var query = '';
|
|
59
|
+
|
|
60
|
+
function apply() {
|
|
61
|
+
var visibleCount = 0;
|
|
62
|
+
var perGroup = Object.create(null);
|
|
63
|
+
for (var i = 0; i < cards.length; i++) {
|
|
64
|
+
var card = cards[i];
|
|
65
|
+
var m = card.getAttribute('data-mutability') || '';
|
|
66
|
+
var search = card.getAttribute('data-search') || '';
|
|
67
|
+
var matchesMutability = activeMutability === 'all' || m === activeMutability;
|
|
68
|
+
var matchesSearch = query === '' || search.indexOf(query) !== -1;
|
|
69
|
+
var visible = matchesMutability && matchesSearch;
|
|
70
|
+
card.hidden = !visible;
|
|
71
|
+
if (visible) {
|
|
72
|
+
visibleCount++;
|
|
73
|
+
perGroup[m] = (perGroup[m] || 0) + 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Hide group headings + grids whose buckets are now empty.
|
|
77
|
+
for (var g = 0; g < groups.length; g++) {
|
|
78
|
+
var key = groups[g].getAttribute('data-group');
|
|
79
|
+
groups[g].hidden = !perGroup[key];
|
|
80
|
+
}
|
|
81
|
+
for (var k = 0; k < grids.length; k++) {
|
|
82
|
+
var gk = grids[k].getAttribute('data-grid');
|
|
83
|
+
grids[k].hidden = !perGroup[gk];
|
|
84
|
+
}
|
|
85
|
+
if (emptyState) emptyState.hidden = visibleCount > 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (var c = 0; c < chips.length; c++) {
|
|
89
|
+
chips[c].addEventListener('click', function(ev) {
|
|
90
|
+
var target = ev.currentTarget;
|
|
91
|
+
var value = target.getAttribute('data-filter-mutability') || 'all';
|
|
92
|
+
activeMutability = value;
|
|
93
|
+
for (var j = 0; j < chips.length; j++) {
|
|
94
|
+
var pressed = chips[j] === target;
|
|
95
|
+
chips[j].setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
|
96
|
+
}
|
|
97
|
+
apply();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (searchInput) {
|
|
102
|
+
searchInput.addEventListener('input', function(ev) {
|
|
103
|
+
query = (ev.currentTarget.value || '').trim().toLowerCase();
|
|
104
|
+
apply();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
})();`;
|
|
34
108
|
return unsafeRaw(`<script>${js}</script>`);
|
|
35
109
|
}
|
|
36
110
|
//# sourceMappingURL=copy-script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-script.js","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/copy-script.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copy-script.js","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/copy-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAiB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEtE,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuFP,CAAC;IACL,OAAO,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,4BAA4B,CAAC;AAKtE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/mcp-server/transports/http/landing-page/assets/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,4BAA4B,CAAC;AAKtE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAurCrD"}
|