Added a simpe Hono server to test
This commit is contained in:
parent
25857bc354
commit
f53bc6867b
1 changed files with 767 additions and 7 deletions
|
|
@ -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
|
||||
Loading…
Reference in a new issue