my-mcp-server
My MCP Server(初心者向け)
MCP(Model Context Protocol)サーバーを自作するための内容です。次の機能を備えています:
.envファイルによる独自のAPIキーとURLのモジュールツール例:
echoとcall_my_apiMCP Inspector ですぐにテスト可能
VS Code(GitHub Copilot Chat)ですぐに利用可能
1. 依存関係をインストール
npm installRelated MCP server: mcp-server-demo
2. .env ファイルを作成
.env.example を .env にコピーし、自分のAPIキーとURLを入力してください:
Copy-Item .env.example .env.env の中身:
MY_API_KEY=api-key-asli-kamu
MY_API_BASE_URL=https://api.contohkamu.com
MCP_SERVER_NAME=my-mcp-server⚠️ 絶対に
.envファイルをgitにコミットしないでください。このファイルは.gitignoreによって自動的に無視されます。
3. プロジェクトをビルド
npm run buildこのコマンドは src/ 内のTypeScriptを build/ 内のJavaScriptにコンパイルします。
4. MCP Inspectorでテスト
MCP Inspectorは、他のクライアントを必要とせずにMCPツールを試せるビジュアル(ブラウザ)ツールです。
npm run inspectorこれにより npx @modelcontextprotocol/inspector node build/index.js が実行され、ブラウザでInspectorが開きます。ここでは次の操作ができます:
Tools タブをクリック
ツール
echoまたはcall_my_apiを選択パラメータを入力し、Run Tool をクリックして結果を確認
5. VS Codeですぐに使う
.vscode/mcp.json ファイルが用意されています。コマンドパレットを開き、MCP: List Servers → my-mcp-server を選択 → Start Server と進みます。このサーバーは envFile 経由で .env を自動的に読み込みます。
プロジェクト構成
├── .env # rahasia kamu (tidak di-commit)
├── .env.example # contoh isi .env
├── .vscode/mcp.json # konfigurasi MCP untuk VS Code
├── src/
│ ├── config.ts # loader environment variable
│ ├── apiClient.ts # modul pemanggilan API eksternal (pakai API key & URL)
│ └── index.ts # server MCP utama + daftar tool
├── package.json
└── tsconfig.json新しいツールを追加する
src/index.ts に新しい server.registerTool("nama_tool", { ... }, async (input) => { ... }) ブロックを追加し、npm run build を再実行してください。
トラブルシューティング
「Environment variable ... belum diisi」エラー →
.envが存在し、内容が入力されていることを確認してください。call_my_apiツールが失敗する →MY_API_BASE_URLとMY_API_KEYが正しいか、APIエンドポイントがAuthorization: Bearer <key>ヘッダーに対応しているかを確認してください。Inspector が開かない → 先に
npm run buildを実行していることを確認してください。
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP for 1,500+ APIs. Vault-managed credentials; OAuth or API key. Search, load, and execute.
Give any MCP-compatible AI assistant a builder for live, hosted web tools and workflows.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables users to expose arbitrary HTTP APIs as configurable MCP tools by defining tool specifications in a JSON configuration file.2,323 npm3-
- FlicenseNot gradedqualityDmaintenanceEnables AI clients to connect to example tools, resources, and prompts over MCP, demonstrating integration with IDEs, chatbots, and agent frameworks.-
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients to search GitHub repositories and users, retrieve weather data and forecasts, and access NASA astronomy and image data through modular MCP tools.-
- AlicenseNot gradedqualityCmaintenanceEnables interaction with Infor systems by exposing verified HTTP/SOAP requests as MCP tools, supporting multiple services, configurable authentication, and extensible request definitions.Apache 2.0