|
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | | -package spring.ai.mcp.client.util; |
| 16 | +package spring.ai.mcp.client.stdio; |
17 | 17 |
|
18 | 18 | import java.util.Map; |
| 19 | +import java.util.List; |
19 | 20 |
|
20 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; |
21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; |
22 | 23 | import com.fasterxml.jackson.databind.ObjectMapper; |
23 | | -import spring.ai.mcp.client.util.McpServerParameterParser.McpServers.McpServer; |
| 24 | +import spring.ai.mcp.client.stdio.ServerParametersParser.McpServerConfigurations.McpServerConfiguration; |
24 | 25 |
|
25 | 26 | /** |
26 | 27 | * @author Christian Tzolov |
27 | 28 | * @since 1.0.0 |
28 | 29 | */ |
29 | 30 |
|
30 | | -public class McpServerParameterParser { |
| 31 | +public class ServerParametersParser { |
31 | 32 |
|
32 | 33 | @JsonInclude(JsonInclude.Include.NON_ABSENT) |
33 | | - public record McpServers(// @formatter:off |
34 | | - @JsonProperty("mcpServers") Map<String, McpServer> mcpServers) { |
| 34 | + public record McpServerConfigurations(// @formatter:off |
| 35 | + @JsonProperty("mcpServers") Map<String, McpServerConfiguration> mcpServers) { |
35 | 36 |
|
36 | 37 | @JsonInclude(JsonInclude.Include.NON_ABSENT) |
37 | | - public record McpServer( |
| 38 | + public record McpServerConfiguration( |
38 | 39 | @JsonProperty("command") String command, |
39 | | - @JsonProperty("args") String[] args, |
| 40 | + @JsonProperty("args") List<String> args, |
40 | 41 | @JsonProperty("env") Map<String, String> env) { |
41 | 42 | } |
42 | 43 | } // @formatter:on |
@@ -72,10 +73,10 @@ public static void main(String[] args) throws Exception { |
72 | 73 | """; |
73 | 74 |
|
74 | 75 | // Deserialize JSON into McpServers |
75 | | - McpServers servers = objectMapper.readValue(jsonInput, McpServers.class); |
| 76 | + McpServerConfigurations servers = objectMapper.readValue(jsonInput, McpServerConfigurations.class); |
76 | 77 |
|
77 | 78 | // Access individual servers |
78 | | - for (Map.Entry<String, McpServer> entry : servers.mcpServers().entrySet()) { |
| 79 | + for (Map.Entry<String, McpServerConfiguration> entry : servers.mcpServers().entrySet()) { |
79 | 80 | System.out.println("Key: " + entry.getKey()); |
80 | 81 | System.out.println("Command: " + entry.getValue().command()); |
81 | 82 | System.out.println("Arguments: " + String.join(", ", entry.getValue().args())); |
|
0 commit comments