# Class MCP

java.lang.Object
com.codename1.mcp.MCP

public final class MCP extends Object

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 Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `MCP.SocketTransportFactory`
  Supplies the platform loopback socket transport.
  `static interface`
  `MCP.StdioTransportFactory`
  Supplies the platform stdio transport.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addTool(Tool tool)`
  Registers a developer defined tool with the shared server.
  `static MCPServer`
  `getServer()`
  Returns the shared server, creating it on first use.
  `static MCPVerbosity`
  `getVerbosity()`
  `static boolean`
  `isRunning()`
  `static boolean`
  `isSocketSupported()`
  Whether a loopback socket transport is available on this platform.
  `static boolean`
  `isStdioSupported()`
  Whether an stdio transport is available on this platform.
  `static void`
  `setSocketTransportFactory(MCP.SocketTransportFactory factory)`
  Registers the platform socket transport factory.
  `static void`
  `setStdioTransportFactory(MCP.StdioTransportFactory factory)`
  Registers the platform stdio transport factory.
  `static void`
  `setVerbosity(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 MCPServer`
  `startSocketServer(int port)`
  Starts a loopback socket server so an agent can attach to this running process.
  `static MCPServer`
  `startStdioServer()`
  Starts the stdio transport server (the standard MCP local transport).
  `static void`
  `stop()`
  Stops the shared server if it is running.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### setStdioTransportFactory

    public static void setStdioTransportFactory(MCP.StdioTransportFactory factory)
    Registers the platform stdio transport factory. Called by the JavaSE port.

  - ### setSocketTransportFactory

    public static void setSocketTransportFactory(MCP.SocketTransportFactory factory)
    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

    public static MCPServer getServer()
    Returns the shared server, creating it on first use.

  - ### isRunning

    public static boolean isRunning()

  - ### startStdioServer

    public static MCPServer startStdioServer()
    Starts the stdio transport server (the standard MCP local transport). Requires a platform stdio transport factory (registered by the JavaSE port).

  - ### startSocketServer

    public static MCPServer startSocketServer(int port)
    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

    public static void addTool(Tool tool)
    Registers a developer defined tool with the shared server.

  - ### setVerbosity

    public static void setVerbosity(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.

  - ### getVerbosity

    public static MCPVerbosity getVerbosity()