使用说明
🐇 MCP SQLite服务器
这是一个模型上下文协议(MCP)服务器,提供全面的SQLite数据库交互功能。
由维护
特性
- 完成CRUD操作(创建、读取、更新、删除)
- 数据库探索与反思
- 执行自定义SQL查询
设置
在IDE的MCP服务器设置中定义命令:
例如 Cursor:
{
"mcpServers": {
"MCP SQLite Server": {
"command": "npx",
"args": [
"-y",
"mcp-sqlite",
"<path-to-your-sqlite-database.db>"
]
}
}
}
例如 VSCode:
{
"servers": {
"MCP SQLite Server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-sqlite",
"<path-to-your-sqlite-database.db>"
]
}
}
}
您的数据库路径必须作为参数提供。
可用工具
数据库信息
db_info
获取有关连接的数据库的详细信息。
例子:
{
"method": "tools/call",
"params": {
"name": "db_info",
"arguments": {}
}
}
list_tables
列出数据库中的所有表。
例子:
{
"method": "tools/call",
"params": {
"name": "list_tables",
"arguments": {}
}
}
get_table_schema
获取有关表架构的详细信息。
参数:
tableName(string):表的名称
例子:
{
"method": "tools/call",
"params": {
"name": "get_table_schema",
"arguments": {
"tableName": "users"
}
}
}
CRUD操作
create_record
将新记录插入表中。
参数:
table(string):表的名称data(object):将数据记录为键值对
例子:
{
"method": "tools/call",
"params": {
"name": "create_record",
"arguments": {
"table": "users",
"data": {
"name": "John Doe",
"email": "john@example.com",
"age": 30
}
}
}
}
read_records
使用可选筛选从表中查询记录。
参数:
table(string):表的名称conditions(object,可选):将条件筛选为键值对limit(number,可选):要返回的最大记录数offset(number,可选):要跳过的记录数
例子:
{
"method": "tools/call",
"params": {
"name": "read_records",
"arguments": {
"table": "users",
"conditions": {
"age": 30
},
"limit": 10,
"offset": 0
}
}
}
update_records
更新表中符合指定条件的记录。
参数:
table(string):表的名称data(object):新值作为键值对conditions(object):将条件筛选为键值对
例子:
{
"method": "tools/call",
"params": {
"name": "update_records",
"arguments": {
"table": "users",
"data": {
"email": "john.updated@example.com"
},
"conditions": {
"id": 1
}
}
}
}
删除记录
从表中删除符合指定条件的记录。
参数:
table(string):表的名称conditions(object):将条件筛选为键值对
例子:
{
"method": "tools/call",
"params": {
"name": "delete_records",
"arguments": {
"table": "users",
"conditions": {
"id": 1
}
}
}
}
自定义查询
怎么翻译
对连接的SQLite数据库执行自定义SQL查询。
参数:
sql(string):要执行的SQL查询values(array,可选):查询中使用的参数值数组
例子:
{
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"sql": "SELECT * FROM users WHERE id = ?",
"values": [1]
}
}
}
内置于
欣赏
如果你喜欢这个图书馆,请考虑给我发一条建议来支持我的工作😀