@mcp-html-bridge/claude-skill 0.2.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/commands/mcp-render.md +109 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +7 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +35 -0
- package/dist/install.js.map +1 -0
- package/dist/render.d.ts +16 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +85 -0
- package/dist/render.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
You are an MCP tool result visualizer powered by MCP-HTML-Bridge. You render MCP tool schemas and result data as beautiful, self-contained HTML pages — zero runtime dependencies.
|
|
2
|
+
|
|
3
|
+
## Core Workflow
|
|
4
|
+
|
|
5
|
+
1. **Identify input** — user provides JSON (file path, inline, or from a recent MCP tool call)
|
|
6
|
+
2. **Detect mode** — `type: "object"` + `properties` → schema (form) / anything else → data (visualization)
|
|
7
|
+
3. **Render** — call `mcp-html-skill render` to generate HTML
|
|
8
|
+
4. **Deliver** — write file + open in browser, or embed HTML in response
|
|
9
|
+
|
|
10
|
+
## Render Commands
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Write to file and open in browser (primary method)
|
|
14
|
+
cat <<'EOF' > /tmp/mcp-input.json
|
|
15
|
+
<JSON_DATA>
|
|
16
|
+
EOF
|
|
17
|
+
mcp-html-skill render --data /tmp/mcp-input.json --title "Title" --tool-name "tool" --open
|
|
18
|
+
|
|
19
|
+
# Schema → interactive form
|
|
20
|
+
mcp-html-skill render --schema /tmp/mcp-schema.json --title "Title" --tool-name "tool" --open
|
|
21
|
+
|
|
22
|
+
# Print raw HTML to stdout (for embedding in response)
|
|
23
|
+
mcp-html-skill render --data /tmp/mcp-input.json --stdout
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If `mcp-html-skill` is not in PATH, use:
|
|
27
|
+
```bash
|
|
28
|
+
npx @mcp-html-bridge/claude-skill render --data /tmp/mcp-input.json --title "Title" --open
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Options Reference
|
|
32
|
+
|
|
33
|
+
| Flag | Description |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `--schema <file>` | Render JSON Schema as interactive form |
|
|
36
|
+
| `--data <file>` | Render JSON data as visualization |
|
|
37
|
+
| `--json '<str>'` | Inline JSON (small payloads) |
|
|
38
|
+
| `--title <title>` | Browser tab & header title |
|
|
39
|
+
| `--tool-name <name>` | MCP tool name (for bridge protocol) |
|
|
40
|
+
| `--tool-desc <desc>` | Tool description |
|
|
41
|
+
| `--debug` | Enable debug playground (LLM relay, JSON injection) |
|
|
42
|
+
| `--output <dir>` | Output dir (default: /tmp/mcp-html-bridge) |
|
|
43
|
+
| `--open` | Auto-open in default browser |
|
|
44
|
+
| `--stdout` | Print raw HTML to stdout |
|
|
45
|
+
|
|
46
|
+
## Delivery Strategy
|
|
47
|
+
|
|
48
|
+
**Default (file + browser):**
|
|
49
|
+
1. Write JSON to temp file
|
|
50
|
+
2. `mcp-html-skill render --data /tmp/mcp-input.json --title "..." --open`
|
|
51
|
+
3. Tell user: "Rendered and opened in browser. File: <path>"
|
|
52
|
+
|
|
53
|
+
**Inline HTML embedding (for hosts that support HTML rendering):**
|
|
54
|
+
1. Render with `--stdout` to get raw HTML
|
|
55
|
+
2. Wrap in a fenced code block with `html` language tag in your response
|
|
56
|
+
3. Hosts that support HTML preview (e.g., future Claude Desktop) can render it inline
|
|
57
|
+
|
|
58
|
+
Always prefer the file + browser approach as the primary delivery method. The inline approach is supplementary.
|
|
59
|
+
|
|
60
|
+
## Auto-Detection
|
|
61
|
+
|
|
62
|
+
| Data Shape | Visualization |
|
|
63
|
+
|---|---|
|
|
64
|
+
| Array of objects (consistent keys) | Sortable data grid with status badges |
|
|
65
|
+
| Flat object with numbers | KPI / metrics cards |
|
|
66
|
+
| Deep nesting (depth > 3) | Collapsible JSON tree |
|
|
67
|
+
| Long text strings | Formatted reading blocks |
|
|
68
|
+
| Mixed structure | Composite (combines above) |
|
|
69
|
+
| JSON Schema with `properties` | Interactive input form |
|
|
70
|
+
|
|
71
|
+
## Example: Baidu Youxuan MCP Integration
|
|
72
|
+
|
|
73
|
+
When the user has a Baidu Youxuan (百度优选) MCP server connected and calls comparison tools:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 1. The MCP tool returns structured comparison data
|
|
77
|
+
# 2. Save the tool result to a temp file
|
|
78
|
+
cat <<'EOF' > /tmp/mcp-input.json
|
|
79
|
+
{
|
|
80
|
+
"compareId": "CMP-001",
|
|
81
|
+
"products": ["SKU-001", "SKU-002", "SKU-003"],
|
|
82
|
+
"comparison": [
|
|
83
|
+
{ "dimension": "商品名称", "SKU-001": "联想小新 Pro 16", "SKU-002": "RedmiBook Pro 15", "SKU-003": "华为 MateBook 14s" },
|
|
84
|
+
{ "dimension": "到手价", "SKU-001": "¥4,699", "SKU-002": "¥4,099", "SKU-003": "¥6,999" },
|
|
85
|
+
{ "dimension": "处理器", "SKU-001": "R7-8845H", "SKU-002": "i7-13700H", "SKU-003": "Ultra 7" },
|
|
86
|
+
{ "dimension": "评分", "SKU-001": "4.8", "SKU-002": "4.7", "SKU-003": "4.9" },
|
|
87
|
+
{ "dimension": "佣金比例", "SKU-001": "3.5%", "SKU-002": "4.2%", "SKU-003": "2.8%" }
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
EOF
|
|
91
|
+
|
|
92
|
+
# 3. Render as visual HTML
|
|
93
|
+
mcp-html-skill render --data /tmp/mcp-input.json \
|
|
94
|
+
--title "商品参数对比" \
|
|
95
|
+
--tool-name "baidu_youxuan_compare" \
|
|
96
|
+
--open
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The engine detects the `comparison` array of objects and renders a sortable comparison table with formatted cells.
|
|
100
|
+
|
|
101
|
+
## Tips
|
|
102
|
+
|
|
103
|
+
- Always use `--open` so the page launches automatically
|
|
104
|
+
- Generated HTML works offline (zero dependencies)
|
|
105
|
+
- Dark mode follows system preference
|
|
106
|
+
- `--debug` adds a playground panel for testing LLM integration
|
|
107
|
+
- Output persists in `/tmp/mcp-html-bridge/` until system cleanup
|
|
108
|
+
|
|
109
|
+
$ARGUMENTS
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @mcp-html-bridge/claude-skill
|
|
4
|
+
*
|
|
5
|
+
* CLI tool for Claude Code integration:
|
|
6
|
+
* mcp-html-skill install — install /mcp-render command into Claude Code
|
|
7
|
+
* mcp-html-skill render — render JSON schema/data to HTML file
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from 'commander';
|
|
10
|
+
import { install } from './install.js';
|
|
11
|
+
import { render } from './render.js';
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program
|
|
14
|
+
.name('mcp-html-skill')
|
|
15
|
+
.description('Claude Code skill for MCP-HTML-Bridge')
|
|
16
|
+
.version('0.1.0');
|
|
17
|
+
program
|
|
18
|
+
.command('install')
|
|
19
|
+
.description('Install /mcp-render command into Claude Code (~/.claude/commands/)')
|
|
20
|
+
.option('--global', 'Install to global ~/.claude/commands/ (default)', true)
|
|
21
|
+
.option('--project', 'Install to current project .claude/commands/')
|
|
22
|
+
.action(install);
|
|
23
|
+
program
|
|
24
|
+
.command('render')
|
|
25
|
+
.description('Render MCP tool schema or result data as HTML')
|
|
26
|
+
.option('--schema <file>', 'JSON Schema file (renders input form)')
|
|
27
|
+
.option('--data <file>', 'JSON data file (renders result view)')
|
|
28
|
+
.option('--json <string>', 'Inline JSON string')
|
|
29
|
+
.option('--mode <mode>', 'Force render mode: schema | data (auto-detected if omitted)')
|
|
30
|
+
.option('--title <title>', 'Page title')
|
|
31
|
+
.option('--tool-name <name>', 'Tool name for bridge protocol')
|
|
32
|
+
.option('--tool-desc <desc>', 'Tool description')
|
|
33
|
+
.option('--debug', 'Enable debug playground panel')
|
|
34
|
+
.option('--output <dir>', 'Output directory', '/tmp/mcp-html-bridge')
|
|
35
|
+
.option('--open', 'Open in browser after rendering')
|
|
36
|
+
.option('--stdout', 'Print raw HTML to stdout instead of writing to file')
|
|
37
|
+
.action(render);
|
|
38
|
+
program.parse();
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,gBAAgB,CAAC;KACtB,WAAW,CAAC,uCAAuC,CAAC;KACpD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,oEAAoE,CAAC;KACjF,MAAM,CAAC,UAAU,EAAE,iDAAiD,EAAE,IAAI,CAAC;KAC3E,MAAM,CAAC,WAAW,EAAE,8CAA8C,CAAC;KACnE,MAAM,CAAC,OAAO,CAAC,CAAC;AAEnB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,iBAAiB,EAAE,uCAAuC,CAAC;KAClE,MAAM,CAAC,eAAe,EAAE,sCAAsC,CAAC;KAC/D,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;KAC/C,MAAM,CAAC,eAAe,EAAE,6DAA6D,CAAC;KACtF,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC;KACvC,MAAM,CAAC,oBAAoB,EAAE,+BAA+B,CAAC;KAC7D,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;KAChD,MAAM,CAAC,SAAS,EAAE,+BAA+B,CAAC;KAClD,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,sBAAsB,CAAC;KACpE,MAAM,CAAC,QAAQ,EAAE,iCAAiC,CAAC;KACnD,MAAM,CAAC,UAAU,EAAE,qDAAqD,CAAC;KACzE,MAAM,CAAC,MAAM,CAAC,CAAC;AAElB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAUA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CA+BrD"}
|
package/dist/install.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the /mcp-render command into Claude Code.
|
|
3
|
+
*/
|
|
4
|
+
import { existsSync, mkdirSync, copyFileSync } from 'node:fs';
|
|
5
|
+
import { join, dirname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
export function install(options) {
|
|
10
|
+
const targetDir = options.project
|
|
11
|
+
? join(process.cwd(), '.claude', 'commands')
|
|
12
|
+
: join(homedir(), '.claude', 'commands');
|
|
13
|
+
mkdirSync(targetDir, { recursive: true });
|
|
14
|
+
// The commands/ dir is at package root, one level up from dist/
|
|
15
|
+
const commandSrc = join(__dirname, '..', 'commands', 'mcp-render.md');
|
|
16
|
+
// Fallback: if running from src/ during development, try two levels up
|
|
17
|
+
const altSrc = join(__dirname, '..', '..', 'commands', 'mcp-render.md');
|
|
18
|
+
const srcFile = existsSync(commandSrc) ? commandSrc : altSrc;
|
|
19
|
+
if (!existsSync(srcFile)) {
|
|
20
|
+
console.error(' Error: command file not found at', commandSrc);
|
|
21
|
+
console.error(' Make sure the package is installed correctly.');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const dest = join(targetDir, 'mcp-render.md');
|
|
25
|
+
copyFileSync(srcFile, dest);
|
|
26
|
+
const scope = options.project ? 'project' : 'global';
|
|
27
|
+
console.log(`\n MCP-HTML-Bridge skill installed!\n`);
|
|
28
|
+
console.log(` Command file: ${dest}`);
|
|
29
|
+
console.log(` Scope: ${scope}\n`);
|
|
30
|
+
console.log(` Usage in Claude Code:`);
|
|
31
|
+
console.log(` /mcp-render — interactive mode`);
|
|
32
|
+
console.log(` /mcp-render schema.json — render a schema file`);
|
|
33
|
+
console.log(` /mcp-render data.json — render a data file\n`);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAO1D,MAAM,UAAU,OAAO,CAAC,OAAuB;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,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AC;IACvC,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface RenderOptions {
|
|
2
|
+
schema?: string;
|
|
3
|
+
data?: string;
|
|
4
|
+
json?: string;
|
|
5
|
+
mode?: 'schema' | 'data';
|
|
6
|
+
title?: string;
|
|
7
|
+
toolName?: string;
|
|
8
|
+
toolDesc?: string;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
output?: string;
|
|
11
|
+
open?: boolean;
|
|
12
|
+
stdout?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function render(options: RenderOptions): void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAQA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAyDD,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAgCnD"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render MCP tool schema or data as a self-contained HTML page.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import { renderFromSchema, renderFromData } from '@mcp-html-bridge/ui-engine';
|
|
8
|
+
function loadJSON(options) {
|
|
9
|
+
let raw;
|
|
10
|
+
if (options.schema) {
|
|
11
|
+
raw = readFileSync(options.schema, 'utf-8');
|
|
12
|
+
return { json: JSON.parse(raw), detectedMode: 'schema' };
|
|
13
|
+
}
|
|
14
|
+
if (options.data) {
|
|
15
|
+
raw = readFileSync(options.data, 'utf-8');
|
|
16
|
+
return { json: JSON.parse(raw), detectedMode: 'data' };
|
|
17
|
+
}
|
|
18
|
+
if (options.json) {
|
|
19
|
+
const parsed = JSON.parse(options.json);
|
|
20
|
+
const isSchema = parsed && typeof parsed === 'object' &&
|
|
21
|
+
parsed.type === 'object' && parsed.properties;
|
|
22
|
+
return { json: parsed, detectedMode: isSchema ? 'schema' : 'data' };
|
|
23
|
+
}
|
|
24
|
+
// Try reading from stdin if piped
|
|
25
|
+
try {
|
|
26
|
+
raw = readFileSync('/dev/stdin', 'utf-8');
|
|
27
|
+
if (raw.trim()) {
|
|
28
|
+
const parsed = JSON.parse(raw);
|
|
29
|
+
const isSchema = parsed && typeof parsed === 'object' &&
|
|
30
|
+
parsed.type === 'object' && parsed.properties;
|
|
31
|
+
return { json: parsed, detectedMode: isSchema ? 'schema' : 'data' };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Not piped, ignore
|
|
36
|
+
}
|
|
37
|
+
console.error(' Error: No input provided.');
|
|
38
|
+
console.error(' Use --schema <file>, --data <file>, --json <string>, or pipe via stdin.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
function buildHTML(json, mode, options) {
|
|
42
|
+
if (mode === 'schema') {
|
|
43
|
+
return renderFromSchema(json, {
|
|
44
|
+
title: options.title ?? options.toolName ?? 'MCP Tool Input',
|
|
45
|
+
toolName: options.toolName,
|
|
46
|
+
toolDescription: options.toolDesc,
|
|
47
|
+
debug: options.debug ?? true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return renderFromData(json, {
|
|
51
|
+
title: options.title ?? options.toolName ?? 'MCP Tool Result',
|
|
52
|
+
toolName: options.toolName,
|
|
53
|
+
toolDescription: options.toolDesc,
|
|
54
|
+
debug: options.debug,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function render(options) {
|
|
58
|
+
const { json, detectedMode } = loadJSON(options);
|
|
59
|
+
const mode = options.mode ?? detectedMode;
|
|
60
|
+
const html = buildHTML(json, mode, options);
|
|
61
|
+
// --stdout: print raw HTML to stdout (for embedding in response streams)
|
|
62
|
+
if (options.stdout) {
|
|
63
|
+
process.stdout.write(html);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const outDir = options.output ?? '/tmp/mcp-html-bridge';
|
|
67
|
+
mkdirSync(outDir, { recursive: true });
|
|
68
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
69
|
+
const toolSlug = (options.toolName ?? 'mcp-tool').replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
70
|
+
const fileName = `${toolSlug}_${timestamp}.html`;
|
|
71
|
+
const outPath = join(outDir, fileName);
|
|
72
|
+
writeFileSync(outPath, html, 'utf-8');
|
|
73
|
+
// Output the path — Claude Code will capture this
|
|
74
|
+
console.log(outPath);
|
|
75
|
+
if (options.open) {
|
|
76
|
+
try {
|
|
77
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
78
|
+
execSync(`${cmd} "${outPath}"`, { stdio: 'ignore' });
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Silently fail if can't open browser
|
|
82
|
+
}
|
|
83
|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IAAI,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;YACzG,QAAQ,CAAC,GAAG,GAAG,KAAK,OAAO,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-html-bridge/claude-skill",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Claude Code skill for MCP-HTML-Bridge — render MCP tool data as interactive HTML pages",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-html-skill": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/",
|
|
13
|
+
"commands/"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@mcp-html-bridge/ui-engine": "*",
|
|
21
|
+
"commander": "^12.0.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/zhongkai/mcp-html-bridge.git",
|
|
30
|
+
"directory": "packages/claude-skill"
|
|
31
|
+
}
|
|
32
|
+
}
|