4D Documentation Viewer MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add 4d-docs -- node "<FULL_PATH_TO_MCP_4D_DOCS>/dist/index.js"

Replace <FULL_PATH_TO_MCP_4D_DOCS>/dist/index.js with the actual folder you prepared in step 1.

README.md

Browse 4D command documentation with integrated caching.

4D Documentation Viewer

A VS Code extension and MCP (Model Context Protocol) server for browsing 4D command documentation.

Overview

This project provides two ways to access 4D command documentation:

  1. VS Code Extension: Browse documentation directly in VS Code with intelligent command detection
  2. MCP Server: Use as a Model Context Protocol server with AI assistants like Claude

Both modes share the same caching system for improved performance.

Features

VS Code Extension Features

  • Smart Command Detection: Automatically detects 4D commands from:
    • Selected text
    • Word at cursor position
    • LSP/hover information
    • Strips command numbers (e.g., :C123 format) when getting command name
  • Two Display Modes:
    • Open in browser (quick external reference)
    • Open in editor webview (integrated documentation with CSS styling)
  • Context Menu Integration: Right-click commands for quick access
  • Automatic Caching: Faster subsequent lookups

MCP Server Features

  • Fetch 4D Command Documentation: Retrieve HTML documentation for any 4D command
  • Smart Caching: Automatically caches documentation in OS-specific cache directories
  • Cache Management: Clear the cache when needed to fetch fresh documentation
  • Browser Integration: Open documentation URLs directly in default browser

Installation

As a VS Code Extension

  1. Build the extension:
npm install
npm run build
  1. Install locally:
    • Press F5 to run the extension in a new VS Code window (for development)
    • Or package and install:
npm run package
code --install-extension mcp-4d-docs-0.1.0.vsix

As an MCP Server

# Clone or navigate to the project
cd mcp-4d-docs

# Install dependencies
npm install

# Build the TypeScript code
npm run build

Usage

Using the VS Code Extension

  1. Open a 4D code file (or any file)
  2. Select a 4D command name or place cursor on it
  3. Use one of these methods:
    • Command Palette (Cmd+Shift+P):
      • 4D: Open Command Documentation in Browser
      • 4D: Open Command Documentation in Editor
    • Right-click Context Menu:
      • Select command text, right-click, choose option
    • Keyboard Shortcut: (can be configured in VS Code)

If no command is detected, you'll be prompted to enter one manually.

Using as MCP Server

Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "4d-docs": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-4d-docs/build/index.js"]
    }
  }
}

For VS Code, add to .vscode/mcp.json:

{
  "mcpServers": {
    "4d-docs": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-4d-docs/build/index.js"]
    }
  }
}

Available MCP Tools

get_4d_command_docs

Fetches documentation for a 4D command.

Parameters:

  • command_name (string): The name of the 4D command (e.g., "ACTIVITY SNAPSHOT", "ARRAY TO LIST")

Returns:

  • HTML documentation content extracted from the <article> tag within the <main> section

Example:

// Fetches from https://developer.4d.com/docs/commands/activity-snapshot
get_4d_command_docs("ACTIVITY SNAPSHOT")

clear_4d_docs_cache

Clears all cached documentation files.

Returns:

  • A message indicating the number of files cleared

open_4d_command_in_browser

Opens a 4D command documentation page in the default web browser.

Parameters:

  • command_name (string): The name of the 4D command (e.g., "ACTIVITY SNAPSHOT", "ARRAY TO LIST")

Returns:

  • A message confirming the URL was opened

Example:

// Opens https://developer.4d.com/docs/commands/activity-snapshot in your browser
open_4d_command_in_browser("ACTIVITY SNAPSHOT")

How It Works

  1. Command Detection (VS Code Extension):

    • Checks for selected text first
    • Falls back to word at cursor position
    • Uses LSP hover information when available
    • Prompts for manual entry if needed
  2. URL Encoding: Command names are converted to lowercase and spaces are replaced with hyphens

    • Example: "ACTIVITY SNAPSHOT" → "activity-snapshot"
  3. Documentation Fetching: The server requests documentation from:

    • https://developer.4d.com/docs/commands/<encoded-command-name>
  4. HTML Extraction: The server parses the HTML and extracts the <article> node from within the <main> tag

  5. Link Rewriting: Relative /docs/ links are converted to absolute URLs

  6. Caching: Results are cached in the OS system cache directory:

    • macOS: ~/Library/Caches/mcp-4d-docs/
    • Windows: %LOCALAPPDATA%\mcp-4d-docs\
    • Linux: ~/.cache/mcp-4d-docs/
  7. Cache Key: Each command is cached using an MD5 hash of its name as the filename

  8. Display (VS Code Extension):

    • Browser mode: Opens URL directly
    • Webview mode: Displays cached HTML with 4D CSS styling and VS Code theme integration

Developm

Tools (3)

get_4d_command_docsFetches documentation for a 4D command.
clear_4d_docs_cacheClears all cached documentation files.
open_4d_command_in_browserOpens a 4D command documentation page in the default web browser.

Configuration

claude_desktop_config.json
{"mcpServers": {"4d-docs": {"command": "node", "args": ["/absolute/path/to/mcp-4d-docs/build/index.js"]}}}

Try it

Can you fetch the documentation for the ACTIVITY SNAPSHOT command?
How do I use the ARRAY TO LIST command in 4D?
Open the documentation for the ARRAY TO LIST command in my browser.
Clear the 4D documentation cache to ensure I have the latest information.

Frequently Asked Questions

What are the key features of 4D Documentation Viewer?

Fetch HTML documentation for any 4D command. Smart caching system for improved performance. Cache management to clear stored documentation. Browser integration to open documentation URLs directly.

What can I use 4D Documentation Viewer for?

Quickly looking up syntax and usage for 4D commands during development. Retrieving detailed technical content for 4D commands within an AI chat interface. Ensuring documentation is accessible offline or via cache for faster lookups. Opening official 4D developer documentation pages directly from an AI assistant.

How do I install 4D Documentation Viewer?

Install 4D Documentation Viewer by running: npm install && npm run build

What MCP clients work with 4D Documentation Viewer?

4D Documentation Viewer works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep 4D Documentation Viewer docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare