Abstract Class: ToolAnnotationsConverterBase<T>
Defined in: packages/core/src/converters/ToolAnnotationsConverter.ts:33
Base class for ToolAnnotations converters.
Extend this and implement convertFrom(annotations) and convertTo(dto).
Example
class MyAnnotationsConverter extends ToolAnnotationsConverterBase<McpAnnotations> {
convertFrom(ta: ToolAnnotations): McpAnnotations {
return { readOnly: ta.readOnlyHint ?? false, destructive: ta.destructiveHint ?? false };
}
convertTo(mcp: McpAnnotations): ToolAnnotations {
return createToolAnnotations({ readOnlyHint: mcp.readOnly, destructiveHint: mcp.destructive });
}
}See
ConverterBase for batch conversion methods
Extends
Type Parameters
| Type Parameter | Description |
|---|---|
T | The target DTO type |
Constructors
Constructor
new ToolAnnotationsConverterBase<T>(): ToolAnnotationsConverterBase<T>;Returns
ToolAnnotationsConverterBase<T>
Inherited from
Methods
convertFrom()
abstract convertFrom(source): T;Defined in: packages/core/src/converters/ConverterBase.ts:56
Convert a single source item to a target item.
Parameters
| Parameter | Type | Description |
|---|---|---|
source | ToolAnnotations | Domain model instance |
Returns
T
The converted DTO
Inherited from
convertFromBatch()
convertFromBatch(sources): T[];Defined in: packages/core/src/converters/ConverterBase.ts:44
Convert a batch of source items to target items. Null/undefined results from single-item conversion are filtered out.
Parameters
| Parameter | Type | Description |
|---|---|---|
sources | ToolAnnotations[] | Array of domain model instances |
Returns
T[]
Array of converted DTOs (nulls removed)
Inherited from
ConverterBase.convertFromBatch
convertTo()
abstract convertTo(target): ToolAnnotations;Defined in: packages/core/src/converters/ConverterBase.ts:77
Convert a single target item back to a source item.
Parameters
| Parameter | Type | Description |
|---|---|---|
target | T | DTO instance |
Returns
The domain model instance
Inherited from
convertToBatch()
convertToBatch(targets): ToolAnnotations[];Defined in: packages/core/src/converters/ConverterBase.ts:65
Convert a batch of target items back to source items. Null/undefined results from single-item conversion are filtered out.
Parameters
| Parameter | Type | Description |
|---|---|---|
targets | T[] | Array of DTOs |
Returns
Array of domain model instances (nulls removed)