TypeSafe MCP Server
by wangBoYi972
README.md
# TypeSafe MCP Server
[Model Context Protocol (MCP)](https://modelcontextprotocol.io) 服务器,为 Claude 提供 TypeSafe Jev 和 Codex 模型的结构化判断能力。
## 功能特性
### 1. 通用结构化判断 (`typesafe_classify`)
支持三种问题类型:
- **choice** - 单选/多选分类
- **score** - 数值评分(1-10)
- **noul** - 布尔判断(是/否概率)
### 2. 工单智能分类 (`typesafe_ticket_classify`)
自动分析工单并输出:
- 类型(bug/性能/需求/咨询)
- 优先级(P0-P3)
- 负责部门(后端/前端/运维/产品/客服)
- 用户情绪(平静/焦急/愤怒)
- 影响范围评分(1-10)
### 3. 内容审核 (`typesafe_content_moderate`)
检测违规内容:
- 暴力/色情/仇恨言论/垃圾信息
- 风险评分(1-10)
- 审核建议(通过/人工审核/拒绝)
## 安装
### 1. 安装依赖
```bash
pip install -r requirements.txt
```
### 2. 获取 TypeSafe API Key
访问 [TypeSafe](https://typesafe.ai) 注册并获取 API Key。
### 3. 配置 Claude Code
编辑 `~/.claude.json`(或项目的 `.claude/settings.json`),添加:
```json
{
"mcpServers": {
"typesafe": {
"command": "python",
"args": ["/path/to/typesafe-mcp/server.py"],
"env": {
"TYPESAFE_API_KEY": "your-api-key-here"
}
}
}
}
```
**注意**:
- 将 `/path/to/typesafe-mcp/server.py` 替换为实际路径
- Windows 用户可能需要使用 Python 的完整路径(如 `C:\\Python313\\python.exe`)
### 4. 重启 Claude Code
```bash
# 或在 Claude Code 中执行
/reload
```
## 使用示例
### 通用分类
```python
# 在 Claude 对话中:
"使用 typesafe_classify 工具,判断这段文本的情感:'这个产品太棒了!'"
# 问题定义:
{
"sentiment": {
"type": "choice",
"criteria": {
"positive": "积极正面",
"neutral": "中性客观",
"negative": "消极负面"
}
},
"confidence": {
"type": "score",
"criteria": ["判断置信度", "1=不确定", "10=非常确定"],
"score": {"min": 1, "max": 10}
}
}
```
### 工单分类
```python
# 在 Claude 对话中:
"使用 typesafe_ticket_classify 工具,分析这个工单:
标题:登录页面加载超过10秒
内容:用户反馈从昨晚开始,登录页面变得特别慢,有时甚至超时"
```
### 内容审核
```python
# 在 Claude 对话中:
"使用 typesafe_content_moderate 工具,审核这段内容:'...'"
```
## 环境变量
| 变量名 | 必需 | 默认值 | 说明 |
|--------|------|--------|------|
| `TYPESAFE_API_KEY` | ✓ | - | TypeSafe API 密钥 |
| `TYPESAFE_API_ENDPOINT` | ✗ | `https://api.typesafe.ai/v1/systemone` | API 端点 |
## 开发
### 项目结构
```
typesafe-mcp/
├── server.py # MCP 服务器主文件
├── requirements.txt # Python 依赖
└── README.md # 本文档
```
### 自定义工具
可以在 `server.py` 中添加新的工具函数:
```python
types.Tool(
name="your_tool_name",
description="工具描述",
inputSchema={
"type": "object",
"properties": {
"param": {"type": "string", "description": "参数说明"}
},
"required": ["param"]
}
)
```
## 故障排查
### MCP 服务器未加载
1. 检查 `~/.claude.json` 配置格式
2. 确认 Python 路径和脚本路径正确
3. 查看 Claude Code 日志:`~/.claude/logs/`
### API 调用失败
1. 验证 `TYPESAFE_API_KEY` 是否正确
2. 检查网络连接
3. 确认 API Key 额度是否充足
### 工具未显示
重启 Claude Code 或执行 `/reload`
## 许可证
MIT License
## 相关链接
- [Model Context Protocol](https://modelcontextprotocol.io)
- [TypeSafe API 文档](https://docs.typesafe.ai)
- [Claude Code](https://claude.ai/code)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues