Skip to main content
Glama

实用工具 MCP 服务器

一个功能齐全的模型上下文协议 (MCP) 服务器,提供实用工具、资源和提示词。使用 TypeScript 和现代 MCP SDK 构建。

📁 项目结构

项目结构旨在实现可扩展性和可读性:

.
├── index.ts              # Entry point: Initializes server and registers modules
├── src/
│   ├── tools.ts          # Tool handlers (Arithmetic, Randomness, Sampling)
│   ├── prompts.ts        # Prompt templates (Math Tutoring)
│   └── resources.ts      # Resource definitions (System Status)
├── tests/
│   └── utility.test.ts   # Comprehensive unit tests
├── package.json          # Dependencies and scripts
├── tsconfig.json         # TypeScript configuration
└── jest.config.js        # Testing configuration

🚀 功能

1. 工具

  • random_number:在指定范围内生成一个随机整数。

  • calculator:执行基本算术运算(add 加、subtract 减、multiply 乘、divide 除)。

  • suggest_arithmetic_task:演示 LLM 采样,通过请求客户端/LLM 生成一个创造性的数学问题。

2. 资源

  • system_status (utility://system/status):提供服务器健康状况和功能数量的实时状态更新。

3. 提示词

  • math_tutor:一个引导 LLM 扮演数学老师角色的模板,可选择专注于特定主题。


📡 调用 API (Postman / JSON-RPC)

模型上下文协议使用 JSON-RPC 2.0。虽然此服务器目前通过 stdio(标准输入/输出)运行,但如果您通过 HTTP/SSE 网桥公开它或使用调试器,则可以使用这些消息格式与它进行交互。

🛠 工具

列出工具

请求:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list"
}

调用 calculator

请求:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "calculator",
    "arguments": {
      "operation": "multiply",
      "a": 5,
      "b": 10
    }
  }
}

📖 资源

列出资源

请求:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "resources/list"
}

读取 system_status

请求:

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "resources/read",
  "params": {
    "uri": "utility://system/status"
  }
}

📝 提示词

列出提示词

请求:

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "prompts/list"
}

获取 math_tutor 提示词

请求:

{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "prompts/get",
  "params": {
    "name": "math_tutor",
    "arguments": {
      "topic": "algebra"
    }
  }
}

🛠 开发

设置

npm install

运行服务器

npm start

运行测试

npm test

🤖 使用自定义客户端

我们包含了一个内置的客户端示例,以便您了解如何以编程方式进行连接:

npm run client

此脚本将:

  1. 将服务器作为子进程启动。

  2. 通过 Stdio 连接。

  3. 自动演示列出工具、调用计算器和读取资源。

🔍 使用 MCP Inspector 进行测试

要以可视化方式与服务器交互:

npx @modelcontextprotocol/inspector npx tsx index.ts
IMPORTANT

此服务器使用Stdio 传输。它通过 stdinstdout 进行通信。若要使 Postman 通过 HTTP 工作,需要在服务器配置中添加 SSE(服务器发送事件)传输层。

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lakshyakumar/typescript-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server