@@ -144,8 +144,8 @@ public static Config loadOrCreateConfig() throws IOException {
144
144
return config ;
145
145
}
146
146
147
- public static Path getBundleFileLocation (String bundleName ) {
148
- return BUNDLE_DIR .resolve (bundleName + ".json" );
147
+ public static Path getBundleFileLocation (String id ) {
148
+ return BUNDLE_DIR .resolve (id + ".json" );
149
149
}
150
150
151
151
/**
@@ -188,47 +188,47 @@ private static void addMcpBundleConfig(Config existingConfig, String name, McpBu
188
188
updateConfig (newConfig );
189
189
}
190
190
191
- public static Bundle getMcpBundle (String bundleName ) {
191
+ public static Bundle getMcpBundle (String id ) {
192
192
try {
193
193
return Bundle .builder ()
194
- .deserialize (JSON_CODEC .createDeserializer (Files .readAllBytes (getBundleFileLocation (bundleName ))))
194
+ .deserialize (JSON_CODEC .createDeserializer (Files .readAllBytes (getBundleFileLocation (id ))))
195
195
.build ();
196
196
} catch (IOException e ) {
197
197
throw new RuntimeException (e );
198
198
}
199
199
}
200
200
201
- public static void removeMcpBundle (Config currentConfig , String bundleName ) throws IOException {
201
+ public static void removeMcpBundle (Config currentConfig , String id ) throws IOException {
202
202
var builder = currentConfig .toBuilder ();
203
203
var newBundles = new LinkedHashMap <>(currentConfig .getToolBundles ());
204
- newBundles .remove (bundleName );
204
+ newBundles .remove (id );
205
205
builder .toolBundles (newBundles );
206
206
var newConfig = builder .build ();
207
207
updateConfig (newConfig );
208
- var bundleFile = getBundleFileLocation (bundleName );
208
+ var bundleFile = getBundleFileLocation (id );
209
209
Files .deleteIfExists (bundleFile );
210
210
// Remove wrapper script if it exists
211
- removeWrapperScript (bundleName );
211
+ removeWrapperScript (id );
212
212
}
213
213
214
- public static void addToClientConfigs (Config config , String name , Set <String > clients , McpServerConfig serverConfig )
214
+ public static void addToClientConfigs (Config config , String id , Set <String > clients , McpServerConfig serverConfig )
215
215
throws IOException {
216
- updateClientConfigs (config , name , clients , serverConfig );
216
+ updateClientConfigs (config , id , clients , serverConfig );
217
217
}
218
218
219
- public static void removeFromClientConfigs (Config config , String name , Set <String > clients ) throws IOException {
220
- updateClientConfigs (config , name , clients , null );
219
+ public static void removeFromClientConfigs (Config config , String id , Set <String > clients ) throws IOException {
220
+ updateClientConfigs (config , id , clients , null );
221
221
}
222
222
223
- private static void updateClientConfigs (Config config , String name , Set <String > clients , McpServerConfig newConfig )
223
+ private static void updateClientConfigs (Config config , String id , Set <String > clients , McpServerConfig newConfig )
224
224
throws IOException {
225
225
var clientConfigsToUpdate = getClientConfigsToUpdate (config , clients );
226
226
boolean isDelete = newConfig == null ;
227
227
for (var clientConfigs : clientConfigsToUpdate ) {
228
228
var filePath = Path .of (clientConfigs .getFilePath ());
229
229
if (Files .notExists (filePath )) {
230
230
System .out .printf ("Skipping updating Mcp config file for %s as the file path '%s' does not exist." ,
231
- name ,
231
+ id ,
232
232
filePath );
233
233
continue ;
234
234
}
@@ -243,11 +243,11 @@ private static void updateClientConfigs(Config config, String name, Set<String>
243
243
244
244
var map = new LinkedHashMap <>(currentMcpConfig .getMcpServers ());
245
245
if (isDelete ) {
246
- if (map .remove (name ) == null ) {
246
+ if (map .remove (id ) == null ) {
247
247
continue ;
248
248
}
249
249
} else {
250
- map .put (name , Document .of (newConfig ));
250
+ map .put (id , Document .of (newConfig ));
251
251
}
252
252
var newMcpConfig = McpServersClientConfig .builder ().mcpServers (map ).build ();
253
253
Files .write (filePath ,
@@ -283,10 +283,10 @@ private static Set<ClientConfig> getClientConfigsToUpdate(Config config, Set<Str
283
283
return clientConfigsToUpdate ;
284
284
}
285
285
286
- private static void writeMcpBundle (String toolBundleName , Bundle bundle )
286
+ private static void writeMcpBundle (String id , Bundle bundle )
287
287
throws IOException {
288
288
var serializedBundle = toJson (bundle );
289
- Files .write (getBundleFileLocation (toolBundleName ),
289
+ Files .write (getBundleFileLocation (id ),
290
290
serializedBundle ,
291
291
StandardOpenOption .TRUNCATE_EXISTING ,
292
292
StandardOpenOption .CREATE );
@@ -297,35 +297,35 @@ public static McpBundleConfig addMcpBundle(Config config, String toolBundleName,
297
297
return addMcpBundle (config , toolBundleName , bundle , false );
298
298
}
299
299
300
- public static McpBundleConfig addMcpBundle (Config config , String toolBundleName , Bundle bundle , boolean isLocal )
300
+ public static McpBundleConfig addMcpBundle (Config config , String id , Bundle bundle , boolean isLocal )
301
301
throws IOException {
302
302
var location = Location .builder ()
303
- .fileLocation (ConfigUtils .getBundleFileLocation (toolBundleName ).toString ())
303
+ .fileLocation (ConfigUtils .getBundleFileLocation (id ).toString ())
304
304
.build ();
305
305
var builder = McpBundleConfig .builder ();
306
306
switch (bundle .getValue ()) {
307
307
case SmithyMcpBundle smithyBundle -> builder .smithyModeled (SmithyModeledBundleConfig .builder ()
308
- .name (toolBundleName )
309
- .description (smithyBundle .getMetadata (). getDescription ())
308
+ .name (id )
309
+ .metadata (smithyBundle .getMetadata ())
310
310
.bundleLocation (location )
311
311
.local (isLocal )
312
312
.build ());
313
313
case GenericBundle genericBundle -> {
314
314
install (genericBundle .getInstall ());
315
315
builder .genericConfig (
316
316
GenericToolBundleConfig .builder ()
317
- .name (toolBundleName )
317
+ .name (id )
318
318
.local (isLocal )
319
319
.bundleLocation (location )
320
- .description (genericBundle .getMetadata (). getDescription ())
320
+ .metadata (genericBundle .getMetadata ())
321
321
.build ());
322
322
}
323
323
default -> throw new IllegalStateException ("Unexpected bundle type: " + bundle .type ());
324
324
}
325
325
326
326
var mcpBundleConfig = builder .build ();
327
- writeMcpBundle (toolBundleName , bundle );
328
- addMcpBundleConfig (config , toolBundleName , mcpBundleConfig );
327
+ writeMcpBundle (id , bundle );
328
+ addMcpBundleConfig (config , id , mcpBundleConfig );
329
329
return mcpBundleConfig ;
330
330
}
331
331
@@ -384,9 +384,9 @@ private static String captureProcessOutput(Process process) throws IOException {
384
384
}
385
385
}
386
386
387
- public static void createWrapperScript (String bundleName ) throws IOException {
388
- Path scriptPath = SHIMS_DIR .resolve (bundleName );
389
- String scriptContent = createScriptContent (bundleName );
387
+ public static void createWrapperScript (String id ) throws IOException {
388
+ Path scriptPath = SHIMS_DIR .resolve (id );
389
+ String scriptContent = createScriptContent (id );
390
390
391
391
Files .writeString (scriptPath , scriptContent , StandardOpenOption .CREATE , StandardOpenOption .TRUNCATE_EXISTING );
392
392
scriptPath .toFile ().setExecutable (true );
@@ -400,8 +400,8 @@ private static String createScriptContent(String bundleName) {
400
400
}
401
401
}
402
402
403
- public static void removeWrapperScript (String bundleName ) throws IOException {
404
- Path scriptPath = SHIMS_DIR .resolve (bundleName );
403
+ public static void removeWrapperScript (String id ) throws IOException {
404
+ Path scriptPath = SHIMS_DIR .resolve (id );
405
405
Files .deleteIfExists (scriptPath );
406
406
}
407
407
@@ -502,22 +502,22 @@ private static void printUnixPathInstructions(String shimsDirStr) {
502
502
}
503
503
504
504
public static void createWrapperAndUpdateClientConfigs (
505
- String name ,
505
+ String id ,
506
506
Bundle bundle ,
507
507
Config config ,
508
508
ClientsInput input
509
509
) throws IOException {
510
510
boolean shouldCreateWrapper = true ;
511
511
List <String > args = List .of ();
512
- String command = name ;
512
+ String command = id ;
513
513
if (bundle .getValue () instanceof GenericBundle genericBundle && genericBundle .isExecuteDirectly ()) {
514
514
command = genericBundle .getRun ().getExecutable ();
515
515
args = genericBundle .getRun ().getArgs ();
516
516
shouldCreateWrapper = false ;
517
517
}
518
518
519
519
if (shouldCreateWrapper ) {
520
- createWrapperScript (name );
520
+ createWrapperScript (id );
521
521
ensureMcpServersDirInPath ();
522
522
}
523
523
@@ -537,11 +537,11 @@ public static void createWrapperAndUpdateClientConfigs(
537
537
}
538
538
539
539
if (print ) {
540
- System .out .println ("You can add the following to your MCP Servers config to use " + name );
540
+ System .out .println ("You can add the following to your MCP Servers config to use " + id );
541
541
var serializedConfig = ByteBufferUtils .getBytes (JSON_CODEC .serialize (newClientConfig ));
542
542
System .out .println (new String (serializedConfig , StandardCharsets .UTF_8 ));
543
543
} else {
544
- addToClientConfigs (config , name , clientConfigs , newClientConfig );
544
+ addToClientConfigs (config , id , clientConfigs , newClientConfig );
545
545
}
546
546
}
547
547
}
0 commit comments