实现Anthropic的MCP(模型上下文协议)用于Firebird数据库。
https://github.com/user-attachments/assets/e68e873f-f87b-4afd-874f-157086e223af
MCP Firebird是一个实现了Anthropic的MCP(模型上下文协议)的服务器,适用于Firebird SQL数据库。它允许大型语言模型(如Claude)安全且可控地访问、分析和操作Firebird数据库中的数据。
在5分钟内将MCP Firebird部署到云端!
Smithery是将MCP Firebird部署到生产环境最简单的方式:
✅ 一键部署 - 不需要基础设施设置 ✅ 自动扩展 - 自动处理流量高峰 ✅ 内置监控 - 跟踪使用情况和性能 ✅ 安全凭证 - 加密环境变量 ✅ 自动更新 - 始终运行最新版本 ✅ 全球CDN - 全球低延迟
mcpFirebird仓库host: "your-firebird-server.com"
port: 3050
database: "/path/to/database.fdb"
user: "SYSDBA"
password: "your-secure-password"
useNativeDriver: true # 启用线缆加密(可选)
logLevel: "info"
您的MCP Firebird服务器将在以下地址可用:
https://server.smithery.ai/your-username/mcp-firebird
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(
"https://server.smithery.ai/your-username/mcp-firebird"
);
const client = new Client({
name: "my-ai-app",
version: "1.0.0"
});
await client.connect(transport);
📚 详细的Smithery部署说明,请参阅 SMITHERY_DEPLOYMENT.md
MCP Firebird支持两种驱动选项:
| 驱动 | 安装 | 线缆加密 | 使用场景 |
|---|---|---|---|
| 纯JavaScript(默认) | ✅ 简单(npx) | ❌ 无 | 大多数用户,快速设置 |
| 本地驱动(可选) | ⚠️ 复杂(需要构建工具) | ✅ 有 | 企业级,需要安全 |
npx mcp-firebird@alpha --database=/path/to/database.fdb
⚠️ 关键:npx不适用于本地驱动。您必须全局安装。
⚠️ 重要:线缆加密必须在Firebird服务器(firebird.conf)上配置,而不是客户端。
服务器配置(首先需要):
# 在服务器上的firebird.conf中
WireCrypt = Required # 或Enabled
客户端安装(必须全局安装):
# 第一步:安装构建工具
# Windows:Visual Studio Build Tools (https://visualstudio.microsoft.com/downloads/)
# Linux:sudo apt-get install build-essential python3 firebird-dev
# macOS:xcode-select --install && brew install firebird
# 第二步:全局安装MCP Firebird
npm install -g mcp-firebird@alpha
# 第三步:全局安装本地驱动
npm install -g node-firebird-driver-native
# 第四步:直接运行(无需npx)
mcp-firebird --use-native-driver \
--database=/path/to/database.fdb \
--host=localhost \
--user=SYSDBA \
--password=masterkey
为什么不能使用npx? 当npx从其临时缓存运行一个包时,它无法访问全局安装的模块,如node-firebird-driver-native。两个包必须在同一位置全局安装。
📚 详细的安装说明,请参阅:
⭐ 推荐用于本地AI客户端(Claude桌面、Cursor等)
Smithery CLI提供了最简单的安装和配置MCP Firebird的方法,以供本地使用:
# 交互式安装(提示配置)
npx -y @smithery/cli@latest install mcp-firebird --client claude
# 预配置安装(跳过提示)
npx -y @smithery/cli@latest install mcp-firebird --client claude --config '{
"database": "/path/to/database.fdb",
"user": "SYSDBA",
"password": "masterkey",
"useNativeDriver": false
}'
# 列出已安装的服务器
npx @smithery/cli list servers --client claude
# 检查服务器配置
npx @smithery/cli inspect mcp-firebird
# 卸载服务器
npx @smithery/cli uninstall mcp-firebird --client claude
📖 完整指南: Smithery CLI安装指南
# 全局安装(稳定版)
npm install -g mcp-firebird
# 运行服务器
npx mcp-firebird --database /path/to/database.fdb
# 或使用特定稳定版本
npm install -g mcp-firebird@2.2.3
稳定功能(v2.2.3):
# 安装具有最新功能的Alpha版本
npm install -g mcp-firebird@alpha
# 或使用特定Alpha版本
npm install -g mcp-firebird@2.4.0-alpha.0
Alpha功能(v2.4.0-alpha.0):
注意:SSE JSON解析错误修复现在在稳定版v2.2.3中可用
对于备份/恢复操作,您需要安装Firebird客户端工具。详情请参阅完整安装。
对于VSCode和GitHub Copilot集成,请参阅VSCode集成。
编辑Claude桌面配置:
code $env:AppData\Claude\claude_desktop_config.json # Windows
code ~/Library/Application\ Support/Claude/claude_desktop_config.json # macOS
添加MCP Firebird配置:
{
"mcpServers": {
"mcp-firebird": {
"command": "npx",
"args": [
"mcp-firebird",
"--host",
"localhost",
"--port",
"3050",
"--database",
"C:\\path\\to\\database.fdb",
"--user",
"SYSDBA",
"--password",
"masterkey"
],
"type": "stdio"
}
}
}
重启Claude桌面
MCP Firebird支持多种传输协议,以适应不同的客户端需求和部署场景。
STDIO传输是Claude桌面集成的标准方法:
{
"mcpServers": {
"mcp-firebird": {
"command": "npx",
"args": [
"mcp-firebird",
"--database", "C:\\path\\to\\database.fdb",
"--user", "SYSDBA",
"--password", "masterkey"
],
"type": "stdio"
}
}
}
SSE传输允许服务器作为Web服务运行,适用于Web应用程序和远程访问:
# 在默认端口3003启动SSE服务器
npx mcp-firebird --transport-type sse --database /path/to/database.fdb
# 自定义端口和完整配置
npx mcp-firebird \
--transport-type sse \
--sse-port 3003 \
--database /path/to/database.fdb \
--host localhost \
--port 2050 \
--user SYSDBA \
--password masterkey
# 设置环境变量
export TRANSPORT_TYPE=sse
export SSE_PORT=3003
export DB_HOST=localhost
export DB_PORT=3050
export DB_DATABASE=/path/to/database.fdb
export DB_USER=SYSDBA
export DB_PASSWORD=masterkey
# 启动服务器
npx mcp-firebird
一旦SSE服务器运行,客户端可以连接到:
http://localhost:3003/ssehttp://localhost:3003/messageshttp://localhost:3003/health最新的MCP协议支持双向通信:
# 使用可流式传输的HTTP启动
npx mcp-firebird --transport-type http --http-port 3003 --database /path/to/database.fdb
同时支持SSE和可流式传输的HTTP协议,并自动检测:
# 启动统一服务器(支持SSE和可流式传输的HTTP)
npx mcp-firebird --transport-type unified --http-port 3003 --database /path/to/database.fdb
http://localhost:3003/ssehttp://localhost:3003/mcphttp://localhost:3003/mcp-autohttp://localhost:3003/healthnpx mcp-firebird \
--transport-type sse \
--sse-port 3003 \
--database ./dev-database.fdb \
--user SYSDBA \
--password masterkey
npx mcp-firebird \
--transport-type unified \
--http-port 3003 \
--database /var/lib/firebird/production.fdb \
--host db-server \
--port 3050 \
--user APP_USER \
--password $DB_PASSWORD
docker run -d \
--name mcp-firebird \
-p 3003:3003 \
-e TRANSPORT_TYPE=sse \
-e SSE_PORT=3003 \
-e DB_DATABASE=/data/database.fdb \
-v /path/to/database:/data \
purodelhi/mcp-firebird:latest
配置会话超时和限制:
# 会话管理环境变量
export SSE_SESSION_TIMEOUT_MS=1800000 # 30分钟
export MAX_SESSIONS=1000 # 最大并发会话数
export SESSION_CLEANUP_INTERVAL_MS=60000 # 每分钟清理一次
npx mcp-firebird --transport-type sse
对于Web应用程序,配置CORS设置:
# 允许特定来源
export CORS_ORIGIN="https://myapp.com,https://localhost:3000"
export CORS_METHODS="GET,POST,OPTIONS"
export CORS_HEADERS="Content-Type,mcp-session-id"
npx mcp-firebird --transport-type sse
对于生产部署,使用反向代理如nginx:
server {
listen 443 ssl;
server_name mcp-firebird.yourdomain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:3003;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
线缆加密不兼容(Firebird 3.0+) ⚠️ 关键
错误:请求的客户端和服务器之间的线缆加密级别不兼容
重要:node-firebird库不支持Firebird 3.0+的线缆加密。--wire-crypt参数不起作用。
唯一解决方案:您必须禁用Firebird服务器上的线缆加密:
对于Firebird 3.0,在firebird.conf中添加:
WireCrypt = Disabled
AuthServer = Srp, Legacy_Auth
对于Firebird 4.0+,在firebird.conf中添加:
WireCrypt = Disabled
AuthServer = Srp256, Srp, Legacy_Auth
对于Firebird 5.0 Docker:
environment:
FIREBIRD_CONF_WireCrypt: Disabled
FIREBIRD_CONF_AuthServer: Srp256, Srp
**如果您无法更改