Skip to main content
Glama
oracle-sqlplus-mcp

oracle-sqlplus-mcp

by sagar1012

oracle-sqlplus-mcp

一个使用 sqlplus 作为连接后端的 Oracle 数据库 MCP (Model Context Protocol) 服务器。无需 Oracle Instant Client Node.js 绑定 —— 只需要一个可用的 sqlplus 二进制文件。


先决条件

  • sqlplus 必须已安装并可在 PATH 中找到(随 Oracle Instant Client 或完整 Oracle 客户端提供)

  • Node.js 18+


Related MCP server: sqlserver-mcp-colossal

安装

npm install -g oracle-sqlplus-mcp
# or run directly with npx (no install needed):
npx oracle-sqlplus-mcp

连接字符串格式

username/password@host:port/servicename

示例:

scott/tiger@localhost:1521/ORCL
myuser/mypass@192.168.1.10:1521/XEPDB1
admin/secret@db.example.com:1521/PROD

Claude Desktop 配置

添加到你的 claude_desktop_config.json 中:

{
  "mcpServers": {
    "oracle": {
      "command": "npx",
      "args": ["-y", "oracle-sqlplus-mcp"],
      "env": {
        "ORACLE_CONNECTION": "username/password@host:port/servicename"
      }
    }
  }
}

可选环境变量

变量

默认值

描述

ORACLE_CONNECTION

(必需)

完整连接字符串

SQLPLUS_PATH

sqlplus

如果不在 PATH 中,则指定 sqlplus 二进制文件的路径

QUERY_TIMEOUT_MS

30000

查询超时时间(毫秒)

自定义 sqlplus 路径示例

{
  "mcpServers": {
    "oracle": {
      "command": "npx",
      "args": ["-y", "oracle-sqlplus-mcp"],
      "env": {
        "ORACLE_CONNECTION": "scott/tiger@192.168.1.10:1521/ORCL",
        "SQLPLUS_PATH": "C:\\oracle\\instantclient_21_9\\sqlplus.exe",
        "QUERY_TIMEOUT_MS": "60000"
      }
    }
  }
}

可用工具

工具

描述

test_connection

测试连接并返回 Oracle 版本

list_schemas

列出所有模式及其表计数

list_tables

列出表,可选择按模式或名称模式过滤

describe_table

显示列、数据类型、可空性、主键

get_table_sample

从表中获取示例行

execute_query

运行任何 SELECT 查询

execute_ddl

运行 DDL/DML (INSERT, UPDATE, DELETE, CREATE 等)

list_procedures

列出存储过程、函数、包


示例提示词

  • "Test the Oracle connection" (测试 Oracle 连接)

  • "List all schemas in the database" (列出数据库中的所有模式)

  • "Show me tables in the SCOTT schema" (显示 SCOTT 模式下的表)

  • "Describe the EMPLOYEES table" (描述 EMPLOYEES 表)

  • "Get 5 sample rows from HR.EMPLOYEES" (从 HR.EMPLOYEES 获取 5 行示例数据)

  • "Run this query: SELECT * FROM departments WHERE department_id < 50" (运行此查询:SELECT * FROM departments WHERE department_id < 50)

  • "List all stored procedures in the HR schema" (列出 HR 模式下的所有存储过程)


故障排除

sqlplus: command not found

将 SQLPLUS_PATH 设置为 sqlplus 二进制文件的完整路径。

ORA-12541: TNS:no listener

检查主机、端口以及 Oracle 监听器是否正在运行。

ORA-01017: invalid username/password

验证凭据。连接字符串格式:user/pass@host:port/service。

SP2-0306: Invalid option

确保 sqlplus 版本支持 -S 静默模式(所有现代版本均支持)。

Available Tools

8 tools
describe_tableA

Describe the columns, data types and constraints of a table.

Inputs: table_name (required).

execute_ddlA

Execute a DDL or DML statement (CREATE, INSERT, UPDATE, DELETE, ALTER, DROP). Use with caution — changes are committed immediately.

Inputs: statement (required).

execute_queryA

Execute a SQL SELECT query against the Oracle database and return the results. Use standard Oracle SQL syntax. Do NOT include a trailing semicolon — it is added automatically.

Inputs: query (required).

get_table_sampleA

Fetch a sample of rows from a table (default: 10 rows).

Inputs: table_name (required), limit.

list_proceduresA

List stored procedures and functions for a given schema.

Inputs: schema.

list_schemasA

List all schemas (users/owners) in the database that have at least one table.

Inputs: no named parameters.

list_tablesB

List all tables accessible to the current user, optionally filtered by schema/owner.

Inputs: schema, search.

test_connectionA

Test the Oracle connection and return server version info.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose: describing tables, executing DDL, running queries, sampling rows, listing procedures, schemas, tables, and testing connections. No overlapping functionality.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with underscores (e.g., describe_table, list_tables), making them easy to parse and predict.

    Tool Count5/5

    Eight tools is an appropriate number for a database interaction server, covering essential operations without being overwhelming or too sparse.

    Completeness4/5

    The toolset covers core database operations (querying, DDL/DML, listing objects, describing, sampling) but lacks capabilities like viewing procedure source code or managing users, which are minor gaps.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      MCP server for accessing Oracle databases, enabling schema exploration, query execution, and performance analysis.
      12
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      A comprehensive MCP server for SQL Server database operations, enabling CRUD operations, schema exploration, and stored procedure execution through natural language.
      7 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP server for Oracle Database enabling AI assistants to explore schemas, run queries, write data, and monitor sessions via natural language. Features read-only mode by default and uses Oracle Thin mode for zero-install connectivity.
      10
      2
      MIT