Framework Integration
Chapplin is framework-agnostic and can be integrated with various server frameworks and UI libraries. This guide covers the most popular options.
Server Frameworks
Section titled “Server Frameworks”Hono (Recommended)
Section titled “Hono (Recommended)”Hono is a fast, lightweight framework that works great with Chapplin.
Installation
Section titled “Installation”npm install hono @hono/mcp @hono/node-serverimport { StreamableHTTPTransport } from "@hono/mcp";import { serve } from "@hono/node-server";import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { applyTools } from "chapplin";import { Hono } from "hono";import getTodos from "./tools/get-todos.js";
const app = new Hono();
// Create MCP serverconst mcp = new McpServer({ name: "my-mcp-server", version: "1.0.0",});
// Register toolsapplyTools(mcp, [getTodos]);
const transport = new StreamableHTTPTransport();// MCP endpointapp.all("/mcp", async (c) => { if (!mcp.isConnected()) await mcp.connect(transport); return transport.handleRequest(c);});
// Start serverserve(app, console.log);Express
Section titled “Express”Traditional Node.js framework with extensive middleware ecosystem.
Installation
Section titled “Installation”npm install express @modelcontextprotocol/sdknpm install -D @types/expressimport { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";import { applyTools } from "chapplin";import express from "express";import getTodos from "./tools/get-todos.js";
const app = express();app.use(express.json());
// Create MCP serverconst mcp = new McpServer({ name: "my-mcp-server", version: "1.0.0",});
applyTools(mcp, [getTodos]);
// MCP endpointapp.all("/mcp", async (req, res) => { const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, }); await mcp.connect(transport); await transport.handleRequest(req, res, req.body);});
app.listen(3000, console.log);UI Libraries
Section titled “UI Libraries”You can create UI with:
- React
- Preact
- SolidJS
- Hono