vsl-mcp-server

v1.4.14
@thinkingos/vsl-mcp-server Checked 4 days ago Published 2 days ago

VSL MCP Server — Model Context Protocol integration for AI agents (Claude Desktop, Cline, TaoCoder)

VSL MCP Server — integration of Visual Scene Language with AI agents via Model Context Protocol (MCP 2025-11-25). Enables AI agents (Claude Desktop, Cline, TaoCoder) to interact with web pages through VSL semantic structure: read pages, execute actions, and receive change diffs. Via npx — automatically downloads the package and runs interactive setup: npx -p @thinkingos/vsl-mcp-server mcp-server-setup

Summary extracted from the README.

@thinkingos/vsl-mcp-server

VSL MCP Server — integration of Visual Scene Language with AI agents via Model Context Protocol (MCP 2025-11-25).

Enables AI agents (Claude Desktop, Cline, TaoCoder) to interact with web pages through VSL semantic structure: read pages, execute actions, and receive change diffs.

Quick Installation (one command)

Via npx — automatically downloads the package and runs interactive setup:

npx -p @thinkingos/vsl-mcp-server mcp-server-setup

The setup script will help you:

  1. Check Node.js >= 18
  2. Install Playwright (optional, for browser tools)
  3. Save configuration to ~/.vsl/config.json
  4. Get instructions for connecting to an agent

Installation from Source (for developers)

From the monorepo root

Clone the repository

git clone visual-scene-language cd visual-scene-language

Install dependencies

npm install

Build the package

cd packages/mcp-server npm run build

From the monorepo root:

node packages/mcp-server/bin/setup.js

Or from the packages/mcp-server directory:

npm run setup

The setup script will help you:

  1. Check Node.js >= 18
  2. Install Playwright (optional, for browser tools)
  3. Save configuration to ~/.vsl/config.json
  4. Get instructions for connecting to an agent

Configuration

API Keys (env vars)

At least one provider for vision-backend (element classification)

export OPENAI_API_KEY="sk-..." # gpt-6-luna export ANTHROPIC_API_KEY="sk-ant-..." # claude-haiku-4-5

Or a custom provider (any OpenAI-compatible endpoint):

export VSL_VISION_PROVIDER="custom" export VSL_VISION_BASE_URL="https://api.together.xyz/v1" export VSL_VISION_API_KEY="your-key" export VSL_VISION_MODEL="meta-llama/Llama-Vision"

Configuration File (optional)

~/.vsl/config.json:

{ "openai": { "apiKey": "sk-..." }, "anthropic": { "apiKey": "sk-ant-..." }, "vision": { "provider": "custom", "baseUrl": "https://api.together.xyz/v1", "apiKey": "your-key", "model": "meta-llama/Llama-Vision" } } Priority: env vars > config file > defaults.

Tools

vsl_get_snapshot

Get the current VSL snapshot of the page. Returns VSL JSON with the semantic structure of elements.

Parameters:

  • url (string, optional) — Page URL. If not specified, uses the current page.
  • detail_level (string, optional) — detail level: low (interactive elements only), medium (interactive + containers, default), high (all objects).
  • ttl (number, optional) — cache TTL in ms (default 5000 = 5s). 0 — disable caching.
  • full (boolean, optional) — full mode: returns the ENTIRE document without viewport filter and detail level filter, bypassing diff-first logic. Use if agent history was truncated and you need the full picture of the page (replaces the removed vsl_get_full_json tool).

Returns: VslDocument — VSL JSON filtered by visible window and detail level (or full when full: true). Contains metadata scrollable: { top, bottom } (whether there is content above/below the visible window).

Caching: repeated calls with the same URL within TTL return the document from cache, re-filtered by new parameters, without accessing the browser.

vsl_execute_action

Execute an action on a VSL element.

Parameters:

  • action (string, required) — action name: click, type, fill (alias for type), scroll, select, hover, focus, blur, check, uncheck, press, upload (file upload, requires value — file path or comma-separated list of paths), download (file download: click on element or direct download by URL via value)
  • target_id (string, required) — element ID in VSL JSON
  • value (string, optional) — value for the action (text for type, option for select, file path for upload)
  • timeout (number, optional) — download completion timeout in ms (only for download action)
  • save_path (string, optional) — path to save the downloaded file (only for download action; relative paths are resolved to the downloads folder with boundary check)
  • return_state (boolean, optional, default true) — whether to return page state after action (diff + snapshot filtered by visible window)

Returns: action execution result.

File upload example:

Agent: vsl_execute_action(action="upload", target_id="file_input_0", value="/path/to/document.pdf") → { success: true, data: { action: "upload", upload: { selector: "#file_input_0", files: ["/path/to/document.pdf"], success: true } } }

For uploading multiple files (if input has multiple attribute):

Agent: vsl_execute_action(action="upload", target_id="file_input_1", value="/path/file1.jpg, /path/file2.jpg") → { success: true, data: { upload: { files: ["/path/file1.jpg", "/path/file2.jpg"], success: true } } }

File download example (download action):

Agent: vsl_execute_action(action="download", target_id="btn_download") → { success: true, data: { download: { downloadId: "dl_1", filename: "report.pdf", url: "https://example.com/report.pdf", status: "completed", path: "/downloads/report.pdf" } } }

Direct download by URL with saving to specified path and timeout:

Agent: vsl_execute_action(action="download", target_id="btn_download", value="https://example.com/file.pdf", save_path="/tmp/file.pdf", timeout=15000) → { success: true, data: { download: { downloadId: "dl_1", filename: "file.pdf", status: "completed", path: "/tmp/file.pdf" } } }

Lazy Navigation (DEC-028): Before executing an action, the system automatically checks if the browser is on the URL from the current snapshot. If not — it automatically navigates to the required URL. This allows the agent to:

  1. Read the page via HTTP path (fast, without browser)
  2. Get VSL JSON with semantic structure
  3. Call vsl_execute_action — the system will automatically launch the browser and navigate to the URL

The agent does NOT need to explicitly call vsl_navigate before executing actions.

vsl_navigate

Navigate to a URL.

Parameters:

  • url (string, required) — URL to navigate to

Returns: navigation success/failure.

vsl_clear_cache

Clear the VSL snapshot cache. The next vsl_get_snapshot call will create a new snapshot from scratch.

Parameters: none.

vsl_get_visual

Get a visual fragment for an element (base64 WebP image). Automatically scrolls the page to the element if it's outside the viewport.

Parameters:

  • element_id (string, required) — element ID in VSL JSON
  • auto_scroll (boolean, optional, default: true) — automatically scroll to element if it's outside viewport
  • auto_refresh (boolean, optional, default: false) — automatically refresh snapshot before searching

Returns: base64 image of the element. If auto-scroll was performed, the result contains scroll_info: { scrolled: true, scroll_offset: { x, y } }.

vsl_read_page

Hybrid web page reading with automatic strategy. HTTP-first for static pages; automatic switching to browser rendering for SPAs.

Parameters:

  • url (string, required) — page URL to read
  • readable (boolean, optional) — noise filtering (nav, footer, cookie banners)

Automatic strategy:

  • The system determines the optimal path itself: HTTP for static pages, Render for SPAs
  • The agent does NOT choose the mode — there is no mode parameter
  • SPA markers (id="root", id="app", data-reactroot, ng-app) automatically switch to Render path

Features:

  • Repeated reads return diff (Snapshot Session)
  • Readable mode filters nav, footer, cookie banners
  • HTTP path returns VSL JSON with semantic structure without coordinates (objects without p/s transparently pass viewport filter)
  • Render path returns full VSL JSON with absolute pixel coordinates for executing actions

Returns: VSL JSON structure of the page (full document or diff).

vsl_get_text_block

Get the full text by txt_ref from lazy text loading. Texts longer than ~200 characters in the snapshot are automatically replaced with txt_preview (first ~50 characters) + txt_ref (reference like tb_001).

Parameters:

  • block_id (string, required) — text block ID from the txt_ref field of the snapshot object (format tb_xxx)

Returns: { block_id, text } — full content of the text block.

Unified Delivery Pipeline: Full Cache + Filtering on Delivery

All delivery paths (vsl_get_snapshot, vsl_navigate, vsl_execute_action with return_state, browser path vsl_read_page) use a unified pipeline:

  1. Full extraction — the FULL DOM tree is extracted from the browser, including elements outside the visible area (no truncation at the extraction stage).
  2. Full cache — the session stores the full VslDocument; diffs are calculated on full documents.
  3. Absolute coordinates — the p field of an object: absolute page-relative pixels [x, y] (accounting for page scroll); s — size [width, height]. Coordinates are invariant to window resize.
  4. Filtering on delivery — visible window = [scroll, scroll + viewport]; first viewport filter (container lives as long as there are visible descendants), then detail_level filter.
  5. Scroll metadata — the result contains scrollable: { top, bottom }: whether there is content above/below the visible window (guide for scroll actions).

Mode differences:

HTTP mode (vsl_read_page) Browser mode
When static pages SPA and interactive pages
Coordinates absent (p/s = null) absolute pixels
Viewport filter transparent (all objects pass) cuts off invisible elements
Actions not directly available — vsl_execute_action will launch the browser itself (lazy navigation) full set of actions

Repeated requests without browser: changing detail_level or full within the cache re-filters the document from cache — without re-extraction.

Resources (MCP Resources)

vsl://current

Current VSL snapshot of the page. Contains the full semantic structure of elements.

vsl://diff

Latest VSL diff since the previous snapshot. Contains only changes (added/modified/removed).

Integration with AI Agents

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{ "mcpServers": { "vsl": { "command": "node", "args": ["/absolute/path/to/visual-scene-language/packages/mcp-server/dist/index.js"], "env": { "OPENAI_API_KEY": "sk-..." } } } }

Cline

Add to Cline settings (VS Code → Settings → Cline → MCP Servers → Add Server → Local (stdio)):

  • Server Name: vsl
  • Command: node
  • Arguments: /absolute/path/to/visual-scene-language/packages/mcp-server/dist/index.js
  • Environment variables: OPENAI_API_KEY=sk-... Or JSON format:

{ "vsl": { "command": "node", "args": ["/absolute/path/to/visual-scene-language/packages/mcp-server/dist/index.js"], "env": { "OPENAI_API_KEY": "sk-..." } } }

TaoCoder

Add to .taocoder/mcp.json:

{ "servers": { "vsl": { "command": "node", "args": ["/absolute/path/to/visual-scene-language/packages/mcp-server/dist/index.js"], "env": { "OPENAI_API_KEY": "sk-..." } } } }

Cursor

Add to .cursor/mcp.json:

{ "mcpServers": { "vsl": { "command": "node", "args": ["/absolute/path/to/visual-scene-language/packages/mcp-server/dist/index.js"], "env": { "OPENAI_API_KEY": "sk-..." } } } }

💡 Tip: Replace /absolute/path/to/visual-scene-language with the actual path to your repository. If you configured vision via ~/.vsl/config.json, you don't need to specify env vars.

Usage Examples

Reading a Static Page

Agent: vsl_read_page(url="https://example.com/article") → { status: "success", data: { mode: "http", content: "...", vslDocument: {...}, metadata: { title: "Example Article", wordCount: 1500 } } }

Reading an SPA (automatic switching to Render)

The system automatically detects SPA markers and switches to Render path

Agent: vsl_read_page(url="https://spa-app.com/dashboard") → { status: "success", data: { mode: "render", vslDocument: {...}, hasDiff: false } }

Agent: vsl_execute_action(action="click", target_id="btn_refresh") → { success: true }

Agent: vsl_read_page(url="https://spa-app.com/dashboard") → { status: "success", data: { mode: "render", diff: { added: [...], modified: [...] }, hasDiff: true } }

Getting Full Snapshot When Context is Lost

Agent history was truncated — request full document without filters

Agent: vsl_get_snapshot(full=true) → { vsl_version: "1.0.0", canvas: {...}, objects: [ ...all elements, including invisible... ] }

Architecture

┌─────────────────────────────────────────────┐ │ AI Agent (Claude Desktop / Cline / etc.) │ └──────────────────┬──────────────────────────┘ │ MCP (JSON-RPC over stdio) ▼ ┌─────────────────────────────────────────────┐ │ @thinkingos/vsl-mcp-server │ │ ├── Tools (7): snapshot, action, navigate, │ │ │ cache, visual, read_page, │ │ │ text_block │ │ ├── Resources (2): vsl://current, │ │ │ vsl://diff │ │ ├── BrowserManager (Playwright, optional) │ │ ├── ServerSession (snapshot state + diff) │ │ └── Config (env + config file) │ └──────────────────┬──────────────────────────┘ │ @thinkingos/vsl-sdk ▼ ┌─────────────────────────────────────────────┐ │ VSL Core SDK │ │ ├── DOM extraction → Segmentation │ │ ├── VSL Builder → VslDocument │ │ ├── Diff Engine → VslDiff │ │ └── Vision Classifier (LLM flash models) │ └─────────────────────────────────────────────┘

Bug Fixes

ID Stability after fill action — elements retain their short IDs after DOM changes.

Iframe ID Resolution — fixed ID resolution for elements inside iframes (uses full target_id with iframe_N: prefix).

Lazy Text Loading — texts longer than ~200 characters are automatically replaced with txt_preview + txt_ref to save tokens.

Lazy Navigation — automatic navigation to URL before executing actions if the browser is not on the correct page.

Requirements

  • Node.js ≥ 18
  • Playwright (optional, for SPA rendering): npx playwright install chromium
  • API key for at least one provider (OpenAI / Anthropic / Custom) for vision-backend

Vision-backend

For classifying elements without A11y semantics, cheap flash models are used:

Provider Model Env var
OpenAI gpt-6-luna OPENAI_API_KEY
Anthropic claude-haiku-4-5 ANTHROPIC_API_KEY
Custom any OpenAI-compatible VSL_VISION_BASE_URL + VSL_VISION_API_KEY + VSL_VISION_MODEL

The model is configured via vision.provider and vision.model in the config file.

Custom Providers

Any OpenAI-compatible APIs are supported (Together AI, Groq, OpenRouter, local models via Ollama/vLLM, etc.). Specify provider: "custom", baseUrl, apiKey, and model in the config or via env vars.

Example for Together AI:

{ "vision": { "provider": "custom", "baseUrl": "https://api.together.xyz/v1", "apiKey": "your-together-key", "model": "meta-llama/Llama-Vision" } } Example for Groq:

{ "vision": { "provider": "custom", "baseUrl": "https://api.groq.com/openai/v1", "apiKey": "your-groq-key", "model": "llama-3.2-90b-vision-preview" } }

License

SEE LICENSE IN LICENSE.txt