home-mcp: Command for Claude Code

.claude/commands/tool-create.md

tool-create is a command for Claude Code from shenjingnan/home-mcp. It costs 5 tokens per session (1,561 once invoked), scanned A, original, MIT.

A command template for creating a new MCP tool, an extension that lets an AI agent call a service or device. It covers requirements, file structure, service implementation, types, tests, and documentation.

In plain words
What is it for?
Use it to scaffold a Home Assistant-related MCP tool in TypeScript, define its parameters and API, implement the service, and create tests and docs.
Why use it?
It provides a repeatable starting structure so a new tool does not miss its implementation, validation, testing, or documentation pieces.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: positional $N argument.

This is shenjingnan/home-mcp's own configuration. It tells Claude Code how to work on home-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything home-mcp configures →

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import type { HassState, ServiceData } from "../types";.

Reuse

Borrowing it

Nothing to install: this file belongs to shenjingnan/home-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/shenjingnan/home-mcp/main/.claude/commands/tool-create.md
Clone the repo
git clone --depth 1 https://github.com/shenjingnan/home-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tool-create

README.md
[![agentmods](https://agentmods.dev/badge/commands/shenjingnan/home-mcp/tool-create.svg)](https://agentmods.dev/commands/shenjingnan/home-mcp/tool-create)
Your own site
<a href="https://agentmods.dev/commands/shenjingnan/home-mcp/tool-create"><img src="https://agentmods.dev/badge/commands/shenjingnan/home-mcp/tool-create.svg" alt="Measured on agentmods" height="20"></a>
Per session 5 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,561 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00005 $0.01561
Opus 5 $0.00003 $0.00781
Sonnet 5 $0.00001 $0.00312
Haiku 4.5 $0.00001 $0.00156

Measured 8d ago against content hash f1b8294382f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

tool-create scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/tool-create.md · 184 lines

How it starts

The opening of the file, as written. The whole thing — 184 lines — stays where its author put it; the contents beside it link to each section on GitHub.

$1 $2

我需要在项目中创建一个新的MCP工具。请帮我完成完整的开发流程:

1. 分析需求

基于我提供的工具名称 <tool-name> 和描述 <tool-description>

  • 确定工具类型:属于哪种Home Assistant设备或服务控制
  • 分析参数需求:确定输入参数的类型和验证规则
  • 设计API接口:定义工具的方法签名和返回格式

2. 生成文件结构

创建以下标准文件:

src/
├── services/
│   └── {kebab-tool-name}.ts          # 工具实现类
├── types/
│   └── {kebab-tool-name}.ts          # 类型定义
└── test/
    └── {kebab-tool-name}.test.ts     # 测试文件

docs/content/mcp-tools/
└── {kebab-tool-name}.mdx             # 工具文档

3. 服务类实现模式

基于现有 LightService 模式:

3.1 基础结构

import { Param, Tool } from "bestmcp";
import { z } from "zod";
import type { HassState, ServiceData } from "../types";

interface IHassService {
  getStates(params?: { entity_id?: string }): Promise<HassState[]>;
  callServices(params: { domain: string; service: string; service_data: Record<string, unknown> }): Promise<{
    changed_states?: HassState[];
  }>;
}

export class {ToolName}Service {
  private static hassServiceInstance: IHassService | null = null;

  public static setHassService(hassService: IHassService) {
    {ToolName}Service.hassServiceInstance = hassService;
  }

  private getHassService(): IHassService {
    if (!{ToolName}Service.hassServiceInstance) {
      throw new Error("{ToolName}Service 未初始化,请先调用 setHassService()");
    }
    return {ToolName}Service.hassServiceInstance;
  }

  @Tool("{工具描述}")
  public async {ToolName}(
    // 参数定义...
  ) {
    // 实现逻辑...
  }
}

3.2 标准方法模式

  • 设备查找getEntitiesByName() 方法
  • 参数验证:使用 Zod schema 进行严格类型检查
  • 错误处理:统一的错误处理和用户友好的错误消息
  • 状态更新:调用 Home Assistant 服务并返回结果

4. 类型定义标准

基于现有 types/light.ts 模式:

4.1 基础类型

  • 参数类型:工具方法的输入参数接口
  • 返回类型:工具方法的返回值接口
  • 错误类型:自定义错误类和错误代码
  • 配置类型:预设配置和常量定义

4.2 Home Assistant 集成

  • 服务参数Hass{ToolName}ServiceParams 接口
  • 状态信息{ToolName}DeviceInfo 接口
  • 控制结果{ToolName}ControlResult 接口

5. 测试文件模式

基于现有测试结构:

5.1 测试覆盖范围

  • 参数验证测试:Zod schema 验证逻辑
  • 服务调用测试:Home Assistant API 交互
  • 错误处理测试:各种错误场景
  • 边界条件测试:极值和异常输入

Read the full file on GitHub · 184 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 184 lines · 0 tokens per session scan A f1b8294382f9

Subscribe to this mod's changes

tool-create is a command published in the GitHub repository shenjingnan/home-mcp (21 stars, last pushed 7mo ago), licensed MIT. It adds 5 tokens to every session and 1,561 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.