PM

pguso/mcp-from-scratch

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

36 stars 11 forks 品質 63 トレンド 16MIT

プレーンNode.jsのスクラッチからモデルコンテキストプロトコル(MCP)を学びます。 JSON-RPC と stdio トランスポートからツール、プロンプト、リソース、...

概要

初心者のための学習リポジトリ。 フレームワークはありません。 黒い箱無し。 純粋なNode.js。 最後に、作業中の MCP サーバーを Claude デスクトップに接続し、各行を把握できます。 そのモジュールは、MCP が何であるか、なぜ存在しているのか、そして後でモジュールが構築するメンタルモデルについて説明しています。 実際のツールを公開する plain Node.js の MCP サーバーが完全に機能し、プロトコルを正確にフォローし、変更なしで Claude デスクトップ (または MCP クライアント) に接続します。 ピースで作ります。 各モジュールは1つの質問に答えます。 その質問に対する答えは、次の質問を明らかにします。 モジュール06はマイルストーンです。 モジュール09は(デスクトップ/カーソルスラッシュコマンド) を追加します。 モジュール07–11はプロトコルを完了します。 モジュール12はMCPを(注文のループ+任意LangChain)接続します。 1つの規則:モジュール01–10 (およびモジュール11の)で。 各サーバーは、node src/server.js で動作します。 ルートpackage.json のエントリは "type": "module" で、ESM のインポートを有効にします.

概要(AI 翻訳)

初心者のための学習リポジトリ。 フレームワークはありません。 黒い箱無し。 純粋なNode.js。

最後に、作業中の MCP サーバーを Claude デスクトップに接続し、各行を把握できます。

[01-what-is-mcp/README.mdで起動します。 そのモジュールは、MCP が何であるか、なぜ存在しているのか、そして後でモジュールが構築するメンタルモデルについて説明しています。

お問い合わせ

ビルドする

実際のツールを公開する plain Node.js の MCP サーバーが完全に機能し、プロトコルを正確にフォローし、変更なしで Claude デスクトップ (または MCP クライアント) に接続します。

ピースで作ります。 各モジュールは1つの質問に答えます。 その質問に対する答えは、次の質問を明らかにします。

モジュール 06 は tools のマイルストーンです。 モジュール09はprompts(デスクトップ/カーソルスラッシュコマンド)を追加します。 モジュール07–11はプロトコルを完了します。 モジュール12はMCPをagentワークフローに接続します(カスタムループ+オプションLangChain)。

お問い合わせ

リポジトリ構造

1つの規則:モジュール01–10の*npmの依存関係** (およびモジュール11のserver)。 [node src/server.js で各サーバーが実行されます。 ルートpackage.json のエントリは "type": "module" で、ESM のインポートを有効にします.

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

MCP from Scratch

A learning repository for complete beginners. No frameworks. No black boxes. Pure Node.js.

By the end you will have built a working MCP server you can connect to Claude Desktop - and you will understand every line of it.

Start with 01-what-is-mcp/README.md. That module explains what MCP is, why it exists, and the mental model every later module builds on.


What you will build

A fully working MCP server in plain Node.js that exposes real tools, follows the protocol exactly, and connects to Claude Desktop (or any MCP client) without modification.

You will build it piece by piece. Each module answers one question. The answer to that question makes the next question obvious.

Module 06 is the tools milestone. Module 09 adds prompts (Desktop / Cursor slash commands). Modules 07–11 complete the protocol. Module 12 connects MCP to agent workflows (custom loop + optional LangChain).


Repository structure

mcp-from-scratch/
├── README.md                  ← you are here
├── package.json               ← { "type": "module" } - that is all
├── images/                    ← shared diagrams and screenshots used across modules
├── models/                    ← shared GGUF cache reused by modules 11 and 12
│
├── 01-what-is-mcp/
│   ├── README.md
│   └── ANSWERS.md             ← optional self-check answers; this module is docs-only
│
├── 02-json-rpc/
│   ├── README.md
│   ├── run.md
│   └── src/
│       ├── jsonrpc.js         ← encode and decode messages
│       └── dispatcher.js      ← route method calls to handlers
│
├── 03-stdio-transport/
│   ├── README.md
│   ├── run.md
│   └── src/
│       ├── framing.js         ← buffer stdin, emit complete messages
│       ├── server.js          ← reads from stdin, writes to stdout
│       └── client.js          ← spawns server, sends a message, reads reply
│
├── 04-lifecycle/
│   ├── README.md
│   ├── run.md
│   └── src/
│       ├── session.js         ← state machine: CREATED → INITIALIZING → READY → CLOSED
│       ├── server.js          ← handles initialize, sends initialized notification
│       └── client.js          ← sends initialize, waits for handshake to complete
│
├── 05-tools-list/
│   ├── README.md
│   ├── run.md
│   └── src/
│       ├── registry.js        ← store tool definitions
│       ├── server.js          ← handles tools/list
│       └── client.js          ← calls tools/list, prints what it finds
│
├── 06-tools-call/
│   ├── README.md
│   ├── run.md                 ← pick run-local or run-desktop
│   ├── run-local.md           ← full local checklist
│   ├── run-desktop.md         ← full Desktop checklist
│   └── src/
│       ├── server.js          ← handles tools/call, runs the function, returns result
│       ├── client.js          ← calls a tool, prints the result
│       ├── inspector.md       ← MCP Inspector (launch, connect, Claude Desktop limits)
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →