@shuji-bonji/w3c-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.ja.md +246 -0
- package/README.md +246 -0
- package/dist/data/loader.d.ts +88 -0
- package/dist/data/loader.d.ts.map +1 -0
- package/dist/data/loader.js +165 -0
- package/dist/data/loader.js.map +1 -0
- package/dist/errors/index.d.ts +50 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +116 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +307 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +97 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +53 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/tools/get-css.d.ts +30 -0
- package/dist/tools/get-css.d.ts.map +1 -0
- package/dist/tools/get-css.js +99 -0
- package/dist/tools/get-css.js.map +1 -0
- package/dist/tools/get-elements.d.ts +14 -0
- package/dist/tools/get-elements.d.ts.map +1 -0
- package/dist/tools/get-elements.js +56 -0
- package/dist/tools/get-elements.js.map +1 -0
- package/dist/tools/get-pwa-specs.d.ts +10 -0
- package/dist/tools/get-pwa-specs.d.ts.map +1 -0
- package/dist/tools/get-pwa-specs.js +100 -0
- package/dist/tools/get-pwa-specs.js.map +1 -0
- package/dist/tools/get-spec.d.ts +10 -0
- package/dist/tools/get-spec.d.ts.map +1 -0
- package/dist/tools/get-spec.js +58 -0
- package/dist/tools/get-spec.js.map +1 -0
- package/dist/tools/get-webidl.d.ts +9 -0
- package/dist/tools/get-webidl.d.ts.map +1 -0
- package/dist/tools/get-webidl.js +50 -0
- package/dist/tools/get-webidl.js.map +1 -0
- package/dist/tools/list-specs.d.ts +6 -0
- package/dist/tools/list-specs.d.ts.map +1 -0
- package/dist/tools/list-specs.js +38 -0
- package/dist/tools/list-specs.js.map +1 -0
- package/dist/tools/search-specs.d.ts +16 -0
- package/dist/tools/search-specs.d.ts.map +1 -0
- package/dist/tools/search-specs.js +117 -0
- package/dist/tools/search-specs.js.map +1 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/logger.d.ts +49 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +113 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 shuji-bonji
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# W3C MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@shuji-bonji/w3c-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://modelcontextprotocol.io/)
|
|
7
|
+
[](https://claude.ai/code)
|
|
8
|
+
|
|
9
|
+
W3C/WHATWG/IETF の Web 仕様にアクセスするための MCP Server です。AI アシスタントに公式 Web 標準データ(仕様、WebIDL 定義、CSS プロパティ、HTML 要素)へのアクセスを提供します。
|
|
10
|
+
|
|
11
|
+
## インストール
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @shuji-bonji/w3c-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
または npx で直接実行:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @shuji-bonji/w3c-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 設定
|
|
24
|
+
|
|
25
|
+
### Claude Desktop
|
|
26
|
+
|
|
27
|
+
Claude Desktop の設定ファイルに追加してください:
|
|
28
|
+
|
|
29
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
30
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"w3c": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["-y", "@shuji-bonji/w3c-mcp"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Cursor
|
|
44
|
+
|
|
45
|
+
Cursor の MCP 設定(プロジェクトの `.cursor/mcp.json` またはグローバル設定)に追加:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"w3c": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "@shuji-bonji/w3c-mcp"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 利用可能なツール
|
|
59
|
+
|
|
60
|
+
### 仕様の検索・取得
|
|
61
|
+
|
|
62
|
+
#### `list_w3c_specs`
|
|
63
|
+
W3C/WHATWG/IETF の Web 仕様一覧を取得します。
|
|
64
|
+
|
|
65
|
+
パラメータ:
|
|
66
|
+
- `organization` (任意): 組織でフィルタ - `"W3C"`, `"WHATWG"`, `"IETF"`, `"all"`
|
|
67
|
+
- `keyword` (任意): タイトルまたは shortname でフィルタ
|
|
68
|
+
- `category` (任意): カテゴリでフィルタ
|
|
69
|
+
- `limit` (任意): 最大件数 (デフォルト: 50)
|
|
70
|
+
|
|
71
|
+
#### `get_w3c_spec`
|
|
72
|
+
特定の Web 仕様の詳細情報を取得します。
|
|
73
|
+
|
|
74
|
+
パラメータ:
|
|
75
|
+
- `shortname` (必須): 仕様の shortname (例: `"service-workers"`, `"appmanifest"`, `"fetch"`)
|
|
76
|
+
|
|
77
|
+
#### `search_w3c_specs`
|
|
78
|
+
クエリ文字列で Web 仕様を検索します。
|
|
79
|
+
|
|
80
|
+
パラメータ:
|
|
81
|
+
- `query` (必須): 検索クエリ (例: `"service worker"`, `"manifest"`, `"storage"`)
|
|
82
|
+
- `limit` (任意): 最大件数 (デフォルト: 20)
|
|
83
|
+
|
|
84
|
+
### WebIDL
|
|
85
|
+
|
|
86
|
+
#### `get_webidl`
|
|
87
|
+
仕様の WebIDL インターフェース定義を取得します。WebIDL は JavaScript API を定義しています。
|
|
88
|
+
|
|
89
|
+
パラメータ:
|
|
90
|
+
- `shortname` (必須): 仕様の shortname (例: `"service-workers"`, `"fetch"`, `"dom"`)
|
|
91
|
+
|
|
92
|
+
#### `list_webidl_specs`
|
|
93
|
+
WebIDL 定義がある仕様の一覧を取得します。
|
|
94
|
+
|
|
95
|
+
### CSS
|
|
96
|
+
|
|
97
|
+
#### `get_css_properties`
|
|
98
|
+
特定の仕様または全仕様から CSS プロパティ定義を取得します。
|
|
99
|
+
|
|
100
|
+
パラメータ:
|
|
101
|
+
- `spec` (任意): 仕様の shortname (例: `"css-grid-1"`, `"css-flexbox-1"`)
|
|
102
|
+
- `property` (任意): 特定の CSS プロパティを名前で検索
|
|
103
|
+
|
|
104
|
+
#### `list_css_specs`
|
|
105
|
+
CSS プロパティ定義がある仕様の一覧を取得します。
|
|
106
|
+
|
|
107
|
+
### HTML 要素
|
|
108
|
+
|
|
109
|
+
#### `get_html_elements`
|
|
110
|
+
特定の仕様または全仕様から HTML 要素定義を取得します。
|
|
111
|
+
|
|
112
|
+
パラメータ:
|
|
113
|
+
- `spec` (任意): 仕様の shortname (例: `"html"`, `"svg"`)
|
|
114
|
+
- `element` (任意): 特定の要素を名前で検索 (例: `"video"`, `"canvas"`)
|
|
115
|
+
|
|
116
|
+
#### `list_element_specs`
|
|
117
|
+
HTML 要素定義がある仕様の一覧を取得します。
|
|
118
|
+
|
|
119
|
+
### PWA
|
|
120
|
+
|
|
121
|
+
#### `get_pwa_specs`
|
|
122
|
+
Progressive Web App (PWA) 関連の全仕様を取得します。
|
|
123
|
+
|
|
124
|
+
パラメータ:
|
|
125
|
+
- `coreOnly` (任意): true の場合、コア PWA 仕様のみ返す (Service Worker, Manifest, Push, Notifications)
|
|
126
|
+
|
|
127
|
+
#### `get_spec_dependencies`
|
|
128
|
+
仕様の依存関係情報を取得します。
|
|
129
|
+
|
|
130
|
+
パラメータ:
|
|
131
|
+
- `shortname` (必須): 仕様の shortname
|
|
132
|
+
|
|
133
|
+
## 使用例
|
|
134
|
+
|
|
135
|
+
### Service Worker API を調べる
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
get_webidl ツールで shortname "service-workers" を指定して ServiceWorker インターフェース定義を取得
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### PWA 技術を探索する
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
get_pwa_specs で PWA 関連の全仕様を取得し、get_w3c_spec で各仕様の詳細を確認
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### CSS Grid プロパティを調べる
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
get_css_properties で spec "css-grid-1" を指定して CSS Grid レイアウトの全プロパティを取得
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### ストレージ API を検索する
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
search_w3c_specs で query "storage" を指定してストレージ関連の仕様を検索
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## データソース
|
|
160
|
+
|
|
161
|
+
この MCP サーバーは以下の W3C/webref データパッケージを使用しています:
|
|
162
|
+
|
|
163
|
+
| パッケージ | 説明 |
|
|
164
|
+
|-----------|------|
|
|
165
|
+
| [web-specs](https://www.npmjs.com/package/web-specs) | 全 Web 仕様のメタデータ |
|
|
166
|
+
| [@webref/idl](https://www.npmjs.com/package/@webref/idl) | WebIDL インターフェース定義 |
|
|
167
|
+
| [@webref/css](https://www.npmjs.com/package/@webref/css) | CSS プロパティと値 |
|
|
168
|
+
| [@webref/elements](https://www.npmjs.com/package/@webref/elements) | HTML 要素定義 |
|
|
169
|
+
|
|
170
|
+
これらのパッケージは W3C によってメンテナンスされており、公式仕様から抽出された機械可読データを提供しています。
|
|
171
|
+
|
|
172
|
+
**GitHub リポジトリ**:
|
|
173
|
+
- https://github.com/w3c/browser-specs
|
|
174
|
+
- https://github.com/w3c/webref
|
|
175
|
+
|
|
176
|
+
## デバッグモード
|
|
177
|
+
|
|
178
|
+
環境変数でデバッグログを有効化できます:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# デバッグログを有効化
|
|
182
|
+
W3C_MCP_DEBUG=true npx @shuji-bonji/w3c-mcp
|
|
183
|
+
|
|
184
|
+
# パフォーマンスログのみ有効化
|
|
185
|
+
W3C_MCP_PERF=true npx @shuji-bonji/w3c-mcp
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
デバッグ出力には以下が含まれます:
|
|
189
|
+
- ツール呼び出しの引数
|
|
190
|
+
- 実行時間
|
|
191
|
+
- データロードのパフォーマンス
|
|
192
|
+
|
|
193
|
+
## アーキテクチャ
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
src/
|
|
197
|
+
├── index.ts # MCP サーバーエントリポイント
|
|
198
|
+
├── data/
|
|
199
|
+
│ └── loader.ts # キャッシュ付きデータロード
|
|
200
|
+
├── tools/ # ツール実装
|
|
201
|
+
│ ├── list-specs.ts
|
|
202
|
+
│ ├── get-spec.ts
|
|
203
|
+
│ ├── search-specs.ts
|
|
204
|
+
│ ├── get-webidl.ts
|
|
205
|
+
│ ├── get-css.ts
|
|
206
|
+
│ ├── get-elements.ts
|
|
207
|
+
│ └── get-pwa-specs.ts
|
|
208
|
+
├── schemas/
|
|
209
|
+
│ └── index.ts # Zod バリデーションスキーマ
|
|
210
|
+
├── errors/
|
|
211
|
+
│ └── index.ts # カスタムエラークラス
|
|
212
|
+
├── utils/
|
|
213
|
+
│ └── logger.ts # デバッグログユーティリティ
|
|
214
|
+
└── types/
|
|
215
|
+
└── index.ts # TypeScript 型定義
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### パフォーマンス
|
|
219
|
+
|
|
220
|
+
- **起動時間**: 約70ms(全データの並列プリロード)
|
|
221
|
+
- **仕様検索**: O(1)(Map ベースのインデックス使用)
|
|
222
|
+
- **テキスト検索**: 完全一致時の早期終了で最適化
|
|
223
|
+
|
|
224
|
+
## 開発
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# リポジトリをクローン
|
|
228
|
+
git clone https://github.com/shuji-bonji/w3c-mcp.git
|
|
229
|
+
cd w3c-mcp
|
|
230
|
+
|
|
231
|
+
# 依存関係をインストール
|
|
232
|
+
npm install
|
|
233
|
+
|
|
234
|
+
# ビルド
|
|
235
|
+
npm run build
|
|
236
|
+
|
|
237
|
+
# 開発モードで実行
|
|
238
|
+
npm run dev
|
|
239
|
+
|
|
240
|
+
# デバッグログ付きで実行
|
|
241
|
+
W3C_MCP_DEBUG=true npm start
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## ライセンス
|
|
245
|
+
|
|
246
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# W3C MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@shuji-bonji/w3c-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://modelcontextprotocol.io/)
|
|
7
|
+
[](https://claude.ai/code)
|
|
8
|
+
|
|
9
|
+
MCP Server for accessing W3C/WHATWG/IETF web specifications. Provides AI assistants with access to official web standards data including specifications, WebIDL definitions, CSS properties, and HTML elements.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @shuji-bonji/w3c-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or use directly with npx:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @shuji-bonji/w3c-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
### Claude Desktop
|
|
26
|
+
|
|
27
|
+
Add to your Claude Desktop configuration file:
|
|
28
|
+
|
|
29
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
30
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"w3c": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["-y", "@shuji-bonji/w3c-mcp"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Cursor
|
|
44
|
+
|
|
45
|
+
Add to your Cursor MCP settings (`.cursor/mcp.json` in your project or global settings):
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"w3c": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "@shuji-bonji/w3c-mcp"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Available Tools
|
|
59
|
+
|
|
60
|
+
### Specification Discovery
|
|
61
|
+
|
|
62
|
+
#### `list_w3c_specs`
|
|
63
|
+
List W3C/WHATWG/IETF web specifications with optional filtering.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
- `organization` (optional): Filter by organization - `"W3C"`, `"WHATWG"`, `"IETF"`, or `"all"`
|
|
67
|
+
- `keyword` (optional): Filter by keyword in title or shortname
|
|
68
|
+
- `category` (optional): Filter by category
|
|
69
|
+
- `limit` (optional): Maximum number of results (default: 50)
|
|
70
|
+
|
|
71
|
+
#### `get_w3c_spec`
|
|
72
|
+
Get detailed information about a specific web specification.
|
|
73
|
+
|
|
74
|
+
Parameters:
|
|
75
|
+
- `shortname` (required): Specification shortname (e.g., `"service-workers"`, `"appmanifest"`, `"fetch"`)
|
|
76
|
+
|
|
77
|
+
#### `search_w3c_specs`
|
|
78
|
+
Search web specifications by query string.
|
|
79
|
+
|
|
80
|
+
Parameters:
|
|
81
|
+
- `query` (required): Search query (e.g., `"service worker"`, `"manifest"`, `"storage"`)
|
|
82
|
+
- `limit` (optional): Maximum number of results (default: 20)
|
|
83
|
+
|
|
84
|
+
### WebIDL
|
|
85
|
+
|
|
86
|
+
#### `get_webidl`
|
|
87
|
+
Get WebIDL interface definitions for a specification. WebIDL defines the JavaScript APIs.
|
|
88
|
+
|
|
89
|
+
Parameters:
|
|
90
|
+
- `shortname` (required): Specification shortname (e.g., `"service-workers"`, `"fetch"`, `"dom"`)
|
|
91
|
+
|
|
92
|
+
#### `list_webidl_specs`
|
|
93
|
+
List all specifications that have WebIDL definitions available.
|
|
94
|
+
|
|
95
|
+
### CSS
|
|
96
|
+
|
|
97
|
+
#### `get_css_properties`
|
|
98
|
+
Get CSS property definitions from a specific spec or all specs.
|
|
99
|
+
|
|
100
|
+
Parameters:
|
|
101
|
+
- `spec` (optional): Specification shortname (e.g., `"css-grid-1"`, `"css-flexbox-1"`)
|
|
102
|
+
- `property` (optional): Search for a specific CSS property by name
|
|
103
|
+
|
|
104
|
+
#### `list_css_specs`
|
|
105
|
+
List all CSS specifications that have property definitions available.
|
|
106
|
+
|
|
107
|
+
### HTML Elements
|
|
108
|
+
|
|
109
|
+
#### `get_html_elements`
|
|
110
|
+
Get HTML element definitions from a specific spec or all specs.
|
|
111
|
+
|
|
112
|
+
Parameters:
|
|
113
|
+
- `spec` (optional): Specification shortname (e.g., `"html"`, `"svg"`)
|
|
114
|
+
- `element` (optional): Search for a specific element by name (e.g., `"video"`, `"canvas"`)
|
|
115
|
+
|
|
116
|
+
#### `list_element_specs`
|
|
117
|
+
List all specifications that have HTML element definitions available.
|
|
118
|
+
|
|
119
|
+
### PWA
|
|
120
|
+
|
|
121
|
+
#### `get_pwa_specs`
|
|
122
|
+
Get all Progressive Web App (PWA) related specifications.
|
|
123
|
+
|
|
124
|
+
Parameters:
|
|
125
|
+
- `coreOnly` (optional): If true, return only the core PWA specs (Service Worker, Manifest, Push, Notifications)
|
|
126
|
+
|
|
127
|
+
#### `get_spec_dependencies`
|
|
128
|
+
Get dependency information for a specification.
|
|
129
|
+
|
|
130
|
+
Parameters:
|
|
131
|
+
- `shortname` (required): Specification shortname
|
|
132
|
+
|
|
133
|
+
## Usage Examples
|
|
134
|
+
|
|
135
|
+
### Find Service Worker APIs
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Use the get_webidl tool with shortname "service-workers" to see the ServiceWorker interface definitions.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Explore PWA Technologies
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Use get_pwa_specs to see all PWA-related specifications, then use get_w3c_spec for details on each one.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Look up CSS Grid Properties
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
Use get_css_properties with spec "css-grid-1" to see all CSS Grid layout properties.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Search for Storage APIs
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
Use search_w3c_specs with query "storage" to find all storage-related specifications.
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Data Sources
|
|
160
|
+
|
|
161
|
+
This MCP server uses the following W3C/webref data packages:
|
|
162
|
+
|
|
163
|
+
| Package | Description |
|
|
164
|
+
|---------|-------------|
|
|
165
|
+
| [web-specs](https://www.npmjs.com/package/web-specs) | Metadata for all web specifications |
|
|
166
|
+
| [@webref/idl](https://www.npmjs.com/package/@webref/idl) | WebIDL interface definitions |
|
|
167
|
+
| [@webref/css](https://www.npmjs.com/package/@webref/css) | CSS properties and values |
|
|
168
|
+
| [@webref/elements](https://www.npmjs.com/package/@webref/elements) | HTML element definitions |
|
|
169
|
+
|
|
170
|
+
These packages are maintained by the W3C and provide machine-readable data extracted from official specifications.
|
|
171
|
+
|
|
172
|
+
**GitHub Repositories**:
|
|
173
|
+
- https://github.com/w3c/browser-specs
|
|
174
|
+
- https://github.com/w3c/webref
|
|
175
|
+
|
|
176
|
+
## Debug Mode
|
|
177
|
+
|
|
178
|
+
Enable debug logging with environment variables:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Enable debug logging
|
|
182
|
+
W3C_MCP_DEBUG=true npx @shuji-bonji/w3c-mcp
|
|
183
|
+
|
|
184
|
+
# Enable performance logging only
|
|
185
|
+
W3C_MCP_PERF=true npx @shuji-bonji/w3c-mcp
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Debug output includes:
|
|
189
|
+
- Tool call arguments
|
|
190
|
+
- Execution timing
|
|
191
|
+
- Data loading performance
|
|
192
|
+
|
|
193
|
+
## Architecture
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
src/
|
|
197
|
+
├── index.ts # MCP server entry point
|
|
198
|
+
├── data/
|
|
199
|
+
│ └── loader.ts # Data loading with caching
|
|
200
|
+
├── tools/ # Tool implementations
|
|
201
|
+
│ ├── list-specs.ts
|
|
202
|
+
│ ├── get-spec.ts
|
|
203
|
+
│ ├── search-specs.ts
|
|
204
|
+
│ ├── get-webidl.ts
|
|
205
|
+
│ ├── get-css.ts
|
|
206
|
+
│ ├── get-elements.ts
|
|
207
|
+
│ └── get-pwa-specs.ts
|
|
208
|
+
├── schemas/
|
|
209
|
+
│ └── index.ts # Zod validation schemas
|
|
210
|
+
├── errors/
|
|
211
|
+
│ └── index.ts # Custom error classes
|
|
212
|
+
├── utils/
|
|
213
|
+
│ └── logger.ts # Debug logging utilities
|
|
214
|
+
└── types/
|
|
215
|
+
└── index.ts # TypeScript type definitions
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Performance
|
|
219
|
+
|
|
220
|
+
- **Startup**: ~70ms parallel preloading of all data
|
|
221
|
+
- **Spec Lookup**: O(1) using Map-based index
|
|
222
|
+
- **Search**: Optimized with early termination on exact matches
|
|
223
|
+
|
|
224
|
+
## Development
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Clone the repository
|
|
228
|
+
git clone https://github.com/shuji-bonji/w3c-mcp.git
|
|
229
|
+
cd w3c-mcp
|
|
230
|
+
|
|
231
|
+
# Install dependencies
|
|
232
|
+
npm install
|
|
233
|
+
|
|
234
|
+
# Build
|
|
235
|
+
npm run build
|
|
236
|
+
|
|
237
|
+
# Run in development mode
|
|
238
|
+
npm run dev
|
|
239
|
+
|
|
240
|
+
# Run with debug logging
|
|
241
|
+
W3C_MCP_DEBUG=true npm start
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data loader for web-specs and webref packages
|
|
3
|
+
*
|
|
4
|
+
* Performance improvements:
|
|
5
|
+
* - Lazy loading with singleton pattern
|
|
6
|
+
* - Promise-based caching to prevent duplicate loads
|
|
7
|
+
* - Parallel loading support
|
|
8
|
+
* - Memory-efficient data structures
|
|
9
|
+
*/
|
|
10
|
+
import type { SpecDetail } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Load specs with singleton promise pattern
|
|
13
|
+
* Multiple simultaneous calls share the same loading promise
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadSpecs(): Promise<SpecDetail[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Find a spec by shortname - O(1) with index
|
|
18
|
+
*/
|
|
19
|
+
export declare function findSpec(shortname: string): Promise<SpecDetail | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Load WebIDL with singleton promise pattern
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadWebIDLRaw(): Promise<Record<string, string>>;
|
|
24
|
+
export interface CSSPropertyDef {
|
|
25
|
+
name: string;
|
|
26
|
+
href?: string;
|
|
27
|
+
syntax?: string;
|
|
28
|
+
initial?: string;
|
|
29
|
+
inherited?: string;
|
|
30
|
+
animationType?: string;
|
|
31
|
+
values?: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
href?: string;
|
|
34
|
+
value?: string;
|
|
35
|
+
}>;
|
|
36
|
+
styleDeclaration?: string[];
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface CSSData {
|
|
40
|
+
properties: CSSPropertyDef[];
|
|
41
|
+
functions: Array<{
|
|
42
|
+
name: string;
|
|
43
|
+
href?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
}>;
|
|
46
|
+
types: Array<{
|
|
47
|
+
name: string;
|
|
48
|
+
href?: string;
|
|
49
|
+
value?: string;
|
|
50
|
+
}>;
|
|
51
|
+
selectors: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
href?: string;
|
|
54
|
+
}>;
|
|
55
|
+
atrules: Array<{
|
|
56
|
+
name: string;
|
|
57
|
+
href?: string;
|
|
58
|
+
value?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Load CSS data with singleton promise pattern
|
|
63
|
+
*/
|
|
64
|
+
export declare function loadCSS(): Promise<CSSData>;
|
|
65
|
+
export interface ElementDef {
|
|
66
|
+
name: string;
|
|
67
|
+
href?: string;
|
|
68
|
+
interface?: string;
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
export interface ElementSpecData {
|
|
72
|
+
spec: {
|
|
73
|
+
title: string;
|
|
74
|
+
url: string;
|
|
75
|
+
};
|
|
76
|
+
elements: ElementDef[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Load elements data with singleton promise pattern
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadElements(): Promise<Record<string, ElementSpecData>>;
|
|
82
|
+
/**
|
|
83
|
+
* Preload all data in parallel
|
|
84
|
+
* Call this at server startup for better first-request performance
|
|
85
|
+
*/
|
|
86
|
+
export declare function preloadAll(): Promise<void>;
|
|
87
|
+
export declare function clearCache(): void;
|
|
88
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/data/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkBpD;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAUvD;AAoBD;;GAEG;AACH,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmBjF;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwBrE;AAMD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAchD;AAMD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAc7E;AAMD;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAOhD;AAMD,wBAAgB,UAAU,IAAI,IAAI,CAOjC"}
|