Skip to main content
Glama
dinek-k

DB & Calculator MCP Server

by dinek-k

MCP Example Server

This is a Model Context Protocol (MCP) server that provides two main categories of tools:

  1. Database Tools - For interacting with a SQLite database

  2. Calculator Tools - For performing mathematical calculations

Features

Database Tools

  • query_database - Execute custom SQL queries

  • get_all_users - Retrieve all users with optional limit

  • get_user_by_id - Get a specific user by ID

  • add_user - Add a new user to the database

  • update_user - Update an existing user

  • delete_user - Delete a user from the database

Calculator Tools

  • calculate - Perform basic mathematical operations (add, subtract, multiply, divide, power, sqrt, sin, cos, tan, log, abs, round, floor, ceil)

  • calculate_expression - Evaluate mathematical expressions

  • calculate_stats - Calculate statistical measures (mean, median, variance, standard deviation, etc.)

Related MCP server: Database MCP Server

Installation

  1. Install dependencies:

npm install
  1. The database will be automatically created when you first run the server.

Usage

Starting the Server

npm start

Or for development with auto-restart:

npm run dev

Database Schema

The server creates a SQLite database with the following schema:

CREATE TABLE users (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  email TEXT UNIQUE NOT NULL,
  age INTEGER,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Sample data is automatically inserted when the database is first created.

Tool Examples

Database Operations

  1. Get all users:

{
  "name": "get_all_users",
  "arguments": {}
}
  1. Get user by ID:

{
  "name": "get_user_by_id",
  "arguments": {
    "id": 1
  }
}
  1. Add a new user:

{
  "name": "add_user",
  "arguments": {
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30
  }
}
  1. Execute custom query:

{
  "name": "query_database",
  "arguments": {
    "query": "SELECT * FROM users WHERE age > 25"
  }
}

Calculator Operations

  1. Basic calculation:

{
  "name": "calculate",
  "arguments": {
    "operation": "add",
    "numbers": [5, 3]
  }
}
  1. Evaluate expression:

{
  "name": "calculate_expression",
  "arguments": {
    "expression": "2 + 3 * 4"
  }
}
  1. Statistical analysis:

{
  "name": "calculate_stats",
  "arguments": {
    "numbers": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  }
}

Available Calculator Operations

  • add - Addition

  • subtract - Subtraction

  • multiply - Multiplication

  • divide - Division (with zero check)

  • power - Exponentiation

  • sqrt - Square root

  • sin - Sine function

  • cos - Cosine function

  • tan - Tangent function

  • log - Natural logarithm

  • abs - Absolute value

  • round - Round to nearest integer

  • floor - Floor function

  • ceil - Ceiling function

Project Structure

├── package.json
├── README.md
├── src/
│   ├── server.js      # Main MCP server
│   ├── database.js    # Database operations
│   └── calculator.js  # Calculator operations
└── data/
    └── example.db     # SQLite database (created automatically)

Error Handling

The server includes comprehensive error handling for:

  • Invalid SQL queries

  • Database connection issues

  • Mathematical operation errors (division by zero, invalid inputs)

  • Missing required parameters

  • Unknown tool names

Development

To modify or extend the server:

  1. Add new tools in the setupTools() method in server.js

  2. Implement corresponding handler methods

  3. Update the tools list in the tools/list handler

  4. Add any necessary database operations in database.js

  5. Add calculator functions in calculator.js

Dependencies

  • @modelcontextprotocol/sdk - MCP SDK for Node.js

  • sqlite3 - SQLite database driver

  • express - Web framework (for potential future HTTP transport)

License

MIT

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • -
    license
    -
    quality
    A
    maintenance
    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.
    Last updated
    89,188
    MIT
  • F
    license
    -
    quality
    D
    maintenance
    A Model Context Protocol server that provides tools for connecting to and interacting with various database systems (SQLite, PostgreSQL, MySQL/MariaDB, SQL Server) through a unified interface.
    Last updated
    3
  • A
    license
    B
    quality
    A
    maintenance
    A Model Context Protocol server that enables SQL operations (SELECT, INSERT, UPDATE, DELETE) and table management through a standardized interface with SQLite databases.
    Last updated
    7
    227
    1
    ISC
  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server implementation that provides basic utility tools including echo, uppercase text conversion, and mathematical calculations.
    Last updated
    3
    321
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dinek-k/MCP-Server-Example-1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server