McpToolExport

Programmatically export MCP tools from Embabel ToolObject or LlmReference.

Naming Strategies

Tool names can be transformed using a StringTransformer naming strategy. This is useful for namespacing tools when exporting from multiple sources:

val export = McpToolExport.fromToolObject(
ToolObject(
objects = listOf(myToolInstance),
namingStrategy = { "myprefix_$it" }
)
)

Common naming strategies include:

  • Prefix: { "namespace_$it" } - adds a prefix to avoid conflicts

  • Uppercase: { it.uppercase() } - converts to uppercase

  • Identity: StringTransformer.IDENTITY - preserves original names

Filtering Tools

Tools can be filtered using ToolObject.filter:

val export = McpToolExport.fromToolObject(
ToolObject(
objects = listOf(myToolInstance),
filter = { it.startsWith("public_") }
)
)

LlmReference Naming

When using fromLlmReference, the LlmReference.namingStrategy is applied automatically, which prefixes tool names with the lowercased reference name. For example, an LlmReference named "MyAPI" will prefix all tools with "myapi_".

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val toolCallbacks: List<<Error class: unknown class>>

Tool callbacks referenced or exposed.