A local MCP server to communicate local Pharo Smalltalk image. It supports: - Code Evaluation: Execute Smalltalk expressions and return results - Code Introspection: Retrieve source code, comments, and metadata for classes and methods - Search & Discovery: Find classes, traits, methods, references, and implementors - Package Management: Export and import packages in Tonel format - Project Installa
Add this skill
npx mdskills install mumez/pharo-smalltalk-interop-mcp-serverComprehensive MCP server bridging AI agents with Pharo Smalltalk through 22 well-documented tools
1# pharo-smalltalk-interop-mcp-server23[](https://github.com/mumez/pharo-smalltalk-interop-mcp-server/actions/workflows/ci.yml)45A local MCP server to communicate local Pharo Smalltalk image.6It supports:78- Code Evaluation: Execute Smalltalk expressions and return results9- Code Introspection: Retrieve source code, comments, and metadata for classes and methods10- Search & Discovery: Find classes, traits, methods, references, and implementors11- Package Management: Export and import packages in Tonel format12- Project Installation: Install projects using Metacello13- Test Execution: Run test suites at package or class level14- UI Debugging: Capture screenshots and inspect UI structure for World morphs, Spec presenters, and Roassal visualizations15- Server Configuration: Retrieve and modify server settings dynamically1617## Prerequisites1819- Python 3.10 or later20- [uv](https://docs.astral.sh/uv/) package manager21- Pharo with [PharoSmalltalkInteropServer](https://github.com/mumez/PharoSmalltalkInteropServer) installed2223## Installation2425### Quick Start (using uvx)2627The easiest way to run the server without cloning the repository:2829```bash30uvx --from git+https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git pharo-smalltalk-interop-mcp-server31```3233### Development Installation3435To set up for development:36371. Clone the repository:3839```bash40git clone https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git41```42432. Install dependencies using uv:4445```bash46cd pharo-smalltalk-interop-mcp-server47uv sync --dev48```4950## Usage5152### Running the MCP Server5354**Using uvx (no installation required):**5556```bash57uvx --from git+https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git pharo-smalltalk-interop-mcp-server58```5960**Using uv (after cloning the repository):**6162```bash63uv run pharo-smalltalk-interop-mcp-server64```6566#### Environment Variables6768You can configure the server using environment variables:6970- **`PHARO_SIS_PORT`**: Port number for PharoSmalltalkInteropServer (default: 8086)7172Examples:7374**Using uvx:**7576```bash77PHARO_SIS_PORT=8086 uvx --from git+https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git pharo-smalltalk-interop-mcp-server78```7980**Using uv:**8182```bash83PHARO_SIS_PORT=9999 uv run pharo-smalltalk-interop-mcp-server84```8586### Cursor MCP settings8788**Using uvx (recommended):**8990```json:mcp.json91{92 "mcpServers": {93 "smalltalk-interop": {94 "command": "uvx",95 "args": [96 "--from",97 "git+https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git",98 "pharo-smalltalk-interop-mcp-server"99 ],100 "env": {101 "PHARO_SIS_PORT": "8086"102 }103 }104 }105}106```107108**Using uv (after cloning):**109110```json:mcp.json111{112 "mcpServers": {113 "smalltalk-interop": {114 "command": "uv",115 "args": [116 "--directory",117 "/your-path/to/pharo-smalltalk-interop-mcp-server",118 "run",119 "pharo-smalltalk-interop-mcp-server"120 ],121 "env": {122 "PHARO_SIS_PORT": "8086"123 }124 }125 }126}127```128129Note: The `env` section is optional and can be used to set environment variables for the MCP server.130131### Claude Code Configuration132133**Using uvx (recommended):**134135```bash136claude mcp add -s user smalltalk-interop -- uvx --from git+https://github.com/mumez/pharo-smalltalk-interop-mcp-server.git pharo-smalltalk-interop-mcp-server137```138139**Using uv (after cloning):**140141```bash142claude mcp add -s user smalltalk-interop -- uv --directory /path/to/pharo-smalltalk-interop-mcp-server run pharo-smalltalk-interop-mcp-server143```144145### MCP Tools Available146147This server provides 22 MCP tools that map to all [PharoSmalltalkInteropServer](https://github.com/mumez/PharoSmalltalkInteropServer/blob/main/spec/openapi.json) APIs:148149#### Code Evaluation150151- **`eval`**: Execute Smalltalk expressions and return results152153#### Code Introspection154155- **`get_class_source`**: Retrieve source code of a class156- **`get_method_source`**: Retrieve source code of a specific method157- **`get_class_comment`**: Retrieve comment/documentation of a class158159#### Search & Discovery160161- **`search_classes_like`**: Find classes matching a pattern162- **`search_methods_like`**: Find methods matching a pattern163- **`search_traits_like`**: Find traits matching a pattern164- **`search_implementors`**: Find all implementors of a method selector165- **`search_references`**: Find all references to a method selector166- **`search_references_to_class`**: Find all references to a class167168#### Package Management169170- **`list_packages`**: List all packages in the image171- **`list_classes`**: List classes in a specific package172- **`list_extended_classes`**: List extended classes in a package173- **`list_methods`**: List methods in a package174- **`export_package`**: Export a package in Tonel format175- **`import_package`**: Import a package from specified path176177#### Project Installation178179- **`install_project`**: Install a project using Metacello with optional load groups180181#### Test Execution182183- **`run_package_test`**: Run test suites for a package184- **`run_class_test`**: Run test suites for a specific class185186#### UI Debugging187188- **`read_screen`**: UI screen reader for debugging Pharo interfaces with screenshot and structure extraction189190#### Server Configuration191192- **`get_settings`**: Retrieve current server configuration193- **`apply_settings`**: Modify server configuration dynamically194195### read_screen Tool196197The `read_screen` tool captures screenshots and extracts UI structure for debugging Pharo UI issues.198199**Parameters:**200201- `target_type` (string, default: 'world'): UI type to inspect ('world' for morphs, 'spec' for windows, 'roassal' for visualizations)202- `capture_screenshot` (boolean, default: true): Include PNG screenshot in response203204**Returns:** UI structure with screenshot and human-readable summary205206**Usage Examples:**207208```python209# Inspect all morphs in World210read_screen(target_type='world')211212# Inspect Spec presenter windows213read_screen(target_type='spec', capture_screenshot=false)214215# Inspect Roassal visualizations without screenshot (faster)216read_screen(target_type='roassal', capture_screenshot=false)217```218219**Extracted Data Includes:**220221*World (morphs):*222223- Class name and type identification224- Bounds (x, y, width, height coordinates)225- Visibility state226- Background color227- Owner class228- Submorph count229- Text content (if available)230231Example output:232233```json234{235 "totalMorphs": 12,236 "displayedMorphCount": 1,237 "morphs": [238 {239 "class": "MenubarMorph",240 "visible": true,241 "bounds": {"x": 0, "y": 0, "width": 976, "height": 18},242 "backgroundColor": "(Color r: 0.883... alpha: 0.8)",243 "owner": "WorldMorph",244 "submorphCount": 8245 }246 ]247}248```249250*Spec (presenters):*251252- Window title and class name253- Geometry (extent, position)254- Window state (maximized, minimized, resizable)255- Decorations (menu, toolbar, statusbar presence)256- Presenter hierarchy (recursive with max depth of 3 levels)257- Presenter class name, child count, and content properties (label, text, value, etc.)258- Enablement and visibility state259260Example output:261262```json263{264 "windowCount": 1,265 "presenters": [266 {267 "class": "SpWindowPresenter",268 "title": "Welcome",269 "extent": "(700@550)",270 "hasMenu": false,271 "presenter": {272 "class": "StWelcomeBrowser",273 "childCount": 2,274 "isVisible": true,275 "children": []276 }277 }278 ]279}280```281282*Roassal (visualizations):*283284- Canvas bounds and visibility state285- Canvas class identification286- Background color and zoom level287- Shape details (color, position, extent, label, text)288- Edge details (source, target, color, label)289- Node and edge counts290291Example output:292293```json294{295 "canvasCount": 1,296 "canvases": [297 {298 "class": "RSAthensMorph",299 "canvasClass": "RSCanvas",300 "bounds": {"x": 203, "y": 145, "width": 490, "height": 467},301 "backgroundColor": "Color blue",302 "zoomLevel": "1.0",303 "shapeCount": 5,304 "shapes": [305 {306 "class": "RSCircle",307 "color": "(Color r: 1.0 g: 0.0 b: 0.0 alpha: 0.2)",308 "position": "(0.0@0.0)",309 "extent": "(5.0@5.0)"310 }311 ],312 "edgeCount": 0,313 "edges": [],314 "nodeCount": 0315 }316 ]317}318```319320### Server Configuration Tools321322The `get_settings` and `apply_settings` tools provide dynamic server configuration management.323324#### get_settings325326Retrieve the current server configuration.327328**Parameters:** None329330**Returns:** Dictionary containing current server settings331332**Usage Example:**333334```python335# Get current settings336get_settings()337# Returns: {"stackSize": 100, "customKey": "customValue"}338```339340**Response Format:**341342```json343{344 "success": true,345 "result": {346 "stackSize": 100,347 "customKey": "customValue"348 }349}350```351352#### apply_settings353354Modify server configuration dynamically. Settings take effect immediately during the current session.355356**Parameters:**357358- `settings` (dict): Dictionary containing settings to modify359360**Returns:** Success confirmation message361362**Usage Example:**363364```python365# Apply new settings366apply_settings(settings={"stackSize": 200, "customKey": "customValue"})367# Returns: "Settings applied successfully"368```369370**Common Settings:**371372| Setting | Type | Default | Description |373| ----------- | ------- | ------- | --------------------------------------------- |374| `stackSize` | integer | 100 | Maximum stack trace depth for error reporting |375376**Note:** The server accepts arbitrary key-value pairs beyond documented settings, allowing custom configuration options.377378## Development379380### Running Tests381382The project includes comprehensive unit tests with mock-based testing to avoid requiring a live Pharo instance:383384```bash385# Run all tests386uv run pytest387388# Run tests with verbose output389uv run pytest -v390391# Run specific test file392uv run pytest tests/test_core.py -v393```394395### Code Quality396397```bash398# Run linting399uv run ruff check400401# Run formatting402uv run ruff format403404# Run all pre-commit hooks405uv run pre-commit run --all-files406```407408### Project Structure409410```411pharo-smalltalk-interop-mcp-server/412├── pharo_smalltalk_interop_mcp_server/413│ ├── __init__.py414│ ├── core.py # HTTP client and core functions415│ └── server.py # FastMCP server with tool definitions416├── tests/417│ ├── __init__.py418│ ├── test_core.py # Tests for core HTTP client functionality419│ └── test_server.py # Tests for MCP server integration420├── pyproject.toml # Project configuration421├── pytest.ini # Test configuration422└── README.md423```424425### Testing Strategy426427The test suite uses mock-based testing to ensure:428429- **No external dependencies**: Tests run without requiring a live Pharo instance430- **Comprehensive coverage**: All 22 endpoints and error scenarios are tested431- **Fast execution**: Tests complete in under 1 second432- **Reliable results**: Tests are deterministic and don't depend on external state433434Test coverage includes:435436- HTTP client functionality (`PharoClient` class)437- All 22 Pharo interop operations438- Error handling (connection errors, HTTP errors, JSON parsing errors)439- MCP server initialization and tool registration440- Integration between core functions and MCP tools441
Full transparency — inspect the skill content before installing.