Discover and Export available Agent(s) as MCP Servers
Transform Java/Kotlin applications into Model Context Protocol (MCP) servers, exposing AI agents and goals as standardized MCP tools, resources, and prompts. Auto-configures Server-Sent Events (SSE) endpoints compatible with Claude Desktop and other MCP clients.
Maven:
<dependency>
<groupId>com.embabel.agent</groupId>
<artifactId>embabel-agent-mcpserver</artifactId>
<version>0.3.3</version>
</dependency>Gradle:
implementation("com.embabel.agent:embabel-agent-mcpserver:0.3.3")Configure execution mode in application.properties:
# Synchronous mode (default)
spring.ai.mcp.server.type=SYNC
# Application name
spring.application.name=my-agent-apiFor async mode:
spring.ai.mcp.server.type=ASYNCExport tools from Embabel objects:
import com.embabel.agent.mcpserver.McpToolExport
import com.embabel.agent.api.common.ToolObject
// Create tool object
val toolObject = ToolObject(
objects = listOf(myToolInstance)
)
// Export to MCP
val export = McpToolExport.fromToolObject(toolObject)Create a custom tool publisher:
import com.embabel.agent.mcpserver.McpExportToolCallbackPublisher
import org.springframework.ai.tool.ToolCallback
import org.springframework.stereotype.Service
@Service
class MyToolPublisher : McpExportToolCallbackPublisher {
override val toolCallbacks: List<ToolCallback>
get() = listOf(/* your tool callbacks */)
override fun infoString(verbose: Boolean?, indent: Int): String {
return "MyToolPublisher: ${toolCallbacks.size} tools"
}
}The server auto-discovers and registers publishers during initialization.
Export Embabel agents and goals as MCP tools with naming strategies and filtering. → Tool Export API | Tool Export Guide
Create extensible tool, resource, and prompt publishers as Spring beans. → Publisher APIs | Publisher Guide
Manage operations through unified interface supporting sync and async modes. → Server Strategy API | Mode Selection Guide
Auto-configuration based on execution mode via Spring Boot. → Configuration API | Configuration Guide
Build resource and prompt specifications with convenient factory methods. → Factory APIs | Resource Guide
Query and manage registered tools across execution modes. → Registry API
Core types for server info, execution modes, capabilities, and health status. → Domain Types API
Essential imports for typical usage:
// Tool export
import com.embabel.agent.mcpserver.McpToolExport
import com.embabel.agent.mcpserver.McpExportToolCallbackPublisher
// Publishers (choose based on mode)
import com.embabel.agent.mcpserver.sync.McpResourcePublisher
import com.embabel.agent.mcpserver.sync.McpPromptPublisher
import com.embabel.agent.mcpserver.async.McpAsyncResourcePublisher
import com.embabel.agent.mcpserver.async.McpAsyncPromptPublisher
// Factories (choose based on mode)
import com.embabel.agent.mcpserver.sync.SyncResourceSpecificationFactory
import com.embabel.agent.mcpserver.sync.McpPromptFactory
import com.embabel.agent.mcpserver.async.McpAsyncPromptFactory
// Server management
import com.embabel.agent.mcpserver.McpServerStrategy
import com.embabel.agent.mcpserver.ToolRegistry
// Domain types
import com.embabel.agent.mcpserver.domain.McpExecutionMode
import com.embabel.agent.mcpserver.domain.ServerInfo
// Spring AI
import org.springframework.ai.tool.ToolCallback
// Embabel types
import com.embabel.agent.api.common.ToolObject
import com.embabel.agent.api.common.LlmReference
// MCP protocol
import io.modelcontextprotocol.server.McpServerFeatures
import io.modelcontextprotocol.spec.McpSchemaSee Complete Import Reference for all available imports organized by use case.
| Property | Values | Default | Description |
|---|---|---|---|
spring.ai.mcp.server.type | SYNC, ASYNC | SYNC | Execution mode for MCP server |
spring.application.name | string | agent-api | Application name for publishers |
This library seamlessly integrates with Embabel Agent Framework to automatically expose:
No manual configuration needed - agents are auto-discovered and exported on initialization.