Skip to main content
Glama
theinfyark

mcp-server-plus

by theinfyark

mcp-server-plus

はじめに

mcp-server-plus は、MCP サーバーツールキットです。繰り返しのボイラープレートを書かずに Model Context Protocol サーバーを構築するための小さな TypeScript フレームワークです。

パッケージ名に関する注記: mcp-server-toolkit は npm で既に使用されているため、このパッケージは mcp-server-plus として公開されています。

Related MCP server: MCP Framework

このパッケージが存在する理由

MCP サーバーを始める開発者は、ツール登録、プロンプト、リソース、認証、ロギング、テストを何度も実装し直しています。Express や Hono のような人気ライブラリは、ハッピーパスを明確にすることで成功しています。mcp-server-plus は、公式の @modelcontextprotocol/sdk の上で同じ DX を目指しています。

インストール

npm install mcp-server-plus zod

Node.js 18+ が必要です。

機能

  • ツール登録

  • プロンプトレジストリ

  • リソース

  • 認証 / 認可

  • ロギング

  • メトリクス

  • ストリーミング(MCP stdio トランスポート経由)

  • ミドルウェア

  • CLI スキャフォルダー

  • テストヘルパー

クイックスタート

import { z } from "zod";
import { createServer, toolResult } from "mcp-server-plus";

const weatherTool = {
  description: "Get weather",
  inputSchema: { city: z.string() },
  async handler({ city }: { city: string }) {
    return toolResult(`Weather in ${city}: sunny`);
  },
};

const server = createServer({
  name: "demo",
  version: "1.0.0",
});

server.tool("weather", weatherTool);

await server.start(); // stdio

CLI

npx mcp-server-plus init my-weather-server
cd my-weather-server
npm install
npm start

API リファレンス

createServer(options) / createMcpServer(options)

McpKitServer を作成します。

オプション

説明

name

string

サーバー名

version

string

サーバーバージョン

instructions

string?

オプションの MCP 指示

auth

AuthOptions?

API キー / カスタム認証

middleware

Middleware[]?

グローバルミドルウェア

logger

Logger?

カスタムロガー

server.tool(name, definition)

ツールを登録します(MCP SDK にも接続されます)。

server.prompt(name, definition)

プロンプトテンプレートを登録します。

server.resource(uri, definition)

リソースを登録します。

server.use(middleware)

ツール呼び出しの周りにミドルウェアを追加します。

server.start()

MCP stdio トランスポートを接続します(ストリーミングは SDK が処理します)。

server.invokeTool(name, args, meta?)

テストやスクリプト用のプロセス内呼び出し。

テストヘルパー

import { callTool, expectText } from "mcp-server-plus/testing";

server.tool("weather", weatherTool);
server.prompt("greet", {
  description: "Greeting",
  arguments: [{ name: "name", required: true }],
  handler: async ({ name }) => ({
    messages: [
      { role: "user", content: { type: "text", text: `Hello ${name}` } },
    ],
  }),
});
server.resource("memo://hello", {
  mimeType: "text/plain",
  handler: async (uri) => ({
    contents: [{ uri: uri.href, text: "Hello", mimeType: "text/plain" }],
  }),
});

高度な例

認証 + RBAC

const server = createServer({
  name: "secure",
  version: "1.0.0",
  // MCP_API_KEY is the expected secret only. Callers must still send meta.apiKey.
  auth: { apiKey: process.env.MCP_API_KEY, required: true },
});

server.tool("deploy", {
  roles: ["admin"],
  scopes: ["deploy"],
  handler: async () => toolResult("deployed"),
});

ミドルウェア + メトリクス

server.use(async (ctx, next) => {
  const started = Date.now();
  try {
    return await next();
  } finally {
    ctx.log.info("tool timing", ctx.toolName, Date.now() - started);
  }
});

console.log(server.metricsSnapshot());

フレームワーク統合

stdio サーバーをサポートする任意の MCP ホストで動作します。ホストを node dist/index.js(または npm start)プロセスに向けてください。

MCP ホスト設定の例:

{
  "mcpServers": {
    "demo": {
      "command": "node",
      "args": ["/path/to/server/src/index.js"]
    }
  }
}

TypeScript の使用

ファーストクラスの TypeScript サポート。ハンドラーを明示的に型指定すると、ツール引数は Zod の inputSchema から推論されます。最良の結果を得るには strict を有効にしてください。

エラーハンドリング

型付きエラー: McpKitErrorAuthErrorForbiddenError
ツールの失敗は { isError: true, content: [...] } を返すため、ホストは安全に表示できます。

パフォーマンス

  • 公式 SDK の薄いラッパー(追加のネットワークホップなし)

  • ミドルウェアはツール呼び出し時のみ

  • メトリクスはシンプルなカウンター(オーバーヘッド低)

ベストプラクティス

  • ツールは小さく、副作用を意識する

  • Zod スキーマで入力を検証する

  • ローカル/開発では optional 認証、共有ホストでは required を使用する

  • 単体テストでは invokeTool を優先し、統合テストでは stdio を使用する

FAQ

これは公式 SDK ですか?
いいえ — @modelcontextprotocol/sdk の上に、より良い DX を提供するものです。

ストリーミングはサポートしていますか?
はい、server.start() が使用する MCP stdio トランスポート経由でサポートしています。

CJS または ESM?
デュアル公開しています。ESM ファーストです。

移行ガイド

生の SDK McpServer から

registerTool のボイラープレートを server.tool(name, definition) に置き換え、Zod スキーマはそのまま使用します。StdioServerTransport を手動で配線する代わりに server.start() を呼び出します。

SemVer

破壊的変更はメジャーバージョンで行われ、CHANGELOG.md に記載されます。

トラブルシューティング

症状

修正方法

ホストがサーバーを起動できない

start() が呼び出され、stdout がログで汚染されていないことを確認する

認証されていないツール呼び出し

meta.apiKey(または Bearer)を送信する。MCP_API_KEY が期待されるシークレットです。

型が見つからない

mcp-server-plus からインポートし、Node 18+ を使用する

貢献

CONTRIBUTING.md を参照してください。

ライセンス

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A TypeScript implementation of a Model Context Protocol server that provides a frictionless framework for developers to build and deploy AI tools and prompts, focusing on developer experience with zero boilerplate and automatic tool registration.
    867
    14
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A TypeScript wrapper library for the Model Context Protocol SDK that provides a simplified interface for creating MCP servers with tools, resources, and prompts without needing to work directly with the protocol.
    23
    AGPL 3.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    A clean, reusable TypeScript boilerplate for building Model Context Protocol servers with support for custom tools and resources.
    8
    -

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/theinfyark/mcp-server-plus'

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