KS
Killer-Skills

mcp-tool-writer — how to use mcp-tool-writer how to use mcp-tool-writer, mcp-tool-writer setup guide, mcp-tool-writer alternative, mcp-tool-writer vs Core ML, what is mcp-tool-writer, mcp-tool-writer install for Naki project

v1.0.0
GitHub

About this Skill

Ideal for AI Agents working with Swift and Core ML, needing to create and modify MCP tools for the Naki project. mcp-tool-writer is a skill that enables the creation and modification of Model Context Protocol tools for the Naki project using a Protocol-based architecture.

Features

Utilizes Protocol-based architecture for MCP tool development
Supports Swift and Core ML for AI-powered projects
Creates and modifies MCP tools using MCPTool.swift and MCPContext.swift
Leverages MCPToolRegistry.swift for tool registration
Follows MCP 调用规则 for testing and development

# Core Topics

Sunalamye Sunalamye
[0]
[0]
Updated: 3/6/2026

Quality Score

Top 5%
60
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add Sunalamye/Naki/mcp-tool-writer

Agent Capability Analysis

The mcp-tool-writer MCP Server by Sunalamye is an open-source Categories.community integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use mcp-tool-writer, mcp-tool-writer setup guide, mcp-tool-writer alternative.

Ideal Agent Persona

Ideal for AI Agents working with Swift and Core ML, needing to create and modify MCP tools for the Naki project.

Core Value

Empowers agents to develop and modify MCP tools using Protocol-based architecture, leveraging Swift and Core ML for AI-powered projects, and utilizing the MCPTool.swift, MCPContext.swift, and MCPToolRegistry.swift components.

Capabilities Granted for mcp-tool-writer MCP Server

Creating custom MCP tools for Naki projects
Modifying existing MCP tools using Swift and Core ML
Developing AI-powered applications with MCP tools

! Prerequisites & Limits

  • Requires knowledge of Swift and Core ML
  • Specific to Naki project's Protocol-based architecture
  • Needs /naki-mcp-proxy skill for testing new MCP tools
Project
SKILL.md
6.6 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8

# Tags

[No tags]
SKILL.md
Readonly

Naki MCP Tool Writer

Base directory: {baseDir}

<IMPORTANT> **MCP 調用規則**: 測試新建的 MCP 工具時,使用 `/naki-mcp-proxy` skill 調用。 </IMPORTANT>

This skill helps create and modify MCP (Model Context Protocol) tools for the Naki project using the Protocol-based architecture.

Architecture Overview

Naki uses a Protocol-based MCP architecture:

command/Services/MCP/
├── MCPTool.swift          - Protocol 定義 + Schema 類型
├── MCPContext.swift       - 執行上下文 (async/await 支持)
├── MCPToolRegistry.swift  - 工具註冊表 (單例)
├── MCPHandler.swift       - MCP 協議處理器
└── Tools/
    ├── SystemTools.swift  - 系統類工具 (get_status, get_help, get_logs, clear_logs)
    ├── BotTools.swift     - Bot 控制工具 (bot_status, bot_trigger, bot_ops, bot_deep, bot_chi, bot_pon, bot_sync)
    ├── GameTools.swift    - 遊戲狀態工具 (game_state, game_hand, game_ops, game_discard, game_action)
    └── UITools.swift      - UI 操作工具 (execute_js, detect, explore, test_indicators, click, calibrate, ui_names_*)

Current Registered Tools (47 total)

CategoryCountExamples
System4get_status, get_help, get_logs, clear_logs
Bot7bot_status, bot_trigger, bot_ops, bot_deep, bot_chi, bot_pon, bot_sync
Game6game_state, game_hand, game_ops, game_discard, game_action, game_emoji
Highlight6highlight_tile, highlight_status, show_recommendations, hide_highlight
Emoji4game_emoji, game_emoji_list, game_emoji_random
Lobby9lobby_status, lobby_navigate, lobby_start_match, lobby_cancel_match
UI11execute_js, detect, explore, click, calibrate, ui_names_*

See /naki-mcp-proxy for complete tool catalog.

How to Create a New MCP Tool

Step 1: Define the Tool Struct

Create a new struct implementing MCPTool protocol in the appropriate Tools/*.swift file:

swift
1struct MyNewTool: MCPTool { 2 // 1. 工具名稱 (唯一標識符) 3 static let name = "my_new_tool" 4 5 // 2. 工具描述 (給 AI 看的說明) 6 static let description = "描述這個工具做什麼,何時使用" 7 8 // 3. 輸入參數 Schema 9 static let inputSchema = MCPInputSchema( 10 properties: [ 11 "param1": .string("參數1的描述"), 12 "param2": .integer("參數2的描述") 13 ], 14 required: ["param1"] // 必填參數 15 ) 16 17 // 4. 上下文 (用於訪問 JS、Bot 等) 18 private let context: MCPContext 19 20 init(context: MCPContext) { 21 self.context = context 22 } 23 24 // 5. 執行邏輯 25 func execute(arguments: [String: Any]) async throws -> Any { 26 guard let param1 = arguments["param1"] as? String else { 27 throw MCPToolError.missingParameter("param1") 28 } 29 30 // 執行邏輯... 31 32 return ["success": true, "result": "..."] 33 } 34}

Step 2: Register the Tool

MCPToolRegistry.swift:142-182registerBuiltInTools() 方法中添加:

swift
1register(MyNewTool.self)

注意: Tools 列表會自動從 Registry 生成,無需手動維護 JSON 檔案。

Input Schema Types

swift
1// 無參數 2static let inputSchema = MCPInputSchema.empty 3 4// 有參數 5static let inputSchema = MCPInputSchema( 6 properties: [ 7 "stringParam": .string("字串參數描述"), 8 "intParam": .integer("整數參數描述"), 9 "numberParam": .number("數字參數描述"), 10 "boolParam": .boolean("布林參數描述"), 11 "objectParam": .object("物件參數描述") 12 ], 13 required: ["stringParam"] // 必填參數列表 14)

Context API

工具可以通過 context 訪問以下功能(定義在 MCPContext.swift:15-38):

swift
1// 執行 JavaScript(async/await) 2let result = try await context.executeJavaScript("return document.title") 3 4// 獲取 Bot 狀態 5let status = context.getBotStatus() 6 7// 觸發自動打牌 8context.triggerAutoPlay() 9 10// 日誌操作 11let logs = context.getLogs() 12context.clearLogs() 13context.log("記錄訊息") 14 15// 服務器埠號 16let port = context.serverPort

⚠️ JavaScript 執行注意事項

重要context.executeJavaScript() 必須使用 return 語句才能正確返回值!

swift
1// ✅ 正確:使用 return 語句 2let title = try await context.executeJavaScript("return document.title") 3let sum = try await context.executeJavaScript("return 1 + 1") 4let json = try await context.executeJavaScript("return JSON.stringify({a:1})") 5 6// ❌ 錯誤:沒有 return,結果為 nil 7let title = try await context.executeJavaScript("document.title") // 返回 nil!

常見模式

swift
1// 調用遊戲 API 並返回 JSON 2let script = "return JSON.stringify(window.__nakiGameAPI.getGameState())" 3let result = try await context.executeJavaScript(script) 4 5// 執行操作並返回布林值 6let script = "return window.__nakiGameAPI.discardTile(0)" 7let success = try await context.executeJavaScript(script) as? Bool ?? false 8 9// 檢查 API 是否存在 10let script = "return typeof window.__nakiGameAPI !== 'undefined'" 11let exists = try await context.executeJavaScript(script) as? Bool ?? false

Error Handling

使用 MCPToolError(定義在 MCPTool.swift:129-147)處理錯誤:

swift
1throw MCPToolError.missingParameter("paramName") 2throw MCPToolError.invalidParameter("paramName", expected: "string") 3throw MCPToolError.executionFailed("原因描述") 4throw MCPToolError.notAvailable("資源名稱")

Tool Categories & File Locations

CategoryFileWhen to Add Here
系統SystemTools.swiftServer status, logs, help
BotBotTools.swiftBot control, AI inference
遊戲GameTools.swiftGame state, hand, actions
UIUITools.swiftJS execution, clicks, detection

Checklist for New Tools

  • 定義唯一的 name(snake_case 格式)
  • 寫清楚的 description(給 AI 理解,包含何時使用)
  • 定義正確的 inputSchema
  • 實現 execute() 方法(async throws)
  • 處理所有錯誤情況(使用 MCPToolError)
  • MCPToolRegistry.swift:142-182 中註冊
  • 構建測試通過
  • 使用 MCP 工具測試功能

Testing

構建並測試:

bash
1# 構建 2xcodebuild build -project Naki.xcodeproj -scheme Naki 3 4# 啟動應用後,使用 MCP 工具測試 5mcp__naki__<tool_name>

Reference Documentation

For detailed specifications and more examples, see:

  • Protocol Reference - Complete MCPTool protocol, context API, schema types, and code examples

Related Skills

Looking for an alternative to mcp-tool-writer or building a Categories.community AI Agent? Explore these related open-source MCP Servers.

View All

widget-generator

Logo of f
f

widget-generator is an open-source AI agent skill for creating widget plugins that are injected into prompt feeds on prompts.chat. It supports two rendering modes: standard prompt widgets using default PromptCard styling and custom render widgets built as full React components.

149.6k
0
Design

chat-sdk

Logo of lobehub
lobehub

chat-sdk is a unified TypeScript SDK for building chat bots across multiple platforms, providing a single interface for deploying bot logic.

73.0k
0
Communication

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication