短信验证器mcp服务器
一个简单的MCP服务器,用于验证和删除Tonel格式的Smalltalk源代码,使用 树保姆tonel闲聊.
- 目的是我们想验证和整理AI生成的音调文件
Smalltalk方法定义,然后将其加载到真实的Smalltalk环境中。
工具
验证工具
validate_tonel_smalltalk_from_file(文件路径,选项)
- 从文件中验证Tonel格式的Smalltalk源代码
validate_tonel_smalltalk(文件内容,选项)
- 从内容字符串中验证Tonel格式的Smalltalk源代码
validate_smalltalk_method_body(method_bod_content)
- 验证Smalltalk方法体的语法正确性
验证选项
without-method-body: true
if true, it only validates tonel structure only (mainly for testing)过梁工具
lint_tonel_smalltalk_from_file(文件路径)
- Lint-Tonel格式化的Smalltalk源代码
lint_tonel_smalltalk(文件内容)
- Lint-Tonel格式的Smalltalk源代码来自内容字符串
看 docs/lint-checks.md 查看完整的支票清单。
安装
快速安装(uvx)
直接运行而不进行克隆:
uvx --from git+https://github.com/mumez/smalltalk-validator-mcp-server.git@main smalltalk-validator-mcp-server开发设置(git clone)
git clone https://github.com/mumez/smalltalk-validator-mcp-server.git
cd smalltalk-validator-mcp-server
uv sync用法
运行MCP服务器
- 使用uvx(建议用于快速运行):
uvx --from git+https://github.com/mumez/smalltalk-validator-mcp-server.git@main smalltalk-validator-mcp-server- 从克隆的仓库中:
uv run smalltalk-validator-mcp-server配置示例
光标配置
添加到您的 .cursor/settings.json:
{
"mcpServers": {
"smalltalk-validator": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/mumez/smalltalk-validator-mcp-server.git@main",
"smalltalk-validator-mcp-server"
]
}
}
}如果您更喜欢使用本地克隆,请使用以下命令:
{
"mcpServers": {
"smalltalk-validator": {
"command": "uv",
"args": [
"--directory",
"/path/to/smalltalk-validator-mcp-server",
"run",
"smalltalk-validator-mcp-server"
]
}
}
}Claude代码配置
添加到您的克劳德代码设置中:
claude mcp add smalltalk-validator -- uvx --from git+https://github.com/mumez/smalltalk-validator-mcp-server.git@main smalltalk-validator-mcp-server改用本地克隆:
claude mcp add smalltalk-validator -- uv --directory /path/to/smalltalk-validator-mcp-server run smalltalk-validator-mcp-server工具使用示例
从文件系统验证Tonel文件
# Validate a complete Tonel file with method bodies
validate_tonel_smalltalk_from_file("/path/to/MyClass.st")
# Validate only Tonel structure (without method body validation)
validate_tonel_smalltalk_from_file("/path/to/MyClass.st", {"without-method-body": true})直接验证Tonel内容
tonel_content = """
Class {
#name : #MyClass,
#superclass : #Object,
#category : #'My-Package'
}
{ #category : #accessing }
MyClass >> getValue [
^ 42
]
"""
validate_tonel_smalltalk(tonel_content)验证Smalltalk方法体
method_body = "^ self name asUppercase"
validate_smalltalk_method_body(method_body)从文件系统中提取Tonel文件
# Lint a Tonel file for best practices and style issues
result = lint_tonel_smalltalk_from_file("/path/to/MyClass.st")
# Example result:
# {
# "success": true,
# "file_path": "/path/to/MyClass.st",
# "issue_list": [
# {
# "severity": "warning",
# "message": "Method 'longMethod' long: 18 lines (recommended: 15)",
# "class_name": "MyClass",
# "selector": "longMethod",
# "is_class_method": false
# }
# ],
# "issues_count": 1,
# "warnings_count": 0,
# "errors_count": 0
# }棉绒爽肤水含量直接
tonel_content = """
Class {
#name : #MyClass,
#superclass : #Object,
#instVars : [
'name',
'age'
],
#category : #'My-Package'
}
{ #category : #accessing }
MyClass >> getName [
^ name
]
"""
result = lint_tonel_smalltalk(tonel_content)发展
# Install dependencies
uv sync
# Run tests
uv run pytest
# Lint and format
uv run ruff check
uv run ruff format
# Install pre-commit hooks
uv run pre-commit install