一键导入
add-mcp-tool
Step-by-step guide for adding a new MCP tool endpoint. Use when creating a new tool that Claude Desktop or other MCP clients can call.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Step-by-step guide for adding a new MCP tool endpoint. Use when creating a new tool that Claude Desktop or other MCP clients can call.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | add-mcp-tool |
| description | Step-by-step guide for adding a new MCP tool endpoint. Use when creating a new tool that Claude Desktop or other MCP clients can call. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep, Task |
Follow these steps in order when adding a new MCP tool to the server.
Create a new class in src/main/java/com/ohmydigital/mcpluceneserver/mcp/dto/.
Pattern:
public record MyToolRequest(
@Description("Description of the parameter")
String requiredParam,
@Nullable @Description("Optional parameter")
String optionalParam
) {
public static MyToolRequest fromMap(final Map<String, Object> map) {
return new MyToolRequest(
(String) map.get("requiredParam"),
(String) map.get("optionalParam")
);
}
}
@Description annotation for MCP schema generation@Nullable for optional fieldsfromMap() static factory methodCreate in the same mcp/dto/ directory.
Pattern:
public record MyToolResponse(
boolean success,
@Nullable String error,
// ... data fields
) {
public static MyToolResponse success(/* data params */) {
return new MyToolResponse(true, null, /* data */);
}
public static MyToolResponse error(final String message) {
return new MyToolResponse(false, message, /* nulls */);
}
}
All responses MUST include success (boolean) and error (nullable String).
In LuceneSearchTools.getToolSpecifications(), add a new ToolSpecification:
new ToolSpecification("myToolName", "Human-readable description", schemaJson)
Add a handler method in LuceneSearchTools:
private CallToolResult myToolName(final Map<String, Object> arguments) {
try {
final var request = MyToolRequest.fromMap(arguments);
// ... implementation
final var response = MyToolResponse.success(/* data */);
return new CallToolResult(List.of(new TextContent(objectMapper.writeValueAsString(response))));
} catch (final SpecificException e) {
logger.error("myToolName failed", e);
return new CallToolResult(List.of(new TextContent(
objectMapper.writeValueAsString(MyToolResponse.error(e.getMessage())))));
}
}
Wire the handler in the callTool() method's switch/if-else chain.
MANDATORY - Add tool documentation to README.md:
fromMap() methodsLook at these existing tools for patterns:
search() in LuceneSearchTools.javaoptimizeIndex() in LuceneSearchTools.javasetCrawlerDirectories() in LuceneSearchTools.javaDetailed architecture documentation including design decisions, processing patterns, and system internals. Use when discussing architecture, understanding why something was built a certain way, or planning significant changes.
Roadmap and analysis of potential improvements, design trade-offs, and feature priorities. Use when planning new features, evaluating what to build next, or understanding why certain approaches were chosen or rejected.
Guides for common development tasks like adding facet fields, file format support, STDIO debugging, and performance tuning. Use when working on specific development recipes.