IM

insiderphd/mcp-course-code

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

27 stars 15 forks 质量 62 趋势 0

该仓库包含多个MCP(模型上下文协议)服务器示例和一个客户端测试工具。每个项目都演示了构建和使用MCP服务器的不同方面。

概览

该仓库包含多个MCP(模型上下文协议)服务器示例和一个客户端测试工具。每个项目都演示了构建和使用MCP服务器的不同方面。 1. : 数学MCP服务器 - 提供基础数学运算和数学笑话 2.: 待办事项列表MCP服务器 - 为用户(Alice和Bob)管理待办事项列表 3.: 天气MCP服务器 - 返回与天气相关的笑话 4.: MCP客户端测试器 - 用于测试和与MCP服务器交互的工具 每个项目都有自己的依赖。导航到每个项目目录并安装依赖: 这使得mcp-client命令全局可用。 一个提供数学运算和数学笑话的服务器。

概述(AI 翻译)

该仓库包含多个MCP(模型上下文协议)服务器示例和一个客户端测试工具。每个项目都演示了构建和使用MCP服务器的不同方面。

项目概述

  1. Ex1 - MCP:数学MCP服务器 - 提供基础数学运算和数学笑话
  2. Ex3 - Priv Esc:待办事项列表 MCP 服务器 - 为用户(Alice 和 Bob)管理待办事项列表
  3. Ex4 - 选择服务器:天气MCP服务器 - 返回与天气相关的笑话
  4. mcp-lite:MCP 客户端测试器——用于测试和与 MCP 服务器交互的工具

先修条件

  • Node.js >= 18.0.0
  • npm >4 = 9.0.0

查看你的版本:

安装

每个项目都有自己的依赖。导航到每个项目目录并安装依赖:

Ex1 - MCP(数学服务器)

Ex3 - Priv Esc (Todo List 服务器)

Ex4 - 选择服务器(天气服务器)

mcp-lite(MCP客户端测试器)

可选 - 全局安装:

这使得 mcp-client 命令全局可用。

用途

Ex1 - MCP:数学服务器

一个提供数学运算和数学笑话的服务器。

运行服务器

或者直接:

可用工具

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Course Code

This repository contains multiple MCP (Model Context Protocol) server examples and a client testing tool. Each project demonstrates different aspects of building and working with MCP servers.

Projects Overview

  1. Ex1 - MCP: Math MCP Server - Provides basic mathematical operations and math jokes
  2. Ex3 - Priv Esc: Todo List MCP Server - Manages todo lists for users (Alice and Bob)
  3. Ex4 - Select server: Weather MCP Server - Returns weather-related jokes
  4. mcp-lite: MCP Client Tester - A tool for testing and interacting with MCP servers

Prerequisites

  • Node.js >= 18.0.0
  • npm >= 9.0.0

To check your versions:

node --version
npm --version

Installation

Each project has its own dependencies. Navigate to each project directory and install dependencies:

Ex1 - MCP (Math Server)

cd "Ex1 - MCP"
npm install

Ex3 - Priv Esc (Todo List Server)

cd "Ex3 - Priv Esc"
npm install

Ex4 - Select server (Weather Server)

cd "Ex4 - Select server"
npm install

mcp-lite (MCP Client Tester)

cd mcp-lite
npm install

Optional - Install globally:

cd mcp-lite
npm install -g

This makes the mcp-client command available globally.

Usage

Ex1 - MCP: Math Server

A server that provides mathematical operations and math jokes.

Running the Server

cd "Ex1 - MCP"
npm start

Or directly:

node src/index.js

Available Tools

  • add: Add two numbers ({ "a": 5, "b": 3 })
  • subtract: Subtract two numbers ({ "a": 10, "b": 4 })
  • multiply: Multiply two numbers ({ "a": 7, "b": 6 })
  • divide: Divide two numbers ({ "a": 20, "b": 4 })
  • power: Raise a number to a power ({ "base": 2, "exponent": 8 })
  • get_math_joke: Get a random math joke ({})

Claude Desktop Configuration

Add to your Claude Desktop config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "math-server": {
      "command": "/Users/katiepaxtonfear/Documents/MCP Course Code/Ex1 - MCP/run-server.sh"
    }
  }
}

Note: Update the path to match your actual project location. Make sure run-server.sh is executable:

chmod +x "Ex1 - MCP/run-server.sh"

Ex3 - Priv Esc: Todo List Server

A server that manages todo lists for users (Alice and Bob).

Running the Server

cd "Ex3 - Priv Esc"
npm start

Or directly:

node src/index.js

Available Tools

  • get_todos: Get all todos for a user

    { "email": "[email protected]" }
    
  • create_todo: Create a new todo for a user

    {
      "email": "[email protected]",
      "title": "Review pull request #123",
      "priority": "high",
      "status": "pending"
    }
    
  • mark_todo_complete: Mark a todo as completed

    {
      "email": "[email protected]",
      "todo_id": 1
    }
    
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "math-server": { "command": "/Users/katiepaxtonfear/Documents/MCP Course Code/Ex1 - MCP/run-server.sh" } } }