Skip to content

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

typescript
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 ParameterDescription
TThe target DTO type

Constructors

Constructor

ts
new ToolAnnotationsConverterBase<T>(): ToolAnnotationsConverterBase<T>;

Returns

ToolAnnotationsConverterBase<T>

Inherited from

ConverterBase.constructor

Methods

convertFrom()

ts
abstract convertFrom(source): T;

Defined in: packages/core/src/converters/ConverterBase.ts:56

Convert a single source item to a target item.

Parameters

ParameterTypeDescription
sourceToolAnnotationsDomain model instance

Returns

T

The converted DTO

Inherited from

ConverterBase.convertFrom


convertFromBatch()

ts
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

ParameterTypeDescription
sourcesToolAnnotations[]Array of domain model instances

Returns

T[]

Array of converted DTOs (nulls removed)

Inherited from

ConverterBase.convertFromBatch


convertTo()

ts
abstract convertTo(target): ToolAnnotations;

Defined in: packages/core/src/converters/ConverterBase.ts:77

Convert a single target item back to a source item.

Parameters

ParameterTypeDescription
targetTDTO instance

Returns

ToolAnnotations

The domain model instance

Inherited from

ConverterBase.convertTo


convertToBatch()

ts
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

ParameterTypeDescription
targetsT[]Array of DTOs

Returns

ToolAnnotations[]

Array of domain model instances (nulls removed)

Inherited from

ConverterBase.convertToBatch