ports library

Port Contracts - Unified interfaces for MCP ecosystem.

This library exports all port contracts defined in mcp_bundle. Use this for accessing LLM, storage, metric, and event ports.

Example:

import 'package:mcp_bundle/ports.dart';

class MyLlmAdapter extends LlmPort {
  @override
  LlmCapabilities get capabilities => const LlmCapabilities.full();

  @override
  Future<LlmResponse> complete(LlmRequest request) async {
    // Implementation
  }
}

Classes

ChannelAttachment
Attachment in a channel event.
ChannelCapabilities
Capabilities of a channel implementation.
ChannelEvent
Event received from a channel.
ChannelIdentity
Identifies a channel platform (e.g., 'slack', 'telegram', 'http', 'websocket').
ChannelPort
Abstract port for bidirectional channel communication.
ChannelResponse
Response to send to a channel.
ConversationKey
Unique key for a conversation within a channel.
EchoChannelPort
Echo channel port that echoes back messages.
EmptyLlmPort
Empty LLM port that throws on use.
EventPort
Event port for pub/sub.
InMemoryEventPort
In-memory event port for testing.
InMemoryKvStoragePort
In-memory KV storage for testing.
InMemoryStoragePort<T>
In-memory typed storage for testing.
KvStoragePort
Key-value storage port.
LlmCapabilities
LLM capabilities configuration.
LlmChunk
Streaming chunk.
LlmMessage
LLM message for multi-turn conversations.
LlmPort
Abstract LLM Port interface.
LlmRequest
LLM request.
LlmResponse
LLM response.
LlmTool
Tool definition for function calling.
LlmToolCall
Tool call from LLM.
LlmUsage
Token usage information.
MetricEvent
Metric event for streaming.
MetricPort
Metric computation port.
MetricValue
Metric value.
PortEvent
Event data.
StoragePort<T>
Generic storage port for typed entities.
StubChannelPort
Stub channel port for testing.
StubLlmPort
Stub LLM port for testing.
StubMetricPort
Stub metric port for testing.

Functions

cosineSimilarity(List<double> a, List<double> b) double
Cosine similarity helper.