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
- Install Bun.
- Install dependencies:
bun installStart the server:
bun run src/index.tsThe server will listen for MCP requests via stdio.
The function load_tools_from_db simulates loading tool definitions and handlers from a PostgreSQL database. Replace this with real database logic as needed.
The add tool takes two numbers (a and b) and returns their sum as result.
bun run lintbun run tscsrc/index.ts: Main server entry pointtsconfig.json: TypeScript configuration.eslintrc.json: ESLint configurationpackage.json: Project metadata and scripts