MCP Hub
Back to servers

Web Viewer MCP Server

A VS Code extension template and MCP server that enables AI agents to interact with webviews through navigation, element manipulation, and state inspection.

Tools
6
Updated
Jan 18, 2026

Web Viewer - VS Code Extension Template

VS Code extension template để hiển thị webview với tích hợp MCP Server cho AI agent.

Tính năng

  • 📱 Web Viewer: Hiển thị HTML/SPA trong VS Code tab
  • 🤖 MCP Server: Standalone server cho AI agent (Claude, Cursor, Gemini)
  • 🔧 Tools: Open, close, navigate, click, input, get state
  • 📦 Resources: State, DOM structure

Cài đặt

npm install
npm run build

Scripts

ScriptMô tả
npm run buildBuild tất cả (webview + extension)
npm run build:webviewBuild webview bằng Vite
npm run dev:webviewWatch mode cho webview
npm run compileCompile TypeScript extension

Chạy Extension

  1. Mở project trong VS Code
  2. Nhấn F5 để chạy Extension Development Host
  3. Chạy command Open Web viewer từ Command Palette

MCP Server

Tools

ToolMô tả
web_openMở tab Web viewer
web_closeĐóng tab Web viewer
web_navigateNavigate đến route
web_clickClick element theo CSS selector
web_inputNhập text vào input field
web_get_stateLấy state hiện tại

Resources

URIMô tả
spa://stateCurrent state (URL, title, forms, links)
spa://domDOM structure

Sử dụng với AI Agent

Cấu hình MCP

Thêm vào MCP config (ví dụ mcp_config.json):

{
  "mcpServers": {
    "web-viewer": {
      "command": "node",
      "args": ["<path-to-project>/out/mcp/mcp-server.js"]
    }
  }
}

Kiến trúc

AI Agent <--stdio--> MCP Server (node) <--HTTP:54321--> VS Code Extension <--postMessage--> Webview

Cấu trúc Project

├── media/                    # Build output (Vite)
│   ├── index.html
│   ├── styles.css
│   └── bundle.js
├── src/
│   ├── extension.ts          # Entry point + business logic
│   ├── core/                 # Generic modules
│   │   ├── ViewerProvider.ts # Configurable webview
│   │   └── HttpBridge.ts     # HTTP command router
│   ├── mcp/
│   │   └── mcp-server.ts     # Standalone MCP server
│   ├── spa/
│   │   └── tools/
│   │       └── index.ts      # Tool definitions
│   └── webview/              # Webview source (Vite)
│       ├── index.html
│       ├── styles.scss
│       ├── bridge.ts
│       └── main.ts
├── vite.config.ts
├── tsconfig.json
└── package.json

Customization

Thay đổi UI

Sửa files trong src/webview/, sau đó chạy npm run build:webview

Thêm MCP Tools

Sửa src/spa/tools/index.tssrc/mcp/mcp-server.ts

Thay đổi Config

Sửa src/extension.ts:

const webviewProvider = new WebviewProvider(context.extensionUri, {
    viewType: 'your.viewType',
    title: 'Your Title',
    mediaFolder: 'media',
});

License

MIT

Reviews

No reviews yet

Sign in to write a review