About Bun-based MCP Server
A minimal MCP server example built with Bun and TypeScript, intended for developers exploring server implementation. It demonstrates stdio transport, a basic addition tool, and simulated dynamic tool loading from PostgreSQL.
Key features
- 01Bun and TypeScript implementation
- 02Stdio server transport
- 03Example add tool
- 04Simulated PostgreSQL tool loading
- 05Lint and type-check scripts
Use cases
- 01Study a minimal MCP server
- 02Test MCP requests over stdio
- 03Experiment with tool definitions loaded from a database
MCP support
It implements an MCP server using `@modelcontextprotocol/sdk` and `StdioServerTransport`. The server exposes an `add` tool and demonstrates simulated dynamic tool loading.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEBun-based MCP Server
This is a minimal Model Context Protocol (MCP) server using Bun, TypeScript, and the @modelcontextprotocol/sdk package. It demonstrates:
- StdioServerTransport for local testing
- A basic example tool (
add) that adds two numbers - Dynamic tool loading from a (mocked) PostgreSQL database
- Strict TypeScript and ESLint configuration
Setup
- Install Bun.
- Install dependencies:
bun install
Usage
Start the server:
bun run src/index.ts
The server will listen for MCP requests via stdio.
Tool Loading
The function load_tools_from_db simulates loading tool definitions and handlers from a PostgreSQL database. Replace this with real database logic as needed.
Example Tool
The add tool takes two numbers (a and b) and returns their sum as result.
Linting
bun run lint
Type Checking
bun run tsc
File Structure
src/index.ts: Main server entry pointtsconfig.json: TypeScript configuration.eslintrc.json: ESLint configurationpackage.json: Project metadata and scripts
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.