4d-mcp

4d-mcp

Enables AI assistants to interact with 4D databases via REST API, supporting authentication, schema inspection, data querying, manipulation, and ORDA function calls.

Category
访问服务器

README

4D MCP Server

Model Context Protocol (MCP) server for 4D REST API integration. Provides tools for authentication, data querying, manipulation, and ORDA class function calls.

Features

  • Authentication: Login with username/password or hashed password
  • Schema Inspection: Get database catalog information
  • Data Querying: Query dataclasses with filtering, sorting, and pagination
  • Data Manipulation: Create, update, and delete records
  • ORDA Functions: Call class functions on the 4D server
  • Session Management: Automatic session cookie handling

Installation

For MCP Client Usage

Install globally via npm:

npm install -g 4d-mcp

For Development

  1. Clone and install dependencies:
git clone <repository-url>
cd 4d-mcp
npm install
  1. Configure environment variables:
cp .env.example .env

Edit .env with your 4D server settings:

FOURD_BASE=https://your-4d-server:port
FOURD_USER=username
FOURD_PASSWORD=password
FOURD_SESSION_MINUTES=60
FOURD_ALLOW_SELF_SIGNED=true  # For development only
  1. Build the project:
npm run build

Usage

Development

npm run dev

Production

npm run build
npm start

Available Tools

1. login

Authenticate with the 4D server and establish a session.

Parameters:

  • user (optional): Username override
  • password (optional): Password override
  • hashed (optional): Whether password is hashed
  • minutes (optional): Session duration override

2. catalog

Get database schema information.

Parameters:

  • all (optional): Include all catalog details

3. query

Query data from a dataclass.

Parameters:

  • dataClass (required): Dataclass name
  • filter (optional): 4D query filter
  • orderby (optional): Sort specification
  • top (optional): Max records to return
  • skip (optional): Records to skip (pagination)
  • attributes (optional): Specific attributes to include
  • expand (optional): Related attributes to expand

4. upsert

Create or update records.

Parameters:

  • dataClass (required): Dataclass name
  • body (required): Record data (object or array)

5. delete

Delete records from a dataclass.

Parameters:

  • dataClass (required): Dataclass name
  • key (optional): Specific record key
  • filter (optional): Query filter for bulk delete

6. callFunction

Call ORDA class functions.

Parameters:

  • target (required): Interface/dataclass name
  • func (required): Function name
  • params (optional): Function parameters array

4D Server Requirements

  1. Enable REST Server: Set "Expose REST server" in 4D settings
  2. Configure Exposure: Ensure dataclasses and attributes are exposed
  3. HTTPS: Use HTTPS in production
  4. Authentication: Configure user authentication as needed

Error Handling

The server provides detailed error messages for:

  • Authentication failures (401 errors)
  • Missing session cookies
  • Invalid parameters
  • 4D server errors

Authentication errors will prompt you to run login again.

Security Notes

  • Use HTTPS when sending credentials
  • Prefer hashed passwords over plain text
  • Limit exposed dataclasses and attributes in production
  • Never log passwords or session cookies

Testing with MCP Inspector

Use the MCP Inspector to test the server:

npm install -g @modelcontextprotocol/inspector
mcp-inspector

Point the inspector to your built server: node dist/index.js

Client Configuration

Claude Code

Add to your Claude Code configuration file (~/.claude-code/config.json):

{
  "mcpServers": {
    "4d": {
      "command": "npx",
      "args": ["4d-mcp"],
      "env": {
        "FOURD_BASE": "https://your-4d-server.com:443",
        "FOURD_USER": "your-username",
        "FOURD_PASSWORD": "your-password",
        "FOURD_SESSION_MINUTES": "60",
        "FOURD_ALLOW_SELF_SIGNED": "false"
      }
    }
  }
}

Cursor

Add to your Cursor settings (Settings > Extensions > MCP > Edit in settings.json):

{
  "mcp": {
    "servers": {
      "4d": {
        "command": "npx",
        "args": ["4d-mcp"],
        "env": {
          "FOURD_BASE": "https://your-4d-server.com:443",
          "FOURD_USER": "your-username",
          "FOURD_PASSWORD": "your-password",
          "FOURD_SESSION_MINUTES": "60",
          "FOURD_ALLOW_SELF_SIGNED": "false"
        }
      }
    }
  }
}

Cline (VS Code Extension)

Add to your Cline MCP settings:

{
  "mcpServers": {
    "4d": {
      "command": "npx",
      "args": ["4d-mcp"],
      "env": {
        "FOURD_BASE": "https://your-4d-server.com:443",
        "FOURD_USER": "your-username",
        "FOURD_PASSWORD": "your-password",
        "FOURD_SESSION_MINUTES": "60",
        "FOURD_ALLOW_SELF_SIGNED": "false"
      }
    }
  }
}

Configuration Notes

  • Replace placeholder values with your actual 4D server details
  • Use HTTPS in production environments
  • Set FOURD_ALLOW_SELF_SIGNED to "true" only for development with self-signed certificates
  • Example configuration files are available in the examples/ directory

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选