@todoist/mcp-core 0.0.1 → 1.1.0

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 (79) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +238 -32
  3. package/dist/annotations.d.ts +15 -0
  4. package/dist/annotations.d.ts.map +1 -0
  5. package/dist/annotations.js +23 -0
  6. package/dist/annotations.js.map +1 -0
  7. package/dist/app-meta.d.ts +8 -0
  8. package/dist/app-meta.d.ts.map +1 -0
  9. package/dist/app-meta.js +21 -0
  10. package/dist/app-meta.js.map +1 -0
  11. package/dist/host/challenge.d.ts +18 -0
  12. package/dist/host/challenge.d.ts.map +1 -0
  13. package/dist/host/challenge.js +10 -0
  14. package/dist/host/challenge.js.map +1 -0
  15. package/dist/host/index.d.ts +6 -0
  16. package/dist/host/index.d.ts.map +1 -0
  17. package/dist/host/index.js +5 -0
  18. package/dist/host/index.js.map +1 -0
  19. package/dist/host/server-contract.d.ts +31 -0
  20. package/dist/host/server-contract.d.ts.map +1 -0
  21. package/dist/host/server-contract.js +2 -0
  22. package/dist/host/server-contract.js.map +1 -0
  23. package/dist/host/transient.d.ts +9 -0
  24. package/dist/host/transient.d.ts.map +1 -0
  25. package/dist/host/transient.js +50 -0
  26. package/dist/host/transient.js.map +1 -0
  27. package/dist/host/validate-bearer-token.d.ts +43 -0
  28. package/dist/host/validate-bearer-token.d.ts.map +1 -0
  29. package/dist/host/validate-bearer-token.js +46 -0
  30. package/dist/host/validate-bearer-token.js.map +1 -0
  31. package/dist/host/verdict-cache.d.ts +21 -0
  32. package/dist/host/verdict-cache.d.ts.map +1 -0
  33. package/dist/host/verdict-cache.js +38 -0
  34. package/dist/host/verdict-cache.js.map +1 -0
  35. package/dist/index.d.ts +8 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +7 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/register-tool.d.ts +41 -0
  40. package/dist/register-tool.d.ts.map +1 -0
  41. package/dist/register-tool.js +44 -0
  42. package/dist/register-tool.js.map +1 -0
  43. package/dist/sanitize.d.ts +18 -0
  44. package/dist/sanitize.d.ts.map +1 -0
  45. package/dist/sanitize.js +44 -0
  46. package/dist/sanitize.js.map +1 -0
  47. package/dist/testing/advertised-schemas.d.ts +25 -0
  48. package/dist/testing/advertised-schemas.d.ts.map +1 -0
  49. package/dist/testing/advertised-schemas.js +68 -0
  50. package/dist/testing/advertised-schemas.js.map +1 -0
  51. package/dist/testing/index.d.ts +5 -0
  52. package/dist/testing/index.d.ts.map +1 -0
  53. package/dist/testing/index.js +5 -0
  54. package/dist/testing/index.js.map +1 -0
  55. package/dist/testing/nullable-output.d.ts +15 -0
  56. package/dist/testing/nullable-output.d.ts.map +1 -0
  57. package/dist/testing/nullable-output.js +57 -0
  58. package/dist/testing/nullable-output.js.map +1 -0
  59. package/dist/testing/token-footprint.d.ts +45 -0
  60. package/dist/testing/token-footprint.d.ts.map +1 -0
  61. package/dist/testing/token-footprint.js +57 -0
  62. package/dist/testing/token-footprint.js.map +1 -0
  63. package/dist/testing/tool-annotations.d.ts +24 -0
  64. package/dist/testing/tool-annotations.d.ts.map +1 -0
  65. package/dist/testing/tool-annotations.js +32 -0
  66. package/dist/testing/tool-annotations.js.map +1 -0
  67. package/dist/tool-output.d.ts +21 -0
  68. package/dist/tool-output.d.ts.map +1 -0
  69. package/dist/tool-output.js +32 -0
  70. package/dist/tool-output.js.map +1 -0
  71. package/dist/tool-schemas.d.ts +15 -0
  72. package/dist/tool-schemas.d.ts.map +1 -0
  73. package/dist/tool-schemas.js +42 -0
  74. package/dist/tool-schemas.js.map +1 -0
  75. package/dist/tool.d.ts +68 -0
  76. package/dist/tool.d.ts.map +1 -0
  77. package/dist/tool.js +2 -0
  78. package/dist/tool.js.map +1 -0
  79. package/package.json +76 -8
@@ -0,0 +1,57 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { readAdvertisedSurface } from './advertised-schemas.js';
3
+ /**
4
+ * Measures the fixed token cost of a server from what it advertises to a client, so nothing
5
+ * here restates how registration titles a tool or compiles its schemas. Closes the server.
6
+ */
7
+ export async function measureTokenFootprint(server, countTokens) {
8
+ const { tools, instructions } = await readAdvertisedSurface(server);
9
+ const costs = tools
10
+ .map((tool) => ({
11
+ name: tool.name,
12
+ total: countTokens(JSON.stringify(tool)),
13
+ description: countTokens(tool.description ?? ''),
14
+ inputSchema: countTokens(JSON.stringify(tool.inputSchema)),
15
+ outputSchema: tool.outputSchema ? countTokens(JSON.stringify(tool.outputSchema)) : 0,
16
+ }))
17
+ .sort((a, b) => b.total - a.total);
18
+ const toolsList = countTokens(JSON.stringify(tools));
19
+ const instructionsCost = instructions ? countTokens(instructions) : 0;
20
+ return {
21
+ tools: costs,
22
+ toolsList,
23
+ instructions: instructionsCost,
24
+ combined: toolsList + instructionsCost,
25
+ };
26
+ }
27
+ function formatFootprint(footprint, budget) {
28
+ return [
29
+ '',
30
+ '=== MCP token footprint ===',
31
+ `tools advertised: ${footprint.tools.length}`,
32
+ `instructions: ${footprint.instructions} tokens`,
33
+ `tools/list payload: ${footprint.toolsList} tokens`,
34
+ `combined fixed cost: ${footprint.combined} tokens`,
35
+ `budget: ${budget} tokens`,
36
+ '',
37
+ 'Per tool (total / description / inputSchema / outputSchema):',
38
+ ...footprint.tools.map((tool) => ` ${String(tool.total).padStart(5)} ${String(tool.description).padStart(4)} ${String(tool.inputSchema).padStart(5)} ${String(tool.outputSchema).padStart(5)} ${tool.name}`),
39
+ ].join('\n');
40
+ }
41
+ /**
42
+ * Tests that the `tools/list` payload plus the `instructions` block stay under `budget`, and
43
+ * prints the cost per tool so a reviewer can see where it went. Fails as well if either half
44
+ * goes missing: a lost block would otherwise read as a saving.
45
+ */
46
+ export function describeTokenFootprint({ createServer, countTokens, budget, }) {
47
+ describe('token footprint', () => {
48
+ it('keeps the tools/list payload and instructions within the budget', async () => {
49
+ const footprint = await measureTokenFootprint(createServer(), countTokens);
50
+ expect(footprint.tools.length, 'tools advertised').toBeGreaterThan(0);
51
+ expect(footprint.instructions, 'instructions advertised').toBeGreaterThan(0);
52
+ console.log(formatFootprint(footprint, budget));
53
+ expect(footprint.combined).toBeLessThan(budget);
54
+ });
55
+ });
56
+ }
57
+ //# sourceMappingURL=token-footprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-footprint.js","sourceRoot":"","sources":["../../src/testing/token-footprint.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,24 @@
1
+ import type { McpServer } from '@modelcontextprotocol/server';
2
+ import type { RequiredToolAnnotations } from '../tool.js';
3
+ /**
4
+ * The annotations one tool should advertise: its own hints, as the tool declares them, plus the
5
+ * full advertised `title`, prefix included (`'Todoist: Add Tasks'`). `openWorldHint` defaults to
6
+ * false, as registration does.
7
+ */
8
+ export type ExpectedToolAnnotations = RequiredToolAnnotations & {
9
+ title: string;
10
+ };
11
+ export type ToolAnnotationsConfig = {
12
+ /** Builds a fresh server with every tool registered. */
13
+ createServer: () => McpServer;
14
+ /** Every tool the server should advertise, by name. */
15
+ expected: Readonly<Record<string, ExpectedToolAnnotations>>;
16
+ };
17
+ /**
18
+ * Pins every tool's annotations as a client receives them on `tools/list`, defaults included.
19
+ * Clients decide from these whether a call needs the user's confirmation, so a hint that changes
20
+ * should change on purpose. Fails as well on a tool advertised without an expectation, or
21
+ * expected and not advertised.
22
+ */
23
+ export declare function describeToolAnnotations({ createServer, expected }: ToolAnnotationsConfig): void;
24
+ //# sourceMappingURL=tool-annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-annotations.d.ts","sourceRoot":"","sources":["../../src/testing/tool-annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,8BAA8B,CAAA;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAGzD;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,uBAAuB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjF,MAAM,MAAM,qBAAqB,GAAG;IAChC,wDAAwD;IACxD,YAAY,EAAE,MAAM,SAAS,CAAA;IAC7B,uDAAuD;IACvD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAA;CAC9D,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,GAAG,IAAI,CAyB/F"}
@@ -0,0 +1,32 @@
1
+ import { beforeAll, describe, expect, it } from 'vitest';
2
+ import { listAdvertisedTools } from './advertised-schemas.js';
3
+ /**
4
+ * Pins every tool's annotations as a client receives them on `tools/list`, defaults included.
5
+ * Clients decide from these whether a call needs the user's confirmation, so a hint that changes
6
+ * should change on purpose. Fails as well on a tool advertised without an expectation, or
7
+ * expected and not advertised.
8
+ */
9
+ export function describeToolAnnotations({ createServer, expected }) {
10
+ describe('tool annotations', () => {
11
+ let advertised;
12
+ beforeAll(async () => {
13
+ const tools = await listAdvertisedTools(createServer());
14
+ advertised = new Map(tools.map((tool) => [tool.name, tool]));
15
+ });
16
+ it('pins every advertised tool, and only those', () => {
17
+ expect([...advertised.keys()].sort()).toEqual(Object.keys(expected).sort());
18
+ });
19
+ describe.each(Object.entries(expected))('%s', (name, expectation) => {
20
+ it('advertises the expected annotations', () => {
21
+ expect(advertised.get(name)?.annotations).toEqual({
22
+ title: expectation.title,
23
+ readOnlyHint: expectation.readOnlyHint,
24
+ destructiveHint: expectation.destructiveHint,
25
+ idempotentHint: expectation.idempotentHint,
26
+ openWorldHint: expectation.openWorldHint ?? false,
27
+ });
28
+ });
29
+ });
30
+ });
31
+ }
32
+ //# sourceMappingURL=tool-annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-annotations.js","sourceRoot":"","sources":["../../src/testing/tool-annotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAgB7D;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAyB;IACrF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC9B,IAAI,UAA6B,CAAA;QAEjC,SAAS,CAAC,KAAK,IAAI,EAAE;YACjB,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,YAAY,EAAE,CAAC,CAAA;YACvD,UAAU,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAChE,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YAClD,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;QAC/E,CAAC,CAAC,CAAA;QAEF,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;YAChE,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;gBAC3C,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;oBAC9C,KAAK,EAAE,WAAW,CAAC,KAAK;oBACxB,YAAY,EAAE,WAAW,CAAC,YAAY;oBACtC,eAAe,EAAE,WAAW,CAAC,eAAe;oBAC5C,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,KAAK;iBACpD,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { CallToolResult } from '@modelcontextprotocol/server';
2
+ import { type RemoveNullFieldsOptions } from './sanitize.js';
3
+ import type { ToolResult } from './tool.js';
4
+ export type ToolOutputOptions = RemoveNullFieldsOptions & {
5
+ /**
6
+ * Also send `structuredContent` as a JSON text block, for clients that ignore
7
+ * `structuredContent`. Defaults to true.
8
+ */
9
+ structuredContentAsText?: boolean;
10
+ };
11
+ /**
12
+ * Shapes a tool's result into an MCP `CallToolResult`.
13
+ *
14
+ * Content order is fixed: the tool's own content items, then the structured payload as JSON text,
15
+ * then the prose summary. A client that surfaces only a text `content[0]` (the OpenAI Responses
16
+ * API drops `structuredContent`) then gets the payload rather than the summary.
17
+ */
18
+ export declare function getToolOutput({ textContent, structuredContent, contentItems }: ToolResult, { structuredContentAsText, ...sanitizeOptions }?: ToolOutputOptions): CallToolResult;
19
+ /** A tool error the model can read and act on. */
20
+ export declare function getErrorOutput(message: string): CallToolResult;
21
+ //# sourceMappingURL=tool-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-output.d.ts","sourceRoot":"","sources":["../src/tool-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GAAG;IACtD;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CACzB,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,EAAE,UAAU,EAC5D,EAAE,uBAA8B,EAAE,GAAG,eAAe,EAAE,GAAE,iBAAsB,GAC/E,cAAc,CAiBhB;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAK9D"}
@@ -0,0 +1,32 @@
1
+ import { removeNullFields } from './sanitize.js';
2
+ /**
3
+ * Shapes a tool's result into an MCP `CallToolResult`.
4
+ *
5
+ * Content order is fixed: the tool's own content items, then the structured payload as JSON text,
6
+ * then the prose summary. A client that surfaces only a text `content[0]` (the OpenAI Responses
7
+ * API drops `structuredContent`) then gets the payload rather than the summary.
8
+ */
9
+ export function getToolOutput({ textContent, structuredContent, contentItems }, { structuredContentAsText = true, ...sanitizeOptions } = {}) {
10
+ const sanitized = structuredContent
11
+ ? removeNullFields(structuredContent, sanitizeOptions)
12
+ : undefined;
13
+ const content = [...(contentItems ?? [])];
14
+ if (structuredContentAsText && sanitized !== undefined) {
15
+ content.push({ type: 'text', text: JSON.stringify(sanitized) });
16
+ }
17
+ if (textContent) {
18
+ content.push({ type: 'text', text: textContent });
19
+ }
20
+ return {
21
+ content,
22
+ ...(sanitized === undefined ? {} : { structuredContent: sanitized }),
23
+ };
24
+ }
25
+ /** A tool error the model can read and act on. */
26
+ export function getErrorOutput(message) {
27
+ return {
28
+ content: [{ type: 'text', text: message }],
29
+ isError: true,
30
+ };
31
+ }
32
+ //# sourceMappingURL=tool-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-output.js","sourceRoot":"","sources":["../src/tool-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,eAAe,CAAA;AAW9E;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CACzB,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAc,EAC5D,EAAE,uBAAuB,GAAG,IAAI,EAAE,GAAG,eAAe,EAAE,GAAsB,EAAE;IAE9E,MAAM,SAAS,GAAG,iBAAiB;QAC/B,CAAC,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,eAAe,CAAC;QACtD,CAAC,CAAC,SAAS,CAAA;IAEf,MAAM,OAAO,GAAmB,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAA;IACzD,IAAI,uBAAuB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;IACnE,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAA;IACrD,CAAC;IAED,OAAO;QACH,OAAO;QACP,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC;KACvE,CAAA;AACL,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,cAAc,CAAC,OAAe;IAC1C,OAAO;QACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI;KAChB,CAAA;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { StandardSchemaWithJSON } from '@modelcontextprotocol/server';
2
+ import type { ToolSchemaSource } from './tool.js';
3
+ type ToolSchema = StandardSchemaWithJSON<Record<string, unknown>, Record<string, unknown>>;
4
+ export type ToolSchemas = {
5
+ input: ToolSchema;
6
+ /** Absent when the tool declares no `outputSchema`. */
7
+ output?: ToolSchema;
8
+ };
9
+ /**
10
+ * The input and output schemas to register a tool with, as Standard Schemas carrying their JSON
11
+ * form. Built once per tool object and reused by every server that registers it.
12
+ */
13
+ export declare function getToolSchemas(tool: ToolSchemaSource): ToolSchemas;
14
+ export {};
15
+ //# sourceMappingURL=tool-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schemas.d.ts","sourceRoot":"","sources":["../src/tool-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD,KAAK,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1F,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,UAAU,CAAA;IACjB,uDAAuD;IACvD,MAAM,CAAC,EAAE,UAAU,CAAA;CACtB,CAAA;AA+BD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,CAclE"}
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+ /** Tool schemas are static, so their JSON form is compiled once per process, not per server. */
3
+ const TOOL_SCHEMAS = new WeakMap();
4
+ /**
5
+ * Wraps a Zod schema so the conversion the SDK asks for on every `tools/list` (JSON Schema
6
+ * 2020-12, no library options) returns a JSON Schema compiled once. Any other conversion is
7
+ * delegated to Zod unchanged.
8
+ */
9
+ function withCachedJsonSchema(schema, io) {
10
+ const jsonSchema = z.toJSONSchema(schema, { target: 'draft-2020-12', io });
11
+ const standard = schema['~standard'];
12
+ return {
13
+ '~standard': {
14
+ ...standard,
15
+ jsonSchema: {
16
+ ...standard.jsonSchema,
17
+ [io]: (options) => options.target === 'draft-2020-12' && options.libraryOptions === undefined
18
+ ? jsonSchema
19
+ : standard.jsonSchema[io](options),
20
+ },
21
+ },
22
+ };
23
+ }
24
+ /**
25
+ * The input and output schemas to register a tool with, as Standard Schemas carrying their JSON
26
+ * form. Built once per tool object and reused by every server that registers it.
27
+ */
28
+ export function getToolSchemas(tool) {
29
+ const cached = TOOL_SCHEMAS.get(tool);
30
+ if (cached) {
31
+ return cached;
32
+ }
33
+ const schemas = {
34
+ input: withCachedJsonSchema(z.object(tool.parameters), 'input'),
35
+ ...(tool.outputSchema
36
+ ? { output: withCachedJsonSchema(z.object(tool.outputSchema), 'output') }
37
+ : {}),
38
+ };
39
+ TOOL_SCHEMAS.set(tool, schemas);
40
+ return schemas;
41
+ }
42
+ //# sourceMappingURL=tool-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["../src/tool-schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,gGAAgG;AAChG,MAAM,YAAY,GAAG,IAAI,OAAO,EAAiC,CAAA;AAEjE;;;;GAIG;AACH,SAAS,oBAAoB,CACzB,MAAkC,EAClC,EAAsB;IAEtB,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAA;IAC1E,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;IAEpC,OAAO;QACH,WAAW,EAAE;YACT,GAAG,QAAQ;YACX,UAAU,EAAE;gBACR,GAAG,QAAQ,CAAC,UAAU;gBACtB,CAAC,EAAE,CAAC,EAAE,CAAC,OAAwD,EAAE,EAAE,CAC/D,OAAO,CAAC,MAAM,KAAK,eAAe,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;oBACtE,CAAC,CAAC,UAAU;oBACZ,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;aAC7C;SACJ;KACU,CAAA;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAsB;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACrC,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,MAAM,OAAO,GAAgB;QACzB,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAC/D,GAAG,CAAC,IAAI,CAAC,YAAY;YACjB,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,EAAE;YACzE,CAAC,CAAC,EAAE,CAAC;KACZ,CAAA;IACD,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,OAAO,CAAA;AAClB,CAAC"}
package/dist/tool.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import type { ContentBlock, ToolAnnotations } from '@modelcontextprotocol/server';
2
+ import type { z } from 'zod';
3
+ /**
4
+ * The three hints every tool must state. The MCP defaults (`readOnlyHint: false`,
5
+ * `destructiveHint: true`, `idempotentHint: false`) describe the riskiest tool possible,
6
+ * so a tool that omits one is either misdescribed or frightens a client for nothing.
7
+ */
8
+ export type RequiredToolAnnotations = ToolAnnotations & {
9
+ readOnlyHint: boolean;
10
+ destructiveHint: boolean;
11
+ idempotentHint: boolean;
12
+ };
13
+ /** What a tool's `execute` returns, before it is shaped into an MCP `CallToolResult`. */
14
+ export type ToolResult<Output extends z.ZodRawShape = z.ZodRawShape> = {
15
+ /** Prose for the model, sent as the last content block. */
16
+ textContent?: string;
17
+ /** The payload `outputSchema` describes. Nulls and empty objects are stripped before it is sent. */
18
+ structuredContent?: z.infer<z.ZodObject<Output>>;
19
+ /** Blocks the tool authors itself, such as images or embedded resources. Sent first. */
20
+ contentItems?: ContentBlock[];
21
+ };
22
+ export type ExecuteResult<Output extends z.ZodRawShape = z.ZodRawShape> = Promise<ToolResult<Output>>;
23
+ /**
24
+ * A tool that can be registered on an MCP server or called directly by another
25
+ * conversational AI integration.
26
+ *
27
+ * `Context` is whatever the server hands each call: an API client, or an object carrying
28
+ * one along with an abort signal and a progress reporter.
29
+ */
30
+ export type McpTool<Params extends z.ZodRawShape, Output extends z.ZodRawShape = Record<string, never>, Context = unknown> = {
31
+ /** Kebab-case. Also the source of the default title ("find-tasks" gives "Find Tasks"). */
32
+ name: string;
33
+ /** What the tool does and how to call it. This is what the model reads. */
34
+ description: string;
35
+ /** The argument schema as a Zod raw shape, not a `z.object`. */
36
+ parameters: Params;
37
+ /**
38
+ * The `structuredContent` schema as a Zod raw shape. Never use `.nullable()`: nulls are
39
+ * stripped before the SDK validates the result, so a nullable field promises a value the
40
+ * tool cannot send. Declare it `.optional()` and leave the key out instead.
41
+ */
42
+ outputSchema?: Output;
43
+ annotations: RequiredToolAnnotations;
44
+ /** Sent with the tool listing, e.g. the MCP Apps `ui` resource. */
45
+ _meta?: Record<string, unknown>;
46
+ execute: (args: z.infer<z.ZodObject<Params>>, context: Context) => ExecuteResult<Output>;
47
+ };
48
+ /**
49
+ * A tool of any parameter and output shape.
50
+ *
51
+ * `McpTool` is generic over its schemas, and `execute` is contravariant in its argument, so no
52
+ * single instantiation of it accepts every tool. Declaring the argument as `never` does: `never`
53
+ * is assignable to any parameter type, so a tool taking concrete args satisfies this while a
54
+ * caller cannot invoke `execute` without narrowing back to the real tool type first.
55
+ *
56
+ * Use it for collections that hold tools of mixed shapes. Each tool keeps its precise type
57
+ * through its own `satisfies McpTool<...>`.
58
+ */
59
+ export type AnyMcpTool<Context = unknown> = Omit<McpTool<z.ZodRawShape, z.ZodRawShape, Context>, 'execute'> & {
60
+ execute: (args: never, context: Context) => ExecuteResult<z.ZodRawShape>;
61
+ };
62
+ /** The parts of a tool its schemas come from. Wide enough for tools not built on `McpTool`. */
63
+ export type ToolSchemaSource = {
64
+ name: string;
65
+ parameters: z.ZodRawShape;
66
+ outputSchema?: z.ZodRawShape;
67
+ };
68
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACjF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG;IACpD,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,yFAAyF;AACzF,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI;IACnE,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oGAAoG;IACpG,iBAAiB,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;IAChD,wFAAwF;IACxF,YAAY,CAAC,EAAE,YAAY,EAAE,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,OAAO,CAC7E,UAAU,CAAC,MAAM,CAAC,CACrB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,CACf,MAAM,SAAS,CAAC,CAAC,WAAW,EAC5B,MAAM,SAAS,CAAC,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACpD,OAAO,GAAG,OAAO,IACjB;IACA,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,uBAAuB,CAAA;IACpC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,CAAA;CAC3F,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,CAC5C,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,EAC9C,SAAS,CACZ,GAAG;IACA,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;CAC3E,CAAA;AAED,+FAA+F;AAC/F,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,CAAC,CAAC,WAAW,CAAA;IACzB,YAAY,CAAC,EAAE,CAAC,CAAC,WAAW,CAAA;CAC/B,CAAA"}
package/dist/tool.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,10 +1,78 @@
1
1
  {
2
- "name": "@todoist/mcp-core",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @todoist/mcp-core",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
2
+ "name": "@todoist/mcp-core",
3
+ "version": "1.1.0",
4
+ "description": "Shared core for the Doist MCP servers",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./host": {
14
+ "types": "./dist/host/index.d.ts",
15
+ "import": "./dist/host/index.js"
16
+ },
17
+ "./testing": {
18
+ "types": "./dist/testing/index.d.ts",
19
+ "import": "./dist/testing/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "dev": "tsc -p tsconfig.build.json --watch",
25
+ "type-check": "tsc --noEmit && tsc --noEmit -p .agents/scripts",
26
+ "check": "oxlint src .agents/scripts && oxfmt --check",
27
+ "fix": "oxlint src .agents/scripts --fix && oxfmt",
28
+ "test": "vitest run --passWithNoTests",
29
+ "test:watch": "vitest",
30
+ "verify": "node .agents/scripts/verify.ts",
31
+ "review:worktree": "node .agents/scripts/review-worktree.ts",
32
+ "prepublishOnly": "npm run build && npm test",
33
+ "prepare": "lefthook install --reset-hooks-path"
34
+ },
35
+ "keywords": [
36
+ "mcp",
37
+ "model-context-protocol",
38
+ "doist"
39
+ ],
40
+ "author": "Doist",
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/todoist/mcp-core.git"
45
+ },
46
+ "homepage": "https://github.com/todoist/mcp-core#readme",
47
+ "bugs": {
48
+ "url": "https://github.com/todoist/mcp-core/issues"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "provenance": true
53
+ },
54
+ "engines": {
55
+ "node": ">=24",
56
+ "npm": ">=11"
57
+ },
58
+ "files": [
59
+ "dist"
60
+ ],
61
+ "devDependencies": {
62
+ "@modelcontextprotocol/client": "2.4.0",
63
+ "@modelcontextprotocol/server": "2.4.0",
64
+ "@types/node": "25.9.9",
65
+ "conventional-changelog-conventionalcommits": "9.3.1",
66
+ "lefthook": "2.2.2",
67
+ "oxfmt": "0.75.0",
68
+ "oxlint": "1.90.0",
69
+ "semantic-release": "25.0.9",
70
+ "typescript": "7.0.2",
71
+ "vitest": "5.0.5",
72
+ "zod": "4.6.7"
73
+ },
74
+ "peerDependencies": {
75
+ "@modelcontextprotocol/server": "^2.2.0",
76
+ "zod": "^4.3.0"
77
+ }
10
78
  }