结构AI MCP服务器
一个模型上下文协议(MCP)服务器,将Fabric AI框架与AI助手集成在一起。
使用TypeScript构建,用于类型安全和现代开发实践。
目的
此MCP服务器为AI助手提供了一个安全的接口,让他们使用Fabric AI的234+模式来增强人类的AI能力。Fabric是一个开源框架,提供模块化的AI提示来解决特定问题。
特性
当前实施情况
execute_pattern-在输入文本上执行任何结构模式list_patterns-通过可选搜索列出所有234+可用模式get_pattern_details-获取特定模式的信息process_url-使用模式获取和处理web内容process_youtube-提取YouTube转录本并使用模式进行处理update_patterns-更新到最新的织物图案
流行图案
extract_wisdom-从内容中提取见解和智慧summarize-创建全面的摘要improve_writing-提高文本质量explain_code-清楚地解释代码analyze_presentation-分析演示文稿质量create_summary-创建结构化摘要youtube_summary-总结YouTube视频
先决条件
- Node.js 20或更高版本
- 启用MCP工具包的Docker桌面
- Docker MCP CLI插件(
docker mcp命令) - 已安装Fabric AI CLI(在Docker中处理安装)
安装
步骤1:克隆并安装依赖项
git clone https://github.com/gufao/mcp-server-fabric-ai.git
cd mcp-server-fabric-ai
npm install第二步:构建TypeScript
npm run build步骤3:构建Docker镜像
docker build -t fabric-ai-mcp-server .步骤4:创建自定义目录
# Create catalogs directory if it doesn't exist
mkdir -p ~/.docker/mcp/catalogs
# Create or edit custom.yaml
nano ~/.docker/mcp/catalogs/custom.yaml将此条目添加到custom.yaml:
version: 2
name: custom
displayName: Custom MCP Servers
registry:
fabric-ai:
description: "Fabric AI framework integration - 234+ patterns for AI-augmented workflows"
title: "Fabric AI"
type: server
dateAdded: "2025-11-21T00:00:00Z"
image: fabric-ai-mcp-server:latest
ref: ""
readme: ""
toolsUrl: ""
source: ""
upstream: "https://github.com/danielmiessler/fabric"
icon: ""
tools:
- name: execute_pattern
- name: list_patterns
- name: get_pattern_details
- name: process_url
- name: process_youtube
- name: update_patterns
secrets: []
metadata:
category: productivity
tags:
- ai
- patterns
- automation
- content-processing
license: GPL-3.0
owner: local步骤5:更新注册表
nano ~/.docker/mcp/registry.yaml在现有条目下添加此条目 registry: 按键:
registry:
# ... existing servers ...
fabric-ai:
ref: ""重要:条目必须在 registry: 密钥,而不是根级别。
步骤6:配置Claude桌面
查找您的Claude Desktop配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
编辑文件并将自定义目录添加到args数组中:
{
"mcpServers": {
"mcp-toolkit-gateway": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-v", "[YOUR_HOME]/.docker/mcp:/mcp",
"docker/mcp-gateway",
"--catalog=/mcp/catalogs/docker-mcp.yaml",
"--catalog=/mcp/catalogs/custom.yaml",
"--config=/mcp/config.yaml",
"--registry=/mcp/registry.yaml",
"--tools-config=/mcp/tools.yaml",
"--transport=stdio"
]
}
}
}替换 [YOUR_HOME] 与:
- macOS:
/Users/your_username - 视窗:
C:\\Users\\your_username(使用双反睫毛) - Linux:
/home/your_username
步骤7:重新启动克劳德桌面
- 完全退出克劳德桌面
- 重新启动克劳德桌面
- 你的新工具应该出现了!
步骤8:测试您的服务器
# Verify it appears in the list
docker mcp server list发展
本地开发
# Install dependencies
npm install
# Run in development mode with auto-reload
npm run dev
# Type check
npm run typecheck
# Build
npm run build
# Run production build
npm start局部测试
# Install Fabric CLI locally first
go install github.com/danielmiessler/fabric/cmd/fabric@latest
# Set up Fabric (configure API keys)
fabric --setup
# Run the server
npm start使用示例
在Claude Desktop中,您可以问:
- “使用Fabric从这篇文章中提取智慧:\[粘贴文本\]”
- “使用Fabric总结此YouTube视频:https://youtube.com/watch?v=..."
- “列出与书写相关的所有可用织物图案”
- “在此草稿上使用improve_writing模式:\[粘贴文本\]”
- “使用结构图案分析此演示文稿”
- “获取extract_widom模式的详细信息”
建筑
Claude Desktop -> MCP Gateway -> Fabric AI MCP Server -> Fabric CLI -> AI Models
|
Docker Desktop
(Fabric installed)TypeScript的好处
- 类型安全:在编译时捕获错误
- 更好的IDE支持:增强的自动补全和重构
- 现代JavaScript:使用最新的ECMAScript功能
- 可维护性:具有类型的自文档化代码
添加新工具
要扩展功能,请执行以下操作:
- 在中添加工具功能
src/index.ts:
async function myNewTool(param: string): Promise {
// Implementation
const result = await execAsync(`fabric --pattern ${param}`);
return `Result: ${result.stdout}`;
}- 将工具定义添加到
TOOLS数组 - 将case添加到工具处理程序switch语句中
- 重建:
npm run build && docker build -t fabric-ai-mcp-server .
故障排除
工具未出现
- 验证Docker镜像构建成功
- 检查目录和注册表文件
- 确保Claude Desktop配置包括自定义目录
- 重新启动克劳德桌面
构建错误
- 检查TypeScript版本兼容性
- 跑
npm run typecheck查看类型错误 - 确保安装了所有依赖项
未找到织物
- 验证Docker容器中是否安装了Fabric CLI
- 检查Dockerfile安装步骤
- 确保织物在路径中
模式执行错误
- 验证模式名称是否正确:
fabric --listpatterns - 检查结构是否配置正确:
fabric --setup - 确保为人工智能模型设置了API密钥
安全考虑
- 织物人工智能需要用于人工智能模型的API密钥(OpenAI、Anthropic等)
- 存储在Docker Desktop secrets中的所有机密
- 从不硬编码凭据
- 以非root用户身份运行
- 从未记录敏感数据
- 所有参数的输入验证
- 外部呼叫超时保护
Fabric AI资源
- GitHub: https://github.com/danielmiessler/Fabric
- 模式: https://github.com/danielmiessler/Fabric/tree/main/patterns
- 文档: https://github.com/danielmiessler/fabric/blob/main/README.md
许可证
GPL-3.0许可证-请参阅 许可证 文件以获取详细信息。
