遵循 ClawDirect 模式,使用基于 ATXP 的身份验证构建面向代理的 Web 体验。在构建 AI 代理通过 MCP 工具与之交互的网站、实施基于 cookie 的代理身份验证或为 Web 应用程序创建代理技能时,请使用此技能。使用@longrun/turtle 提供模板
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install clawdirect-dev或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install clawdirect-dev⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/clawdirect-dev/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: clawdirect-dev description: Build agent-facing web experiences with ATXP-based authentication, following the ClawDirect pattern. Use this skill when building websites that AI agents interact with via MCP tools, implementing cookie-based agent auth, or creating agent skills for web apps. Provides templates using @longrun/turtle, Express, SQLite, and ATXP. ---
Build agent-facing web experiences with ATXP-based authentication.
Reference implementation: https://github.com/napoleond/clawdirect
ATXP (Agent Transaction Protocol) enables AI agents to authenticate and pay for services. When building agent-facing websites, ATXP provides:
For full ATXP details: https://skills.sh/atxp-dev/cli/atxp
Agents interact with your site in two ways:
The cookie-based auth pattern bridges these: agents get an auth cookie via MCP, then use it while browsing.
Important: Agent browsers often cannot set HTTP-only cookies directly. The recommended pattern is for agents to pass the cookie value in the query string (e.g., ?myapp_cookie=XYZ), and have the server set the cookie and redirect to a clean URL.
┌──────────────────────────────────────────────────────────────────┐
│ AI Agent │
│ ┌─────────────────────┐ ┌─────────────────────────┐ │
│ │ Browser Tool │ │ MCP Client │ │
│ │ (visits website) │ │ (calls tools) │ │
│ └─────────┬───────────┘ └───────────┬─────────────┘ │
└────────────┼─────────────────────────────────┼──────────────────┘
│ │
▼ ▼
┌────────────────────────────────────────────────────────────────┐
│ Your Application │
│ ┌─────────────────────┐ ┌─────────────────────────┐ │
│ │ Web Server │ │ MCP Server │ │
│ │ (Express) │ │ (@longrun/turtle) │ │
│ │ │ │ │ │
│ │ - Serves UI │ │ - yourapp_cookie │ │
│ │ - Cookie auth │ │ - yourapp_action │ │
│ └─────────┬───────────┘ └───────────┬─────────────┘ │
│ │ │ │
│ └──────────┬─────────────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ SQLite │ │
│ │ auth_cookies │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Initialize a Node.js project with the required stack:
mkdir my-agent-app && cd my-agent-app
npm init -y
npm install @longrun/turtle @atxp/server @atxp/express better-sqlite3 express cors dotenv zod
npm install -D typescript @types/node @types/express @types/cors @types/better-sqlite3 tsx
Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*"]
}
Create .env:
FUNDING_DESTINATION_ATXP=<your_atxp_account>
PORT=3001
Create src/db.ts:
import Database from 'better-sqlite3';
import crypto from 'crypto';
const DB_PATH = process.env.DB_PATH || './data.db';
let db: Database.Database;
export function getDb(): Database.Database {
if (!db) {
db = new Database(DB_PATH);
db.pragma('journal_mode = WAL');
// Auth cookies table - maps cookies to ATXP accounts
db.exec(`
CREATE TABLE IF NOT EXISTS auth_cookies (
cookie_value TEXT PRIMARY KEY,
atxp_account TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Add your app's tables here
}
return db;
}
export function createAuthCookie(atxpAccount: string): string {
const cookieValue = crypto.randomBytes(32).toString('hex');
getDb().prepare(`
INSERT INTO auth_cookies (cookie_value, atxp_account)
VALUES (?, ?)
`).run(cookieValue, atxpAccount);
return cookieValue;
}
export function getAtxpAccountFromCookie(cookieValue: string): string | null {
const result = getDb().prepare(`
SELECT atxp_account FROM auth_cookies WHERE cookie_value = ?
`).get(cookieValue) as { atxp_account: string } | undefined;
return result?.atxp_account || null;
}
Create src/tools.ts:
import { defineTool } from '@longrun/turtle';
import { z } from 'zod';
import { requirePayment, atxpAccountId } from '@atxp/server';
import BigNumber from 'bignumber.js';
import { createAuthCookie } from './db.js';
// Cookie tool - agents call this to get browser auth
export const cookieTool = defineTool(
'myapp_cookie', // Replace 'myapp' with your app name
'Get an authentication cookie for browser use. Set this cookie to authenticate when using the web interface.',
z.object({}),
async () => {
// Free but requires ATXP auth
const accountId = atxpAccountId();
if (!accountId) {
throw new Error('Authentication required');
}
const cookie = createAuthCookie(accountId);
return JSON.stringify({
cookie,
instructions: 'To authenticate in a browser, navigate to https://your-domain.com?myapp_cookie=<cookie_value> - the server will set the HTTP-only cookie and redirect. Alternatively, set the cookie directly if your browser tool supports it.'
});
}
);
// Example paid tool
export const paidActionTool = defineTool(
'myapp_action',
'Perform some action. Cost: $0.10',
z.object({
input: z.string().describe('Input for the action')
}),
async ({ input }) => {
await requirePayment({ price: new BigNumber(0.10) });
const accountId = atxpAccountId();
if (!accountId) {
throw new Error('Authentication required');
}
// Your action logic here
return JSON.stringify({ success: true, input });
}
);
export const allTools = [cookieTool, paidActionTool];
Create src/api.ts:
import { Router, Request, Response } from 'express';
import { getAtxpAccountFromCookie } from './db.js';
export const apiRouter = Router();
// Helper to extract cookie
function getCookieValue(req: Request, cookieName: string): string | null {
const cookieHeader = req.headers.cookie;
if (!cookieHeader) return null;
const cookies = cookieHeader.split(';').map(c => c.trim());
for (const cookie of cookies) {
if (cookie.startsWith(`${cookieName}=`)) {
return cookie.substring(cookieName.length + 1);
}
}
return null;
}
// Middleware to require cookie auth
function requireCookieAuth(req: Request, res: Response, next: Function) {
const cookieValue = getCookieValue(req, 'myapp_cookie');
...安装 ClawDirect 开发 后,可以对 AI 说这些话来触发它
Help me get started with ClawDirect Dev
Explains what ClawDirect Dev does, walks through the setup, and runs a quick demo based on your current project
Use ClawDirect Dev to build agent-facing web experiences with ATXP-based authentication, ...
Invokes ClawDirect Dev with the right parameters and returns the result directly in the conversation
What can I do with ClawDirect Dev in my data & analytics workflow?
Lists the top use cases for ClawDirect Dev, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/clawdirect-dev/ 目录(个人级,所有项目可用),或 .claude/skills/clawdirect-dev/(项目级)。重启 AI 客户端后,用 /clawdirect-dev 主动调用,或让 AI 根据上下文自动发现并使用。
ClawDirect 开发 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
ClawDirect 开发 可免费安装使用。请查阅仓库了解许可证信息。
遵循 ClawDirect 模式,使用基于 ATXP 的身份验证构建面向代理的 Web 体验。在构建 AI 代理通过 MCP 工具与之交互的网站、实施基于 cookie 的代理身份验证或为 Web 应用程序创建代理技能时,请使用此技能。使用@longrun/turtle 提供模板
ClawDirect 开发 属于「Data & Analytics」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my data & analytics tasks using ClawDirect Dev
Identifies repetitive steps in your workflow and sets up ClawDirect Dev to handle them automatically