Skip to content

Commit 251f8ce

Browse files
committed
Rename mcp-registry server to tool-assistant
1 parent c3ca9f2 commit 251f8ce

File tree

4 files changed

+115
-100
lines changed

4 files changed

+115
-100
lines changed

mcp/mcp-cli/src/main/java/software/amazon/smithy/java/mcp/cli/commands/StartServer.java

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
package software.amazon.smithy.java.mcp.cli.commands;
77

8+
import static picocli.CommandLine.*;
9+
810
import java.io.IOException;
911
import java.util.ArrayList;
12+
import java.util.Arrays;
1013
import java.util.HashMap;
1114
import java.util.HashSet;
1215
import java.util.List;
@@ -15,8 +18,8 @@
1518
import java.util.concurrent.CompletableFuture;
1619
import java.util.concurrent.CopyOnWriteArraySet;
1720
import java.util.function.Supplier;
21+
import java.util.stream.Collectors;
1822
import picocli.CommandLine.Command;
19-
import picocli.CommandLine.Option;
2023
import picocli.CommandLine.Parameters;
2124
import picocli.CommandLine.Unmatched;
2225
import software.amazon.smithy.java.mcp.cli.ConfigUtils;
@@ -27,17 +30,17 @@
2730
import software.amazon.smithy.java.mcp.cli.model.GenericToolBundleConfig;
2831
import software.amazon.smithy.java.mcp.cli.model.McpBundleConfig;
2932
import software.amazon.smithy.java.mcp.cli.model.SmithyModeledBundleConfig;
30-
import software.amazon.smithy.java.mcp.registry.model.InstallToolInput;
31-
import software.amazon.smithy.java.mcp.registry.model.InstallToolOutput;
32-
import software.amazon.smithy.java.mcp.registry.model.SearchToolsInput;
33-
import software.amazon.smithy.java.mcp.registry.model.SearchToolsOutput;
34-
import software.amazon.smithy.java.mcp.registry.model.Tool;
35-
import software.amazon.smithy.java.mcp.registry.service.InstallToolOperation;
36-
import software.amazon.smithy.java.mcp.registry.service.McpRegistry;
37-
import software.amazon.smithy.java.mcp.registry.service.SearchToolsOperation;
3833
import software.amazon.smithy.java.mcp.server.McpServer;
3934
import software.amazon.smithy.java.mcp.server.StdioProxy;
4035
import software.amazon.smithy.java.mcp.server.ToolFilter;
36+
import software.amazon.smithy.java.mcp.toolassistant.model.InstallToolInput;
37+
import software.amazon.smithy.java.mcp.toolassistant.model.InstallToolOutput;
38+
import software.amazon.smithy.java.mcp.toolassistant.model.SearchToolsInput;
39+
import software.amazon.smithy.java.mcp.toolassistant.model.SearchToolsOutput;
40+
import software.amazon.smithy.java.mcp.toolassistant.model.Tool;
41+
import software.amazon.smithy.java.mcp.toolassistant.service.InstallToolOperation;
42+
import software.amazon.smithy.java.mcp.toolassistant.service.SearchToolsOperation;
43+
import software.amazon.smithy.java.mcp.toolassistant.service.ToolAssistant;
4144
import software.amazon.smithy.java.server.FilteredService;
4245
import software.amazon.smithy.java.server.OperationFilters;
4346
import software.amazon.smithy.java.server.RequestContext;
@@ -58,11 +61,12 @@
5861
@Command(name = "start-server", description = "Starts an MCP server.")
5962
public final class StartServer extends SmithyMcpCommand {
6063

61-
@Parameters(paramLabel = "TOOL_BUNDLES", description = "Name(s) of the Tool Bundles to expose in this MCP Server.")
62-
List<String> toolBundles;
64+
@Parameters(paramLabel = "MCP_SERVER_IDS",
65+
description = "Id(s) of MCP Servers to start and expose as a single MCP server.")
66+
List<String> mcpServerIds = List.of();
6367

64-
@Option(names = "--registry-server", description = "Serve the registry as an MCP server")
65-
boolean registryServer;
68+
@Option(names = {"--tool-assistant", "-ts"}, description = "Exposes a Tool Assistant to Search and Install tools")
69+
boolean toolAssistant;
6670

6771
@Unmatched
6872
List<String> additionalArgs;
@@ -82,9 +86,9 @@ public final class StartServer extends SmithyMcpCommand {
8286
public void execute(ExecutionContext context) throws IOException {
8387

8488
var config = context.config();
85-
// By default, load all available tools
86-
if (toolBundles == null || toolBundles.isEmpty()) {
87-
toolBundles = config.getToolBundles()
89+
// By default, load all available tools only if not in tool-assistant mode.
90+
if (!toolAssistant && mcpServerIds.isEmpty()) {
91+
mcpServerIds = config.getToolBundles()
8892
.entrySet()
8993
.stream()
9094
.filter(entry -> {
@@ -96,22 +100,22 @@ public void execute(ExecutionContext context) throws IOException {
96100
.toList();
97101
}
98102

99-
if (toolBundles.isEmpty() && !registryServer) {
100-
throw new IllegalArgumentException("No bundles installed");
103+
if (!toolAssistant && mcpServerIds.isEmpty()) {
104+
throw new IllegalArgumentException("No MCP servers installed");
101105
}
102106

103107
var registry = context.registry();
104108

105-
List<McpBundleConfig> toolBundleConfigs = new ArrayList<>(toolBundles.size());
109+
List<McpBundleConfig> toolBundleConfigs = new ArrayList<>(mcpServerIds.size());
106110

107-
for (var toolBundle : toolBundles) {
108-
var toolBundleConfig = config.getToolBundles().get(toolBundle);
111+
for (var id : mcpServerIds) {
112+
var toolBundleConfig = config.getToolBundles().get(id);
109113
if (toolBundleConfig == null) {
110-
var bundle = registry.getMcpBundle(toolBundle);
114+
var bundle = registry.getMcpBundle(id);
111115
if (bundle == null) {
112-
throw new IllegalArgumentException("Can't find a configured tool bundle for '" + toolBundle + "'.");
116+
throw new IllegalArgumentException("Can't find a configured MCP server for '" + id + "'.");
113117
} else {
114-
toolBundleConfig = ConfigUtils.addMcpBundle(config, toolBundle, bundle);
118+
toolBundleConfig = ConfigUtils.addMcpBundle(config, id, bundle);
115119
}
116120
}
117121
toolBundleConfigs.add(toolBundleConfig);
@@ -168,7 +172,7 @@ public void execute(ExecutionContext context) throws IOException {
168172
awaitCompletion = proxyServer::awaitCompletion;
169173
shutdownMethod = proxyServer::shutdown;
170174
} else {
171-
if (registryServer) {
175+
if (toolAssistant) {
172176
allowedTools = new CopyOnWriteArraySet<>();
173177
final SearchToolsOperation searchToolsOperation;
174178
if (registry instanceof SearchableRegistry searchableRegistry) {
@@ -180,8 +184,8 @@ public void execute(ExecutionContext context) throws IOException {
180184
};
181185
}
182186
allowedTools.add("InstallTool");
183-
services.put("registry-mcp",
184-
McpRegistry.builder()
187+
services.put("tool-assistant",
188+
ToolAssistant.builder()
185189
.addInstallToolOperation(new InstallTool(registry, config, allowedTools))
186190
.addSearchToolsOperation(searchToolsOperation)
187191
.build());
@@ -248,8 +252,7 @@ public SearchToolsOutput searchTools(SearchToolsInput input, RequestContext cont
248252
return SearchToolsOutput.builder()
249253
.tools(tools.stream()
250254
.map(t -> Tool.builder()
251-
.serverId(t.serverId())
252-
.toolName(t.toolName())
255+
.toolName(t.serverId() + "__" + t.toolName())
253256
.build())
254257
.toList())
255258
.build();
@@ -270,9 +273,13 @@ private InstallTool(Registry registry, Config config, Set<String> installedTools
270273

271274
@Override
272275
public InstallToolOutput installTool(InstallToolInput input, RequestContext context) {
273-
var tool = input.getTool();
274-
var toolName = tool.getToolName();
275-
var serverId = tool.getServerId();
276+
var tool = input.getToolName();
277+
var toolParts = tool.split("__");
278+
if (toolParts.length < 2) {
279+
throw new IllegalArgumentException("Invalid tool name");
280+
}
281+
var serverId = toolParts[0];
282+
var toolName = Arrays.stream(toolParts).skip(1).collect(Collectors.joining("__"));
276283
Bundle bundle;
277284
if (!config.getToolBundles().containsKey(serverId)) {
278285
bundle = registry.getMcpBundle(serverId);

mcp/mcp-schemas/model/registry.smithy

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
$version: "2"
2+
3+
namespace smithy.mcp.toolassistant
4+
5+
/// This service provides methods to search MCP Tools and install MCP servers.
6+
/// Be aware that tools installed using InstallTool are available as part of the ToolAssistant MCP server and the MCP serverId returned from search tool needs to be ignored while tool calling.
7+
service ToolAssistant {
8+
operations: [
9+
SearchTools
10+
InstallTool
11+
]
12+
}
13+
14+
/// You MUST use the SearchTools MCP tool whenever the current toolset is not sufficient to complete the task.
15+
/// Do not attempt to proceed with incomplete or inadequate tools.
16+
/// SearchTools returns a ranked list of tools relevant to the task description—always use it to expand your capabilities.
17+
/// If any required tool is missing, immediately install it using the InstallTool API.
18+
/// This process can and should be repeated: keep invoking SearchTools and InstallTool until you have the tools needed to complete the task successfully.
19+
/// Do not rely solely on the preloaded tools. Tool discovery and installation is a core part of your workflow.
20+
operation SearchTools {
21+
input := {
22+
/// Generate a concise tool description based on the current dialogue context.
23+
///
24+
/// Focus on the user’s intent, including specific actions, platforms, or systems mentioned.
25+
///
26+
/// Include concrete nouns, URLs, acronyms, or product names that help identify the task.
27+
///
28+
/// The goal is to create a search query that helps SearchTools return the most relevant tools.
29+
///
30+
/// Avoid vague or generic phrasing—be as specific and task-oriented as possible.
31+
///
32+
// Example
33+
///
34+
/// Dialogue: "Hi, can you help me create a code review? I use code.amazon.com"
35+
///
36+
/// Tool Description: "Create a code review on code.amazon.com"
37+
toolDescription: String
38+
39+
/// Number of tools to return based on relevance in descending order of relevance. If not specified, the default is 1
40+
@default(1)
41+
numberOfTools: Integer
42+
}
43+
44+
output := {
45+
/// List of MCP tools most relevant for the query, sorted by order of relevance,
46+
/// the first tool being the most relevant.
47+
@required
48+
tools: Tools
49+
}
50+
}
51+
52+
list Tools {
53+
member: Tool
54+
}
55+
56+
structure Tool {
57+
/// Name of this tool
58+
@required
59+
toolName: String
60+
}
61+
62+
/// Install a new MCP Tool for local use.
63+
/// Be aware that tools installed using InstallTool are available as part of the ToolAssistant MCP server.
64+
operation InstallTool {
65+
input := {
66+
/// The name of the MCP tool to install
67+
@required
68+
toolName: String
69+
}
70+
71+
output := {
72+
message: String
73+
}
74+
}

mcp/mcp-schemas/smithy-build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"runtimeTraits": ["smithy.api#documentation", "smithy.api#examples" ]
88
},
99
"java-server-codegen": {
10-
"service": "smithy.mcp.registry#McpRegistry",
11-
"namespace": "software.amazon.smithy.java.mcp.registry",
10+
"service": "smithy.mcp.toolassistant#ToolAssistant",
11+
"namespace": "software.amazon.smithy.java.mcp.toolassistant",
1212
"headerFile": "license.txt",
1313
"runtimeTraits": ["smithy.api#documentation", "smithy.api#examples" ]
1414
}

0 commit comments

Comments
 (0)