@webpieces/core-util 0.4.806 → 0.4.807

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DtoSchema.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/DtoSchema.ts"],"names":[],"mappings":";;;AA4FA,sBAEC;AAID,gCAYC;AAID,sCAQC;AA1HD,4BAA0B;AAE1B,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAShD,uFAAuF;AACvF,MAAa,iBAAiB;IAEN;IAEA;IAEA;IAEA;IACA;IACA;IACA;IAEA;IAZpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB;IACjC,wEAAwE;IACxD,UAA2B;IAC3C,uEAAuE;IACvD,UAAmB,KAAK,EACxB,OAAgB,EAChB,OAAgB,EAChB,UAA2C;IAC3D,+DAA+D;IAC/C,SAAuB;QAXvB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QAEjB,eAAU,GAAV,UAAU,CAAiB;QAE3B,YAAO,GAAP,OAAO,CAAiB;QACxB,YAAO,GAAP,OAAO,CAAS;QAChB,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAAiC;QAE3C,cAAS,GAAT,SAAS,CAAc;IACxC,CAAC;CACP;AAfD,8CAeC;AAED;;;;GAIG;AACH,MAAa,WAAW;IACQ;IAA5B,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CAC/C;AAFD,kCAEC;AAED;;;;GAIG;AACH,MAAa,oBAAoB;IAET;IAEA;IACA;IAJpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB,EACjB,SAAyB;QAHzB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,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IAEO,UAAU,CAAC,QAAkB;QACjC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CACX,GAAG,QAAQ,CAAC,IAAI,yDAAyD,CAC5E,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAzVD,4CAyVC","sourcesContent":["import 'reflect-metadata';\n\nconst DTO_MARKER = 'webpieces:dto-schema';\nconst DTO_FIELDS = 'webpieces:dto-fields';\nconst RESPONSE_DTOS = 'webpieces:response-dtos';\n\n// webpieces-disable no-any-unknown -- abstract class tokens necessarily erase constructor parameters\nexport type DtoClass = abstract new (...args: any[]) => unknown;\n/** The element type of an array or the value type of a map; TypeScript erases both at runtime. */\nexport type DtoElementType = 'string' | 'number' | 'integer' | 'boolean' | DtoClass;\n/** Runtime values accepted at the DTO validation boundary. */\nexport type DtoValue = object | string | number | boolean | null;\n\n/** Additive field metadata; the scalar/object type itself comes from `design:type`. */\nexport class WpDtoFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n /** Required for arrays because TypeScript erases their element type. */\n public readonly arrayItems?: DtoElementType,\n /** A reflected Number is otherwise emitted as JSON Schema `number`. */\n public readonly integer: boolean = false,\n public readonly minimum?: number,\n public readonly maximum?: number,\n public readonly enumValues?: readonly [string, ...string[]],\n /** MCP 2026 SEP-2243 header mirrored as `Mcp-Param-{name}`. */\n public readonly mcpHeader?: WpMcpHeader,\n ) {}\n}\n\n/**\n * Names the `x-mcp-header` a primitive tool parameter is mirrored into (`Mcp-Param-{name}`). A class,\n * not a bare string, so the 8th `WpDtoFieldOptions` argument can never be mistaken for a map value\n * type (maps use `WpDtoMapFieldOptions`).\n */\nexport class WpMcpHeader {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.\n * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same\n * reason `arrayItems` is: TypeScript erases it, and a `Record` reflects as plain `Object`.\n */\nexport class WpDtoMapFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n public readonly mapValues: DtoElementType,\n ) {}\n}\n\nexport class WpDtoFieldMetadata {\n constructor(\n public readonly propertyKey: string,\n public readonly options: WpDtoFieldOptions | WpDtoMapFieldOptions,\n ) {}\n}\n\n/** The JSON Schema subset emitted for Webpieces API DTOs. */\nexport class ApiJsonSchema {\n type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array';\n description?: string;\n properties?: Record<string, ApiJsonSchema>;\n required?: string[];\n /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */\n additionalProperties?: boolean | ApiJsonSchema;\n items?: ApiJsonSchema;\n enum?: string[];\n minimum?: number;\n maximum?: number;\n /** MCP 2026 SEP-2243 schema extension consumed by the official SDK. */\n declare 'x-mcp-header'?: string;\n\n constructor(type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array') {\n this.type = type;\n }\n}\n\n/** A validation result safe to show to an API caller/model. */\nexport class DtoValidationFailure {\n constructor(\n /** JSON path of the offending value, e.g. `$.address.city`. */\n public readonly field: string,\n public readonly message: string,\n ) {}\n}\n\n/** Marks a request/response class as a schema-bearing DTO, including intentionally empty DTOs. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDto(): ClassDecorator {\n return (target: Function): void => Reflect.defineMetadata(DTO_MARKER, true, target);\n}\n\n/** Adds documentation and runtime-only shape facts to a DTO property. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDtoField(options: WpDtoFieldOptions | WpDtoMapFieldOptions): PropertyDecorator {\n if (options.description.trim() === '') {\n throw new Error('@WpDtoField requires non-empty field documentation.');\n }\n return (target: object, propertyKey: string | symbol): void => {\n const dtoClass = target.constructor;\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n const name = String(propertyKey);\n fields[name] = new WpDtoFieldMetadata(name, options);\n Reflect.defineMetadata(DTO_FIELDS, fields, dtoClass);\n };\n}\n\n/** Declares an async API method's response DTO because reflection sees Promise, not its generic. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpResponseDto(responseDto: () => DtoClass): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n responses[String(propertyKey)] = responseDto;\n Reflect.defineMetadata(RESPONSE_DTOS, responses, apiClass);\n };\n}\n\n/** Builds and validates the same DTO schema used for MCP input and structured output. */\nexport class DtoSchemaBuilder {\n requestClassOf(apiClass: Function, methodName: string): DtoClass {\n // webpieces-disable no-any-unknown -- reflect-metadata returns erased runtime constructor tokens\n const params = Reflect.getMetadata('design:paramtypes', apiClass.prototype, methodName) as\n | DtoClass[]\n | undefined;\n if (!params || params.length !== 1) {\n throw new Error(\n `${apiClass.name}.${methodName} must take exactly one @WpDto request class to be an MCP tool.`,\n );\n }\n return params[0];\n }\n\n responseClassOf(apiClass: Function, methodName: string): DtoClass {\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n const response = responses[methodName];\n if (!response) {\n throw new Error(\n `${apiClass.name}.${methodName} must declare @WpResponseDto(() => ResponseClass) before MCP exposure.`,\n );\n }\n return response();\n }\n\n /**\n * The one closure gate for an object schema. Closed means no key can carry an unspecified value:\n * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is\n * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.\n * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.\n */\n isClosedSchema(schema: ApiJsonSchema): boolean {\n const extra = schema.additionalProperties;\n return extra === false || (typeof extra === 'object' && extra !== null);\n }\n\n build(dtoClass: DtoClass): ApiJsonSchema {\n const schema = this.buildAt(dtoClass, new Set<DtoClass>());\n this.validateMcpHeaders(schema, new Map<string, string>());\n return schema;\n }\n\n validate(dtoClass: DtoClass, value: DtoValue): DtoValidationFailure | undefined {\n return this.validateAt(dtoClass, value, '$');\n }\n\n private buildAt(dtoClass: DtoClass, parents: Set<DtoClass>): ApiJsonSchema {\n this.requireDto(dtoClass);\n if (parents.has(dtoClass)) {\n throw new Error(`Recursive DTO ${dtoClass.name} cannot use an inline MCP schema.`);\n }\n const nextParents = new Set(parents);\n nextParents.add(dtoClass);\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of this.fields(dtoClass)) {\n schema.properties[field.propertyKey] = this.fieldSchema(dtoClass, field, nextParents);\n if (field.options.required) required.push(field.propertyKey);\n }\n if (required.length > 0) schema.required = required;\n return schema;\n }\n\n private fieldSchema(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n parents: Set<DtoClass>,\n ): ApiJsonSchema {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass | undefined;\n if (!reflected)\n throw new Error(`No reflected type for ${dtoClass.name}.${field.propertyKey}.`);\n this.validateOptions(dtoClass, field, reflected);\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n const mapSchema = new ApiJsonSchema('object');\n mapSchema.description = options.description;\n mapSchema.additionalProperties = this.itemSchema(options.mapValues, parents);\n return mapSchema;\n }\n let schema: ApiJsonSchema;\n switch (reflected.name) {\n case 'String':\n schema = new ApiJsonSchema('string');\n break;\n case 'Number':\n schema = new ApiJsonSchema(options.integer ? 'integer' : 'number');\n break;\n case 'Boolean':\n schema = new ApiJsonSchema('boolean');\n break;\n case 'Array':\n if (!options.arrayItems) {\n throw new Error(\n `${dtoClass.name}.${field.propertyKey} must declare arrayItems.`,\n );\n }\n schema = new ApiJsonSchema('array');\n schema.items = this.itemSchema(options.arrayItems, parents);\n break;\n default:\n schema = this.buildAt(reflected, parents);\n }\n schema.description = options.description;\n if (options.minimum !== undefined) schema.minimum = options.minimum;\n if (options.maximum !== undefined) schema.maximum = options.maximum;\n if (options.enumValues) schema.enum = [...options.enumValues];\n if (options.mcpHeader) schema['x-mcp-header'] = options.mcpHeader.name;\n return schema;\n }\n\n private validateOptions(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n reflected: DtoClass,\n ): void {\n const label = `${dtoClass.name}.${field.propertyKey}`;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n if (reflected !== Object) {\n throw new Error(\n `${label} declares mapValues but is not a map (Record<string, V>).`,\n );\n }\n return;\n }\n if (reflected === Object) {\n throw new Error(\n `${label} has type Object: an interface or Record can never be a @WpDto. ` +\n 'For a map, use WpDtoMapFieldOptions.',\n );\n }\n if (reflected.name !== 'Array' && options.arrayItems) {\n throw new Error(`${label} declares arrayItems but is not an array.`);\n }\n if (\n reflected.name !== 'Number' &&\n (options.integer || options.minimum !== undefined || options.maximum !== undefined)\n ) {\n throw new Error(`${label} declares numeric constraints but is not a number.`);\n }\n if (\n options.minimum !== undefined &&\n options.maximum !== undefined &&\n options.minimum > options.maximum\n ) {\n throw new Error(`${label} minimum cannot exceed maximum.`);\n }\n if (options.enumValues && reflected.name !== 'String') {\n throw new Error(`${label} enumValues require a string field.`);\n }\n if (options.mcpHeader !== undefined) {\n if (!/^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/.test(options.mcpHeader.name)) {\n throw new Error(`${label} mcpHeader must be an RFC 9110 token.`);\n }\n if (!['String', 'Number', 'Boolean'].includes(reflected.name)) {\n throw new Error(`${label} mcpHeader requires a primitive field.`);\n }\n if (reflected.name === 'Number' && !options.integer) {\n throw new Error(\n `${label} mcpHeader cannot mirror a non-integer number (MCP 2026-07-28).`,\n );\n }\n }\n }\n\n private itemSchema(item: DtoElementType, parents: Set<DtoClass>): ApiJsonSchema {\n if (typeof item !== 'string') return this.buildAt(item, parents);\n return new ApiJsonSchema(item === 'integer' ? 'integer' : item);\n }\n\n private validateMcpHeaders(schema: ApiJsonSchema, seen: Map<string, string>): void {\n const header = schema['x-mcp-header'];\n if (header) {\n const key = header.toLowerCase();\n const prior = seen.get(key);\n if (prior) {\n throw new Error(`mcpHeader '${header}' duplicates '${prior}' case-insensitively.`);\n }\n seen.set(key, header);\n }\n for (const child of Object.values(schema.properties ?? {})) {\n this.validateMcpHeaders(child, seen);\n }\n }\n\n private validateAt(\n dtoClass: DtoClass,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n this.requireDto(dtoClass);\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an object`);\n }\n const fields = this.fields(dtoClass);\n const known = new Set(fields.map((field: WpDtoFieldMetadata) => field.propertyKey));\n for (const key of Object.keys(value)) {\n if (!known.has(key))\n return new DtoValidationFailure(`${path}.${key}`, `${path}.${key} is not allowed`);\n }\n for (const field of fields) {\n const fieldValue = Object.getOwnPropertyDescriptor(value, field.propertyKey)?.value;\n if (fieldValue === undefined) {\n if (field.options.required) {\n return new DtoValidationFailure(\n `${path}.${field.propertyKey}`,\n `${path}.${field.propertyKey} is required`,\n );\n }\n continue;\n }\n const failure = this.validateField(\n dtoClass,\n field,\n fieldValue,\n `${path}.${field.propertyKey}`,\n );\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateField(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) return this.validateMap(options, value, path);\n const expected = reflected?.name;\n if (expected === 'Array') return this.validateArray(options, value, path);\n if (expected === 'String') {\n if (typeof value !== 'string')\n return new DtoValidationFailure(path, `${path} must be a string`);\n if (options.enumValues && !options.enumValues.includes(value)) {\n return new DtoValidationFailure(\n path,\n `${path} must be one of: ${options.enumValues.join(', ')}`,\n );\n }\n return undefined;\n }\n if (expected === 'Number') {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n return new DtoValidationFailure(path, `${path} must be a number`);\n }\n if (options.integer && !Number.isInteger(value)) {\n return new DtoValidationFailure(path, `${path} must be an integer`);\n }\n if (options.minimum !== undefined && value < options.minimum) {\n return new DtoValidationFailure(path, `${path} must be >= ${options.minimum}`);\n }\n if (options.maximum !== undefined && value > options.maximum) {\n return new DtoValidationFailure(path, `${path} must be <= ${options.maximum}`);\n }\n return undefined;\n }\n if (expected === 'Boolean') {\n return typeof value === 'boolean'\n ? undefined\n : new DtoValidationFailure(path, `${path} must be a boolean`);\n }\n return this.validateAt(reflected, value, path);\n }\n\n private validateArray(\n options: WpDtoFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (!Array.isArray(value))\n return new DtoValidationFailure(path, `${path} must be an array`);\n if (!options.arrayItems) return new DtoValidationFailure(path, `${path} has no item type`);\n for (let index = 0; index < value.length; index += 1) {\n const failure = this.validateElement(\n options.arrayItems,\n value[index],\n `${path}[${index}]`,\n );\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateMap(\n options: WpDtoMapFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an object map`);\n }\n const prototype: object | null = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return new DtoValidationFailure(path, `${path} must be a plain object map`);\n }\n for (const key of Object.keys(value)) {\n const entry: DtoValue = Object.getOwnPropertyDescriptor(value, key)?.value;\n const failure = this.validateElement(options.mapValues, entry, `${path}.${key}`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateElement(\n type: DtoElementType,\n item: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof type !== 'string') return this.validateAt(type, item, path);\n const wanted = type === 'integer' ? 'number' : type;\n if (typeof item !== wanted || (type === 'integer' && !Number.isInteger(item))) {\n return new DtoValidationFailure(path, `${path} must be ${type}`);\n }\n return undefined;\n }\n\n private fields(dtoClass: DtoClass): WpDtoFieldMetadata[] {\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n return Object.values(fields);\n }\n\n private requireDto(dtoClass: DtoClass): void {\n if (!Reflect.getMetadata(DTO_MARKER, dtoClass)) {\n throw new Error(\n `${dtoClass.name} must be decorated with @WpDto() for schema generation.`,\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"DtoSchema.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/DtoSchema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAmBH,6DAA6D;AAC7D,MAAa,aAAa;IACtB,uDAAuD;IACvD,IAAI,CAAoD;IACxD,WAAW,CAAU;IACrB,UAAU,CAAiC;IAC3C,QAAQ,CAAY;IACpB,kGAAkG;IAClG,oBAAoB,CAA2B;IAC/C,KAAK,CAAiB;IACtB,IAAI,CAAY;IAChB,OAAO,CAAU;IACjB,OAAO,CAAU;IAIjB,YAAY,IAAuD;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,6EAA6E;IAC7E,MAAM,CAAC,UAAU,CAAC,MAAqB;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAChD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC,IAAI,CAAC;QACxD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAsB,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;IACxE,CAAC;IA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**\n * The JSON Schema subset webpieces publishes on its API boundaries, and the ONE runtime validator of\n * it.\n *\n * ## Nothing here reads reflect-metadata any more\n *\n * Until #984 this file also carried `@WpDto`, `@WpDtoField`, `WpDtoFieldOptions`,\n * `WpDtoMapFieldOptions`, `WpMcpHeader`, `@WpResponseDto` and `DtoSchemaBuilder` — a second, runtime\n * spelling of facts the TypeScript compiler already holds. #983 measured the two against each other\n * and found the compiler reproduces every one of those arguments byte for byte, so they are deleted\n * rather than deprecated (`.claude/rules/no-backwards-compat.md`): a schema is now BUILT at build\n * time from the source by `@webpieces/api-doc-model`, and the runtime is HANDED the result.\n *\n * What survives is the schema itself, a builder for the boundaries that construct one by hand, and a\n * validator that reads the schema instead of a decorator.\n */\n\n/** Runtime values accepted at the DTO validation boundary. */\nexport type DtoValue = object | string | number | boolean | null;\n\n/**\n * One JSON Schema `type`. `null` is a member because NULLABLE is expressed as `[\"string\", \"null\"]`,\n * which is how JSON Schema says \"present, and may hold null\" — a different wire document from an\n * ABSENT property, and one the reflect-metadata runtime could neither see nor write down.\n */\nexport type ApiJsonSchemaType =\n | 'object'\n | 'string'\n | 'number'\n | 'integer'\n | 'boolean'\n | 'array'\n | 'null';\n\n/** The JSON Schema subset emitted for Webpieces API DTOs. */\nexport class ApiJsonSchema {\n /** One type, or `[T, \"null\"]` for a nullable field. */\n type?: ApiJsonSchemaType | readonly ApiJsonSchemaType[];\n description?: string;\n properties?: Record<string, ApiJsonSchema>;\n required?: string[];\n /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */\n additionalProperties?: boolean | ApiJsonSchema;\n items?: ApiJsonSchema;\n enum?: string[];\n minimum?: number;\n maximum?: number;\n /** MCP 2026 SEP-2243 schema extension consumed by the official SDK. */\n declare 'x-mcp-header'?: string;\n\n constructor(type?: ApiJsonSchemaType | readonly ApiJsonSchemaType[]) {\n this.type = type;\n }\n\n /**\n * The non-`null` member of the type, which is the one that decides how a value is checked.\n *\n * These three are STATIC and not instance methods on purpose: an instance method would put a\n * function on the structural type, and this class is handed straight to the MCP SDK, whose\n * parameter types are index-signature JSON objects that a class carrying methods no longer\n * satisfies. It stays a data-only structure (`CLAUDE.md` §1) and the helpers live beside it.\n */\n // webpieces-disable no-function-outside-class -- static reader of this class\n static baseTypeOf(schema: ApiJsonSchema): ApiJsonSchemaType | undefined {\n if (schema.type === undefined) return undefined;\n if (typeof schema.type === 'string') return schema.type;\n return schema.type.find((one: ApiJsonSchemaType) => one !== 'null');\n }\n\n /** True when the schema was widened with `\"null\"`, i.e. the property may hold `null`. */\n // webpieces-disable no-function-outside-class -- static reader of this class\n static allowsNull(schema: ApiJsonSchema): boolean {\n return typeof schema.type !== 'string' && (schema.type?.includes('null') ?? false);\n }\n\n /**\n * The one closure gate for an object schema. Closed means no key can carry an unspecified value:\n * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is\n * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.\n * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.\n */\n // webpieces-disable no-function-outside-class -- static reader of this class\n static isClosed(schema: ApiJsonSchema): boolean {\n const extra = schema.additionalProperties;\n return extra === false || (typeof extra === 'object' && extra !== null);\n }\n}\n\n/**\n * Builds the CLOSED object schema a hand-written runtime boundary validates against — `@WpStream`'s\n * two event schemas are the whole of its client list today.\n *\n * It exists because the alternative spellings are both worse: a decorator that re-states the field\n * types the compiler already knows is exactly what #984 deleted, and a bare object literal is what\n * `CLAUDE.md` §3 forbids. A generated schema never comes through here — it is read from the build's\n * own artifact.\n */\nexport class ObjectSchemaBuilder {\n private readonly schema = new ApiJsonSchema('object');\n private readonly requiredNames: string[] = [];\n\n constructor() {\n this.schema.properties = {};\n this.schema.additionalProperties = false;\n }\n\n required(name: string, type: ApiJsonSchema): this {\n this.requiredNames.push(name);\n return this.optional(name, type);\n }\n\n optional(name: string, type: ApiJsonSchema): this {\n this.schema.properties![name] = type;\n return this;\n }\n\n build(): ApiJsonSchema {\n if (this.requiredNames.length > 0) this.schema.required = [...this.requiredNames];\n return this.schema;\n }\n}\n\n/** A validation result safe to show to an API caller/model. */\nexport class DtoValidationFailure {\n constructor(\n /** JSON path of the offending value, e.g. `$.address.city`. */\n public readonly field: string,\n public readonly message: string,\n ) {}\n}\n\n/**\n * Validates a value against an {@link ApiJsonSchema} — the ONE runtime narrowing boundary for MCP\n * tool arguments, MCP structured output and typed stream events.\n *\n * It reads the SCHEMA, which is the same object the build published to agents, so a document that\n * says a field is required and a server that accepts it missing cannot disagree. The predecessor\n * walked reflect-metadata instead, which meant the published document and the accepted request were\n * derived from two different declarations.\n */\nexport class ApiJsonSchemaValidator {\n validate(schema: ApiJsonSchema, value: DtoValue): DtoValidationFailure | undefined {\n return this.validateAt(schema, value, '$');\n }\n\n private validateAt(\n schema: ApiJsonSchema,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (value === null) {\n return ApiJsonSchema.allowsNull(schema)\n ? undefined\n : new DtoValidationFailure(path, `${path} must not be null`);\n }\n switch (ApiJsonSchema.baseTypeOf(schema)) {\n case 'object':\n return this.validateObject(schema, value, path);\n case 'array':\n return this.validateArray(schema, value, path);\n case 'string':\n return this.validateString(schema, value, path);\n case 'number':\n case 'integer':\n return this.validateNumber(schema, value, path);\n case 'boolean':\n return typeof value === 'boolean'\n ? undefined\n : new DtoValidationFailure(path, `${path} must be a boolean`);\n default:\n return undefined;\n }\n }\n\n private validateObject(\n schema: ApiJsonSchema,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an object`);\n }\n const properties = schema.properties ?? {};\n const extra = schema.additionalProperties;\n for (const key of Object.keys(value)) {\n const entry: DtoValue = Object.getOwnPropertyDescriptor(value, key)?.value;\n const declared = Object.getOwnPropertyDescriptor(properties, key)?.value as\n | ApiJsonSchema\n | undefined;\n if (declared === undefined) {\n if (typeof extra !== 'object' || extra === null) {\n return new DtoValidationFailure(\n `${path}.${key}`,\n `${path}.${key} is not allowed`,\n );\n }\n const failure = this.validateAt(extra, entry, `${path}.${key}`);\n if (failure) return failure;\n continue;\n }\n const failure = this.validateAt(declared, entry, `${path}.${key}`);\n if (failure) return failure;\n }\n for (const name of schema.required ?? []) {\n if (Object.getOwnPropertyDescriptor(value, name)?.value === undefined) {\n return new DtoValidationFailure(`${path}.${name}`, `${path}.${name} is required`);\n }\n }\n return undefined;\n }\n\n private validateArray(\n schema: ApiJsonSchema,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (!Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an array`);\n }\n const items = schema.items;\n if (items === undefined) return undefined;\n for (let index = 0; index < value.length; index += 1) {\n const failure = this.validateAt(items, value[index], `${path}[${index}]`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateString(\n schema: ApiJsonSchema,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'string') {\n return new DtoValidationFailure(path, `${path} must be a string`);\n }\n if (schema.enum && !schema.enum.includes(value)) {\n return new DtoValidationFailure(\n path,\n `${path} must be one of: ${schema.enum.join(', ')}`,\n );\n }\n return undefined;\n }\n\n private validateNumber(\n schema: ApiJsonSchema,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n return new DtoValidationFailure(path, `${path} must be a number`);\n }\n if (ApiJsonSchema.baseTypeOf(schema) === 'integer' && !Number.isInteger(value)) {\n return new DtoValidationFailure(path, `${path} must be an integer`);\n }\n if (schema.minimum !== undefined && value < schema.minimum) {\n return new DtoValidationFailure(path, `${path} must be >= ${schema.minimum}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n return new DtoValidationFailure(path, `${path} must be <= ${schema.maximum}`);\n }\n return undefined;\n }\n}\n"]}
@@ -2,34 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const McpMetadata_1 = require("./McpMetadata");
5
- const DtoSchema_1 = require("./DtoSchema");
6
- const invalidEmptyEnum = new DtoSchema_1.WpDtoFieldOptions('invalid enum', true, undefined, false, undefined, undefined,
7
- // @ts-expect-error enumValues must contain at least one allowed string
8
- []);
9
- // @ts-expect-error a map's value type must be a scalar name or a DtoClass
10
- const invalidMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true, 'date');
11
- // @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions
12
- const missingMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true);
13
- const noEighthFieldArgument = new DtoSchema_1.WpDtoFieldOptions('maps are not a WpDtoFieldOptions argument', false, undefined, false, undefined, undefined, undefined,
14
- // @ts-expect-error maps use WpDtoMapFieldOptions; the 8th argument is only a WpMcpHeader
15
- 'string');
5
+ /**
6
+ * Compile-time pins for `@WpMcpTool`. These live in a COMPILED file rather than a `.spec.ts` because
7
+ * vitest strips types with esbuild and `tsconfig.lib.json` excludes specs, so a `@ts-expect-error` in
8
+ * a spec is inert (`.claude/rules/no-backwards-compat.md` shim shape #4). Here, tsc fails the build
9
+ * with TS2578 the moment one of these starts compiling.
10
+ */
16
11
  class InvalidMcpContract {
17
- invalid(_request) {
12
+ // @ts-expect-error @WpMcpTool takes the stable protocol NAME, not an options object
13
+ options(_request) {
14
+ throw new Error('contract only');
15
+ }
16
+ // @ts-expect-error side-effect claims belong on @Endpoint.operation, never @WpMcpTool
17
+ hints(_request) {
18
18
  throw new Error('contract only');
19
19
  }
20
20
  }
21
21
  tslib_1.__decorate([
22
- (0, McpMetadata_1.WpMcpTool)({
23
- name: 'invalid',
24
- description: 'This declaration must never compile.',
25
- // @ts-expect-error side-effect claims belong on @Endpoint.operation, never @WpMcpTool
26
- readOnlyHint: true,
27
- openWorldHint: false,
28
- }),
22
+ (0, McpMetadata_1.WpMcpTool)({ name: 'invalid' }),
23
+ tslib_1.__metadata("design:type", Function),
24
+ tslib_1.__metadata("design:paramtypes", [Object]),
25
+ tslib_1.__metadata("design:returntype", Promise)
26
+ ], InvalidMcpContract.prototype, "options", null);
27
+ tslib_1.__decorate([
28
+ (0, McpMetadata_1.WpMcpTool)('invalid', true),
29
29
  tslib_1.__metadata("design:type", Function),
30
30
  tslib_1.__metadata("design:paramtypes", [Object]),
31
31
  tslib_1.__metadata("design:returntype", Promise)
32
- ], InvalidMcpContract.prototype, "invalid", null);
32
+ ], InvalidMcpContract.prototype, "hints", null);
33
33
  class InvalidMcpArities {
34
34
  // @ts-expect-error MCP tools require exactly one request DTO
35
35
  zero() {
@@ -41,29 +41,17 @@ class InvalidMcpArities {
41
41
  }
42
42
  }
43
43
  tslib_1.__decorate([
44
- (0, McpMetadata_1.WpMcpTool)({
45
- name: 'zero-arity',
46
- description: 'This declaration must never compile.',
47
- openWorldHint: false,
48
- }),
44
+ (0, McpMetadata_1.WpMcpTool)('zero-arity'),
49
45
  tslib_1.__metadata("design:type", Function),
50
46
  tslib_1.__metadata("design:paramtypes", []),
51
47
  tslib_1.__metadata("design:returntype", Promise)
52
48
  ], InvalidMcpArities.prototype, "zero", null);
53
49
  tslib_1.__decorate([
54
- (0, McpMetadata_1.WpMcpTool)({
55
- name: 'multi-arity',
56
- description: 'This declaration must never compile.',
57
- openWorldHint: false,
58
- }),
50
+ (0, McpMetadata_1.WpMcpTool)('multi-arity'),
59
51
  tslib_1.__metadata("design:type", Function),
60
52
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
61
53
  tslib_1.__metadata("design:returntype", Promise)
62
54
  ], InvalidMcpArities.prototype, "multi", null);
63
55
  void InvalidMcpContract;
64
56
  void InvalidMcpArities;
65
- void invalidEmptyEnum;
66
- void invalidMapValue;
67
- void missingMapValue;
68
- void noEighthFieldArgument;
69
57
  //# sourceMappingURL=McpCompileAssertions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpCompileAssertions.ts"],"names":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,WAAW,EAAE,sCAAsC;QACnD,aAAa,EAAE,KAAK;KACvB,CAAC;;;;8CAGD;AAGL,KAAK,kBAAkB,CAAC;AACxB,KAAK,iBAAiB,CAAC;AACvB,KAAK,gBAAgB,CAAC;AACtB,KAAK,eAAe,CAAC;AACrB,KAAK,eAAe,CAAC;AACrB,KAAK,qBAAqB,CAAC","sourcesContent":["import { WpMcpTool } from './McpMetadata';\nimport { WpDtoFieldOptions, WpDtoMapFieldOptions } from './DtoSchema';\n\nconst invalidEmptyEnum = new WpDtoFieldOptions(\n 'invalid enum',\n true,\n undefined,\n false,\n undefined,\n undefined,\n // @ts-expect-error enumValues must contain at least one allowed string\n [],\n);\n\n// @ts-expect-error a map's value type must be a scalar name or a DtoClass\nconst invalidMapValue = new WpDtoMapFieldOptions('invalid map', true, 'date');\n\n// @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions\nconst missingMapValue = new WpDtoMapFieldOptions('invalid map', true);\n\nconst noEighthFieldArgument = new WpDtoFieldOptions(\n 'maps are not a WpDtoFieldOptions argument',\n false,\n undefined,\n false,\n undefined,\n undefined,\n undefined,\n // @ts-expect-error maps use WpDtoMapFieldOptions; the 8th argument is only a WpMcpHeader\n 'string',\n);\n\nabstract class InvalidMcpContract {\n @WpMcpTool({\n name: 'invalid',\n description: 'This declaration must never compile.',\n // @ts-expect-error side-effect claims belong on @Endpoint.operation, never @WpMcpTool\n readOnlyHint: true,\n openWorldHint: false,\n })\n invalid(_request: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nabstract class InvalidMcpArities {\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'zero-arity',\n description: 'This declaration must never compile.',\n openWorldHint: false,\n })\n zero(): Promise<object> {\n throw new Error('contract only');\n }\n\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'multi-arity',\n description: 'This declaration must never compile.',\n openWorldHint: false,\n })\n multi(_first: object, _second: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nvoid InvalidMcpContract;\nvoid InvalidMcpArities;\nvoid invalidEmptyEnum;\nvoid invalidMapValue;\nvoid missingMapValue;\nvoid noEighthFieldArgument;\n"]}
1
+ {"version":3,"file":"McpCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C;;;;;GAKG;AACH,MAAe,kBAAkB;IAC7B,oFAAoF;IAEpF,OAAO,CAAC,QAAgB;QACpB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,sFAAsF;IAEtF,KAAK,CAAC,QAAgB;QAClB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AATG;IADC,IAAA,uBAAS,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;;;iDAG9B;AAID;IADC,IAAA,uBAAS,EAAC,SAAS,EAAE,IAAI,CAAC;;;;+CAG1B;AAGL,MAAe,iBAAiB;IAC5B,6DAA6D;IAE7D,IAAI;QACA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,6DAA6D;IAE7D,KAAK,CAAC,MAAc,EAAE,OAAe;QACjC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AATG;IADC,IAAA,uBAAS,EAAC,YAAY,CAAC;;;;6CAGvB;AAID;IADC,IAAA,uBAAS,EAAC,aAAa,CAAC;;;;8CAGxB;AAGL,KAAK,kBAAkB,CAAC;AACxB,KAAK,iBAAiB,CAAC","sourcesContent":["import { WpMcpTool } from './McpMetadata';\n\n/**\n * Compile-time pins for `@WpMcpTool`. These live in a COMPILED file rather than a `.spec.ts` because\n * vitest strips types with esbuild and `tsconfig.lib.json` excludes specs, so a `@ts-expect-error` in\n * a spec is inert (`.claude/rules/no-backwards-compat.md` shim shape #4). Here, tsc fails the build\n * with TS2578 the moment one of these starts compiling.\n */\nabstract class InvalidMcpContract {\n // @ts-expect-error @WpMcpTool takes the stable protocol NAME, not an options object\n @WpMcpTool({ name: 'invalid' })\n options(_request: object): Promise<object> {\n throw new Error('contract only');\n }\n\n // @ts-expect-error side-effect claims belong on @Endpoint.operation, never @WpMcpTool\n @WpMcpTool('invalid', true)\n hints(_request: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nabstract class InvalidMcpArities {\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool('zero-arity')\n zero(): Promise<object> {\n throw new Error('contract only');\n }\n\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool('multi-arity')\n multi(_first: object, _second: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nvoid InvalidMcpContract;\nvoid InvalidMcpArities;\n"]}
@@ -8,15 +8,6 @@ export declare class WpMcpToolHints {
8
8
  readonly openWorldHint: boolean;
9
9
  constructor(readOnlyHint: boolean, destructiveHint: boolean, idempotentHint: boolean, openWorldHint: boolean);
10
10
  }
11
- type CommonToolOptions = {
12
- /** Stable protocol name. Renaming this breaks saved agent workflows. */
13
- name: string;
14
- /** Tool-level documentation published verbatim by tools/list. */
15
- description: string;
16
- openWorldHint: boolean;
17
- };
18
- /** Tool-specific declarations. Side-effect hints come only from the endpoint operation. */
19
- export type WpMcpToolOptions = CommonToolOptions;
20
11
  type AsyncObjectMethod = (...args: never[]) => Promise<object>;
21
12
  type ExactOneParameter<TMethod extends AsyncObjectMethod> = Parameters<TMethod>['length'] extends 1 ? object : never;
22
13
  type ExactOneMethodDescriptor<TMethod extends AsyncObjectMethod> = TypedPropertyDescriptor<TMethod> & ExactOneParameter<TMethod>;
@@ -26,18 +17,33 @@ export type WpMcpMethodDecorator = <TMethod extends AsyncObjectMethod>(target: o
26
17
  export declare class WpMcpToolMetadata {
27
18
  readonly methodName: string;
28
19
  readonly name: string;
29
- readonly description: string;
30
- readonly openWorldHint: boolean;
31
- constructor(methodName: string, name: string, description: string, openWorldHint: boolean);
20
+ constructor(methodName: string, name: string);
32
21
  }
33
22
  /**
34
- * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool.
23
+ * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool, under
24
+ * the STABLE protocol name given here.
25
+ *
26
+ * The name is the whole argument, and deliberately the only one. It is independent of the method
27
+ * name because renaming a method must not break a saved agent workflow, and nothing else about a
28
+ * tool is unsayable in the source:
29
+ *
30
+ * | fact | where it comes from |
31
+ * |---|---|
32
+ * | `description` | the method's JSDoc body, or its `@mcp` tag — the same words the partner reads |
33
+ * | `readOnlyHint` / `destructiveHint` / `idempotentHint` | `@Endpoint`'s `operation`, via {@link mcpHintsForOperation} |
34
+ * | `openWorldHint` | `@Endpoint`'s `openWorld` option |
35
+ * | `inputSchema` / `outputSchema` | the declared request and response types |
36
+ *
37
+ * ```typescript
38
+ * @WpMcpTool('search_stores')
39
+ * ```
35
40
  *
36
- * This annotation owns tool-level documentation only. Input/output field documentation and JSON
37
- * Schema come from the request/response DTO metadata. The endpoint's `@WpAuth*` annotation remains
38
- * the sole runtime authorization policy.
41
+ * Until #984 it also took a `description`, duplicating the JSDoc. Two authored copies of one
42
+ * paragraph drift the first time somebody edits one, and nothing catches it — the partner reads the
43
+ * OpenAPI text and the agent reads the decorator text. With `description` gone the options object
44
+ * held one field, so it is a plain string and `WpMcpToolOptions` is deleted with it.
39
45
  */
40
- export declare function WpMcpTool(options: WpMcpToolOptions): WpMcpMethodDecorator;
46
+ export declare function WpMcpTool(name: string): WpMcpMethodDecorator;
41
47
  /** The one mapping from endpoint side effects to MCP advisory annotations. */
42
48
  export declare function mcpHintsForOperation(operation: EndpointOperation, openWorldHint: boolean): WpMcpToolHints;
43
49
  /** Returns only methods explicitly opted in through {@link WpMcpTool}. */
@@ -25,35 +25,45 @@ exports.WpMcpToolHints = WpMcpToolHints;
25
25
  class WpMcpToolMetadata {
26
26
  methodName;
27
27
  name;
28
- description;
29
- openWorldHint;
30
- constructor(methodName, name, description, openWorldHint) {
28
+ constructor(methodName, name) {
31
29
  this.methodName = methodName;
32
30
  this.name = name;
33
- this.description = description;
34
- this.openWorldHint = openWorldHint;
35
31
  }
36
32
  }
37
33
  exports.WpMcpToolMetadata = WpMcpToolMetadata;
38
34
  /**
39
- * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool.
35
+ * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool, under
36
+ * the STABLE protocol name given here.
37
+ *
38
+ * The name is the whole argument, and deliberately the only one. It is independent of the method
39
+ * name because renaming a method must not break a saved agent workflow, and nothing else about a
40
+ * tool is unsayable in the source:
40
41
  *
41
- * This annotation owns tool-level documentation only. Input/output field documentation and JSON
42
- * Schema come from the request/response DTO metadata. The endpoint's `@WpAuth*` annotation remains
43
- * the sole runtime authorization policy.
42
+ * | fact | where it comes from |
43
+ * |---|---|
44
+ * | `description` | the method's JSDoc body, or its `@mcp` tag — the same words the partner reads |
45
+ * | `readOnlyHint` / `destructiveHint` / `idempotentHint` | `@Endpoint`'s `operation`, via {@link mcpHintsForOperation} |
46
+ * | `openWorldHint` | `@Endpoint`'s `openWorld` option |
47
+ * | `inputSchema` / `outputSchema` | the declared request and response types |
48
+ *
49
+ * ```typescript
50
+ * @WpMcpTool('search_stores')
51
+ * ```
52
+ *
53
+ * Until #984 it also took a `description`, duplicating the JSDoc. Two authored copies of one
54
+ * paragraph drift the first time somebody edits one, and nothing catches it — the partner reads the
55
+ * OpenAPI text and the agent reads the decorator text. With `description` gone the options object
56
+ * held one field, so it is a plain string and `WpMcpToolOptions` is deleted with it.
44
57
  */
45
58
  // webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope
46
- function WpMcpTool(options) {
47
- if (options.name.trim() === '')
59
+ function WpMcpTool(name) {
60
+ if (name.trim() === '')
48
61
  throw new Error('@WpMcpTool requires a non-empty stable name.');
49
- if (options.description.trim() === '') {
50
- throw new Error('@WpMcpTool requires non-empty tool documentation.');
51
- }
52
62
  return (target, propertyKey, _descriptor) => {
53
63
  const apiClass = target.constructor;
54
64
  const tools = Reflect.getMetadata(decorators_1.METADATA_KEYS.MCP_TOOLS, apiClass) ?? {};
55
65
  const methodName = String(propertyKey);
56
- tools[methodName] = new WpMcpToolMetadata(methodName, options.name, options.description, options.openWorldHint);
66
+ tools[methodName] = new WpMcpToolMetadata(methodName, name);
57
67
  Reflect.defineMetadata(decorators_1.METADATA_KEYS.MCP_TOOLS, tools, apiClass);
58
68
  };
59
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"McpMetadata.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpMetadata.ts"],"names":[],"mappings":";;;AA8DA,8BAsBC;AAID,oDAYC;AAID,sCAIC;AA5GD,4BAA0B;AAC1B,mDAAmD;AACnD,qEAKqC;AAErC,wFAAwF;AACxF,MAAa,cAAc;IAEH;IACA;IACA;IACA;IAJpB,YACoB,YAAqB,EACrB,eAAwB,EACxB,cAAuB,EACvB,aAAsB;QAHtB,iBAAY,GAAZ,YAAY,CAAS;QACrB,oBAAe,GAAf,eAAe,CAAS;QACxB,mBAAc,GAAd,cAAc,CAAS;QACvB,kBAAa,GAAb,aAAa,CAAS;IACvC,CAAC;CACP;AAPD,wCAOC;AA2BD,4DAA4D;AAC5D,MAAa,iBAAiB;IAEN;IACA;IACA;IACA;IAJpB,YACoB,UAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,aAAsB;QAHtB,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,kBAAa,GAAb,aAAa,CAAS;IACvC,CAAC;CACP;AAPD,8CAOC;AAED;;;;;;GAMG;AACH,iGAAiG;AACjG,SAAgB,SAAS,CAAC,OAAyB;IAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IA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,CAAC,WAAW,CAAC,0BAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { METADATA_KEYS } from '../http/decorators';\nimport {\n EndpointOperation,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n} from '../http/HttpEndpointOptions';\n\n/** The immutable hints MCP clients use when deciding whether and how to call a tool. */\nexport class WpMcpToolHints {\n constructor(\n public readonly readOnlyHint: boolean,\n public readonly destructiveHint: boolean,\n public readonly idempotentHint: boolean,\n public readonly openWorldHint: boolean,\n ) {}\n}\n\ntype CommonToolOptions = {\n /** Stable protocol name. Renaming this breaks saved agent workflows. */\n name: string;\n /** Tool-level documentation published verbatim by tools/list. */\n description: string;\n openWorldHint: boolean;\n};\n\n/** Tool-specific declarations. Side-effect hints come only from the endpoint operation. */\nexport type WpMcpToolOptions = CommonToolOptions;\n\ntype AsyncObjectMethod = (...args: never[]) => Promise<object>;\ntype ExactOneParameter<TMethod extends AsyncObjectMethod> = Parameters<TMethod>['length'] extends 1\n ? object\n : never;\ntype ExactOneMethodDescriptor<TMethod extends AsyncObjectMethod> =\n TypedPropertyDescriptor<TMethod> & ExactOneParameter<TMethod>;\n\n/** Method decorator restricted to one request DTO and one async response DTO. */\nexport type WpMcpMethodDecorator = <TMethod extends AsyncObjectMethod>(\n target: object,\n propertyKey: string | symbol,\n descriptor: ExactOneMethodDescriptor<TMethod>,\n) => void;\n\n/** Runtime metadata for one explicitly exposed endpoint. */\nexport class WpMcpToolMetadata {\n constructor(\n public readonly methodName: string,\n public readonly name: string,\n public readonly description: string,\n public readonly openWorldHint: boolean,\n ) {}\n}\n\n/**\n * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool.\n *\n * This annotation owns tool-level documentation only. Input/output field documentation and JSON\n * Schema come from the request/response DTO metadata. The endpoint's `@WpAuth*` annotation remains\n * the sole runtime authorization policy.\n */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpMcpTool(options: WpMcpToolOptions): WpMcpMethodDecorator {\n if (options.name.trim() === '') throw new Error('@WpMcpTool requires a non-empty stable name.');\n if (options.description.trim() === '') {\n throw new Error('@WpMcpTool requires non-empty tool documentation.');\n }\n return <TMethod extends AsyncObjectMethod>(\n target: object,\n propertyKey: string | symbol,\n _descriptor: ExactOneMethodDescriptor<TMethod>,\n ): void => {\n const apiClass = target.constructor;\n const tools: Record<string, WpMcpToolMetadata> =\n Reflect.getMetadata(METADATA_KEYS.MCP_TOOLS, apiClass) ?? {};\n const methodName = String(propertyKey);\n tools[methodName] = new WpMcpToolMetadata(\n methodName,\n options.name,\n options.description,\n options.openWorldHint,\n );\n Reflect.defineMetadata(METADATA_KEYS.MCP_TOOLS, tools, apiClass);\n };\n}\n\n/** The one mapping from endpoint side effects to MCP advisory annotations. */\n// webpieces-disable no-function-outside-class -- pure metadata mapping shared by MCP registration\nexport function mcpHintsForOperation(\n operation: EndpointOperation,\n openWorldHint: boolean,\n): WpMcpToolHints {\n switch (operation) {\n case READ:\n return new WpMcpToolHints(true, false, true, openWorldHint);\n case WRITE_IDEMPOTENT:\n return new WpMcpToolHints(false, true, true, openWorldHint);\n case WRITE:\n return new WpMcpToolHints(false, true, false, openWorldHint);\n }\n}\n\n/** Returns only methods explicitly opted in through {@link WpMcpTool}. */\n// webpieces-disable no-function-outside-class -- metadata reader paired with the decorator\nexport function getWpMcpTools(apiClass: Function): WpMcpToolMetadata[] {\n const tools: Record<string, WpMcpToolMetadata> =\n Reflect.getMetadata(METADATA_KEYS.MCP_TOOLS, apiClass) ?? {};\n return Object.values(tools);\n}\n"]}
1
+ {"version":3,"file":"McpMetadata.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpMetadata.ts"],"names":[],"mappings":";;;AA6DA,8BAcC;AAID,oDAYC;AAID,sCAIC;AAnGD,4BAA0B;AA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CAAC;QAChB,KAAK,0BAAI;YACL,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAChE,KAAK,sCAAgB;YACjB,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAChE,KAAK,2BAAK;YACN,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrE,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,2FAA2F;AAC3F,SAAgB,aAAa,CAAC,QAAkB;IAC5C,MAAM,KAAK,GACP,OAAO,CAAC,WAAW,CAAC,0BAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { METADATA_KEYS } from '../http/decorators';\nimport { EndpointOperation, READ, WRITE_IDEMPOTENT, WRITE } from '../http/HttpEndpointOptions';\n\n/** The immutable hints MCP clients use when deciding whether and how to call a tool. */\nexport class WpMcpToolHints {\n constructor(\n public readonly readOnlyHint: boolean,\n public readonly destructiveHint: boolean,\n public readonly idempotentHint: boolean,\n public readonly openWorldHint: boolean,\n ) {}\n}\n\ntype AsyncObjectMethod = (...args: never[]) => Promise<object>;\ntype ExactOneParameter<TMethod extends AsyncObjectMethod> = Parameters<TMethod>['length'] extends 1\n ? object\n : never;\ntype ExactOneMethodDescriptor<TMethod extends AsyncObjectMethod> =\n TypedPropertyDescriptor<TMethod> & ExactOneParameter<TMethod>;\n\n/** Method decorator restricted to one request DTO and one async response DTO. */\nexport type WpMcpMethodDecorator = <TMethod extends AsyncObjectMethod>(\n target: object,\n propertyKey: string | symbol,\n descriptor: ExactOneMethodDescriptor<TMethod>,\n) => void;\n\n/** Runtime metadata for one explicitly exposed endpoint. */\nexport class WpMcpToolMetadata {\n constructor(\n public readonly methodName: string,\n public readonly name: string,\n ) {}\n}\n\n/**\n * Explicitly publishes an existing `@Endpoint(POST, path, WRITE, RPC)` method as an MCP tool, under\n * the STABLE protocol name given here.\n *\n * The name is the whole argument, and deliberately the only one. It is independent of the method\n * name because renaming a method must not break a saved agent workflow, and nothing else about a\n * tool is unsayable in the source:\n *\n * | fact | where it comes from |\n * |---|---|\n * | `description` | the method's JSDoc body, or its `@mcp` tag — the same words the partner reads |\n * | `readOnlyHint` / `destructiveHint` / `idempotentHint` | `@Endpoint`'s `operation`, via {@link mcpHintsForOperation} |\n * | `openWorldHint` | `@Endpoint`'s `openWorld` option |\n * | `inputSchema` / `outputSchema` | the declared request and response types |\n *\n * ```typescript\n * @WpMcpTool('search_stores')\n * ```\n *\n * Until #984 it also took a `description`, duplicating the JSDoc. Two authored copies of one\n * paragraph drift the first time somebody edits one, and nothing catches it — the partner reads the\n * OpenAPI text and the agent reads the decorator text. With `description` gone the options object\n * held one field, so it is a plain string and `WpMcpToolOptions` is deleted with it.\n */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpMcpTool(name: string): WpMcpMethodDecorator {\n if (name.trim() === '') throw new Error('@WpMcpTool requires a non-empty stable name.');\n return <TMethod extends AsyncObjectMethod>(\n target: object,\n propertyKey: string | symbol,\n _descriptor: ExactOneMethodDescriptor<TMethod>,\n ): void => {\n const apiClass = target.constructor;\n const tools: Record<string, WpMcpToolMetadata> =\n Reflect.getMetadata(METADATA_KEYS.MCP_TOOLS, apiClass) ?? {};\n const methodName = String(propertyKey);\n tools[methodName] = new WpMcpToolMetadata(methodName, name);\n Reflect.defineMetadata(METADATA_KEYS.MCP_TOOLS, tools, apiClass);\n };\n}\n\n/** The one mapping from endpoint side effects to MCP advisory annotations. */\n// webpieces-disable no-function-outside-class -- pure metadata mapping shared by MCP registration\nexport function mcpHintsForOperation(\n operation: EndpointOperation,\n openWorldHint: boolean,\n): WpMcpToolHints {\n switch (operation) {\n case READ:\n return new WpMcpToolHints(true, false, true, openWorldHint);\n case WRITE_IDEMPOTENT:\n return new WpMcpToolHints(false, true, true, openWorldHint);\n case WRITE:\n return new WpMcpToolHints(false, true, false, openWorldHint);\n }\n}\n\n/** Returns only methods explicitly opted in through {@link WpMcpTool}. */\n// webpieces-disable no-function-outside-class -- metadata reader paired with the decorator\nexport function getWpMcpTools(apiClass: Function): WpMcpToolMetadata[] {\n const tools: Record<string, WpMcpToolMetadata> =\n Reflect.getMetadata(METADATA_KEYS.MCP_TOOLS, apiClass) ?? {};\n return Object.values(tools);\n}\n"]}
@@ -0,0 +1,83 @@
1
+ import { ApiJsonSchema } from './DtoSchema';
2
+ import { WpMcpToolHints } from './McpMetadata';
3
+ /**
4
+ * ONE MCP tool, as `tools/list` publishes it.
5
+ *
6
+ * It is BUILT from the source by `@webpieces/api-doc-model`'s `McpSchemaRenderer` at build time, and
7
+ * READ here at boot — so the tool an agent is shown and the tool the server accepts are the same
8
+ * bytes by construction, not by two declarations agreeing.
9
+ *
10
+ * It lives in `core-util` rather than in the extractor package because both ends need it and only
11
+ * one end may depend on the TypeScript compiler API. `ApiJsonSchema` and {@link WpMcpToolHints},
12
+ * which it is made of, are already here for the same reason.
13
+ */
14
+ export declare class McpToolDefinition {
15
+ /** The stable protocol name from `@WpMcpTool('...')`. */
16
+ readonly name: string;
17
+ /** The contract method it was rendered from, so a mismatch report can name the source. */
18
+ readonly methodName: string;
19
+ /**
20
+ * The tool documentation: the method's `@mcp` tag when it has one, its JSDoc body otherwise.
21
+ * Documentation has exactly ONE source — the doc comment above the declaration — for the
22
+ * partner reading OpenAPI and the agent reading `tools/list` alike.
23
+ */
24
+ readonly description: string;
25
+ /**
26
+ * All four hints. Three are COMPUTED from `@Endpoint`'s `operation` by
27
+ * `mcpHintsForOperation`, which is the one place that mapping lives; `openWorldHint` comes
28
+ * from `@Endpoint`'s `openWorld` option.
29
+ */
30
+ readonly hints: WpMcpToolHints;
31
+ readonly inputSchema: ApiJsonSchema;
32
+ readonly outputSchema: ApiJsonSchema;
33
+ constructor(
34
+ /** The stable protocol name from `@WpMcpTool('...')`. */
35
+ name: string,
36
+ /** The contract method it was rendered from, so a mismatch report can name the source. */
37
+ methodName: string,
38
+ /**
39
+ * The tool documentation: the method's `@mcp` tag when it has one, its JSDoc body otherwise.
40
+ * Documentation has exactly ONE source — the doc comment above the declaration — for the
41
+ * partner reading OpenAPI and the agent reading `tools/list` alike.
42
+ */
43
+ description: string,
44
+ /**
45
+ * All four hints. Three are COMPUTED from `@Endpoint`'s `operation` by
46
+ * `mcpHintsForOperation`, which is the one place that mapping lives; `openWorldHint` comes
47
+ * from `@Endpoint`'s `openWorld` option.
48
+ */
49
+ hints: WpMcpToolHints, inputSchema: ApiJsonSchema, outputSchema: ApiJsonSchema);
50
+ }
51
+ /** Thrown when the catalog a server was handed is not a catalog this release can read. */
52
+ export declare class McpToolCatalogError extends Error {
53
+ /** What to do instead, in one sentence. */
54
+ readonly cure: string;
55
+ constructor(message: string,
56
+ /** What to do instead, in one sentence. */
57
+ cure: string);
58
+ }
59
+ /**
60
+ * Every MCP tool one build published, keyed by protocol name — the artifact `wp-openapi` writes as
61
+ * `mcp-tools.json` and `WpMcpServer` is constructed with.
62
+ *
63
+ * A tool the build never saw is a tool whose schema nobody checked, so `McpToolRegistry` fails fast
64
+ * at boot rather than publishing a shape derived from a second source.
65
+ */
66
+ export declare class McpToolCatalog {
67
+ readonly tools: readonly McpToolDefinition[];
68
+ private readonly byName;
69
+ constructor(tools: readonly McpToolDefinition[]);
70
+ find(name: string): McpToolDefinition | undefined;
71
+ /** The names this catalog carries, sorted, so a failure can print what WAS published. */
72
+ names(): readonly string[];
73
+ /** The bytes `wp-openapi` writes. Sorted by name so the artifact is diffable. */
74
+ toJsonText(): string;
75
+ /**
76
+ * Reads `mcp-tools.json`. Every nested value is rebuilt as a real class instance, because this is
77
+ * the one place untyped bytes become the schemas a live protocol surface publishes.
78
+ *
79
+ * Malformed JSON is not caught here: it throws `SyntaxError` to the caller's own top-level
80
+ * handler, which is where every other read-the-world failure in webpieces is reported.
81
+ */
82
+ static fromJsonText(text: string): McpToolCatalog;
83
+ }