Self-built MCP client and server

Self-built MCP client and server

mcp-client-server-okikusan-public•byokikusan-public

A project that implements its own Model Context Protocol client and server, with the server providing a RESTful API, Anthropic-integrated AI processing, and messaging and context management.

License: MIT•Runtime: Awaiting documentation review•Category: ai agents-models

WHAT IT DOES

  • •Runs an MCP server as an Express.js RESTful API server.
  • •Integrates Anthropic's API as an AI processing engine with messaging and context management.
  • •Exposes HTTP endpoints for health checks, sending full MCP messages, and sending simple text prompts.
  • •Supports WebSocket streaming responses and event-based asynchronous communication.

BEST FOR

  • •Learning how a Model Context Protocol client and server are implemented.
  • •Interactive command-line conversations with streaming responses and retained conversation history.

ABOUT MCP-CLIENT-SERVER-OKIKUSAN-PUBLIC

Self-built MCP client and server is cataloged as an MCP server attributed to okikusan-public. A project that implements its own Model Context Protocol client and server, with the server providing a RESTful API, Anthropic-integrated AI processing, and messaging and context management. It is categorized under ai agents-models. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Self-built MCP client and server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What does the MCP server part consist of?

An Express.js RESTful API server combined with an AI processing engine integrated with Anthropic's API, plus messaging and context management.

Is the project intended for production use?

No, it is offered for educational and research purposes, and security and error handling should be strengthened for production use.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 25874d7cfe52 · 采集于 2026-11-13 12:06:03 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

自作の Model Context Protocol (MCP) クライアントとサーバー

このリポジトリは、Model Context Protocol (MCP)のクライアントとサーバーを自作で実装したものです。AnthropicのClaudeモデルとのインタラクションを通じて、MCPの実装方法と活用例を示しています。

概要

Model Context Protocol (MCP)は、AIアシスタントと様々なデータソースを接続するためのオープンスタンダードです。このプロジェクトでは、MCPの基本的な概念を理解し、実際に動作するクライアントとサーバーの両方を実装しています。

主な機能

  • MCPサーバー:

    • Express.jsを使用したRESTful APIサーバー
    • AnthropicのAPIと連携したAI処理エンジン
    • メッセージングとコンテキスト管理機能
  • WebSocketサポート:

    • リアルタイムストリーミングレスポンス
    • 双方向通信によるインタラクティブな対話
    • イベントベースの非同期通信
  • MCPクライアント:

    • HTTPとWebSocketの両方をサポートする統合クライアント
    • シンプルで使いやすいAPI
    • 複数の通信方式に対応
  • デモアプリケーション:

    • HTTP通信の基本デモ
    • WebSocketストリーミングデモ
    • インタラクティブチャットコンソール

技術スタック

  • バックエンド: Node.js, Express, WebSocket (ws)
  • フロントエンド: TypeScript, Axios
  • AI連携: Anthropic Claude API
  • その他: dotenv(環境変数管理), TypeScript(型安全な開発)

プロジェクト構造

mcp-client-server/
├── client/               # MCPクライアント実装
│   ├── http-client.ts    # HTTP通信クライアント
│   ├── ws-client.ts      # WebSocket通信クライアント
│   ├── mcp-client.ts     # 統合クライアント
│   ├── types.ts          # 型定義
│   └── index.ts          # エントリーポイント
├── server/               # MCPサーバー実装
│   ├── controllers/      # APIコントローラー
│   ├── routes/           # APIルート定義
│   ├── services/         # MCPサービス
│   ├── websocket/        # WebSocketサポート
│   ├── types.ts          # 型定義
│   └── index.ts          # サーバーエントリーポイント
├── examples/             # サンプルアプリケーション
│   ├── http-demo.ts      # HTTPデモ
│   ├── websocket-demo.ts # WebSocketデモ
│   └── chat-demo.ts      # チャットデモ
├── MCP_DOCUMENTATION.md  # MCPに関する詳細資料
├── dist/                 # ビルド出力ディレクトリ
└── .env                  # 環境変数設定

セットアップ方法

前提条件

  • Node.js 14以上
  • Anthropic API Key (Claude APIにアクセスするため)

インストール手順

  1. リポジトリをクローンまたはダウンロードします

  2. 依存関係をインストールします

npm install
  1. 環境変数ファイルを設定します
# .envファイルを作成し、以下の内容を設定
PORT=3000
HOST=localhost
ANTHROPIC_API_KEY=your_anthropic_api_key_here
MODEL_NAME=claude-3-opus-20240229
MAX_TOKENS=1000

使い方

サーバーの起動

npm run start:server

サーバーはデフォルトで http://localhost:3000 で起動します。 WebSocketサーバーも同時に ws://localhost:3000 で利用可能になります。

デモアプリケーションの実行

1. HTTPデモの実行

サーバーが起動していることを確認してから実行します。

npm run demo:http

このデモはHTTP APIを使用してMCPサーバーと通信し、以下を行います:

  • サーバーのヘルスチェック
  • シンプルなプロンプトの送信と応答の表示
  • 完全なメッセージリクエストの送信とレスポンスの解析

2. WebSocketストリーミングデモの実行

npm run demo:ws

このデモはWebSocketを使用して以下を実演します:

  • WebSocket接続の確立
  • シンプルなプロンプトの送信
  • リアルタイムのストリーミングレスポンスの受信
  • ストリーミングの進行状況の表示

3. インタラクティブチャットデモの実行

npm run demo:chat

コマンドライン上でリアルタイムにMCPと会話できるインタラクティブなデモです:

  • 「exit」と入力するまで会話を継続
  • WebSocketを使用したストリーミングレスポンス
  • 会話履歴の保持と文脈を考慮した応答

APIリファレンス

HTTP API

エンドポイントメソッド説明
/api/healthGETサーバーのヘルスチェック
/api/messagePOST完全なMCPメッセージを送信
/api/promptPOSTシンプルなテキストプロンプトを送信

WebSocket API

WebSocketエンドポイント: ws://localhost:3000

クライアントからサーバーへのメッセージタイプ

  • message - 完全なMCPメッセージを送信
  • prompt - シンプルなテキストプロンプトを送信
  • stream - ストリーミングレスポンスをリクエスト

サーバーからクライアントへのイベントタイプ

  • connection - 接続状態の通知
  • message_response - メッセージへの応答
  • prompt_response - プロンプトへの応答
  • stream_start - ストリーミング開始通知
  • stream_chunk - ストリーミングデータチャンク
  • stream_end - ストリーミング終了通知
  • error - エラー通知

プログラム例

クライアントAPIの使用例

import { createMCPClient, createPromptRequest, MCPRole } from './client';

// クライアントの作成
const client = createMCPClient({
  apiBaseUrl: 'http://localhost:3000',
  wsBaseUrl: 'ws://localhost:3000'
});

// HTTP APIを使用した例
async function httpExample() {
  // サーバーの状態確認
  const health = await client.healthCheck();
  console.log('サーバー状態:', health.status);
  
  // シンプルなプロンプト送信
  const response = await client.sendPrompt('AIの未来について教えてください');
  console.log('応答:', response.response);
}

// WebSocketを使用した例
async function wsExample() {
  // WebSocket接続
  await client.connectWebSocket();
  
  // イベントリスナーの登録
  client.on('prompt_response', (data) => {
    console.log('応答:', data.response);
  });
  
  // プロンプトの送信
  client.sendWebSocketPrompt('量子コンピューティングの可能性は?');
  
  // ストリーミングでのリクエスト
  client.on('stream_chunk', (chunk) => {
    // リアルタイムでチャンクを処理
    process.stdout.write(chunk.content[0].text);
  });
  
  // ストリーミングリクエストの送信
  client.sendStreamRequest({
    messages: [{
      role: MCPRole.USER,
      content: [{ type: 'text', text: 'AIと人間の協調について詩を書いてください' }]
    }],
    model: 'claude-3-opus-20240229'
  });
}

拡張と貢献

このプロジェクトは基本的な実装を提供していますが、以下のような拡張が可能です:

  • マルチモーダル機能の追加(画像処理など)
  • 会話履歴の永続化
  • 認証機能の強化
  • ユーザーインターフェースの実装
  • より高度なエラーハンドリング

関連資料

詳細な技術資料は MCP_DOCUMENTATION.md を参照してください。このドキュメントには以下の情報が含まれています:

  • MCPの概念と原理
  • アーキテクチャの詳細
  • 実装パターン
  • ベストプラクティス
  • 性能最適化のヒント

ライセンス

MIT

注意事項

  • このプロジェクトは教育・研究目的で提供されています
  • 本番環境で使用する場合は、セキュリティやエラー処理などを強化してください
  • APIキーなどの機密情報を適切に管理してください
  • Anthropic APIの利用規約に従ってください

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Self-built MCP client and server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-client-server-okikusan-public)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related ai agents-models MCP Servers

Alternative and complementary servers in the same category

View all in ai agents-models →
Knowledge Graph Memory
@modelcontextprotocol/server-memory•Model Context Protocol

Store and retrieve entities, relations and observations in a persistent local knowledge graph.

create_entitiescreate_relationsadd_observations+6 more
92K
AI & Multi-Agent
Sequential Thinking
@modelcontextprotocol/server-sequential-thinking•Model Context Protocol

Organize problem solving into revisable, branching thought steps through an MCP tool.

sequential_thinking
92K
AI & Multi-Agent

Query-aware context compression with an MCP plugin for coding agents, plus Python and HTTP interfaces for reducing the context sent to a language model.

146
AI & Multi-Agent