Oracle MCP Server 是一个模型上下文协议(MCP)服务器,它为像 Claude 这样的 AI 助手提供了灵活访问 Oracle 数据库的能力。支持跨多个模式进行查询以及全面的数据库自省。
在使用 Oracle MCP Server 前,请确保你已满足以下要求:
在项目根目录下,执行以下命令进行安装:
npm install
创建一个 .env 文件,并填写你的 Oracle 连接信息。你可以选择以下其中一种方式:
ORACLE_CONNECTION_STRING=hostname:1521/service_name
ORACLE_USER=your_username
ORACLE_PASSWORD=your_password
ORACLE_TNS_NAME=ORCL
ORACLE_USER=your_username
ORACLE_PASSWORD=your_password
ORACLE_HOST=localhost
ORACLE_PORT=1521
ORACLE_SERVICE_NAME=ORCL # 或者 ORACLE_SID=ORCL
ORACLE_USER=your_username
ORACLE_PASSWORD=your_password
可选设置:
ORACLE_DEFAULT_SCHEMA=HR # 如果默认模式与用户不同
将以下配置添加到你的 Claude Desktop 配置文件中:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"oracle": {
"command": "node",
"args": ["/path/to/oracle-mcp/src/index.js"],
"env": {
"ORACLE_CONNECTION_STRING": "hostname:1521/service_name",
"ORACLE_USER": "your_username",
"ORACLE_PASSWORD": "your_password"
}
}
}
}
或者,如果你发布了该包,也可以使用 npx:
{
"mcpServers": {
"oracle": {
"command": "npx",
"args": ["-y", "oracle-mcp-server"],
"env": {
"ORACLE_CONNECTION_STRING": "hostname:1521/service_name",
"ORACLE_USER": "your_username",
"ORACLE_PASSWORD": "your_password"
}
}
}
}
在 ~/.claude.json 文件中添加以下配置:
{
"mcpServers": {
"oracle": {
"type": "stdio",
"command": "node",
"args": ["/path/to/oracle-mcp/src/index.js"],
"env": {
"ORACLE_CONNECTION_STRING": "hostname:1521/service_name",
"ORACLE_USER": "your_username",
"ORACLE_PASSWORD": "your_password"
}
}
}
}
配置更新完成后,请重启 Claude Desktop 或 Claude Code。
execute_query - 执行任意 SQL 查询
list_tables - 列出数据库表
describe_table - 获取表结构
get_table_indexes - 查看表索引
get_table_constraints - 查看表约束
list_schemas - 列出所有可访问的模式
本项目采用 MIT 许可证。