IIIF MCP服务器
一种模型上下文协议(MCP)服务器,提供对IIIF(国际图像互操作性框架)文档的访问。该服务器使人工智能助手能够检索、缓存和搜索IIIF API规范,包括图像API、API演示、搜索API和身份验证API文档。
特性
- 📚 文献检索:从IIIF.io获取并缓存IIIF API文档
- 🔍 智能搜索:使用关键字匹配在缓存文档中搜索
- 💾 智能高速缓存:基于SQLite的缓存,具有可配置的TTL(默认24小时)
- ✅ 内容效度:验证检索到的内容是否包含IIIF特定模式
- 📊 健康监测:操作状态的基本健康检查
安装
# Clone the repository
git clone
cd iiif-mcp
# Install dependencies
npm install
# Build the project
npm run build用法
启动服务器
# Development mode
npm run dev
# Production mode
npm start可用工具
1. get_api_docs -检索IIIF文档
获取特定IIIF API的文档。
{
"name": "get_api_docs",
"arguments": {
"api": "image",
"version": "3.0",
"section": "parameters",
"forceRefresh": false
}
}参数:
api(必需):API类型(image,presentation,search,auth)version(可选):API版本(默认:3.0)section(可选):按标题筛选到特定部分forceRefresh(可选):强制从源刷新(默认值:false)
2. search_docs -搜索文档
搜索缓存的IIIF文档。
{
"name": "search_docs",
"arguments": {
"query": "image parameters",
"apis": ["image", "presentation"],
"maxResults": 5
}
}参数:
query(必填):要查找的搜索词apis(可选):要搜索的特定API(默认:所有通用API)maxResults(可选):返回的最大结果(默认值:10)
3. health_check -服务器运行状况
检查服务器运行状态和数据库连接。
{
"name": "health_check",
"arguments": {}
}4. ping -测试连接性
测试服务器连接和响应能力。
{
"name": "ping",
"arguments": {
"includeTimestamp": true
}
}配置
使用环境变量配置服务器:
# Cache directory (default: ./cache)
export IIIF_CACHE_DIR=/path/to/cache
# HTTP request timeout in milliseconds (default: 5000)
export IIIF_HTTP_TIMEOUT=10000
# Log level (default: info)
export IIIF_LOG_LEVEL=debug建筑
核心组件
- MCP服务器:处理工具请求和响应
- HTTP客户端:使用重试逻辑从iiif.io获取内容
- 内容缓存:带TTL管理的基于SQLite的缓存
- 解析器:从HTML文档中提取和构造内容
- 验证器:确保检索到的内容是有效的IIIF文档
- 监视器:运行状态健康检查
文件结构
src/
├── server.ts # MCP server setup and tool routing
├── config.ts # Configuration management
├── http.ts # HTTP client with retry logic
├── cache.ts # SQLite content caching
├── parser.ts # HTML parsing and text extraction
├── validation.ts # Content validation and error handling
├── monitoring.ts # Health monitoring
└── tools/
├── ping.ts # Ping tool implementation
├── get-docs.ts # Documentation retrieval tool
└── search.ts # Search functionality发展
运行测试
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run specific test file
npm test -- config.test.ts类型检查
# Check TypeScript types
npm run typecheck代码检查
# Run ESLint
npm run lintAPI覆盖范围
服务器提供对这些IIIF API文档的访问:
- 图片API 3.0:用于图像传递的Web服务
- 演示文稿API 3.0:结构化元数据格式
- 搜索API 1.0:资源内的内容搜索
- 身份验证API 1.0:访问控制模式
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
