ahooks-mcp
English |Simplified Chinese
one for ahooks Designed Model Context Protocol (MCP) server - a high-quality and reliable React Hooks library.
feature
This MCP server provides comprehensive information on ahooks hooks, including:
- 📋 List all available hook names
- 🔍 Search for hooks by keywords
- 📚 Get detailed hook information (description, usage, parameters, return value)
- 🗂️ Browse hooks by category
- 📖 Get the complete documentation for any hook
install
npm install -g ahooks-mcpInstructions for use
Used in conjunction with Claude Desktop
Add the following configuration to the Claude Desktop configuration file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ahooks": {
"command": "ahooks-mcp"
}
}
}Used in conjunction with MCP client
You can also use this server in any MCP compatible client:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "node",
args: ["/path/to/ahooks-mcp/dist/index.js"],
});
const client = new Client({
name: "ahooks-client",
version: "1.0.0",
}, {
capabilities: {},
});
await client.connect(transport);Available tools
one get_all_hook_names
Get a list of all available ahooks hook names.
Example:
get_all_hook_names()two get_hook_info
Get detailed information about a specific hook.
Parameters:
name(string, required): Hook name (e.g. "useBoolean", "useRequest")
Example:
get_hook_info({ name: "useBoolean" })three search_hooks
Search for hooks by keywords in the name, description, or category.
Parameters:
keyword(string, required): Search keywords
Example:
search_hooks({ keyword: "state" })four get_hooks_by_category
Retrieve all hooks under a specific category.
Parameters:
category(string, required): Classification name (e.g. "State", "Effect", "DOM", "Request")
Example:
get_hooks_by_category({ category: "State" })five get_all_categories
Get a list of all available hook categories.
Example:
get_all_categories()six get_all_hooks
Get complete information on all ahooks hooks.
Example:
get_all_hooks()classification
The Ahooks library is organized according to the following categories:
- State: State management hooks (useBoolean, useToggle, usetState, etc.)
- EffectSide effect related hooks (useDebounce, useThrottle, useUpdating Effect, etc.)
- DOMDOM operation hooks (useEventListener, useClickAway, useHover, etc.)
- RequestAsynchronous request hooks (useRequest, useWebSocket)
- AdvancedAdvanced tool hooks (useMemoizedFn, useLatest)
- LifeCycleComponent lifecycle hooks (useMount, useUnmount)
- UIUI related hooks (useVirtualList)
Example Hooks
Some commonly used hooks:
useRequest-Powerful asynchronous data managementuseBoolean-Boolean state managementuseDebounce-Anti shake valueuseThrottle-Throttle valueuseLocalStorageState-Synchronization status with local storageuseEventListener-Elegant addEventListener wrapperuseClickAway-Detecting external clicks on elements- more. ..
development
# 安装依赖
npm install
# 构建项目
npm run build
# 开发监听模式
npm run watchPublish to npm
view PUBLISHING.md Understand detailed release instructions.
Quickly publish using automated scripts:
# 首次登录 npm
npm login
# 运行发布脚本(交互式)
./publish.shOr manually publish:
# 更新版本
npm version patch # 或 minor, major
# 发布到 npm
npm publishlink
license
MIT
