Skip to content

Commit 63ef9ff

Browse files
committed
Rename mcp-registry server to tool-assistant
1 parent c3ca9f2 commit 63ef9ff

File tree

4 files changed

+116
-100
lines changed

4 files changed

+116
-100
lines changed

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

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.io.IOException;
99
import java.util.ArrayList;
10+
import java.util.Arrays;
1011
import java.util.HashMap;
1112
import java.util.HashSet;
1213
import java.util.List;
@@ -15,8 +16,10 @@
1516
import java.util.concurrent.CompletableFuture;
1617
import java.util.concurrent.CopyOnWriteArraySet;
1718
import java.util.function.Supplier;
19+
import java.util.stream.Collectors;
20+
21+
import picocli.CommandLine;
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,14 +30,14 @@
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;
33+
import software.amazon.smithy.java.mcp.toolassistant.model.InstallToolInput;
34+
import software.amazon.smithy.java.mcp.toolassistant.model.InstallToolOutput;
35+
import software.amazon.smithy.java.mcp.toolassistant.model.SearchToolsInput;
36+
import software.amazon.smithy.java.mcp.toolassistant.model.SearchToolsOutput;
37+
import software.amazon.smithy.java.mcp.toolassistant.model.Tool;
38+
import software.amazon.smithy.java.mcp.toolassistant.service.InstallToolOperation;
39+
import software.amazon.smithy.java.mcp.toolassistant.service.ToolAssistant;
40+
import software.amazon.smithy.java.mcp.toolassistant.service.SearchToolsOperation;
3841
import software.amazon.smithy.java.mcp.server.McpServer;
3942
import software.amazon.smithy.java.mcp.server.StdioProxy;
4043
import software.amazon.smithy.java.mcp.server.ToolFilter;
@@ -48,6 +51,8 @@
4851
import software.amazon.smithy.mcp.bundle.api.model.Bundle;
4952
import software.amazon.smithy.mcp.bundle.api.model.GenericBundle;
5053

54+
import static picocli.CommandLine.*;
55+
5156
/**
5257
* Command to start a Smithy MCP server exposing specified tool bundles.
5358
* <p>
@@ -58,11 +63,11 @@
5863
@Command(name = "start-server", description = "Starts an MCP server.")
5964
public final class StartServer extends SmithyMcpCommand {
6065

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

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

6772
@Unmatched
6873
List<String> additionalArgs;
@@ -82,9 +87,9 @@ public final class StartServer extends SmithyMcpCommand {
8287
public void execute(ExecutionContext context) throws IOException {
8388

8489
var config = context.config();
85-
// By default, load all available tools
86-
if (toolBundles == null || toolBundles.isEmpty()) {
87-
toolBundles = config.getToolBundles()
90+
// By default, load all available tools only if not in tool-assistant mode.
91+
if (!toolAssistant && mcpServerIds.isEmpty()) {
92+
mcpServerIds = config.getToolBundles()
8893
.entrySet()
8994
.stream()
9095
.filter(entry -> {
@@ -96,22 +101,22 @@ public void execute(ExecutionContext context) throws IOException {
96101
.toList();
97102
}
98103

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

103108
var registry = context.registry();
104109

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

107-
for (var toolBundle : toolBundles) {
108-
var toolBundleConfig = config.getToolBundles().get(toolBundle);
112+
for (var id : mcpServerIds) {
113+
var toolBundleConfig = config.getToolBundles().get(id);
109114
if (toolBundleConfig == null) {
110-
var bundle = registry.getMcpBundle(toolBundle);
115+
var bundle = registry.getMcpBundle(id);
111116
if (bundle == null) {
112-
throw new IllegalArgumentException("Can't find a configured tool bundle for '" + toolBundle + "'.");
117+
throw new IllegalArgumentException("Can't find a configured MCP server for '" + id + "'.");
113118
} else {
114-
toolBundleConfig = ConfigUtils.addMcpBundle(config, toolBundle, bundle);
119+
toolBundleConfig = ConfigUtils.addMcpBundle(config, id, bundle);
115120
}
116121
}
117122
toolBundleConfigs.add(toolBundleConfig);
@@ -168,7 +173,7 @@ public void execute(ExecutionContext context) throws IOException {
168173
awaitCompletion = proxyServer::awaitCompletion;
169174
shutdownMethod = proxyServer::shutdown;
170175
} else {
171-
if (registryServer) {
176+
if (toolAssistant) {
172177
allowedTools = new CopyOnWriteArraySet<>();
173178
final SearchToolsOperation searchToolsOperation;
174179
if (registry instanceof SearchableRegistry searchableRegistry) {
@@ -180,8 +185,8 @@ public void execute(ExecutionContext context) throws IOException {
180185
};
181186
}
182187
allowedTools.add("InstallTool");
183-
services.put("registry-mcp",
184-
McpRegistry.builder()
188+
services.put("tool-assistant",
189+
ToolAssistant.builder()
185190
.addInstallToolOperation(new InstallTool(registry, config, allowedTools))
186191
.addSearchToolsOperation(searchToolsOperation)
187192
.build());
@@ -248,8 +253,7 @@ public SearchToolsOutput searchTools(SearchToolsInput input, RequestContext cont
248253
return SearchToolsOutput.builder()
249254
.tools(tools.stream()
250255
.map(t -> Tool.builder()
251-
.serverId(t.serverId())
252-
.toolName(t.toolName())
256+
.toolName(t.serverId() + "__" + t.toolName())
253257
.build())
254258
.toList())
255259
.build();
@@ -270,9 +274,13 @@ private InstallTool(Registry registry, Config config, Set<String> installedTools
270274

271275
@Override
272276
public InstallToolOutput installTool(InstallToolInput input, RequestContext context) {
273-
var tool = input.getTool();
274-
var toolName = tool.getToolName();
275-
var serverId = tool.getServerId();
277+
var tool = input.getToolName();
278+
var toolParts = tool.split("__");
279+
if (toolParts.length < 2) {
280+
throw new IllegalArgumentException("Invalid tool name");
281+
}
282+
var serverId = toolParts[0];
283+
var toolName = Arrays.stream(toolParts).skip(1).collect(Collectors.joining("__"));
276284
Bundle bundle;
277285
if (!config.getToolBundles().containsKey(serverId)) {
278286
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)