npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mako10k/mcp-async

v1.0.0

Published

MCP server bridge with async functionality and timeout handling

Readme

MCP Async Bridge Server

MCPサーバをブリッジし、非同期処理機能を追加するMCPサーバです。

機能

  • 非同期化: 既存のMCPサーバのすべてのツールに sync パラメータを追加(デフォルト:async)
  • タイムアウト処理: 1秒で応答がない場合、実行制御用ハンドルを返却
  • 状況確認: 非同期ツールの実行状況管理とキャンセル機能
  • リソース/サブスクリプション: task://{taskId} でタスクの状態/結果をリソースとして公開。resources/subscribe で更新を購読可能

セットアップ

1. 依存関係のインストール

npm install

2. ビルド

npm run build

3. 実行

npm start

4. 開発モード

npm run dev

設定

環境変数

  • MCP_TARGET_SERVER: ブリッジ先MCPサーバのコマンド(例:python server.py
  • MCP_TIMEOUT_MS: タイムアウト時間(ミリ秒、デフォルト:1000)
  • MCP_ENV: ターゲットMCPプロセスへ渡す環境変数の宣言(空白区切り)。
    • 形式: <ENV_ITEM> ::= NAME | NAME=VALUE を空白で列挙
    • VALUE はシェル風にクオート/展開可能('...' はリテラル、"..."/非クオートは $VAR ${VAR} 展開、" \ $ をエスケープ)
    • 値省略時は NAME="$NAME" と等価(現在の環境からコピー)
    • 宣言順にカスケード展開(前に定義した変数を後段で参照可能)
    • 例: MCP_ENV='FOO=abc BAR="$FOO-suf" BAZ=${BAR}-end'
  • MCP_WORKDIR: ターゲットMCPプロセスの作業ディレクトリ(未指定時は継承)

既定で未指定でも引き継ぐ環境変数: PATH, HOME, SHELL(安全のため値はログ表示しません)。

VS Codeでのデバッグ

このプロジェクトにはMCP設定が含まれています(.vscode/mcp.json)。VS CodeでMCPサーバとしてデバッグできます。

アーキテクチャ

コンポーネント

  1. AsyncBridgeServer: メインのMCPサーバ
  2. TargetServerProxy: 既存MCPサーバへのプロキシ
  3. AsyncTaskManager: 非同期タスクの管理
  4. TimeoutHandler: タイムアウト処理

提供ツール

ブリッジツール

  • 既存MCPサーバのすべてのツールに sync パラメータを追加
  • デフォルトで非同期実行、sync: true で同期実行

リクエストペイロード形式

Model Context Protocol の仕様に合わせ、ブリッジ経由のツール呼び出しは次のように arguments オブジェクト内へ元のパラメータを格納してください。

{
    "arguments": {
        "a": 1,
        "b": 2
    },
    "sync": false // 省略時は false(非同期実行)
}

既存クライアントとの互換性のため、トップレベルに置かれたパラメータ (例: { "a": 1, "b": 2 })も自動的に arguments にラップされますが、 仕様準拠のため上記形式での利用を推奨します。

管理ツール

  • async_list_pending_tasks: 未完了の非同期タスク一覧
  • async_get_task_result: タスク結果の取得(完了時にハンドル開放)
  • async_cancel_task: 実行中タスクのキャンセル

応答取得用リソースとサブスクリプション

  • ブリッジは resources 機能を公開し、task://{taskId} でタスクの状態と結果を読み取れます。
  • 非同期ツール開始時の応答には ResourceLinktask://{taskId})が含まれます。
  • クライアントは以下の流れで最新状態を追跡します。
  1. resources/subscribetask://{taskId} を購読
  2. サーバーから notifications/resources/updated が届いたら
  3. resources/readtask://{taskId} を取得(JSON: status, result

例(概念):

// リソース購読
{
    "method": "resources/subscribe",
    "params": { "uri": "task://<taskId>" }
}

// 更新通知(サーバー→クライアント)
{
    "method": "notifications/resources/updated",
    "params": { "uri": "task://<taskId>" }
}

// リソース読み取り
{
    "method": "resources/read",
    "params": { "uri": "task://<taskId>" }
}

使用例

// 非同期実行(デフォルト)
const handle = await callTool('some_tool', { param: 'value' });

// 同期実行
const result = await callTool('some_tool', { param: 'value', sync: true });

// 非同期結果の確認
const tasks = await callTool('async_list_pending_tasks');
const result = await callTool('async_get_task_result', { taskId: handle });

開発

プロジェクト構造

src/
├── index.ts                 # エントリーポイント
├── server/
│   ├── AsyncBridgeServer.ts # メインサーバー
│   └── TargetServerProxy.ts # プロキシ実装
├── async/
│   ├── TaskManager.ts       # タスク管理
│   └── TimeoutHandler.ts    # タイムアウト処理
├── types/
│   └── index.ts            # 型定義
└── utils/
    └── logger.ts           # ログ機能

テスト

npm test

ライセンス

MIT