[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KVX0QF0DZ20V4C4HEEG827":3,"skill-same:01M6KVX0QF0DZ20V4C4HEEG827":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":6,"updatedAt":52,"install":53,"resources":66},"01M6KVX0QF0DZ20V4C4HEEG827","claude-sdk-tool-creation",null,"Building custom tools for Claude Agent SDK agents — the @tool decorator, schema dicts, return shape, error returns, and the mcp__server__tool naming gotcha. Read when adding a new tool to a Claude Agent SDK project, when you need to expose Python functions to Claude, or when designing tool boundaries.","Folken2\u002Fnuvel","Folken2","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F175213316?v=4","01M6KVPA04RKNPCC04H2G96FAS","Albert Folch","01M6KVPA43VNTA4PXSEB1TCD81",2,"MIT","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fnuvel\u002Fbackends\u002Fclaude_agent_sdk\u002Fskills\u002Fclaude-sdk-tool-creation\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"claude sdk tool creation","sdk","tool","creation","claude agent sdk","custom","for","you","naming","error","agent sdk","project","MCP","new tool","functions","shape","schema","read","server","python","2026-11-10 10:12:30",false,"---\nname: claude-sdk-tool-creation\ndescription: Building custom tools for Claude Agent SDK agents — the @tool decorator, schema dicts, return shape, error returns, and the mcp__server__tool naming gotcha. Read when adding a new tool to a Claude Agent SDK project, when you need to expose Python functions to Claude, or when designing tool boundaries.\n---\n\n# Building tools for the Claude Agent SDK\n\nTools in this SDK are not standalone functions — they're entries in an in-process MCP server. You define them with `@tool`, register them with `create_sdk_mcp_server`, and Claude calls them through that server like any other MCP-exposed tool. This is the only \"private\" mechanism worth knowing; once you internalize it, every other tool concept (permissions, naming, error handling) follows.\n\n## The minimal example\n\n```python\nfrom claude_agent_sdk import tool, create_sdk_mcp_server\n\n@tool(\"greet\", \"Greet a user by name\", {\"name\": str})\nasync def greet(args):\n    return {\"content\": [{\"type\": \"text\", \"text\": f\"Hello, {args['name']}!\"}]}\n\nserver = create_sdk_mcp_server(name=\"my-tools\", version=\"1.0.0\", tools=[greet])\n```\n\nThree things happen here. The decorator wraps the async function with metadata (`name`, `description`, `input_schema`). `create_sdk_mcp_server` bundles tools into one MCP server. The server is later passed to `ClaudeAgentOptions(mcp_servers={\"my-tools\": server})`.\n\n## The naming gotcha\n\nAfter registration, Claude does **not** see a tool named `greet`. It sees `mcp__my-tools__greet` — `mcp__\u003Cserver-name>__\u003Ctool-name>`. This matters in two places:\n\n1. **`allowed_tools` pre-approval**: to skip permission prompts you must list the qualified name: `allowed_tools=[\"mcp__my-tools__greet\"]`. Listing `\"greet\"` does nothing.\n2. **Hook matchers**: a `PreToolUse` matcher targeting your tool needs the qualified name (or a regex matching it).\n\nThe most common bug we see is `allowed_tools=[\"greet\"]` followed by surprise that the tool prompts on every call. Always use the qualified name.\n\n## Return shape\n\nTools return a dict shaped like an MCP tool result:\n\n```python\nreturn {\n    \"content\": [\n        {\"type\": \"text\", \"text\": \"human-readable result\"},\n    ],\n}\n```\n\nFor errors, set `is_error=True` at the top level and put the message in a text content block:\n\n```python\nreturn {\n    \"content\": [{\"type\": \"text\", \"text\": \"Division by zero\"}],\n    \"is_error\": True,\n}\n```\n\nDon't raise — Claude can't see the exception. Always return a result. If you raise, the SDK surfaces it as a generic protocol error and Claude is left without context to recover.\n\n## Schema is positional, not Pydantic\n\nThe third argument to `@tool` is a dict mapping parameter names to Python types:\n\n```python\n@tool(\"calc\", \"Calculate a + b\", {\"a\": float, \"b\": float})\n```\n\nSupported types: `str`, `int`, `float`, `bool`, `list`, `dict`. For richer schemas (enums, nested objects, descriptions on each field), pass a JSON Schema dict instead:\n\n```python\n@tool(\"send_email\", \"Send an email\", {\n    \"type\": \"object\",\n    \"properties\": {\n        \"to\":      {\"type\": \"string\", \"format\": \"email\"},\n        \"subject\": {\"type\": \"string\"},\n        \"urgent\":  {\"type\": \"boolean\", \"default\": False},\n    },\n    \"required\": [\"to\", \"subject\"],\n})\n```\n\nUse the dict shorthand for prototyping; switch to JSON Schema once you need defaults, descriptions, or constraints — Claude reads them and writes better tool calls.\n\n## When to split into multiple servers\n\nDefault: one server per agent. A handful of tools in one `tools\u002F` package, one `create_sdk_mcp_server` call.\n\nSplit when:\n- Tools have distinct **lifecycle** — e.g. one set needs DB connections at server start, another doesn't.\n- You want to **disable** half the tools via env config without touching code (`mcp_servers={\"core\": core, **({\"admin\": admin} if is_admin else {})}`).\n- A subagent should only see a subset of tools (each subagent gets its own `ClaudeAgentOptions` and you pick which servers to wire).\n\nDon't split for organizational reasons alone — Claude doesn't care, and you pay an extra `mcp__server__` prefix in every name.\n\n## Common patterns\n\nFor deeper patterns — long-running tools, streaming results, sharing state between tools, parameter validation, mocking in tests — see `references\u002Ftool-patterns.md`.\n\n## Quick reference\n\n| Concept | API |\n|---------|-----|\n| Define tool | `@tool(name, description, schema)` |\n| Bundle tools | `create_sdk_mcp_server(name, version, tools=[...])` |\n| Register server | `ClaudeAgentOptions(mcp_servers={\"name\": server})` |\n| Pre-approve | `allowed_tools=[\"mcp__name__toolname\"]` |\n| Tool callable name | `mcp__\u003Cserver>__\u003Ctool>` |\n| Error return | `{\"content\": [...], \"is_error\": True}` |\n","# Building tools for the Claude Agent SDK\n\nTools in this SDK are not standalone functions — they're entries in an in-process MCP server. You define them with `@tool`, register them with `create_sdk_mcp_server`, and Claude calls them through that server like any other MCP-exposed tool. This is the only \"private\" mechanism worth knowing; once you internalize it, every other tool concept (permissions, naming, error handling) follows.\n\n## The minimal example\n\n```python\nfrom claude_agent_sdk import tool, create_sdk_mcp_server\n\n@tool(\"greet\", \"Greet a user by name\", {\"name\": str})\nasync def greet(args):\n    return {\"content\": [{\"type\": \"text\", \"text\": f\"Hello, {args['name']}!\"}]}\n\nserver = create_sdk_mcp_server(name=\"my-tools\", version=\"1.0.0\", tools=[greet])\n```\n\nThree things happen here. The decorator wraps the async function with metadata (`name`, `description`, `input_schema`). `create_sdk_mcp_server` bundles tools into one MCP server. The server is later passed to `ClaudeAgentOptions(mcp_servers={\"my-tools\": server})`.\n\n## The naming gotcha\n\nAfter registration, Claude does **not** see a tool named `greet`. It sees `mcp__my-tools__greet` — `mcp__\u003Cserver-name>__\u003Ctool-name>`. This matters in two places:\n\n1. **`allowed_tools` pre-approval**: to skip permission prompts you must list the qualified name: `allowed_tools=[\"mcp__my-tools__greet\"]`. Listing `\"greet\"` does nothing.\n2. **Hook matchers**: a `PreToolUse` matcher targeting your tool needs the qualified name (or a regex matching it).\n\nThe most common bug we see is `allowed_tools=[\"greet\"]` followed by surprise that the tool prompts on every call. Always use the qualified name.\n\n## Return shape\n\nTools return a dict shaped like an MCP tool result:\n\n```python\nreturn {\n    \"content\": [\n        {\"type\": \"text\", \"text\": \"human-readable result\"},\n    ],\n}\n```\n\nFor errors, set `is_error=True` at the top level and put the message in a text content block:\n\n```python\nreturn {\n    \"content\": [{\"type\": \"text\", \"text\": \"Division by zero\"}],\n    \"is_error\": True,\n}\n```\n\nDon't raise — Claude can't see the exception. Always return a result. If you raise, the SDK surfaces it as a generic protocol error and Claude is left without context to recover.\n\n## Schema is positional, not Pydantic\n\nThe third argument to `@tool` is a dict mapping parameter names to Python types:\n\n```python\n@tool(\"calc\", \"Calculate a + b\", {\"a\": float, \"b\": float})\n```\n\nSupported types: `str`, `int`, `float`, `bool`, `list`, `dict`. For richer schemas (enums, nested objects, descriptions on each field), pass a JSON Schema dict instead:\n\n```python\n@tool(\"send_email\", \"Send an email\", {\n    \"type\": \"object\",\n    \"properties\": {\n        \"to\":      {\"type\": \"string\", \"format\": \"email\"},\n        \"subject\": {\"type\": \"string\"},\n        \"urgent\":  {\"type\": \"boolean\", \"default\": False},\n    },\n    \"required\": [\"to\", \"subject\"],\n})\n```\n\nUse the dict shorthand for prototyping; switch to JSON Schema once you need defaults, descriptions, or constraints — Claude reads them and writes better tool calls.\n\n## When to split into multiple servers\n\nDefault: one server per agent. A handful of tools in one `tools\u002F` package, one `create_sdk_mcp_server` call.\n\nSplit when:\n- Tools have distinct **lifecycle** — e.g. one set needs DB connections at server start, another doesn't.\n- You want to **disable** half the tools via env config without touching code (`mcp_servers={\"core\": core, **({\"admin\": admin} if is_admin else {})}`).\n- A subagent should only see a subset of tools (each subagent gets its own `ClaudeAgentOptions` and you pick which servers to wire).\n\nDon't split for organizational reasons alone — Claude doesn't care, and you pay an extra `mcp__server__` prefix in every name.\n\n## Common patterns\n\nFor deeper patterns — long-running tools, streaming results, sharing state between tools, parameter validation, mocking in tests — see `references\u002Ftool-patterns.md`.\n\n## Quick reference\n\n| Concept | API |\n|---------|-----|\n| Define tool | `@tool(name, description, schema)` |\n| Bundle tools | `create_sdk_mcp_server(name, version, tools=[...])` |\n| Register server | `ClaudeAgentOptions(mcp_servers={\"name\": server})` |\n| Pre-approve | `allowed_tools=[\"mcp__name__toolname\"]` |\n| Tool callable name | `mcp__\u003Cserver>__\u003Ctool>` |\n| Error return | `{\"content\": [...], \"is_error\": True}` |\n",{"name":5,"description":7},"main","41d246dd855999c6bc4be528bc8d0d1b10ac8c47","nuvel\u002Fbackends\u002Fclaude_agent_sdk\u002Fskills\u002Fclaude-sdk-tool-creation",1,"https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel","https:\u002F\u002Ffolken2.github.io\u002Fnuvel\u002F","https:\u002F\u002Fgithub.com\u002FFolken2","folch.ai","2026-11-05 22:40:38",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add Folken2\u002Fnuvel --skill claude-sdk-tool-creation",{"tool":59,"command":60},"bunx","bunx skills add Folken2\u002Fnuvel --skill claude-sdk-tool-creation",{"tool":62,"command":63},"pnpm","pnpm dlx skills add Folken2\u002Fnuvel --skill claude-sdk-tool-creation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fnuvel\u002Fbackends\u002Fclaude_agent_sdk\u002Fskills\u002Fclaude-sdk-tool-creation\u002FSKILL.md",true,[67],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Ftool-patterns.md","REFERENCE","参考文档",5266,"https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fnuvel\u002Fbackends\u002Fclaude_agent_sdk\u002Fskills\u002Fclaude-sdk-tool-creation\u002Freferences\u002Ftool-patterns.md",[74,83,94,115,131,145],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":39},"01M6KVZNJQ7AVMVBS205404CS7","greet","Greet a user warmly by name.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Ftests\u002Ftest_agent_plugins\u002Ffixtures\u002Fvalid-full\u002Fskills\u002Fgreet\u002FSKILL.md",[],[76,81,82],"user","name",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":39},"01M6KVZHYK2C9S5GRM3PZAFDXG","hello","A simple hello skill that survives a broken mcp.json.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Ftests\u002Ftest_agent_plugins\u002Ffixtures\u002Fbad-mcp\u002Fskills\u002Fhello\u002FSKILL.md",[],[85,31,90,91,92,93],"hello skill","json","broken","simple",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":39},"01M6KVZC94REQZ852EJ99ZXATK","grok-workflows","Prompt templates and workflows for using xAI GrokBot with Nuvel — code, design, research, and automated pipelines.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fplugins\u002Fgrokbot-plugin\u002Fskills\u002Fgrok-workflows\u002FSKILL.md",[],[101,102,103,104,105,106,107,108,109,110,111,112,113,25,114],"workflows","grok","grok workflows","design","research","prompt","prompt templates","code","templates","xai","grokbot","pipelines","with","nuvel",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":39},"01M6KVZ7BA5MJ1N614MTP2JXCQ","grok-setup","Configure xAI GrokBot with Nuvel API integration and project context for Nuvel-aligned development.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fplugins\u002Fgrokbot-plugin\u002Fskills\u002Fgrok-setup\u002FSKILL.md",[],[102,122,123,25,113,30,114,124,125,126,111,127,128,129,110,130],"grok setup","setup","project context","api integration","configure","development","integration","api","context",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":39},"01M6KVZ3WYQ6V6XVCRE77WT2WY","cursor-setup","Configure Cursor IDE with Nuvel rules, MCP server integration, and project settings for OrgMemory-aware development.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fplugins\u002Fcursor-plugin\u002Fskills\u002Fcursor-setup\u002FSKILL.md",[],[138,139,123,128,31,140,127,37,141,126,142,143,30,113,25,144,114],"cursor","cursor setup","mcp server","ide","Rules","settings","project settings",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":39},"01M6KVZ0GGSJM4AC8PK7G53H85","cursor-review","Use Cursor IDE with Nuvel OrgMemory to review changes — diff analysis, standards checking, and pre-commit review.","https:\u002F\u002Fgithub.com\u002FFolken2\u002Fnuvel\u002Fblob\u002Fmain\u002Fplugins\u002Fcursor-plugin\u002Fskills\u002Fcursor-review\u002FSKILL.md",[],[152,138,153,154,155,156,157,141,158,159,160,113,161,162,114],"cursor review","review","commit","review changes","pre-commit","analysis","use","diff","standards","changes","diff analysis"]