计算器

使用 mcp-framework 构建的模型上下文协议 (MCP) 服务器。
快速入门
# Install dependencies
npm install
# Build the project
npm run build
Related MCP server: MCP Tool
项目结构
calculator/
├── src/
│ ├── tools/ # MCP Tools
│ │ └── ExampleTool.ts
│ └── index.ts # Server entry point
├── package.json
└── tsconfig.json
添加组件
该项目附带一个示例工具,位于src/tools/ExampleTool.ts 。您可以使用 CLI 添加更多工具:
# Add a new tool
mcp add tool my-tool
# Example tools you might create:
mcp add tool data-processor
mcp add tool api-client
mcp add tool file-handler
工具开发
示例工具结构:
import { MCPTool } from "mcp-framework";
import { z } from "zod";
interface MyToolInput {
message: string;
}
class MyTool extends MCPTool<MyToolInput> {
name = "my_tool";
description = "Describes what your tool does";
schema = {
message: {
type: z.string(),
description: "Description of this input parameter",
},
};
async execute(input: MyToolInput) {
// Your tool logic here
return `Processed: ${input.message}`;
}
}
export default MyTool;
发布到 npm
更新你的 package.json:
本地构建和测试:
npm run build
npm link
calculator # Test your CLI locally
登录 npm(如有必要,请创建帐户):
发布你的包:
发布后,用户可以将其添加到他们的 claude 桌面客户端(见下文)或使用 npx 运行它
## Using with Claude Desktop
### Installing via Smithery
To install Calculator for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@QuantGeekDev/mcp-add-sse):
```bash
npx -y @smithery/cli install @QuantGeekDev/mcp-add-sse --client claude
本地开发
将此配置添加到您的 Claude Desktop 配置文件:
MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json Windows : %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "node",
"args":["/absolute/path/to/calculator/dist/index.js"]
}
}
}
发布后
将此配置添加到您的 Claude Desktop 配置文件:
MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json Windows : %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["calculator"]
}
}
}
构建和测试
更改你的工具
运行npm run build进行编译
服务器将在启动时自动加载您的工具
了解更多