这是一个提供全面SQLite数据库交互能力的模型上下文协议(MCP)服务器。
在IDE的MCP服务器设置中定义命令:
例如 Cursor:
{
"mcpServers": {
"MCP SQLite 服务器": {
"command": "npx",
"args": [
"-y",
"mcp-sqlite",
"<path-to-your-sqlite-database.db>"
]
}
}
}
例如 VSCode:
{
"servers": {
"MCP SQLite 服务器": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-sqlite",
"<path-to-your-sqlite-database.db>"
]
}
}
}
必须将数据库路径作为参数提供。
获取连接数据库的详细信息。
示例:
{
"method": "tools/call",
"params": {
"name": "db_info",
"arguments": {}
}
}
列出数据库中的所有表。
示例:
{
"method": "tools/call",
"params": {
"name": "list_tables",
"arguments": {}
}
}
获取表模式的详细信息。
参数:
tableName (字符串):表名示例:
{
"method": "tools/call",
"params": {
"name": "get_table_schema",
"arguments": {
"tableName": "users"
}
}
}
向表中插入一条新记录。
参数:
table (字符串):表名data (对象):以键值对形式表示的记录数据示例:
{
"method": "tools/call",
"params": {
"name": "create_record",
"arguments": {
"table": "users",
"data": {
"name": "John Doe",
"email": "john@example.com",
"age": 30
}
}
}
}
从表中查询记录,可选过滤条件。
参数:
table (字符串):表名conditions (对象,可选):以键值对形式表示的过滤条件limit (数字,可选):返回的最大记录数offset (数字,可选):跳过的记录数示例:
{
"method": "tools/call",
"params": {
"name": "read_records",
"arguments": {
"table": "users",
"conditions": {
"age": 30
},
"limit": 10,
"offset": 0
}
}
}
更新匹配指定条件的表中的记录。
参数:
table (字符串):表名data (对象):以键值对形式表示的新值conditions (对象):以键值对形式表示的过滤条件示例:
{
"method": "tools/call",
"params": {
"name": "update_records",
"arguments": {
"table": "users",
"data": {
"email": "john.updated@example.com"
},
"conditions": {
"id": 1
}
}
}
}
删除匹配指定条件的表中的记录。
参数:
table (字符串):表名conditions (对象):以键值对形式表示的过滤条件示例:
{
"method": "tools/call",
"params": {
"name": "delete_records",
"arguments": {
"table": "users",
"conditions": {
"id": 1
}
}
}
}
执行针对连接的SQLite数据库的自定义SQL查询。
参数:
sql (字符串):要执行的SQL查询values (数组,可选):用于查询的参数值数组示例:
{
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"sql": "SELECT * FROM users WHERE id = ?",
"values": [1]
}
}
}
如果您喜欢这个库,请考虑给我打赏以支持我的工作 😀