mcpField
J
json-schema-lookup

json-schema-lookup

github.com/sammcj开发16781 次安装2 天前更新
代码仓库

关于 json-schema-lookup

通过 SchemaStore 目录查询公开配置文件 Schema 的参考技能,指导开发者查找 Schema,并检查属性、必填字段和允许值。

主要功能

  1. 01按名称或文件名搜索 Schema
  2. 02从目录链接获取 Schema
  3. 03检查属性和必填字段
  4. 04查询枚举值及嵌套定义
  5. 05查找特定版本的 Schema 链接

适用场景

  1. 01检查 tsconfig 的有效选项
  2. 02为配置文件名查找 Schema
  3. 03查看字段允许的取值

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sammcj/agentic-coding --skill json-schema-lookup

安装后在 Claude Code 中输入/json-schema-lookup确认已加载。

详细介绍

通过 SchemaStore 查找 JSON Schema

查询 schemastore.org 的公共配置文件架构目录,以验证结构、发现选项并检查允许的值。

API

  • 目录:https://www.schemastore.org/api/json/catalog.json
    • 结构:{ "schemas": [{ "name", "description", "fileMatch", "url", "versions"? }] }
  • 单个架构:从匹配的目录条目中获取 url

工作流

1. 查找架构

按名称或文件名模式搜索目录:

# Search by name (case-insensitive)
curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.name | test("tsconfig"; "i")) | {name, url, fileMatch}'

# Search by filename match
curl -s https://www.schemastore.org/api/json/catalog.json | jq '.schemas[] | select(.fileMatch[]? | test("package\\.json")) | {name, url}'

或者,对目录 URL 使用 WebFetch,并请求查找相关条目。

2. 获取并检查架构
# List top-level properties
curl -s SCHEMA_URL | jq '.properties | keys'

# Inspect a specific field (type, enum values, description)
curl -s SCHEMA_URL | jq '.properties.FIELD_NAME'

# Check definitions/shared types (schemas use $ref to these)
curl -s SCHEMA_URL | jq '.definitions.DEF_NAME.properties'

# Get the full schema (warning - might be large!)
curl -s SCHEMA_URL | jq .
3. 常见查询
# Find enum values for a field
curl -s SCHEMA_URL | jq '.properties.FIELD.enum'

# List nested properties (e.g. compilerOptions in tsconfig)
curl -s SCHEMA_URL | jq '.definitions.compilerOptionsDefinition.properties.compilerOptions.properties | keys'

# Find all required fields
curl -s SCHEMA_URL | jq '.required'

提示

  • 某些架构使用 allOf/anyOf 组合——检查这些数组以获取完整的属性集
  • 目录条目中的 versions 字段会提供特定版本的架构 URL(如有)
  • 架构 URL 各不相同:有些指向 json.schemastore.org,有些指向 raw.githubusercontent.com
  • 对于大型架构,请查询特定路径,而不是转储整个文档
  • 如果在一个会话中进行多次查找,请在本地缓存目录响应

评论

支持 Markdown