Files
SnowLuma/.pnpm-store/v11/files/12/71bf2d133349eb6b0f124ae161092bb6dec52f910b390e0fcd2e4f219b3bf80e53a768374ad7c2a9a87ad42bc7863d5df29f959589fa9f1f9db2d4a7ecbd58
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

41 lines
1.9 KiB
Plaintext

# @modelcontextprotocol/core
Canonical public home for the [Model Context Protocol](https://modelcontextprotocol.io) specification and OAuth/OpenID **Zod schemas**.
These are the exact schema constants the SDK validates protocol and OAuth/OpenID payloads against internally. The `@modelcontextprotocol/server` and `@modelcontextprotocol/client` packages keep a Zod-free public surface, so this package exists as the supported place to import the
raw schemas when you need to validate or parse MCP messages yourself.
## Install
```sh
npm install @modelcontextprotocol/core
```
## Usage
```ts
import { CallToolResultSchema } from '@modelcontextprotocol/core';
// Throws on invalid input; returns the typed result on success.
const result = CallToolResultSchema.parse(payload);
// Or non-throwing:
const parsed = CallToolResultSchema.safeParse(payload);
if (parsed.success) {
// parsed.data is a fully typed CallToolResult
}
```
## Scope
This package exports **only** Zod schema constants (`*Schema`), in two groups:
- the MCP **spec** schemas — `CallToolResultSchema`, `ListToolsResultSchema`, …; and
- the **OAuth/OpenID** auth schemas — `OAuthTokensSchema`, `OAuthMetadataSchema`, `IdJagTokenExchangeResponseSchema`, … (the schemas v1 exposed from `@modelcontextprotocol/sdk/shared/auth.js`).
The corresponding TypeScript types, error classes, enums, and type guards are part of the public API of [`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server) and
[`@modelcontextprotocol/client`](https://www.npmjs.com/package/@modelcontextprotocol/client).
> **Migrating from v1?** In v1 these schemas were imported from `@modelcontextprotocol/sdk/types.js` (spec schemas) and `@modelcontextprotocol/sdk/shared/auth.js` (OAuth/OpenID schemas). Point those `*Schema` imports at `@modelcontextprotocol/core` and your existing `.parse()` /
> `.safeParse()` calls keep working unchanged.