使用说明
🧠 MCP代理入门套件
🚀 使用以下工具构建自定义AI代理的完整入门套件 模型上下文协议(MCP) 和 开放人工智能.
学习如何创建、运行和扩展智能代理,这些代理可以将现实世界的工具与LLM连接起来。
🧩 这是什么?
这个项目是 最小但功能强大的模板 这有助于开发人员使用 模型上下文协议(MCP) --实现工具和大型语言模型(LLM)之间结构化交互的新标准。
它附带了:
- ✅ 基本的 MCP服务器
- ✅ 一个样本 AI工具(
WeatherTool) - ✅ 与集成 OpenAI API
- ✅ A工作 客户端示例 演示工具调用
🏗️ 项目结构
mcp试剂入门套件/ │ ├── index.js#主客户端入口点(OpenAI+MCP) ├── mcp/ │ ├── server.js#MCP服务器设置 │ └── 工具/ │ └── weatherTool.js#自定义工具示例 │ ├── .env#OpenAI API密钥 ├── package.json └── README.md
⚙️ 安装说明
1.️⃣ 克隆存储库
git clone https://github.com/thusharanavod123/mcp-agent-starter-kit.git
cd mcp-agent-starter-kit
2️⃣ Install Dependencies
npm install
3️⃣ Configure Environment Variables
Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
4️⃣ Run the MCP Server
node mcp/server.js
✅ You should see:
MCP-like server running on http://localhost:8080
5️⃣ Test Your MCP Agent
If you’re using PowerShell (Windows):
Invoke-WebRequest -Uri "http://localhost:8080/run-tool" -Method POST -Body '{"city":"Colombo"}' -ContentType "application/json"
If you’re using Mac/Linux terminal:
curl -X POST http://localhost:8080/run-tool \
-H "Content-Type: application/json" \
-d '{"city":"Colombo"}'
✅ You’ll get a JSON response like:
{"result": "Weather in Colombo is 28°C and sunny."}
🧠 How It Works
MCP Server (mcp/server.js)
Hosts your custom AI tools (e.g., WeatherTool).
Listens on a local port (default: 8080).
MCP Tools (mcp/tools/)
Define real-world functions (e.g., fetching weather, sending emails, running commands).
Each tool can expose name, description, and execute().
OpenAI Client (index.js)
Connects your LLM with your MCP server.
Sends user queries → triggers MCP tools → returns intelligent responses.
🧩 Example Custom Tool
Example: mcp/tools/weatherTool.js
export const WeatherTool = {
name: "WeatherTool",
description: "Fetches current weather for a given city",
async execute({ city }) {
return { result: `Weather in ${city} is 28°C and sunny.` };
},
};
You can replace this with any tool (e.g., file searcher, calendar integration, API fetcher).
🧭 Branch Structure
Branch Purpose
main Stable version ready for production
dev Experimental branch for testing new tools and features
agent-core MCP core logic improvements
tool-plugins For building and testing modular tools (e.g., calculator, email sender)
docs Documentation, examples, and tutorials
🌍 Topics
mcp ai-agent model-context-protocol openai nodejs ai-framework ai-tools llm mcp-server developer-tools
🤝 Contributing
Contributions are welcome!
Fork the repo, make your changes, and submit a PR.
If you build an awesome custom tool, feel free to add it under /mcp/tools/ and share it with the community.
📜 License
This project is licensed under the MIT License
.
⭐ Support
If this repo helps you, please star ⭐ it and share it on:
LinkedIn
X (Twitter)
Dev.to
Every star helps inspire new developers to explore MCP and AI tools. 🌱
---
Would you like me to also create a **`CONTRIBUTING.md`** and **GitHub banner idea (header image prompt)** so your repo looks visually stunning and professional on GitHub?
