diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a0119b..5374092 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: # This job can push tags and publish, so it restores nothing from the shared # cache, as setup-node advises for privileged workflows. package-manager-cache: false - scope: '@doist' + scope: '@todoist' registry-url: 'https://registry.npmjs.org/' - name: Install dependencies diff --git a/AGENTS.md b/AGENTS.md index 579b8e5..0244b0d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # mcp-core -Shared core for the Doist MCP servers (`@doist/todoist-mcp`, `@doist/comms-mcp`, `@doist/automations-mcp`): the tool contract, tool registration, how a result is shaped for the wire, and contract test suites. TypeScript, ESM-only, Node ≥ 24. +Shared core for the Doist MCP servers (`@todoist/mcp`, `@todoist/comms-mcp`, `@todoist/automations-mcp`): the tool contract, tool registration, how a result is shaped for the wire, and contract test suites. TypeScript, ESM-only, Node ≥ 24. > For where things are, read [`CODEBASE.md`](./CODEBASE.md). This file covers the _rules_. diff --git a/CODEBASE.md b/CODEBASE.md index f7620c5..88c7cf1 100644 --- a/CODEBASE.md +++ b/CODEBASE.md @@ -6,8 +6,8 @@ ## What this project is -`@doist/mcp-core` is a **shared TypeScript library** for the Doist MCP servers -(`@doist/todoist-mcp`, `@doist/comms-mcp`, `@doist/automations-mcp`). It is **not a server**: +`@todoist/mcp-core` is a **shared TypeScript library** for the Doist MCP servers +(`@todoist/mcp`, `@todoist/comms-mcp`, `@todoist/automations-mcp`). It is **not a server**: it ships the tool contract, a tool registrar with hooks for what differs per product, the wire shaping of tool results, the contract a server offers its host (token validation and the factory options), and contract test suites each server runs over its own tools. @@ -43,11 +43,11 @@ oxlint + oxfmt · semantic-release. ## Public API surface (`package.json#exports`) -| Subpath | Provides | Peers it needs | -| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -| `.` (root) | The tool types, `createToolRegistrar`, `getToolOutput`, `removeNullFields`, schema cache, annotations | `@modelcontextprotocol/server`, `zod` | -| `@doist/mcp-core/host` | `validateBearerToken`, `TokenValidationError`, the host contract types (`TokenValidationResult`, `ValidateToken`, `McpServerOptions`), and the host's helpers (`isTransientValidationError`, `buildBearerChallenge`, `createTokenVerdictCache`) | none | -| `@doist/mcp-core/testing` | `describeOutputSchemaNullability`, `describeAdvertisedToolSchemas`, `describeToolAnnotations`, `describeTokenFootprint` and the helpers they use | the above; also imports `@modelcontextprotocol/client` and `vitest`, undeclared | +| Subpath | Provides | Peers it needs | +| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `.` (root) | The tool types, `createToolRegistrar`, `getToolOutput`, `removeNullFields`, schema cache, annotations | `@modelcontextprotocol/server`, `zod` | +| `@todoist/mcp-core/host` | `validateBearerToken`, `TokenValidationError`, the host contract types (`TokenValidationResult`, `ValidateToken`, `McpServerOptions`), and the host's helpers (`isTransientValidationError`, `buildBearerChallenge`, `createTokenVerdictCache`) | none | +| `@todoist/mcp-core/testing` | `describeOutputSchemaNullability`, `describeAdvertisedToolSchemas`, `describeToolAnnotations`, `describeTokenFootprint` and the helpers they use | the above; also imports `@modelcontextprotocol/client` and `vitest`, undeclared | ## `src/` tree diff --git a/README.md b/README.md index 1f8e12e..3ef94af 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# @doist/mcp-core +# @todoist/mcp-core Shared core for Todoist's MCP servers ([todoist-mcp](https://github.com/todoist/todoist-mcp), [comms-mcp](https://github.com/todoist/comms-mcp) and the Automations MCP server): the tool contract, tool registration, how a tool result is shaped for the wire, the contract a server offers the host that serves it, and the contract test suites every server runs over its own tools. @@ -7,9 +7,11 @@ TypeScript, ESM-only, Node ≥ 24, npm ≥ 11. ## Install ```bash -npm install @doist/mcp-core +npm install @todoist/mcp-core ``` +Previously published as `@doist/mcp-core`. + The MCP SDK and Zod are peer dependencies, so the server and the core share one copy of each. That matters: a host that serves several MCP servers unwraps them with `instanceof McpServer`, which fails against a second copy of the SDK. | Peer | Range | @@ -40,7 +42,7 @@ The MCP SDK and Zod are peer dependencies, so the server and the core share one `McpTool` is generic over what each call receives, so each server picks its own context: an API client, or an object carrying one with an abort signal and a progress reporter. A server usually aliases it with its context filled in. ```ts -import type { McpTool } from '@doist/mcp-core' +import type { McpTool } from '@todoist/mcp-core' import { z } from 'zod' import type { NotesApi } from './notes-api.js' @@ -71,8 +73,8 @@ export const findNotes = { `createToolRegistrar` returns a function that registers tools on a server. Everything that differs between products comes in through its options: ```ts -import { createToolRegistrar } from '@doist/mcp-core' import { McpServer } from '@modelcontextprotocol/server' +import { createToolRegistrar } from '@todoist/mcp-core' export function getMcpServer({ token }: { token: string }): McpServer { const server = new McpServer({ name: 'notes-mcp-server', version: '1.0.0' }) @@ -113,7 +115,7 @@ For each tool this: ### Serving a server from a host -`@doist/mcp-core/host` is the contract between a server package and a host that serves several of them, such as todoist-ai-integrations. Every server exports the same two shapes: +`@todoist/mcp-core/host` is the contract between a server package and a host that serves several of them, such as todoist-ai-integrations. Every server exports the same two shapes: - `getMcpServer(options)`, taking `McpServerOptions` (`{ token, baseUrl? }`), or `McpServerOptions & { ... }` when it needs more; - a `ValidateToken`: `(token, baseUrl?) => Promise<'valid' | 'invalid' | 'forbidden'>`. @@ -121,7 +123,7 @@ For each tool this: A validator resolves only with a verdict on the token and rejects for anything else, so the host can retry a failure without caching it as a verdict. `validateBearerToken` builds one from a status-only `GET`: ```ts -import { validateBearerToken, type ValidateToken } from '@doist/mcp-core/host' +import { validateBearerToken, type ValidateToken } from '@todoist/mcp-core/host' export const validateNotesToken: ValidateToken = (token, baseUrl = 'https://notes.example.com') => validateBearerToken({ url: `${baseUrl}/api/v1/me`, token }) @@ -145,7 +147,7 @@ import { buildBearerChallenge, createTokenVerdictCache, isTransientValidationError, -} from '@doist/mcp-core/host' +} from '@todoist/mcp-core/host' const verdicts = createTokenVerdictCache({ ttlMs: 120_000, maxEntries: 10_000 }) @@ -181,13 +183,13 @@ async function checkToken(token: string, baseUrl: string): Promise getMcpServer({ token: 'test-token' }) diff --git a/package-lock.json b/package-lock.json index 3dfcd0f..4825e79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@doist/mcp-core", + "name": "@todoist/mcp-core", "version": "0.0.0-development", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@doist/mcp-core", + "name": "@todoist/mcp-core", "version": "0.0.0-development", "license": "MIT", "devDependencies": { diff --git a/package.json b/package.json index 8b45125..34af1ad 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@doist/mcp-core", + "name": "@todoist/mcp-core", "version": "0.0.0-development", "description": "Shared core for the Doist MCP servers", "type": "module",