MCP Test Server
A testing server that demonstrates Model Context Protocol features, providing access to user data, todos, and system information through resources, tools for user management and calculations, and prompt templates for various analyses.
README
MCP 测试项目
这是一个基于 Model Context Protocol (MCP) TypeScript SDK 的测试项目,用于演示和测试 MCP 的不同机制,包括 Resources、Tools 和 Prompts。
项目特性
📄 Resources (资源)
- 用户列表 (
test://users) - 获取所有用户数据 - 待办事项 (
test://todos) - 获取所有待办事项数据 - 配置信息 (
test://config) - 系统配置信息 - 系统日志 (
test://logs) - 查看系统操作日志
🔧 Tools (工具)
- add_user - 添加新用户
- search_users - 搜索用户(支持按姓名、邮箱和角色筛选)
- create_todo - 创建待办事项
- calculate - 执行数学计算(支持表达式和基本运算)
💬 Prompts (提示模板)
- user_analysis - 用户数据分析提示
- todo_summary - 待办事项摘要提示
- system_report - 系统状态报告提示
- code_review - 代码审查提示模板
快速开始
1. 安装依赖
npm install
2. 构建项目
npm run build
3. 启动 MCP 服务器
npm start
4. 运行测试客户端
在另一个终端中运行:
npm test
项目结构
mcp-test-project/
├── src/
│ ├── index.ts # MCP 服务器主文件
│ └── test-client.ts # 测试客户端
├── dist/ # 编译后的文件
├── package.json
├── tsconfig.json
└── README.md
使用示例
Resources 示例
// 列出所有资源
const resources = await client.listResources();
// 读取用户资源
const usersResource = await client.readResource({
uri: "test://users"
});
Tools 示例
// 添加用户
const result = await client.callTool({
name: "add_user",
arguments: {
name: "张三",
email: "zhangsan@example.com",
role: "admin"
}
});
// 计算
const calcResult = await client.callTool({
name: "calculate",
arguments: {
expression: "10 + 5 * 2"
}
});
Prompts 示例
// 获取用户分析提示
const userAnalysis = await client.getPrompt({
name: "user_analysis",
arguments: {
user_id: "1",
analysis_type: "detailed"
}
});
// 获取代码审查提示
const codeReview = await client.getPrompt({
name: "code_review",
arguments: {
language: "typescript",
code_snippet: "function hello() { return 'world'; }",
focus_areas: "代码质量、性能"
}
});
测试数据
项目包含以下测试数据:
用户数据
[
{ "id": 1, "name": "张三", "email": "zhangsan@example.com", "role": "admin" },
{ "id": 2, "name": "李四", "email": "lisi@example.com", "role": "user" },
{ "id": 3, "name": "王五", "email": "wangwu@example.com", "role": "user" }
]
待办事项数据
[
{ "id": 1, "title": "完成MCP测试项目", "completed": false, "userId": 1 },
{ "id": 2, "title": "学习TypeScript", "completed": true, "userId": 2 },
{ "id": 3, "title": "测试MCP功能", "completed": false, "userId": 1 }
]
开发脚本
npm run build- 编译 TypeScript 代码npm start- 启动 MCP 服务器npm run dev- 构建并启动服务器npm test- 运行测试客户端npm run clean- 清理构建文件
MCP 协议说明
Model Context Protocol (MCP) 是一个标准化协议,用于在大型语言模型和外部数据源/工具之间建立安全、可控的连接。
核心概念
- Resources - 静态数据或文档,模型可以读取但不能修改
- Tools - 模型可以调用的函数,用于执行操作或获取动态数据
- Prompts - 可重用的提示模板,支持参数化
技术栈
- TypeScript - 主要编程语言
- MCP TypeScript SDK - MCP 协议实现
- Node.js - 运行时环境
许可证
MIT License
参考链接
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.