ph-law-mcp 翻译为中文可以是“法律(或法规)- MCP(可能指某种特定系统、协议或框架,具体需根据上下文确定)”。不过,由于“MCP”是一个较为通用的缩写,没有固定的翻译,所以需要结合具体语境来确定其准确含义。如果“MCP”在某个特定领域或语境中有固定含义,那么翻译时应采用该领域的通用术语
使用mcp-framework构建的模型上下文协议(MCP)服务器。
快速入门
# Install dependencies
npm install
# Build the project
npm run build
项目结构
ph-law-mcp/
├── 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 {
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:
- 确保 name 是独一无二的,并遵循npm的命名规范 - 设置适当的 version - 添加 description, author, license等。 - 检查 bin 指向正确的入口文件
- 本地构建和测试:
npm run build
npm link
ph-law-mcp # Test your CLI locally- 登录到npm(如需创建账户则进行创建):
npm login- 发布您的包:
npm publish发布后,用户可以将其添加到他们的Claude桌面客户端(见下文)或使用npx运行它
## Using with Claude Desktop
### Local Development
Add this configuration to your Claude Desktop config file:
**MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
{ "mcpServers": { "ph-law-mcp": { "command": "node", "args":["/absolute/path/to/ph-law-mcp/dist/index.js"] } } }
### 发布后
将此配置添加到您的Claude桌面配置文件中:
**MacOS(中文常称为“苹果电脑操作系统”或简称“苹果系统”)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
{ "mcpServers": { "ph-law-mcp": { "command": "npx", "args": ["ph-law-mcp"] } } }
## 构建与测试
1. 修改你的工具
1. 跑 `npm run build` 编译
1. 服务器将在启动时自动加载您的工具
## 了解更多
-
- [MCP框架文档](https://mcp-framework.com)