Added a simpe Hono server to test

This commit is contained in:
Glen Maddern 2025-06-24 17:26:16 +10:00
commit f53bc6867b

View file

@ -1,9 +1,32 @@
import { Hono } from "hono";
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StreamableHTTPTransport } from '@hono/mcp'
import { Hono } from 'hono'
import { z } from "zod";
import { cors } from 'hono/cors'
const app = new Hono<{ Bindings: CloudflareBindings }>();
const app = new Hono()
app.get("/message", (c) => {
return c.text("Hello Hono!");
});
// Your MCP server implementation
const mcpServer = new McpServer({
name: 'my-mcp-server',
version: '1.0.0',
})
export default app;
mcpServer.registerTool("add",
{
title: "Addition Tool",
description: "Add two numbers",
inputSchema: { a: z.number(), b: z.number() }
},
async ({ a, b }) => ({
content: [{ type: "text", text: String(a + b) }]
})
);
app.all('/mcp', cors(), async (c) => {
const transport = new StreamableHTTPTransport()
await mcpServer.connect(transport)
return transport.handleRequest(c)
})
export default app