UNPKG

@modelcontextprotocol/core

Version:

Model Context Protocol for TypeScript — public Zod schemas (spec + OAuth/OpenID)

1 lines • 7.27 kB
{"version":3,"file":"index.mjs","names":["SKILL_LIMITS: Readonly<{ files: number; bytes: number }>"],"sources":["../../../src/ext/skills/constants.ts","../../../src/ext/skills/schemas.ts","../../../src/ext/skills/capability.ts"],"sourcesContent":["/**\n * Wire constants for the MCP Skills extension (SEP-2640).\n *\n * Runtime-neutral: this module imports nothing.\n */\n\n/** The identifier a server advertises in `ServerCapabilities.extensions`. */\nexport const SKILLS_EXTENSION_ID = 'io.modelcontextprotocol/skills';\n\n/** Enumerates the skills a server serves. */\nexport const SKILLS_LIST_METHOD = 'skills/list';\n\n/** Returns one skill's entry by its `SKILL.md` URI, listed or not. */\nexport const SKILLS_GET_METHOD = 'skills/get';\n\n/** Lists the direct children of a directory resource (gated by `directoryRead`). */\nexport const RESOURCES_DIRECTORY_READ_METHOD = 'resources/directory/read';\n\n/** The `mimeType` of a directory resource. */\nexport const DIRECTORY_MIME_TYPE = 'inode/directory';\n\n/**\n * Per-skill interoperability limits. Hosts MUST accept skills up to these;\n * servers SHOULD NOT publish skills over them.\n */\nexport const SKILL_LIMITS: Readonly<{ files: number; bytes: number }> = Object.freeze({ files: 512, bytes: 16_777_216 });\n\n/** `sha256:` followed by 64 lowercase hexadecimal characters. */\nexport const SKILL_DIGEST_PATTERN = /^sha256:[\\da-f]{64}$/;\n","import * as z from 'zod/v4';\n\nimport { BaseRequestParamsSchema, PaginatedRequestParamsSchema, PaginatedResultSchema, ResourceSchema, ResultSchema } from '../../schemas';\nimport { SKILL_DIGEST_PATTERN } from './constants';\n\n// Every object schema here is loose: none of the stable spec's types declare\n// `additionalProperties: false`, so unknown keys (including `_meta`) survive.\n\nexport const SkillDigestSchema = z\n .string()\n .regex(SKILL_DIGEST_PATTERN, 'digest must be \"sha256:\" followed by 64 lowercase hexadecimal characters');\n\nexport const SkillResourceEntrySchema = z.looseObject({\n /** Resource URI of the file. */\n uri: z.string(),\n /** SHA-256 digest of the file's raw bytes. */\n digest: SkillDigestSchema,\n /** Length of the file's raw bytes. */\n size: z.number().int().nonnegative()\n});\n\nexport const SkillFrontmatterSchema = z\n .looseObject({\n name: z.string(),\n description: z.string()\n })\n // Zod copies an own `__proto__` field by assignment, which makes it the prototype: fields no key listing shows.\n .refine(frontmatter => Object.getPrototypeOf(frontmatter) === Object.prototype, 'frontmatter must not have a \"__proto__\" field');\n\nexport const SkillResourcesSchema = z.union([z.array(SkillResourceEntrySchema), z.literal('dynamic')]);\n\nexport const SkillSchema = z.looseObject({\n /** Resource URI of the skill's `SKILL.md`. */\n uri: z.string(),\n /** The `SKILL.md` frontmatter, verbatim. */\n frontmatter: SkillFrontmatterSchema,\n /** Every file of the skill, or `\"dynamic\"`. */\n resources: SkillResourcesSchema,\n _meta: z.record(z.string(), z.unknown()).optional()\n});\n\nexport const SkillCacheScopeSchema = z.enum(['public', 'private']);\n\n// Required, as the stable spec (2026-07-28) defines them; only SkillsClient reads the 2025-11-25 backport, which has none.\nconst cacheFields = {\n ttlMs: z.number().int().nonnegative(),\n cacheScope: SkillCacheScopeSchema\n};\n\nexport const ListSkillsResultSchema = z.looseObject({\n ...PaginatedResultSchema.shape,\n skills: z.array(SkillSchema),\n ...cacheFields\n});\n\nexport const GetSkillRequestParamsSchema = BaseRequestParamsSchema.extend({\n /** The `SKILL.md` URI of the skill to fetch. */\n uri: z.string()\n});\n\nexport const GetSkillResultSchema = z.looseObject({\n ...ResultSchema.shape,\n skill: SkillSchema,\n ...cacheFields\n});\n\nexport const DirectoryResourceSchema = z.looseObject(ResourceSchema.shape);\n\nexport const ReadResourceDirectoryRequestParamsSchema = PaginatedRequestParamsSchema.extend({\n /** URI of the directory resource to read. */\n uri: z.string()\n});\n\nexport const ReadResourceDirectoryResultSchema = z.looseObject({\n ...PaginatedResultSchema.shape,\n resources: z.array(DirectoryResourceSchema),\n ...cacheFields\n});\n\nexport const SkillsCapabilitySchema = z.looseObject({\n /** Whether the server serves `resources/directory/read`. */\n directoryRead: z.boolean().optional()\n});\n\nexport { PaginatedRequestParamsSchema as ListSkillsRequestParamsSchema } from '../../schemas';\n","import { SKILLS_EXTENSION_ID } from './constants';\nimport { SkillsCapabilitySchema } from './schemas';\nimport type { SkillsCapability } from './types';\n\n/**\n * The shape this module reads capabilities out of. Declared structurally so\n * the helper stays in the runtime-neutral core package: the nominal\n * `ServerCapabilities` type lives downstream, and every value of it satisfies\n * this.\n */\nexport interface CapabilitiesWithExtensions {\n extensions?: Record<string, unknown>;\n}\n\n/**\n * Reads the Skills extension capability out of a peer's advertised\n * capabilities, returning `undefined` when the peer does not advertise the\n * extension or advertises a malformed value.\n *\n * Shared by both roles: servers use it to check what they published, clients\n * to gate `skills/list` / `skills/get` on negotiation.\n */\nexport function skillsCapabilityOf(capabilities: CapabilitiesWithExtensions | undefined): SkillsCapability | undefined {\n const declared = capabilities?.extensions?.[SKILLS_EXTENSION_ID];\n if (declared === undefined) {\n return undefined;\n }\n const parsed = SkillsCapabilitySchema.safeParse(declared);\n return parsed.success ? parsed.data : undefined;\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,sBAAsB;;AAGnC,MAAa,qBAAqB;;AAGlC,MAAa,oBAAoB;;AAGjC,MAAa,kCAAkC;;AAG/C,MAAa,sBAAsB;;;;;AAMnC,MAAaA,eAA2D,OAAO,OAAO;CAAE,OAAO;CAAK,OAAO;CAAY,CAAC;;AAGxH,MAAa,uBAAuB;;;;ACpBpC,MAAa,oBAAoB,EAC5B,QAAQ,CACR,MAAM,sBAAsB,6EAA2E;AAE5G,MAAa,2BAA2B,EAAE,YAAY;CAElD,KAAK,EAAE,QAAQ;CAEf,QAAQ;CAER,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa;CACvC,CAAC;AAEF,MAAa,yBAAyB,EACjC,YAAY;CACT,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ;CAC1B,CAAC,CAED,QAAO,gBAAe,OAAO,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