npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tidbcloud/serverless-mcp

v0.0.2

Published

MCP server for TiDB Cloud Serverless Driver

Readme

tidbcloud-serverelss-js-mcp

MCP server built with TypeScript and TiDB Cloud Serverless Driver.

It supports:

  • Local MCP transport: stdio
  • Remote MCP transport: Streamable HTTP
  • Vercel deployment for remote mode

Quickstart

  1. Prepare TiDB URL:
TIDB_DATABASE_URL="mysql://<user>:<password>@<host>/<database>"
  1. Add this MCP server to Agent (stdio):
{
  "mcpServers": {
    "tidbcloud": {
      "command": "npx",
      "args": ["-y", "@tidbcloud/serverless-mcp"],
      "env": {
        "TIDB_DATABASE_URL": "mysql://<user>:<password>@<host>/<database>"
      }
    }
  }
}
  1. Restart your agent, then verify tools are loaded:
  • run_sql
  • run_sql_transaction
  • get_database_tables
  • describe_table_schema

Deploy to Vercel

deploy your own server to vercel and you don't need to provide any secret to AI agent.

  1. Set env var in Vercel project:
    • TIDB_DATABASE_URL
  2. Deploy:
vercel deploy

Route mapping is defined in vercel.json:

  • /mcp -> api/mcp.ts

Build Locally

Requirements

  • Node.js 18+
  • TiDB Cloud Serverless connection URL

Set environment variable:

export TIDB_DATABASE_URL="mysql://<user>:<password>@<host>/<database>"

Install (for contributors)

npm install

Build

npm run build

Run Local (stdio)

npm start

Entry file: src/index.ts

Run Local (Streamable HTTP)

npm run start:http

Endpoint:

POST http://127.0.0.1:3000/mcp

Entry file: src/http.ts

Use with AI Agents (Cursor, Claude Desktop, Others)

This MCP server can be attached to agent clients through either stdio (local subprocess) or Streamable HTTP (remote URL).

Cursor

Add an MCP server entry in Cursor settings and use stdio mode:

{
  "mcpServers": {
    "tidbcloud": {
      "command": "node",
      "args": ["/absolute/path/to/tidbcloud-serverelss-js-mcp/dist/src/index.js"],
      "env": {
        "TIDB_DATABASE_URL": "mysql://<user>:<password>@<host>/<database>"
      }
    }
  }
}

After saving config, restart Cursor and confirm tools are visible:

  • run_sql
  • run_sql_transaction
  • get_database_tables
  • describe_table_schema

Remote-agent setup (Streamable HTTP)

For clients that support remote MCP endpoint, use:

  • URL: https://<your-domain>/mcp
  • Method: POST
  • Transport: Streamable HTTP

This works for Vercel deployment and any compatible MCP client.

Prompt examples for agents

  • "Create an orders table if not exists and insert 3 rows for 2026-03-05."
  • "Calculate total order amount on 2026-03-05."
  • "List all tables in current database."
  • "Describe schema of table orders."

Security notes

  • Never commit real connection strings.
  • Keep credentials only in client env settings or deployment environment variables.
  • Use a least-privilege DB account when possible.

Tools

1) run_sql

Execute one SQL statement.

Input:

  • sql: string
  • args?: (string | number | boolean | null)[]

Example:

{
  "sql": "SELECT * FROM orders WHERE id = ?",
  "args": [1]
}

2) run_sql_transaction

Execute multiple statements in one transaction. Auto rollback on error.

Input:

  • statements: { sql: string; args?: (string | number | boolean | null)[] }[]

Example:

{
  "statements": [
    {"sql": "INSERT INTO orders(order_date, amount, customer_name) VALUES (?, ?, ?)", "args": ["2026-03-05", 100, "Alice"]},
    {"sql": "INSERT INTO orders(order_date, amount, customer_name) VALUES (?, ?, ?)", "args": ["2026-03-05", 50, "Bob"]}
  ]
}

3) get_database_tables

List all tables in a database.

Input:

  • database?: string (default is database in TIDB_DATABASE_URL)

4) describe_table_schema

Get schema details for one table.

Input:

  • table: string
  • database?: string

Test with ref/secret.md

This project includes an integration script that reads the connection URL from ref/secret.md, then:

  1. Creates a test orders table.
  2. Inserts order rows.
  3. Queries total amount for one day.
  4. Verifies table list and table schema tools.
  5. Drops the test table.

Run:

npm run test:secret

Files

  • Architecture doc: docs/architecture.md
  • Developer doc (Inspector): docs/developer-guide.md
  • MCP server and tools: src/server.ts
  • DB wrapper: src/db/client.ts
  • Local stdio entry: src/index.ts
  • Local HTTP entry: src/http.ts
  • Vercel entry: api/mcp.ts
  • Secret-based integration test: scripts/test-with-secret.ts