my-mcp-server
My MCP Server(面向初学者)
自制 MCP(Model Context Protocol)服务器,包含:
通过
.env文件配置自己的 API key 和 URL示例工具:
echo和call_my_api可直接用 MCP Inspector 测试
可直接在 VS Code(GitHub Copilot Chat)中使用
1. 安装依赖
npm installRelated MCP server: mcp-server-demo
2. 创建 .env 文件
将 .env.example 复制为 .env,然后填入你自己的 API key 和 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。在那里你可以:
点击 工具 标签页
选择工具
echo或call_my_api填写参数,点击 运行工具,查看结果
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。
故障排查
错误:“环境变量 ... 未填写” → 请确保
.env文件已存在并已填写。工具
call_my_api失败 → 检查MY_API_BASE_URL和MY_API_KEY是否正确,以及 API 端点是否支持Authorization: Bearer <key>请求头。Inspector 无法打开 → 请确保已先运行
npm run build。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Related MCP Connectors
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
Remote MCP for 1,500+ APIs. Vault-managed credentials; OAuth or API key. Search, load, and execute.
Email inboxes, webhook URLs, mock APIs and 170+ tools for coding agents over one MCP connection.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables users to expose arbitrary HTTP APIs as configurable MCP tools by defining tool specifications in a JSON configuration file.3-
- FlicenseNot gradedqualityDmaintenanceEnables AI clients to connect to example tools, resources, and prompts over MCP, demonstrating integration with IDEs, chatbots, and agent frameworks.-

automate-mcp-serverofficial
AlicenseNot gradedqualityBmaintenanceEnables building and running MCP servers for Umbraco add-ons, with tools for API interactions, OAuth setup, and testing via MCP Inspector or Claude Code.1MIT- AlicenseNot gradedqualityBmaintenanceEnables developers to build, test, debug, and operate MCP servers from VS Code or CI, while also exposing trusted MCP capabilities to AI agents.MIT