|
1 |
| -# MCP Mediator Docker Implementation |
| 1 | +# Docker MCP Server |
2 | 2 |
|
3 |
| -This module provides a implementation of a Model Context Protocol MCP server for Docker commands using the [`mcp_mediator`](https://github.com/makbn/mcp_mediator) core framework. |
4 |
| -Check all the supported commands [here](#supported-docker-commands-as-mcp-server-tools). |
| 3 | +This module provides a implementation of a Model Context Protocol MCP server for Docker commands using the [`mcp_mediator`](https://github.com/makbn/mcp_mediator) core framework. Docker MCP Servr uses the MCP Mediator automactic MCP Server generation feature to generate MCP Tools for the existing Docker commands using `@@McpTool` and minimal description. |
| 4 | + |
| 5 | +Check all the supported commands [here](#supported-docker-commands-as-mcp-server-tools). |
5 | 6 |
|
6 | 7 | 
|
7 | 8 |
|
@@ -73,6 +74,50 @@ using `java -jar` command. Or, you can create a standalone executable applicatio
|
73 | 74 | ```
|
74 | 75 | and this command creates an executable file: `'mcp-mediator-implementation-docker-[version]` that can be executed.
|
75 | 76 |
|
| 77 | + |
| 78 | +### Automatically generate MCP Tools |
| 79 | +As it mentioned before, this project uses [`MCP Mediator`](https://github.com/makbn/mcp_mediator) to generate MCP Tools from the existing Docker Service. In order to create MCP Tool, each method is annotated with `@McpTool` to provide a minimal information about the tool. |
| 80 | +Howeve, this step is not required and MCP Mediator can generate the MCP Tools withot using the `@McpTool` annotation. It generates the name and description automatically using method, class, and package name. |
| 81 | +To enable this feature, you can simply set `create for non-annotated methods` to be true: |
| 82 | +```java |
| 83 | + DefaultMcpMediator mediator = new DefaultMcpMediator(McpMediatorConfigurationBuilder.builder() |
| 84 | + .createDefault() |
| 85 | + .serverName(serverName) |
| 86 | + .serverVersion(serverVersion) |
| 87 | + .build()); |
| 88 | + mediator.registerHandler(McpServiceFactory.create(dockerClientService) |
| 89 | + .createForNonAnnotatedMethods(true) // set to true |
| 90 | +``` |
| 91 | +Keep that in mind, a proper `name` and `description` for MCP Tool can significantly improve the performance of the MCP client to identify and use the tool and generating automatic name and description based on the method, class, and package name can't provide the best peresntation. |
| 92 | +
|
| 93 | +
|
| 94 | +
|
| 95 | +
|
| 96 | +### Automatically Generate MCP Tools |
| 97 | +
|
| 98 | +This project integrates with [`MCP Mediator`](https://github.com/makbn/mcp_mediator) to automatically generate MCP Tools from existing Docker services. |
| 99 | +
|
| 100 | +Each method in the Docker service class can optionally be annotated with `@McpTool` to explicitly define the tool’s **name**, **description**, and other metadata. |
| 101 | +
|
| 102 | +However, annotation is **not required**—MCP Mediator supports automatic generation for **non-annotated methods** by inferring details from the method, class, and package names. To enable this behavior, set `createForNonAnnotatedMethods` to `true`: |
| 103 | +
|
| 104 | +```java |
| 105 | +DefaultMcpMediator mediator = new DefaultMcpMediator(McpMediatorConfigurationBuilder.builder() |
| 106 | + .createDefault() |
| 107 | + .serverName(serverName) |
| 108 | + .serverVersion(serverVersion) |
| 109 | + .build()); |
| 110 | +
|
| 111 | +mediator.registerHandler(McpServiceFactory.create(dockerClientService) |
| 112 | + .createForNonAnnotatedMethods(true)); // Enables support for non-annotated methods |
| 113 | +
|
| 114 | +``` |
| 115 | +
|
| 116 | +Check `io.github.makbn.mcp.mediator.docker.server.DockerMcpServer` for the full Mcp Mediator configuration. |
| 117 | +
|
| 118 | +
|
| 119 | +
|
| 120 | + |
76 | 121 | ### Supported CLI Options
|
77 | 122 |
|
78 | 123 | | Option | Description | Default |
|
|
0 commit comments