Skip to main content
Glama

Hono MCP Sample Server

by y-moriya
README.md2.78 kB
# Hono MCP Sample Server Honoフレームワークと`hono/mcp`を使用したModel Context Protocol (MCP) サーバーのサンプル実装です。 ## 機能 このサンプルサーバーは以下のMCP機能を提供します: ### リソース - **weather://tokyo**: 東京の天気情報を取得 - **news://latest**: 最新ニュースヘッドラインを取得 ### ツール - **calculator**: 2つの数値を加算 - パラメータ: `a` (number), `b` (number) - **reverse-string**: 文字列を反転 - パラメータ: `text` (string) ### プロンプト - **code-review**: コードレビューを依頼するプロンプトテンプレート - 引数: `code` (string) ## セットアップ ### 依存関係のインストール ```bash npm install ``` ## 使用方法 ### 開発モード ```bash npm run dev ``` ### ビルド ```bash npm run build ``` ### 本番環境で実行 ```bash npm start ``` ## エンドポイント サーバーが起動すると、以下のエンドポイントが利用可能になります: - `http://localhost:3000/` - サーバー情報 - `http://localhost:3000/mcp` - MCPエンドポイント ## 技術スタック - **Hono**: 高速で軽量なWebフレームワーク - **hono/mcp**: HonoのMCPサポートパッケージ - **@modelcontextprotocol/sdk**: MCP公式SDK - **zod**: スキーマ定義(v3系を使用) - **TypeScript**: 型安全な開発 - **tsx**: TypeScriptの実行環境 ## 構成 ``` mcp-sample/ ├── src/ │ └── index.ts # メインサーバーファイル ├── package.json # プロジェクト設定 ├── tsconfig.json # TypeScript設定 └── README.md # このファイル ``` ## カスタマイズ ### 新しいリソースを追加 ```typescript mcpServer.registerResource( "custom resource", new ResourceTemplate("custom://resource", { list: undefined }), { description: "リソースの説明", mimeType: "text/plain", }, async (uri) => ({ contents: [ { url: uri.href, mimeType: "text/plain", text: "リソースの内容", }, ], }), ); ``` ### 新しいツールを追加 ```typescript mcpServer.registerTool( "custom-tool", { description: "ツールの説明", inputSchema: { param1: z.string().describe("パラメータの説明"), }, }, async ({ param1 }) => { const result = a + b; return { content: [ { type: "text", text: `処理結果: ${param1}`, }, ], }; }, ); ``` ## ライセンス MIT

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/y-moriya/mcp-sample'

If you have feedback or need assistance with the MCP directory API, please join our Discord server