MCP HubMCP Hub
modelcontextprotocol

sqlite

by: modelcontextprotocol

A Model Context Protocol (MCP) server implementation that provides database interaction and business intelligence capabilities through SQLite. This server enables running SQL queries, analyzing business data, and automatically generating business insight memos.

0created 19/11/2024
Visit
SQLite
BI

📌Overview

Purpose: The SQLite MCP Server aims to facilitate database interaction and business intelligence by providing a framework for running SQL queries and generating business insights.

Overview: This server implements the Model Context Protocol (MCP) to enable users to analyze business data and automatically produce insights. It leverages SQLite for data management, making it a powerful tool for business analysis.

Key Features:

  • Dynamic Insights Resource: The memo://insights resource continuously aggregates and updates business insights derived from data analysis, providing users with real-time access to valuable information.

  • Interactive Prompt: The mcp-demo prompt assists users in navigating database operations, generating schemas, and facilitating insight generation, which enhances usability and encourages effective data analysis.

  • Core Query Tools: The framework includes essential tools for reading, writing, and creating database tables (read_query, write_query, create_table) that streamline database management tasks.

  • Schema Tools: Tools like list_tables and describe-table allow users to easily view and manage database schemas, enhancing the efficiency of data handling.

  • Analysis Tool: The append_insight tool enables the addition of newly discovered business insights to the memo, ensuring that users have a live and updated overview of their analytical findings.


SQLite MCP Server

Overview

A Model Context Protocol (MCP) server implementation that provides database interaction and business intelligence capabilities through SQLite. This server enables running SQL queries, analyzing business data, and automatically generating business insight memos.

Components

Resources

The server exposes a single dynamic resource:

  • memo://insights: A continuously updated business insights memo that aggregates discovered insights during analysis.
    • Auto-updates as new insights are discovered via the append-insight tool.

Prompts

The server provides a demonstration prompt:

  • mcp-demo: Interactive prompt that guides users through database operations.
    • Required argument: topic - The business domain to analyze.
    • Generates appropriate database schemas and sample data.
    • Guides users through analysis and insight generation.
    • Integrates with the business insights memo.

Tools

The server offers six core tools:

Query Tools

  • read_query

    • Execute SELECT queries to read data from the database.
    • Input:
      • query (string): The SELECT SQL query to execute.
    • Returns: Query results as array of objects.
  • write_query

    • Execute INSERT, UPDATE, or DELETE queries.
    • Input:
      • query (string): The SQL modification query.
    • Returns: { affected_rows: number }.
  • create_table

    • Create new tables in the database.
    • Input:
      • query (string): CREATE TABLE SQL statement.
    • Returns: Confirmation of table creation.

Schema Tools

  • list_tables

    • Get a list of all tables in the database.
    • No input required.
    • Returns: Array of table names.
  • describe-table

    • View schema information for a specific table.
    • Input:
      • table_name (string): Name of table to describe.
    • Returns: Array of column definitions with names and types.

Analysis Tools

  • append_insight
    • Add new business insights to the memo resource.
    • Input:
      • insight (string): Business insight discovered from data analysis.
    • Returns: Confirmation of insight addition.
    • Triggers update of memo://insights resource.

Usage with Claude Desktop

uv

Add the server to your claude_desktop_config.json:

"mcpServers": {
  "sqlite": {
    "command": "uv",
    "args": [
      "--directory",
      "parent_of_servers_repo/servers/src/sqlite",
      "run",
      "mcp-server-sqlite",
      "--db-path",
      "~/test.db"
    ]
  }
}

Docker

Add the server to your claude_desktop_config.json:

"mcpServers": {
  "sqlite": {
    "command": "docker",
    "args": [
      "run",
      "--rm",
      "-i",
      "-v",
      "mcp-test:/mcp",
      "mcp/sqlite",
      "--db-path",
      "/mcp/test.db"
    ]
  }
}

Building

Build the Docker image:

docker build -t mcp/sqlite .

Test with MCP inspector

uv add "mcp[cli]"
mcp dev src/mcp_server_sqlite/server.py:wrapper  

License

This MCP server is licensed under the MIT License. You are free to use, modify, and distribute the software under the terms of this license. Please see the LICENSE file in the project repository for details.