A Model Context Protocol (MCP) server built with Bun, Hono, and mcp-handler. Exposes a createAsciiArt tool over Streamable HTTP at /mcp.
Companion to the blog post: MCP on Bun and Hono with mcp-handler
Install dependencies:
bun add mcp-handler @modelcontextprotocol/sdk@1.26.0 zod
bun installPin the MCP SDK to 1.26.0 or later — earlier versions had a known security issue.
Run the development server with hot reloading:
bun run devThe MCP endpoint is available at http://localhost:3000/mcp.
Run the in-memory integration test suite (no port binding required):
bun testThese tests exercise the MCP initialize, tools/list, and tools/call flows via Hono's app.request() API. Use the MCP Inspector below for manual end-to-end verification with a real client.
Before wiring up Claude Code, Cursor, or another AI client, test the server with the MCP Inspector:
npx @modelcontextprotocol/inspectorConnect to your local server, find the createAsciiArt tool, and call it with test inputs. Verify the response shape before involving an AI client.
Clients that support remote Streamable HTTP can connect with a URL:
{
"mcpServers": {
"my-server": {
"url": "http://localhost:3000/mcp"
}
}
}Some desktop apps expect a spawned process, not a URL. Use mcp-remote as a bridge:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/mcp"]
}
}
}Config location varies by client:
- Cursor: Settings → MCP → Add server
- Claude Code:
~/.claude.jsonundermcpServers
Switch the URL to your deployed server when you go to production. Add OAuth or token verification before exposing anything sensitive — see the handler's authorization docs.
mcp-handler is the right default when you want HTTP/SSE MCP behind a web framework quickly. Reach for the official MCP TypeScript SDK directly if you need stdio-only local tools, minimal dependencies, or you're learning the protocol from the ground up.
docker build -t mcp-server-bun .docker run -p 3000:3000 mcp-server-bun- Runtime: Bun
- Web Framework: Hono
- MCP Integration: mcp-handler
- Validation: Zod
- ASCII Art: figlet
mcp-server-bun/
├── src/
│ └── index.ts # Hono app and MCP tools
├── package.json
├── tsconfig.json
├── Dockerfile
└── .dockerignore