返回市场
法罗MCP服务器

法罗MCP服务器

作者:mumez2 星标更新:2025-06-21

项目介绍

pharo-nc-mcp-server

Tests

一个本地的MCP服务器,用于评估Pharo Smalltalk表达式并通过NeoConsole获取系统信息。

预备条件

  • Python 3.10或更高版本
  • uv 包管理器
  • 已安装NeoConsole的Pharo

Pharo 设置

  1. 安装Pharo和NeoConsole
  2. 将环境变量PHARO_DIR设置为你的Pharo安装目录(默认:~/pharo
  3. 确保NeoConsole.image在Pharo目录中可用

安装

  1. 克隆仓库:
git clone <repository-url>
cd pharo-nc-mcp-server
  1. 使用uv安装依赖:
uv sync --dev

使用方法

运行MCP服务器

启动服务器:

uv run pharo-nc-mcp-server

Cursor 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表达式:

# 在MCP客户端中的示例用法
evaluate_smalltalk_with_neo_console(expression="42 factorial", command="eval")

evaluate_simple_smalltalk

使用Pharo的简单-e选项执行Smalltalk表达式:

# 简单评估
evaluate_simple_smalltalk(expression="Time now")

get_pharo_metric

从Pharo获取系统指标:

# 获取系统状态
get_pharo_metric(metric="system.status")

# 获取内存信息
get_pharo_metric(metric="memory.free")

get_class_comment

获取Pharo类的注释:

# 获取Array类的注释
get_class_comment(class_name="Array")

get_class_definition

获取Pharo类的定义:

# 获取Array类的定义
get_class_definition(class_name="Array")

get_method_list

获取Pharo类的方法选择器列表:

# 获取Array类的所有方法选择器
get_method_list(class_name="Array")

get_method_source

获取Pharo类中特定方法的源代码:

# 获取Array>>asSet方法的源代码
get_method_source(class_name="Array", selector="asSet")

环境变量

  • PHARO_DIR:Pharo安装目录的路径(默认:~/pharo

开发

代码格式化和检查

# 格式化代码
uv run black pharo_nc_mcp_server/

# 检查代码
uv run ruff check pharo_nc_mcp_server/

# 运行测试
uv run python -m pytest

# 或使用测试脚本
./scripts/test.sh

开发脚本

项目包括几个方便的脚本在scripts/目录下:

scripts/format.sh

通过一个命令格式化所有代码和文档文件:

  • 使用Black格式化Python代码
  • 使用mdformat格式化markdown文件
  • 使用Ruff运行检查
./scripts/format.sh

scripts/test.sh

使用pytest运行测试套件:

./scripts/test.sh