mcp-ts-morph: Skill for Claude Code

.claude/skills/new-mcp-tool/SKILL.md

new-mcp-tool is a skill for Claude Code from SiroSuzume/mcp-ts-morph. It costs 116 tokens per session (1,654 once invoked), scanned A, original, MIT.

A development guide for adding a new TypeScript code-refactoring tool to an MCP server. It uses ts-morph, a library for analyzing and changing TypeScript code, and describes the related tests, registration, and documentation updates.

In plain words
What is it for?
Use it when creating a new ts-morph refactoring tool: write Vitest tests, implement the refactoring logic, register the MCP tool, add it to the tool aggregator, and update the README and project instructions.
Why use it?
Adding a tool touches several parts of a repository, so it is easy to omit tests, server registration, or documentation. The guide organizes those changes around test-first development, meaning tests are written before the implementation.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions CLAUDE.md.

This is SiroSuzume/mcp-ts-morph's own configuration. It tells Claude Code how to work on mcp-ts-morph 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 mcp-ts-morph configures →

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { initializeProject } from "../../ts-morph/_utils/ts-morph-project";.

Reuse

Borrowing it

Nothing to install: this file belongs to SiroSuzume/mcp-ts-morph. 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/SiroSuzume/mcp-ts-morph/main/.claude/skills/new-mcp-tool/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/SiroSuzume/mcp-ts-morph

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 new-mcp-tool

README.md
[![agentmods](https://agentmods.dev/badge/skills/sirosuzume/mcp-ts-morph/new-mcp-tool/github.svg)](https://agentmods.dev/skills/sirosuzume/mcp-ts-morph/new-mcp-tool)
Your own site
<a href="https://agentmods.dev/skills/sirosuzume/mcp-ts-morph/new-mcp-tool"><img src="https://agentmods.dev/badge/skills/sirosuzume/mcp-ts-morph/new-mcp-tool/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for new-mcp-tool

Your own site · 80×15
<a href="https://agentmods.dev/skills/sirosuzume/mcp-ts-morph/new-mcp-tool"><img src="https://agentmods.dev/badge/skills/sirosuzume/mcp-ts-morph/new-mcp-tool.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 116 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,654 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.00116 $0.01654
Opus 5 $0.00058 $0.00827
Sonnet 5 $0.00023 $0.00331
Haiku 4.5 $0.00012 $0.00165

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

Security

Grade A, and why

new-mcp-tool 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 11d 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/skills/new-mcp-tool/SKILL.md · 141 lines

How it starts

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

新しい MCP ツールを追加する

@sirosuzume/mcp-tsmorph-refactor に新ツールを 1 つ追加するときの定型手順。過去に README のツール表と CLAUDE.md のモジュール一覧が実態とドリフトしたため、ドキュメント追記まで含めて 1 つの作業として扱う。

t-wada 式 TDD で進める(テストファースト → レッド → グリーン → リファクタ)。ロジックは ts-morph レイヤーに置き、MCP レイヤーは薄い登録だけにする。

作成・更新するファイル一覧

新ツール名を仮に do_something_by_tsmorph、ロジックを src/ts-morph/do-something/ に置く場合:

  1. ts-morph ロジック: src/ts-morph/do-something/do-something.ts
    • 純粋関数として実装。initializeProject(tsconfigPath) で受け取った Project を引数に取り、結果オブジェクトを返す(または Result 型を検討)。
    • 例外は握りつぶさず、呼び出し側でメッセージ化できるよう投げる。
  2. コロケートテスト: src/ts-morph/do-something/do-something.test.ts
    • Vitest。仕様としてのテストを先に書く。Mock は極力使わず、使うときはコメントで理由を補足。
    • src/ts-morph/_test-utils/ のヘルパーで一時プロジェクトを組み立てる(既存テストを参照)。
    • 既知の落とし穴を必ずケース化: default export / 再エクスポート / パスエイリアス / node_modules 越し参照のうち、該当するもの。
  3. MCP 登録ファイル: src/mcp/tools/register-do-something-tool.ts
    • 既存の register-get-type-at-position-tool.ts を雛形にする(下記テンプレ)。
  4. aggregator へ登録: src/mcp/tools/ts-morph-tools.ts
    • import を 1 行追加し、registerTsMorphTools 内で registerDoSomethingTool(server); を呼ぶ。
  5. README.md:
    • 「提供されるツール」のツール表に 1 行追加([\do_something_by_tsmorph`](#do_something_by_tsmorph)`)。
    • 対応する詳細セクション(機能・ユースケース・必要な情報・注意)を追加。
  6. CLAUDE.md:
    • 「ts-morphレイヤー」のモジュール一覧に do-something/ を追加。
    • 「主要な機能と実装ファイル」に 1 行追加。

register-*.ts テンプレート

既存ツールに合わせた骨格。server.tool(name, description, zodSchema, handler) の 4 引数。

import { performance } from "node:perf_hooks";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { initializeProject } from "../../ts-morph/_utils/ts-morph-project";
import { doSomething } from "../../ts-morph/do-something/do-something";
import logger from "../../utils/logger";

// logger 自体が投げても MCP レスポンス生成を阻まないようにラップする
function safeLogError(error: unknown, toolArgs: Record<string, unknown>): void {
	try {
		logger.error({ err: error, toolArgs }, "Error executing do_something_by_tsmorph");
	} catch (loggerErr) {
		console.error("Failed to write error log:", loggerErr);
	}
}

function safeLogInfo(fields: Record<string, unknown>): void {
	try {
		logger.info(fields, "do_something_by_tsmorph tool finished");
	} catch (loggerErr) {
		console.error("Failed to write info log:", loggerErr);
	}
}

export function registerDoSomethingTool(server: McpServer): void {
	server.tool(
		"do_something_by_tsmorph",
		`[ts-morph] <一行サマリ>

## When to use
- ...

## When NOT to use
- ...

## Critical constraints
- All paths (\`tsconfigPath\`, ...) MUST be absolute.
- position は 1-based(line/column)。`,
		{
			tsconfigPath: z.string().describe("Path to the project's tsconfig.json file."),
			// ... 他パラメータ
		},
		async (args) => {
			const startTime = performance.now();
			let message = "";
			let isError = false;
			let duration = "0.00";
			const logArgs = { /* 主要 args */ };

			try {
				const project = initializeProject(args.tsconfigPath);
				const result = doSomething(project /*, ...args */);
				message = /* result を文字列化 */ "";
			} catch (error) {
				safeLogError(error, logArgs);
				message = `Error: ${error instanceof Error ? error.message : String(error)}`;
				isError = true;
			} finally {
				const endTime = performance.now();
				duration = ((endTime - startTime) / 1000).toFixed(2);
				safeLogInfo({
					status: isError ? "Failure" : "Success",
					durationMs: Number.parseFloat((endTime - startTime).toFixed(2)),
					...logArgs,
				});
				try {
					logger.flush();
				} catch (flushErr) {
					console.error("Failed to flush logs:", flushErr);
				}
			}

			return {
				content: [
					{
						type: "text",
						text: `${message}\nStatus: ${isError ? "Failure" : "Success"}\nProcessing time: ${duration} seconds`,
					},
				],
				isError,
			};
		},
	);
}

Read the full file on GitHub · 141 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. 11d ago First seen · 141 lines · 116 tokens per session scan A 9314a4a1a0f0

Subscribe to this mod's changes

new-mcp-tool is a skill published in the GitHub repository SiroSuzume/mcp-ts-morph (16 stars, last pushed 3mo ago), licensed MIT. It adds 116 tokens to every session and 1,654 once invoked, about $0.0006 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.

Related

Other skills, from other repositories

no-bare-casts

Writing as in TypeScript or TSX production code, modifying a file that contains a bare as cast, silencing a type error with a cast, encountering as unknown as, or reviewing a cast site.

prisma/orm · 52 tokens

aws-sst-development

SST v4 (Ion) expert for managing AWS resources as code with the Pulumi-backed framework.

sickn33/agentic-awesome-skills · 26 tokens

league-akari-shard-development

Use when creating, extending, refactoring, splitting, or reviewing League Akari main or renderer shards, including shard file organization, controller/loader/executor/handler boundaries, naming conventions, renderer TSX usage, platform guards, and public contract compatibility.

LeagueAkari/LeagueAkari · 58 tokens

dd-code-generation

Use pup CLI for immediate Datadog operations or generate code for integration into applications.

DataDog/pup · 16 tokens

fast-typescript-check

Keep www-sacred's TypeScript fast to type-check and fast to run. Use when touching the ASCII/canvas animation components (the only real per-frame code here), tightening type-check wall-clock, or auditing a change for runtime or compiler regressions. Scoped to this repo — a React 19 / Next.js 16 component library plus…

internet-development/www-sacred · 84 tokens

migrate-better-result-3

Migrate a TypeScript codebase from better-result 2.x to 3.0. Use when upgrading better-result across the TaggedError syntax, removed Result serialization helpers, recovery inference, matching, or retry APIs.

dmmulroy/better-result · 52 tokens