使用说明
Schema.org MCP服务器
用于完整schema.org词汇表的模型上下文协议服务器
授权AI助手探索schema.org类型,生成JSON-LD示例,验证结构化数据,并通过智能模糊匹配和持久缓存浏览完整的本体。
目录
特性
v1.1.0亮点
| 特性 | 描述 |
|---|---|
| 持久缓存 | Schema.org数据通过基于TTL的刷新在本地缓存——无冷启动延迟 |
| 模糊匹配 | 带有智能“你是说什么?”建议的拼写错误容忍查找 |
| 类型别名 | 自然语言快捷方式: blog → 博客发布, faq → 常见问题页面 |
| 筛选属性 | 仅获取直接、仅继承或分页的属性列表 |
| 批量操作 | 比较类型、验证多个JSON-LD对象、批量查找 |
| 动态示例 | 生成的示例使用当前日期和现实数据 |
核心能力
- 类型探索 --有关任何具有弃用状态的schema.org类型的详细信息
- 智能搜索 --基于相关性排名的关键字搜索
- 层次导航 --探索继承关系、祖先和后代
- 房产发现 --列出所有具有预期类型的属性,包括继承的属性
- JSON-LD生成 --以最低、标准或全面的细节级别创建现实的示例
- 验证 --对照schema.org词汇表检查结构化数据,并提供可操作的反馈
- 关系映射 --发现通过属性关系连接的类型
安装
先决条件
- Node.js >= 18.0.0
- npm 或 纱线
通过npm安装(推荐)
npm install -g schema-org-mcp
或者直接运行而不安装:
npx schema-org-mcp
从源代码构建
# Clone the repository
git clone https://github.com/Theycallmeholla/schema-org-mcp.git
cd schema-org-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Verify the installation
npm start
快速开始
与Claude Desktop集成
将服务器添加到您的Claude Desktop配置中:
| Platform | Configuration Path |
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
通过npx(推荐):
{
"mcpServers": {
"schema-org": {
"command": "npx",
"args": ["schema-org-mcp"]
}
}
}
本地构建:
{
"mcpServers": {
"schema-org": {
"command": "node",
"args": ["/absolute/path/to/schema-org-mcp/dist/index.js"]
}
}
}
可用工具
服务器提供 14工具 分为三类。
操作工具
server_info
返回服务器版本、构建元数据和运行时信息。使用此选项验证部署了哪个版本。
{}
答复:
version,gitSha,gitBranch,buildTimeruntime--节点版本、平台、正常运行时间tools--注册工具的数量和名称cache--缓存状态
server_stats
返回性能统计数据,包括缓存命中率、工具调用计数和时间度量。
{}
答复:
coldStartMs,warmStartMscacheHits,cacheMisses,cacheStaleHitstoolInvocations--每工具计数、错误、平均持续时间uptimeMs
核心工具
get_schema_type
检索有关schema.org类型的详细信息。支持拼写错误和自然别名的模糊匹配。
{
"typeName": "Person"
}
还接受:
- 拼写错误:
"Persn"→ 暗示Person - 别名:
"blog"→BlogPosting,"faq"→FAQPage
答复:
name,description,id,urlsuperTypes--直接父类型category—core,pending,auto,bib,或health-lifescideprecated和supersededBy(如适用)
search_schemas
通过基于相关性的排名按关键字搜索模式类型。
{
"query": "local business",
"limit": 10
}
get_type_hierarchy
获取完整的继承层次结构,包括祖先和子代。
{
"typeName": "NewsArticle"
}
get_type_properties
列出具有过滤和分页支持的类型的所有可用属性。
{
"typeName": "Organization",
"mode": "direct",
"includeDeprecated": false,
"limit": 20,
"offset": 0
}
| 参数 | 选项 | 默认值 |
|---|---|---|
mode |
all, direct, inherited |
all |
includeDeprecated |
true, false |
false |
limit |
编号 | -- |
offset |
编号 | 0 |
generate_example
生成具有动态日期和嵌套类型的逼真JSON-LD示例。
{
"typeName": "LocalBusiness",
"style": "comprehensive",
"customProperties": {
"name": "My Coffee Shop"
}
}
| 样式 | 描述 |
|---|---|
minimal |
仅命名属性 |
standard |
常见属性 |
comprehensive |
具有嵌套类型的完整属性集 |
支持的域预设: 个人、组织、本地业务、产品、活动、文章、博客发布、食谱、网站、常见问题页面、地点
get_property_details
获取有关特定房产的全面信息。支持模糊匹配。
{
"propertyName": "address"
}
get_enumeration_values
检索枚举类型的所有有效值。
{
"enumerationType": "DayOfWeek"
}
validate_jsonld
使用拼写错误的智能建议验证JSON-LD结构化数据。
{
"jsonld": {
"@context": "https://schema.org",
"@type": "Product",
"name": "Widget",
"nmae": "typo"
}
}
答复:
valid--布尔结果errors--带有建议的未知类型或属性warnings--弃用项目,缺少上下文suggestions--要添加的推荐属性
get_related_types
发现通过属性关系连接的类型。
{
"typeName": "Person"
}
批处理工具
get_multiple_types
在一次呼叫中检索有关多种类型的信息。
{
"typeNames": ["Person", "Organization", "LocalBusiness"]
}
compare_types
将2-5种schema.org类型与使用建议并排比较。
{
"typeNames": ["Article", "BlogPosting", "NewsArticle"]
}
答复:
types--每种类型的总结sharedProperties--所有人共有的属性uniqueProperties--每个人独有的属性recommendation--何时使用每种类型
validate_jsonld_batch
在一次调用中验证多个JSON-LD对象。
{
"items": [
{ "@context": "https://schema.org", "@type": "Person", "name": "John" },
{ "@context": "https://schema.org", "@type": "Organization", "name": "Acme" }
]
}
示例工作流
电子商务产品页面
1. search_schemas → {"query": "product"}
2. compare_types → {"typeNames": ["Product", "Offer", "AggregateOffer"]}
3. get_type_properties → {"typeName": "Product", "mode": "direct", "limit": 15}
4. generate_example → {"typeName": "Product", "style": "comprehensive"}
文章与博客发布决策
1. compare_types → {"typeNames": ["Article", "BlogPosting"]}
Response includes recommendation:
"Use BlogPosting for blog content with clear publication dates and author.
Use Article for general news or editorial content."
批量标记验证
1. validate_jsonld_batch → {"items": [...array of JSON-LD objects...]}
Returns per-object validation with actionable suggestions
伤寒恢复
1. get_schema_type → {"typeName": "Perosn"}
Error: "Type 'Perosn' not found. Did you mean: Person, Physician, Performer?"
运作原理
缓存架构
服务器获取完整的schema.org词汇表并实现多层缓存:
| 图层 | 位置 | 行为 |
|---|---|---|
| 内存 | 运行时 | 首次加载后的即时访问 |
| 磁盘 | ~/.cache/schema-org-mcp/schema-org-data.json |
在重启过程中持续存在 |
- TTL: 24小时(可配置)
- 退路: 如果schema.org不可用,则使用过时的缓存
模糊匹配流水线
- 检查自然语言别名(
blog→BlogPosting) - 尝试不区分大小写和规范化匹配
- 使用Levenshtein距离计算相似性得分
- 如果得分>0.4,返回前3条建议
索引数据
| 类别 | 计数 |
|---|---|
| 类型(类) | ~800+ |
| 房产 | ~1400+ |
| 枚举类型 | ~80+ |
配置
客户端接受可选配置参数:
const client = new SchemaOrgClient({
cacheDir: '/custom/cache/path', // Default: ~/.cache/schema-org-mcp
ttlMs: 12 * 60 * 60 * 1000, // Default: 24 hours
offline: false, // Default: false
});
发展
# Watch mode for development
npm run dev
# Run the test suite
npm test
# Build for production (generates build fingerprint)
npm run build
# Run full QA checklist
npm run qa
# Verify deployment
npm run verify
部署
使用指纹构建
每个构建都嵌入了版本元数据以实现可追溯性:
npm run build
# Output: Build info generated: v1.1.0 (abc1234)
验证部署
确认正在运行正确的版本:
npm run verify
# Or with explicit version:
npm run verify 1.1.0 abc1234
验证检查:
- 版本和git SHA匹配
compare_types工具响应正确- 模糊匹配返回建议
- 常见问题页面示例包括
mainEntity - 缓存状态可用
运行时指纹
启动时,服务器会记录其身份:
═══════════════════════════════════════════
schema-org-mcp v1.1.0 (abc1234)
Built: 2025-04-04T15:00:00.000Z
Branch: main
Node: v22.20.0
Tools: 14 registered
server_info, server_stats, get_schema_type, ...
═══════════════════════════════════════════
使用 server_info 以编程方式检查运行版本的工具。
故障排除
缓慢冷启动
如果第一个请求很慢,则缓存可能已过期:
ls -la ~/.cache/schema-org-mcp/
模糊建议未出现
确保架构数据已完全加载。这 initialize() 该方法必须在模糊匹配工作之前完成。
强制缓存刷新
删除缓存目录以获取新数据:
rm -rf ~/.cache/schema-org-mcp/
贡献
欢迎投稿!请按照以下步骤操作:
- 分叉存储库
- 创建要素分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
请确保在提交之前通过所有测试。
许可证
该项目根据 MIT 许可证 --看看 许可证 文件以获取详细信息。