AI Agent with MCP
Playground create my first MCP (Model Context Protocol) server
moises-paschoalick
README
基于 MCP 的 AI 代理
本项目实现了一个使用模型上下文协议 (MCP) 与外部资源交互的 AI 代理。
可用资源
MCP 服务器提供以下资源:
用户资源
- api://users: 列出系统中所有注册用户
- 返回信息包括 ID、姓名、电话号码和线程 ID
- 格式:JSON
- 响应示例:
{ "content": [ { "id": 1, "phoneNumber": "553496341404", "name": "Moisés Paschoalick", "threadId": "thread_bZEPVYVBvHxY9Ok6WqR63M2D" }, { "id": 2, "phoneNumber": "553496338888", "name": "José Silva", "threadId": "1thread_t8SFjKio6yN9pppqypilwGoR__" }, { "id": 3, "phoneNumber": "553496338889", "name": "Maria Antonia", "threadId": "1thread_t8SFjKio6yN9pppqypilwGoR__" } ], "pageable": { "pageNumber": 0, "pageSize": 12, "sort": { "empty": false, "sorted": true, "unsorted": false }, "offset": 0, "paged": true, "unpaged": false }, "last": true, "totalPages": 1, "totalElements": 3, "first": true, "size": 12, "number": 0, "sort": { "empty": false, "sorted": true, "unsorted": false }, "numberOfElements": 3, "empty": false }
消息资源
- hello://world: 返回一个简单的问候消息
- 格式:纯文本 (text/plain)
- 响应示例:"Hello, World! This is my first MCP resource."
Cursor 安装
首先,请确保您已安装 Cursor 并在您的系统上配置了 npm。
选项 1:通过终端安装
在终端中执行以下命令:
npx -y @smithery/cli@latest install @wonderwhy-er/desktop-commander --client cursor --key dda23bec-caa6-4487-a1e9-eb74e22e33eb
如果 Cursor 正在运行,请重新启动它。
选项 2:手动安装
将适当的条目添加到您的 mcp.json 文件:
对于 Mac/Linux:
在 Linux 中:~/.config/cursor.json
{
"mcpServers": {
"desktop-commander": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@wonderwhy-er/desktop-commander",
"--key",
"dda23bec-caa6-4487-a1e9-eb74e22e33eb"
]
}
}
}
对于 Windows:
{
"mcpServers": {
"desktop-commander": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@smithery/cli@latest",
"run",
"@wonderwhy-er/desktop-commander",
"--key",
"dda23bec-caa6-4487-a1e9-eb74e22e33eb"
]
}
}
}
如果 Cursor 正在运行,请重新启动它。
选项 3:本地克隆
克隆并构建:
git clone https://github.com/moises-paschoalick/ai-agent-with-mcp.git
cd ai-agent-with-mcp
npm run setup
如果 Cursor 正在运行,请重新启动它。
配置命令将:
- 安装依赖项
- 构建服务器
- 配置 Cursor
- 如果需要,将 MCP 服务器添加到 Cursor 配置
如何使用
MCP 客户端
该项目包含一个 MCP 客户端,可用于访问可用资源:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
const client = new Client({
name: "hello-mcp-client",
version: "1.0.0"
});
const transport = new StdioClientTransport({
command: "node",
args: ["build/index.js"]
});
try {
await client.connect(transport);
// Listar recursos disponíveis
const resources = await client.listResources();
console.log("Recursos disponíveis:", resources);
// Ler o recurso de usuários
const content = await client.readResource({ uri: "api://users" });
console.log("\nLista de Usuários:", content);
} catch (error) {
console.error("Erro ao executar o cliente:", error);
}
}
main().catch(console.error);
直接 REST API
您还可以通过 REST API 直接访问资源:
# 列出所有用户
curl http://3.238.149.189:8080/users
安装和执行
# 安装依赖项
npm install
# 编译项目
npm run build
# 运行服务器
npm start
# 在开发模式下运行
npm run dev
要求
- Node.js (与 AbortController 兼容的版本)
- TypeScript
- @modelcontextprotocol/sdk
推荐服务器
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
MCP Package Docs Server
促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。
Claude Code MCP
一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。
@kazuph/mcp-taskmanager
用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。
mermaid-mcp-server
一个模型上下文协议 (MCP) 服务器,用于将 Mermaid 图表转换为 PNG 图像。
Jira-Context-MCP
MCP 服务器向 AI 编码助手(如 Cursor)提供 Jira 工单信息。

Linear MCP Server
一个模型上下文协议(Model Context Protocol)服务器,它与 Linear 的问题跟踪系统集成,允许大型语言模型(LLM)通过自然语言交互来创建、更新、搜索和评论 Linear 问题。

Sequential Thinking MCP Server
这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。
Curri MCP Server
通过管理文本笔记、提供笔记创建工具以及使用结构化提示生成摘要,从而实现与 Curri API 的交互。