@cyanheads/mcp-ts-core 0.11.2 → 0.11.4
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 +14 -10
- package/CLAUDE.md +14 -10
- package/README.md +3 -3
- package/changelog/0.11.x/0.11.3.md +49 -0
- package/changelog/0.11.x/0.11.4.md +67 -0
- package/dist/config/index.d.ts +0 -10
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -25
- package/dist/config/index.js.map +1 -1
- package/dist/config/logLevelAlias.d.ts +15 -0
- package/dist/config/logLevelAlias.d.ts.map +1 -0
- package/dist/config/logLevelAlias.js +30 -0
- package/dist/config/logLevelAlias.js.map +1 -0
- package/dist/core/context.d.ts +10 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +10 -1
- package/dist/core/context.js.map +1 -1
- package/dist/core/worker.js +1 -1
- package/dist/core/worker.js.map +1 -1
- package/dist/linter/rules/enrichment-rules.d.ts +3 -2
- package/dist/linter/rules/enrichment-rules.d.ts.map +1 -1
- package/dist/linter/rules/enrichment-rules.js +35 -7
- package/dist/linter/rules/enrichment-rules.js.map +1 -1
- package/dist/linter/rules/format-parity-rules.d.ts +8 -4
- package/dist/linter/rules/format-parity-rules.d.ts.map +1 -1
- package/dist/linter/rules/format-parity-rules.js +72 -20
- package/dist/linter/rules/format-parity-rules.js.map +1 -1
- package/dist/linter/rules/index.d.ts +1 -1
- package/dist/linter/rules/index.d.ts.map +1 -1
- package/dist/linter/rules/index.js +1 -1
- package/dist/linter/rules/index.js.map +1 -1
- package/dist/linter/rules/prompt-rules.d.ts.map +1 -1
- package/dist/linter/rules/prompt-rules.js +6 -3
- package/dist/linter/rules/prompt-rules.js.map +1 -1
- package/dist/linter/rules/resource-rules.d.ts.map +1 -1
- package/dist/linter/rules/resource-rules.js +11 -5
- package/dist/linter/rules/resource-rules.js.map +1 -1
- package/dist/linter/rules/schema-rules.d.ts +21 -2
- package/dist/linter/rules/schema-rules.d.ts.map +1 -1
- package/dist/linter/rules/schema-rules.js +110 -2
- package/dist/linter/rules/schema-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +11 -5
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +44 -10
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts +10 -10
- package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts.map +1 -1
- package/dist/services/mirror/sqlite/sqliteMirrorStore.js +29 -24
- package/dist/services/mirror/sqlite/sqliteMirrorStore.js.map +1 -1
- package/dist/storage/core/storageValidation.d.ts +4 -4
- package/dist/storage/core/storageValidation.d.ts.map +1 -1
- package/dist/storage/core/storageValidation.js +4 -20
- package/dist/storage/core/storageValidation.js.map +1 -1
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +57 -2
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/testing/index.d.ts +45 -13
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +29 -76
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/vitest.d.ts +1 -1
- package/dist/utils/formatting/diffFormatter.d.ts +5 -5
- package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/diffFormatter.js +1 -1
- package/dist/utils/formatting/diffFormatter.js.map +1 -1
- package/dist/utils/formatting/tableFormatter.d.ts +3 -3
- package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/tableFormatter.js +1 -1
- package/dist/utils/formatting/tableFormatter.js.map +1 -1
- package/dist/utils/formatting/treeFormatter.d.ts +3 -3
- package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/treeFormatter.js +1 -1
- package/dist/utils/formatting/treeFormatter.js.map +1 -1
- package/dist/utils/metrics/tokenCounter.d.ts +3 -3
- package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
- package/dist/utils/metrics/tokenCounter.js.map +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts +43 -15
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +163 -44
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/network/httpError.d.ts.map +1 -1
- package/dist/utils/network/httpError.js +1 -2
- package/dist/utils/network/httpError.js.map +1 -1
- package/dist/utils/network/responseBody.d.ts +27 -7
- package/dist/utils/network/responseBody.d.ts.map +1 -1
- package/dist/utils/network/responseBody.js +54 -13
- package/dist/utils/network/responseBody.js.map +1 -1
- package/dist/utils/network/retry.d.ts +2 -2
- package/dist/utils/network/retry.d.ts.map +1 -1
- package/dist/utils/overflow/outlineOnOverflow.d.ts +4 -3
- package/dist/utils/overflow/outlineOnOverflow.d.ts.map +1 -1
- package/dist/utils/overflow/outlineOnOverflow.js +27 -8
- package/dist/utils/overflow/outlineOnOverflow.js.map +1 -1
- package/dist/utils/pagination/pagination.d.ts +3 -3
- package/dist/utils/pagination/pagination.d.ts.map +1 -1
- package/dist/utils/pagination/pagination.js.map +1 -1
- package/dist/utils/parsing/csvParser.d.ts +2 -2
- package/dist/utils/parsing/csvParser.d.ts.map +1 -1
- package/dist/utils/parsing/csvParser.js +1 -1
- package/dist/utils/parsing/csvParser.js.map +1 -1
- package/dist/utils/parsing/dateParser.d.ts +11 -7
- package/dist/utils/parsing/dateParser.d.ts.map +1 -1
- package/dist/utils/parsing/dateParser.js +8 -4
- package/dist/utils/parsing/dateParser.js.map +1 -1
- package/dist/utils/parsing/frontmatterParser.d.ts +5 -4
- package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
- package/dist/utils/parsing/frontmatterParser.js +5 -4
- package/dist/utils/parsing/frontmatterParser.js.map +1 -1
- package/dist/utils/parsing/htmlExtractor.d.ts +5 -4
- package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
- package/dist/utils/parsing/htmlExtractor.js +4 -3
- package/dist/utils/parsing/htmlExtractor.js.map +1 -1
- package/dist/utils/parsing/inputBudget.d.ts +18 -11
- package/dist/utils/parsing/inputBudget.d.ts.map +1 -1
- package/dist/utils/parsing/inputBudget.js +20 -17
- package/dist/utils/parsing/inputBudget.js.map +1 -1
- package/dist/utils/parsing/jsonParser.d.ts +5 -4
- package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
- package/dist/utils/parsing/jsonParser.js +5 -4
- package/dist/utils/parsing/jsonParser.js.map +1 -1
- package/dist/utils/parsing/pdfParser.d.ts +38 -24
- package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
- package/dist/utils/parsing/pdfParser.js +42 -31
- package/dist/utils/parsing/pdfParser.js.map +1 -1
- package/dist/utils/parsing/xmlParser.d.ts +3 -3
- package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
- package/dist/utils/parsing/xmlParser.js +3 -6
- package/dist/utils/parsing/xmlParser.js.map +1 -1
- package/dist/utils/parsing/yamlParser.d.ts +3 -3
- package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
- package/dist/utils/parsing/yamlParser.js +3 -3
- package/dist/utils/parsing/yamlParser.js.map +1 -1
- package/dist/utils/security/rateLimiter.d.ts +2 -2
- package/dist/utils/security/rateLimiter.d.ts.map +1 -1
- package/dist/utils/security/rateLimiter.js +1 -1
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +3 -3
- package/dist/utils/telemetry/trace.d.ts.map +1 -1
- package/dist/utils/telemetry/trace.js.map +1 -1
- package/package.json +1 -1
- package/scripts/tree.ts +9 -3
- package/skills/add-test/SKILL.md +2 -2
- package/skills/api-auth/SKILL.md +5 -5
- package/skills/api-context/SKILL.md +14 -12
- package/skills/api-linter/SKILL.md +59 -5
- package/skills/api-testing/SKILL.md +31 -10
- package/skills/api-utils/SKILL.md +4 -2
- package/skills/api-utils/references/parsing.md +3 -2
- package/skills/setup/SKILL.md +6 -3
- package/skills/techniques/SKILL.md +1 -1
- package/skills/techniques/references/outline-on-overflow.md +3 -1
- package/templates/AGENTS.md +1 -1
- package/templates/CLAUDE.md +1 -1
- package/templates/Dockerfile +7 -2
- package/templates/_tsconfig.build.json +5 -0
- package/templates/_tsconfig.json +4 -2
- package/templates/package.json +1 -0
- package/templates/tests/prompts/echo.prompt.test.ts +4 -3
- package/templates/tests/resources/echo.resource.test.ts +11 -3
- package/templates/tests/smoke/definitions.smoke.test.ts +8 -4
- package/templates/tests/tools/echo.tool.test.ts +23 -4
|
@@ -13,23 +13,27 @@ import { echoTool } from '@/mcp-server/tools/definitions/echo.tool.js';
|
|
|
13
13
|
|
|
14
14
|
describe('scaffold definition smoke test', () => {
|
|
15
15
|
it('executes the shipped tool, resource, and prompt definitions', async () => {
|
|
16
|
-
|
|
16
|
+
// `echoTool` declares an error contract, so its handler wants a context
|
|
17
|
+
// typed against it — passing `errors` narrows what `createMockContext` returns.
|
|
18
|
+
const ctx = createMockContext({ errors: echoTool.errors });
|
|
17
19
|
const toolResult = await echoTool.handler(
|
|
18
20
|
echoTool.input.parse({ message: 'smoke' }),
|
|
19
21
|
ctx,
|
|
20
22
|
);
|
|
21
23
|
const resourceResult = await echoResource.handler(
|
|
22
|
-
echoResource.params
|
|
24
|
+
echoResource.params!.parse({ message: 'smoke' }),
|
|
23
25
|
ctx,
|
|
24
26
|
);
|
|
25
|
-
const promptMessages = echoPrompt.generate(
|
|
27
|
+
const promptMessages = await echoPrompt.generate(
|
|
28
|
+
echoPrompt.args!.parse({ message: 'smoke' }),
|
|
29
|
+
);
|
|
26
30
|
const appResult = await echoAppTool.handler(
|
|
27
31
|
echoAppTool.input.parse({ message: 'smoke app' }),
|
|
28
32
|
ctx,
|
|
29
33
|
);
|
|
30
34
|
const appContent = echoAppTool.format?.(appResult);
|
|
31
35
|
const appHtml = await echoAppUiResource.handler(
|
|
32
|
-
echoAppUiResource.params
|
|
36
|
+
echoAppUiResource.params!.parse({}),
|
|
33
37
|
createMockContext({ uri: new URL('ui://template-echo-app/app.html') }),
|
|
34
38
|
);
|
|
35
39
|
|
|
@@ -3,22 +3,41 @@
|
|
|
3
3
|
* @module tests/tools/echo.tool.test
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { HandlerContext, ReasonOf } from '@cyanheads/mcp-ts-core';
|
|
6
7
|
import { describe, expect, it } from 'vitest';
|
|
7
8
|
import { createMockContext } from '@cyanheads/mcp-ts-core/testing';
|
|
8
9
|
import { mcpTest } from '@cyanheads/mcp-ts-core/testing/vitest';
|
|
9
10
|
import { echoTool } from '@/mcp-server/tools/definitions/echo.tool.js';
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* A tool that declares `errors[]` types its handler's `ctx` against that
|
|
14
|
+
* contract, so tests hand it a context built the same way — `createMockContext`
|
|
15
|
+
* narrows its return type from the `errors` it is given. Drop this if your tool
|
|
16
|
+
* declares no error contract; a bare `createMockContext()` is enough then.
|
|
17
|
+
*/
|
|
18
|
+
type EchoContext = HandlerContext<ReasonOf<typeof echoTool.errors>>;
|
|
19
|
+
|
|
20
|
+
const echoContext = () => createMockContext({ errors: echoTool.errors });
|
|
21
|
+
|
|
11
22
|
// ---------------------------------------------------------------------------
|
|
12
23
|
// Fixture-based tests (mcpTest) — fresh ctx per test, no manual construction
|
|
13
24
|
// ---------------------------------------------------------------------------
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
/** Function form, not a bare value — every test gets its own context. */
|
|
27
|
+
const echoTest = mcpTest.extend<{ ctx: EchoContext }>({
|
|
28
|
+
// biome-ignore lint/correctness/noEmptyPattern: vitest's fixture API requires a destructuring pattern as the first parameter
|
|
29
|
+
ctx: async ({}, use) => {
|
|
30
|
+
await use(echoContext());
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
echoTest('echoTool: echoes the message back (fixture)', async ({ ctx }) => {
|
|
16
35
|
const input = echoTool.input.parse({ message: 'hello world' });
|
|
17
36
|
const result = await echoTool.handler(input, ctx);
|
|
18
37
|
expect(result).toEqual({ message: 'hello world' });
|
|
19
38
|
});
|
|
20
39
|
|
|
21
|
-
|
|
40
|
+
echoTest('echoTool: output conforms to declared schema (fixture)', async ({ ctx }) => {
|
|
22
41
|
const input = echoTool.input.parse({ message: 'hello world' });
|
|
23
42
|
const result = await echoTool.handler(input, ctx);
|
|
24
43
|
expect(result).toEqual(expect.schemaMatching(echoTool.output));
|
|
@@ -30,14 +49,14 @@ mcpTest('echoTool: output conforms to declared schema (fixture)', async ({ ctx }
|
|
|
30
49
|
|
|
31
50
|
describe('echoTool', () => {
|
|
32
51
|
it('echoes the message back', async () => {
|
|
33
|
-
const ctx =
|
|
52
|
+
const ctx = echoContext();
|
|
34
53
|
const input = echoTool.input.parse({ message: 'hello world' });
|
|
35
54
|
const result = await echoTool.handler(input, ctx);
|
|
36
55
|
expect(result).toEqual({ message: 'hello world' });
|
|
37
56
|
});
|
|
38
57
|
|
|
39
58
|
it('output conforms to the declared output schema', async () => {
|
|
40
|
-
const ctx =
|
|
59
|
+
const ctx = echoContext();
|
|
41
60
|
const input = echoTool.input.parse({ message: 'hello world' });
|
|
42
61
|
const result = await echoTool.handler(input, ctx);
|
|
43
62
|
expect(result).toEqual(expect.schemaMatching(echoTool.output));
|