bun-mcp-server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bun-mcp-serverget weather for Tokyo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
bun-mcp-server
A white-label HTTP-based Model Context Protocol (MCP) server built with Bun.
Motivation
This project began as a personal learning exercise to better understand how MCP servers work by building one from the ground up. As such, it currently implements a meaningful subset of the MCP specification, with compliance support being added over time as the project evolves.
You can read the full MCP specification here.
Related MCP server: Bun Fun MCP Server
Features
White-label Config — Server identity (name, title, description, version, categories) is controlled entirely from a single
mcp.config.jsfile.Auto Tool Discovery — Tools placed in the
tools/directory are loaded and registered automatically at startup — no manual wiring required.HTTP Transport — Serves MCP over a standard HTTP endpoint (
/mcp), supportingPOST,GET,DELETE, andOPTIONS.JSON-RPC 2.0 — Fully compliant request/response framing with proper error codes (
-32700,-32600,-32601,-32602,-32603).Session Management — Issues an
mcp-session-idoninitialize, tracks sessions in memory, and automatically expires them after 5 minutes of inactivity.Protocol Version Enforcement — Validates the
mcp-protocol-versionheader on every non-initialization request.Origin-aware CORS — Reflects the request
Originheader and exposesmcp-session-idandmcp-protocol-versionto browser clients.
Quick Start
Install dependencies
bun installStart the server
bun run devThe server starts on http://localhost:3000 with file-watching enabled for live reload during development.
White-labeling
Clone the repo, edit the config, add your tools. Follow the steps below to get started.
Step 1 — Configure your identity
Open mcp.config.js and update the following values:
export const config = {
name: "my-mcp-server", // Machine-readable identifier (used in client configs)
title: "My MCP Server", // Human-readable display name
description: "Does something useful.",
version: "1.0.0",
protocolVersion: "2025-11-25", // MCP spec version this server targets
categories: ["demo"], // Descriptive tags for discoverability
}These values flow into two places automatically:
The
initializeresponse — returned to any MCP client during the handshakeThe Server Card at
GET /.well-known/mcp— used for server discovery
Step 2 — Add your tools
Drop .js files into the tools/ directory. The server loads them automatically at startup — no registration needed. See Tools for the file format.
Step 3 — Announce your server
Once running, your server self-describes via the /.well-known/mcp endpoint — the MCP Server Card. This gives clients a machine-readable way to discover your server's identity, transport type, and endpoint URL without any manual configuration.
curl http://localhost:3000/.well-known/mcp{
"name": "my-mcp-server",
"title": "My MCP Server",
"description": "Does something useful.",
"version": "1.0.0",
"url": "http://localhost:3000/mcp",
"transport": "http",
"categories": ["demo"]
}[!Note] The
/.well-known/mcpServer Card is not yet part of the official MCP specification, but it fills a gap: there is currently no standardized way for HTTP-based MCP servers to announce themselves. This endpoint follows the established/.well-known/convention for service discovery on the web.
Tools
Available Tools
Tool | Description | Parameters |
| Get the current weather for a given city |
|
The
get_weathertool returns simulated data (random temperature, "Cloudy" condition) — it is included as a demo tool for testing the MCP lifecycle.
Adding New Tools
Drop a new .js file into the tools/ directory. The server picks it up automatically at startup.
Each tool file must export two things:
metadata — the tool's schema (name, description, input shape):
export const metadata = {
name: "my_tool",
title: "My Tool",
description: "Does something useful.",
parameters: {
type: "object",
properties: {
input: { type: "string", description: "Some input value" }
},
required: ["input"]
}
}handler — an async function that receives the tool's arguments:
export async function handler({ input }) {
// Your tool logic here
return { result: `Processed: ${input}` }
}The tool is automatically available via tools/list and executable via tools/call — no additional wiring needed.
See tools/get_weather.js for a working example.
Project Structure
bun-mcp-server/
├── src/
│ ├── index.js # Entry point — starts the Bun HTTP server and runs session cleanup
│ ├── lib/
│ │ ├── sessions.js # In-memory session store (Map)
│ │ └── utils.js # Shared utilities (timestamps, CORS headers, logging, IP parsing)
│ ├── mcp/
│ │ ├── index.js # Core MCP request handler (JSON-RPC dispatch)
│ │ └── tools.js # Auto-loads tools from the tools/ directory
│ └── routes/
│ └── index.js # HTTP route definitions (/mcp, /.well-known/mcp, catch-all)
├── tools/ # Drop tool files here — they are picked up automatically
│ └── get_weather.js # Example tool (simulated weather data)
├── mcp.config.js # Server identity and capabilities config
├── package.json
└── jsconfig.jsonPrerequisites
Bun v1.3+ installed
API Reference
POST /mcp
The main MCP endpoint. Accepts JSON-RPC 2.0 requests and dispatches them to the appropriate handler.
For all methods except initialize and notifications, the request must include:
mcp-session-idheader — a valid session ID issued duringinitializemcp-protocol-versionheader — must match the server's configured protocol version
Supported methods:
Method | Description |
| Handshake — returns server info, protocol version, and capabilities. Issues |
| No-op keep-alive — returns an empty result |
| Returns the list of available tools with their schemas |
| Executes a registered tool by name with the given arguments |
| Acknowledges client initialization (returns |
| Acknowledges root change notifications (returns |
GET /mcp
Session probe. Requires a valid mcp-session-id header. Returns 200 if the session exists, 404 if not. Returns 406 if the client requests text/event-stream (SSE is not currently supported).
DELETE /mcp
Session termination. Requires a valid mcp-session-id header. Removes the session and returns 204.
OPTIONS /mcp
CORS preflight. Returns 204 with appropriate Access-Control-* headers.
GET /.well-known/mcp
See Step 3 — Announce your server above.
* /*
Catch-all route that returns a 404 Not Found JSON response for any unmatched path.
Usage Examples
Initialize the server
On success, the server returns an mcp-session-id header. Save it — all subsequent requests must include it.
curl -D - -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-11-25",
"capabilities": {},
"clientInfo": { "name": "test-client", "version": "1.0.0" }
}
}'List available tools
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: <your-session-id>" \
-H "mcp-protocol-version: 2025-11-25" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}'Call a tool
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "mcp-session-id: <your-session-id>" \
-H "mcp-protocol-version: 2025-11-25" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_weather",
"arguments": { "city": "Tokyo" }
}
}'Terminate a session
curl -X DELETE http://localhost:3000/mcp \
-H "mcp-session-id: <your-session-id>"Connecting a Client
You can verify that the server is functioning correctly by connecting it to an MCP client, such as VS Code or AntiGravity.
[!Note] Ensure your MCP server is already running locally before connecting. Upon success, you will see connection activity in your server's console logs.
VS Code
Create or open
.vscode/mcp.jsonin your project directory.Add the following entry:
{
"servers": {
"my-mcp-server": {
"url": "http://localhost:3000/mcp"
}
}
}In the VS Code Chat panel, click the gear icon to open the Agent Customizations dialog.
Select MCP Servers from the sidebar. You should see
my-mcp-serverlisted under Workspace.Right-click
my-mcp-serverand select Start Server from the context menu to initialize the connection.
AntiGravity
Open Configuration: Navigate to Additional Options (
...) and select MCP Servers.Manage Servers: Click Manage MCP Servers, then select View raw config to open the
mcp_config.jsonfile.Add Server: Add the following configuration:
{
"mcpServers": {
"my-mcp-server": {
"serverUrl": "http://localhost:3000/mcp"
}
}
}Connect: Save the file, return to the Manage MCP Servers menu, and click Refresh.
Once connected, confirm that tool discovery and execution are working by sending a prompt through your IDE's chat interface:
"Let's test the MCP server. Get the weather for Tokyo today."
If successful, the chat should trigger the tool and return the relevant data from your server.
Error Handling
The server returns standard JSON-RPC 2.0 error responses:
Code | Meaning |
| Parse error — malformed JSON body |
| Invalid Request — missing |
| Method not found — unsupported MCP method |
| Invalid params — missing or malformed tool parameters |
| Internal error — unexpected server-side failure |
Musings & Future Direction
2026-07-01 — Streamable HTTP
The MCP specification defines Streamable HTTP as one of the supported transport mechanisms for MCP servers. It replaces the HTTP+SSE transport used in earlier versions of the protocol.
I haven't implemented Streamable HTTP in this project yet, as I'm still learning how it works. Support for it will be added in the future, hopefully.
2026-06-30 - MCP Server Card
The idea is to introduce an MCP Server Card, similar to the Web App Manifest for web applications. A Server Card would provide standardized metadata that serves as the foundation for searchable directories of MCP servers, making it easy for users to discover and add servers to their MCP clients or IDEs. That’s the dream, at least.
License
MIT © supershaneski
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/supershaneski/bun-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server