Mcp Tool Export
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" }
)
)Content copied to clipboard
Common naming strategies include:
Prefix:
{ "namespace_$it" }- adds a prefix to avoid conflictsUppercase:
{ it.uppercase() }- converts to uppercaseIdentity: 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_") }
)
)Content copied to clipboard
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_".