4D Documentation Viewer
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@4D Documentation Viewer show me the documentation for the ACTIVITY SNAPSHOT command"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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:
VS Code Extension: Browse documentation directly in VS Code with intelligent command detection
MCP Server: Use as a Model Context Protocol server with AI assistants like Claude
Both modes share the same caching system for improved performance.
Related MCP server: MCP Docs Server
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.,
:C123format) 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
Build the extension:
npm install
npm run buildInstall locally:
Press
F5to 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.vsixAs an MCP Server
# Clone or navigate to the project
cd mcp-4d-docs
# Install dependencies
npm install
# Build the TypeScript code
npm run buildUsage
Using the VS Code Extension
Open a 4D code file (or any file)
Select a 4D command name or place cursor on it
Use one of these methods:
Command Palette (
Cmd+Shift+P):4D: Open Command Documentation in Browser4D: 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
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
URL Encoding: Command names are converted to lowercase and spaces are replaced with hyphens
Example: "ACTIVITY SNAPSHOT" → "activity-snapshot"
Documentation Fetching: The server requests documentation from:
https://developer.4d.com/docs/commands/<encoded-command-name>
HTML Extraction: The server parses the HTML and extracts the
<article>node from within the<main>tagLink Rewriting: Relative
/docs/links are converted to absolute URLsCaching: 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/
Cache Key: Each command is cached using an MD5 hash of its name as the filename
Display (VS Code Extension):
Browser mode: Opens URL directly
Webview mode: Displays cached HTML with 4D CSS styling and VS Code theme integration
Development
Project Structure
mcp-4d-docs/
├── src/
│ ├── index.ts # MCP server implementation
│ ├── extension.ts # VS Code extension entry point
│ ├── docService.ts # Shared documentation service
│ ├── commandDetector.ts # Command name detection logic
│ └── webviewProvider.ts # Webview panel management
├── build/ # Compiled JavaScript output
├── logo.png # Extension icon
├── package.json # Project metadata & VS Code extension config
├── tsconfig.json # TypeScript configuration
├── .vscodeignore # Files excluded from extension package
└── README.mdBuilding
# Install dependencies
npm install
# Build TypeScript
npm run build
# Watch mode for development
npm run watch
# Package extension
npm run packageTesting the Extension
Press F5 in VS Code to launch the Extension Development Host with the extension loaded.
Testing the MCP Server
# Use MCP Inspector
npx @modelcontextprotocol/inspector node build/index.jsDependencies
@modelcontextprotocol/sdk- Model Context Protocol SDKcheerio- HTML parsing@types/vscode- VS Code API types@vscode/vsce- VS Code extension packaging
Configuration
Extension Settings
The extension works out of the box with no configuration needed. It will:
Activate when opening 4D files (
onLanguage:4d)Be available via command palette for any file type
Cache documentation in your system cache directory
Custom Keybindings
You can add custom keyboard shortcuts in VS Code:
{
"key": "cmd+k cmd+d",
"command": "4d-docs.openInWebview",
"when": "editorTextFocus"
},
{
"key": "cmd+k cmd+b",
"command": "4d-docs.openInBrowser",
"when": "editorTextFocus"
}Publishing
For Personal Use
The extension is ready to use locally. After building and packaging:
npm run package
code --install-extension mcp-4d-docs-0.1.0.vsixFor Distribution
Before publishing to the VS Code Marketplace:
Update publisher name in
package.json:"publisher": "your-actual-publisher-id"Add repository URL in
package.json:"repository": { "type": "git", "url": "https://github.com/yourusername/mcp-4d-docs.git" }Add a LICENSE file (e.g., LICENSE.txt with MIT license text)
Publish to marketplace:
vsce publishOr create a VSIX for sharing:
npm run package # Share the .vsix file
License
MIT
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
If the remote CSS doesn’t exist (for instance, if it was renamed), consider embedding one in the plugin.
Support 4D language highlighting (Prism?).
Keep a key pressed when requesting documentation via the command palette to allow forcing a download (i.e., bypassing the cache).
Available Tools
3 toolsclear_4d_docs_cacheA
Clear the local cache of 4D documentation. This removes all cached documentation files, forcing fresh fetches on subsequent requests.
Inputs: no named parameters.
get_4d_command_docsA
Get documentation for a 4D command. Fetches the documentation from https://developer.4d.com/docs/commands/ and extracts the article content from the main tag. Results are cached locally for faster subsequent access.
Inputs: command_name (required).
open_4d_command_in_browserA
Open a 4D command documentation page in the default web browser. This opens the URL https://developer.4d.com/docs/commands/ directly in your browser.
Inputs: command_name (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: clearing cache, fetching documentation content, and opening documentation in a browser. There is no overlap in functionality, making tool selection unambiguous for an agent.
All tool names follow a consistent verb_noun pattern with '4d' as a prefix (clear_4d_docs_cache, get_4d_command_docs, open_4d_command_in_browser). The naming is uniform and predictable throughout the set.
With only 3 tools, the set feels thin for a documentation viewer that might benefit from additional operations like listing commands or searching documentation. However, it covers basic needs without being excessive.
The tools provide core functionality for accessing and managing 4D documentation (fetch, open, clear cache). Minor gaps exist, such as no tool for browsing or searching command lists, but agents can work around this by using the provided tools effectively.
Related MCP Connectors
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
An MCP server that gives your AI access to the source code and docs of all public github repos
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server to expose VS Code editing features to an LLM for AI coding9561 npm392MIT
- FlicenseNot gradedqualityDmaintenanceA centralized MCP server for internal technical documentation that integrates with IDEs like Claude Code and VS Code, enabling semantic search and management of Markdown documents via natural language.-
- AlicenseNot gradedqualityCmaintenanceProvides a local MCP server for searching and retrieving documentation from 22+ open-source projects, enabling AI coding assistants to access up-to-date docs without network dependency.9 npm3MIT
- AlicenseNot gradedqualityDmaintenanceA self-hosted MCP server that provides up-to-date documentation for enterprise and development tools directly to AI coding assistants like Claude Code and Cursor.MIT