Expose允许您构建可以使用MCP客户端(如Claude桌面应用)调用的MCP工具。
expose-cli进行注册。设置expose CLI
curl -fsSL https://github.com/a0dotrun/expose/releases/download/stable/download_cli.sh | bash
安装依赖项
npm i @a0dotrun/expose
创建服务器
touch src/server.ts
import { create } from "@a0dotrun/expose"
const app = create({
tools: [],
})
export default {
port: 3000,
fetch: app.fetch,
}
定义您的工具
+ import { tool } from "@a0dotrun/expose/tool"
+ import { subscription } from "@acme/lib/subscription"
+ import { z } from "zod"
+ const getCustomerSubscription = tool({
+ name: "getCustomerSubscription",
+ description: "获取客户的订阅信息",
+ args: z.object({
+ customer: z.string().uuid()
+ }),
+ run: async (input) => {
+ // 您的订阅逻辑在这里
+ return input;
+ },
+ });
+ const createCustomerSubscription = tool({
+ name: "createCustomerSubscription",
+ description: "为客户创建订阅",
+ args: z.object({
+ customer: z.string().uuid()
+ }),
+ run: async (input) => {
+ // 您的订阅逻辑在这里
+ return input;
+ },
+ });
const app = create({
tools: [
+ getCustomerSubscription,
+ createCustomerSubscription,
],
});
启动服务器
npm run dev
您也可以部署服务器并记录下公共URL。
在Claude桌面应用中注册
macOS Claude桌面MCP配置路径:~/Library/Application Support/Claude/claude_desktop_config.json
{
...
"mcpServers": {
"subscriptionManager": {
"command": "/Users/acmeuser/.local/bin/expose-cli",
"args": ["--url", "http://localhost:3000", "--timeout", "15"]
}
}
...
}
将localhost替换为您自己的公共URL
expose由@_sanchitrk在a0创建
我受到了opencontrol的启发