pharo nc mcp服务器

本地MCP服务器,用于评估Pharo Smalltalk表达式并通过以下方式获取系统信息 NeoConsole.
先决条件
- Python 3.10或更高版本
- 紫外线 包管理器
- 安装了NeoConsole的Pharo
Pharo设置
- 安装Pharo和NeoConsole
- 设置
PHARO_DIR将环境变量添加到Pharo安装目录(默认值:~/pharo) - 确保
NeoConsole.image可在Pharo目录中找到
安装
- 克隆存储库:
git clone
cd pharo-nc-mcp-server- 使用uv安装依赖项:
uv sync --dev用法
运行MCP服务器
启动服务器:
uv run pharo-nc-mcp-server光标MCP设置
{
"mcpServers": {
"pharo-nc-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/your-path/to/pharo-nc-mcp-server",
"run",
"pharo-nc-mcp-server"
]
}
}
}MCP工具可用
evaluate_smalltalk_with_neo_console
使用NeoConsole在Pharo中执行Smalltalk表达式:
# Example usage in MCP client
evaluate_smalltalk_with_neo_console(expression="42 factorial", command="eval")evaluate_simple_smalltalk
使用Pharo的simple-e选项执行Smalltalk表达式:
# Simple evaluation
evaluate_simple_smalltalk(expression="Time now")get_pharo_metric
从Pharo检索系统指标:
# Get system status
get_pharo_metric(metric="system.status")
# Get memory information
get_pharo_metric(metric="memory.free")get_class_comment
获取Pharo类的注释:
# Get Array class comment
get_class_comment(class_name="Array")get_class_definition
获取Pharo类的定义:
# Get Array class definition
get_class_definition(class_name="Array")get_method_list
获取Pharo类的方法选择器列表:
# Get all method selectors for Array class
get_method_list(class_name="Array")get_method_source
获取Pharo类中特定方法的源代码:
# Get source code for Array>>asSet method
get_method_source(class_name="Array", selector="asSet")环境变量
PHARO_DIR:Pharo安装目录的路径(默认:~/pharo)
发展
代码格式化和Linting
# Format code
uv run black pharo_nc_mcp_server/
# Lint code
uv run ruff check pharo_nc_mcp_server/
# Run tests
uv run python -m pytest
# Or use the test script
./scripts/test.sh开发脚本
该项目在 scripts/ 目录:
scripts/format.sh
在一个命令中格式化所有代码和文档文件:
- 使用黑色格式化Python代码
- 使用mdformat格式化markdown文件
- 与Ruff一起运行linting检查
./scripts/format.shscripts/test.sh
使用pytest运行测试套件:
./scripts/test.sh