Skip to main content
Glama
y-moriya

Hono MCP Sample Server

by y-moriya

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)

セットアップ

依存関係のインストール

npm install

使用方法

開発モード

npm run dev

ビルド

npm run build

本番環境で実行

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          # このファイル

カスタマイズ

新しいリソースを追加

mcpServer.registerResource(
    "custom resource",
    new ResourceTemplate("custom://resource", { list: undefined }),
    {
        description: "リソースの説明",
        mimeType: "text/plain",
    },
    async (uri) => ({
        contents: [
            {
                url: uri.href,
                mimeType: "text/plain",
                text: "リソースの内容",
            },
        ],
    }),
);

新しいツールを追加

mcpServer.registerTool(
    "custom-tool",
    {
        description: "ツールの説明",
        inputSchema: {
            param1: z.string().describe("パラメータの説明"),
        },
    },
    async ({ param1 }) => {
        const result = a + b;
        return {
            content: [
                {
                    type: "text",
                    text: `処理結果: ${param1}`,
                },
            ],
        };
    },
);

ライセンス

MIT

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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