LLM工具服务器

一个基于TypeScript的模型上下文协议(MCP)服务器,为Claude等LLM提供计算器、日期时间和笔记工具,具有可扩展架构。

  • by Albo3
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 albo3/mcp-server

使用说明

MCP TypeScript工具服务器

TypeScript中的模型上下文协议(MCP)服务器实现,为Claude等LLM提供了各种实用工具。此服务器包括计算器、日期时间和笔记工具,具有可扩展的架构,可添加更多工具。

特性

  • 🧮 用于基本数学运算的计算器工具
  • 📅 用于不同格式的当前日期/时间的DateTime工具
  • 📝 用于保存和检索文本注释的注释工具
  • 🔌 与Claude兼容,适用于桌面和光标
  • 🚀 易于使用新工具进行扩展

先决条件

  • Node.js(v16或更高版本)
  • npm(附带Node.js)
  • Claude用于桌面和/或光标(用于使用工具)

安装

  1. 克隆存储库:
git clone <your-repo-url>
cd MCP
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build

使用Claude进行桌面设置

  1. 打开或创建您的Claude桌面配置文件:

    • 窗户: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. 添加MCP服务器配置:

{
  "mcpServers": {
    "MCPllmContext": {
      "command": "node",
      "args": [
        "ABSOLUTE_PATH_TO_YOUR_PROJECT/dist/index.js"
      ]
    }
  }
}

替换 ABSOLUTE_PATH_TO_YOUR_PROJECT 带有项目目录的实际路径。

  1. 重新启动桌面版的Claude
  2. 在输入框中查找锤子图标,以确认工具可用

使用光标进行设置

  1. 打开的游标
  2. 首选 Cursor Settings > Features > MCP
  3. 点击 + Add New MCP Server
  4. 填写表格:
    • 类型:stdio
    • 名称:MCPllmContext
    • 命令: node ABSOLUTE_PATH_TO_YOUR_PROJECT/dist/index.js

可用工具

计算器

  • 工具名称: calculate
  • 描述:计算数学表达式
  • 用法:“计算2+2”

日期时间

  • 工具名称: current-date
  • 描述:返回当前日期/时间
  • 格式:“短”或“长”
  • 用法:“今天几号?”

备注

  • 工具名称: save-note, get-note, list-notes
  • 说明:保存和检索文本注释
  • 用法:“保存标题为“会议”、内容为“讨论项目”的笔记”

添加新工具

  1. 在中创建新文件 src/tools/ (例如。, src/tools/myTool.ts)
  2. 使用模板实现您的工具:
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

export function registerMyTools(server: McpServer) {
  server.tool(
    "tool-name",
    { 
      param: z.string().describe("Parameter description") 
    },
    async ({ param }) => {
      return {
        content: [{ type: "text", text: "Result" }]
      };
    }
  );
}
  1. 将工具导出到 src/tools/index.ts
  2. 在中注册您的工具 src/index.ts

发展

# Build the project
npm run build

# Run the server directly
node dist/index.js

# Watch for changes (if you have nodemon installed)
nodemon dist/index.js

故障排除

Claude桌面问题

  • 查看日志 %APPDATA%\Claude\logs\mcp*.log (Windows)或 ~/Library/Logs/Claude/mcp*.log (macOS)
  • 验证中的路径 claude_desktop_config.json 绝对正确
  • 确保服务器已构建(npm run build)
  • 配置更改后重新启动Claude for Desktop

光标问题

  • 验证Cursor的MCP设置中的命令路径
  • 尝试刷新MCP设置中的工具列表
  • 检查Cursor的日志是否有任何错误消息