数据库查询 MCP 服务

truss-db-mcp 是一个用于 AI 助手的数据库查询 MCP 服务器,支持连接 SQLite、PostgreSQL 和 MySQL,提供只读查询、表结构浏览、SQL 优化、自然语言查询及数据迁移等功能,适用于在 Claude Code 等环境中直接访问数据库。

  • by rhkiswani
  • 本地部署
  • 更新于
在 GitHub 查看 OyaAIProd/truss-db-mcp

使用说明

truss-db-mcp

Database query MCP server for Claude Code. Connect to SQLite, PostgreSQL, or MySQL databases directly from your AI assistant.

Quick Start

{
  "mcpServers": {
    "truss-db": {
      "command": "npx",
      "args": ["-y", "truss-db-mcp"]
    }
  }
}

Free Tier Tools

Tool Description
connect Connect to a SQLite database file
list_tables List all tables with row counts and column info
describe_table Detailed schema: columns, types, indexes, foreign keys
query Execute read-only SQL queries (SELECT)

Pro Tier Tools ($25/mo)

Tool Description
natural_language_query Ask questions in plain English, get SQL + results
optimize_query EXPLAIN analysis with index suggestions
generate_migration Generate up/down SQL migrations from descriptions
export_data Export query results as CSV or JSON

Environment Variables

Variable Required Description
TRUSS_LICENSE_KEY No Pro license key
ANTHROPIC_API_KEY Pro For AI-powered features (natural language query, migration generation)
OPENAI_API_KEY Pro Alternative AI provider
DATABASE_URL No Connection URL for PostgreSQL/MySQL (Pro)

Usage Examples

Connect to a database

Use the connect tool with path: "./my-app.db"

Query data

Use the query tool with sql: "SELECT * FROM users LIMIT 10"

Natural language query (Pro)

Use natural_language_query with question: "What are the top 5 customers by total spend?"

Optimize a slow query (Pro)

Use optimize_query with sql: "SELECT * FROM orders WHERE status = 'pending'"

License

MIT


A2A Discovery

This server publishes a Google A2A Protocol Agent Card, making it discoverable by any A2A-compatible agent framework (LangGraph, CrewAI, Google ADK, AutoGen, and others).

Agent Card: agent-card.json

The agent card describes this server's skills, capabilities, input/output modalities, and authentication requirements in a machine-readable format. A2A clients can use it to discover and invoke tools automatically without manual configuration.

# Fetch the agent card
curl https://raw.githubusercontent.com/claw-factory/truss-db-mcp/main/agent-card.json