database-remote-mcp

database-remote-mcp

Enables remote database access (RDBMS and MongoDB) through MCP tools, supporting read/write queries, schema management, and more.

Category
Visit Server

README

DataBase Remote MCP Server

リモートデータベースへのアクセス機能を Model Context Protocol (MCP) ツールとして公開するサーバーです。HTTPstdio の両トランスポートに対応しています。

概要

  • MCP_TRANSPORT 環境変数でトランスポートを切替
    • 未設定 / http → HTTP サーバーモード(/mcp, /mcp/stream
    • stdio → stdin/stdout MCP プロトコルモード
  • DB_TYPE に応じてランタイムを自動切替
    • sqlserver / postgres / mysql -> RDBMS runtime
    • mongodb -> NoSQL runtime
  • ツールの有効化は環境変数で制御
    • RDBMS: ENABLED_TOOLS
    • NoSQL: ENABLED_NOSQL_TOOLS

現在の対応機能

RDBMS ツール

  • read_query
  • write_query
  • export_query
  • list_tables
  • describe_table
  • get_schema
  • create_table
  • alter_table
  • drop_table
  • append_insight
  • list_insights

NoSQL ツール

  • list_collections(MongoDB のコレクション一覧取得)

NoSQL は現在 list_collections のみ実装済みです。

サポートDB

  • SQL Server(mssql
  • PostgreSQL(pg
  • MySQL(mysql2
  • MongoDB(mongodb

システム要件

  • Node.js >= 24
  • pnpm 推奨

起動

pnpm install
pnpm build
pnpm start          # HTTPモード(デフォルト)

stdioモード:

MCP_TRANSPORT=stdio pnpm start

開発モード(HTTP):

pnpm start:dev

MCP クライアント設定例

stdio

Claude Code / Claude Desktop

Claude Code — グローバル登録(全プロジェクトで利用可能):

claude mcp add database-remote-mcp --scope user -e MCP_TRANSPORT=stdio -- \
  node --env-file=/path/to/database-remote-mcp/.env /path/to/database-remote-mcp/dist/main.js

Claude Code — プロジェクトローカル(.mcp.json):

{
  "mcpServers": {
    "database-remote-mcp": {
      "command": "node",
      "args": [
        "--env-file=/path/to/database-remote-mcp/.env",
        "/path/to/database-remote-mcp/dist/main.js"
      ],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Claude Desktopclaude_desktop_config.json:

{
  "mcpServers": {
    "database-remote-mcp": {
      "command": "node",
      "args": [
        "--env-file=/path/to/database-remote-mcp/.env",
        "/path/to/database-remote-mcp/dist/main.js"
      ],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Codex

~/.codex/config.toml:

[mcp_servers.database-remote-mcp]
command = "node"
args = [
  "--env-file=/path/to/database-remote-mcp/.env",
  "/path/to/database-remote-mcp/dist/main.js"
]

[mcp_servers.database-remote-mcp.env]
MCP_TRANSPORT = "stdio"

GitHub Copilot(VS Code)

.vscode/mcp.json:

{
  "servers": {
    "database-remote-mcp": {
      "type": "stdio",
      "command": "node",
      "args": [
        "--env-file=/path/to/database-remote-mcp/.env",
        "/path/to/database-remote-mcp/dist/main.js"
      ],
      "env": {
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

HTTP

Claude Code / Claude Desktop

Claude Code — グローバル登録:

claude mcp add database-remote-mcp --scope user --transport http \
  http://localhost:3000/mcp/stream

Claude Desktopclaude_desktop_config.json:

{
  "mcpServers": {
    "database-remote-mcp": {
      "type": "http",
      "url": "http://localhost:3000/mcp/stream"
    }
  }
}

Codex

~/.codex/config.toml:

[mcp_servers.database-remote-mcp]
url = "http://localhost:3000/mcp/stream"
enabled = true

GitHub Copilot(VS Code)

.vscode/mcp.json:

{
  "servers": {
    "database-remote-mcp": {
      "type": "http",
      "url": "http://localhost:3000/mcp/stream"
    }
  }
}

環境変数

.env.sample.env にコピーして設定します。

共通

APP_PORT=3000          # HTTPモードのみ使用
ALLOWED_ORIGINS=
DB_TYPE=postgres
MCP_TRANSPORT=         # 未設定またはhttp=HTTPモード / stdio=stdioモード

ツール有効化

ENABLED_TOOLS=
ENABLED_NOSQL_TOOLS=

RDBMS 接続

SERVER=localhost
PORT=5432
DATABASE=postgres
USER=postgres
PASSWORD=
DB_SSL=

DB_TYPEsqlserver / postgres / mysql のときに利用されます。

MongoDB 接続

MONGO_URI=mongodb://localhost:27017
MONGO_DATABASE=admin

MONGO_URI 未設定時は mongodb://SERVER:PORT を使用します。

アーキテクチャ

依存方向: Presentation -> Application -> Domain <- Infrastructure

src/
├── app.module.ts          # HTTPモード用ルートモジュール
├── app-stdio.module.ts    # stdioモード用ルートモジュール(Presentation層なし)
├── presentation/          # HTTPモードのみ使用
│   └── mcp/
│       ├── mcp.controller.ts
│       ├── mcp.controller.module.ts
│       └── sse.interceptor.ts
├── application/
│   └── mcp/
│       ├── mcp.service.ts
│       ├── runtime-resolver.service.ts
│       ├── shared/           # connectStdio() を含む共通実装
│       ├── rdbms/
│       └── nosql/
├── domain/
│   ├── mcp/
│   │   ├── shared/
│   │   ├── rdbms/
│   │   └── nosql/
│   ├── rdbms/
│   └── nosql/
└── infrastructure/
    ├── config/
    ├── rdbms/
    └── nosql/

テスト・品質チェック

pnpm lint
pnpm build
pnpm test

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured