Class MCP
java.lang.Object
com.codename1.mcp.MCP
Public entry point for the Codename One MCP headless API. Invoking a starter here is the enablement; there is no build hint or property to toggle. A single server instance exists per process.
This API is supported by the Codename One JavaSE port, which powers the simulator and the desktop tooling. It is not part of a packaged application build.
Typical usage
// Let a running tool or the simulator accept an attaching agent on a local port:
MCP.startSocketServer(8642);
// Or serve over stdio when a host launches the tool as a subprocess:
MCP.startStdioServer();
// Publish domain tools alongside the automatic UI driving tools:
MCP.addTool(myTool);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSupplies the platform loopback socket transport.static interfaceSupplies the platform stdio transport. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidRegisters a developer defined tool with the shared server.static MCPServerReturns the shared server, creating it on first use.static MCPVerbositystatic booleanstatic booleanWhether a loopback socket transport is available on this platform.static booleanWhether an stdio transport is available on this platform.static voidRegisters the platform socket transport factory.static voidRegisters the platform stdio transport factory.static voidsetVerbosity(MCPVerbosity verbosity) Sets how much of the MCP conversation is echoed to the Codename One log so a developer can watch and debug what an agent is doing.static MCPServerstartSocketServer(int port) Starts a loopback socket server so an agent can attach to this running process.static MCPServerStarts the stdio transport server (the standard MCP local transport).static voidstop()Stops the shared server if it is running.
-
Method Details
-
setStdioTransportFactory
Registers the platform stdio transport factory. Called by the JavaSE port. -
setSocketTransportFactory
Registers the platform socket transport factory. Called by the JavaSE port. -
isStdioSupported
public static boolean isStdioSupported()Whether an stdio transport is available on this platform. -
isSocketSupported
public static boolean isSocketSupported()Whether a loopback socket transport is available on this platform. -
getServer
Returns the shared server, creating it on first use. -
isRunning
public static boolean isRunning() -
startStdioServer
Starts the stdio transport server (the standard MCP local transport). Requires a platform stdio transport factory (registered by the JavaSE port). -
startSocketServer
Starts a loopback socket server so an agent can attach to this running process. Requires a platform socket transport factory (registered by the JavaSE port). -
stop
public static void stop()Stops the shared server if it is running. -
addTool
Registers a developer defined tool with the shared server. -
setVerbosity
Sets how much of the MCP conversation is echoed to the Codename One log so a developer can watch and debug what an agent is doing. -
getVerbosity
-