This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PharoSmalltalkInteropServer is a Smalltalk-based web API server that provides interoperability between Smalltalk environments and external tools like AI agents or editors. It serves as an MCP (Model Context Protocol) server core for Smalltalk integration.
- SisServer (
src/Sis-Core/SisServer.class.st): Main server class using Teapot web framework- Singleton pattern via
SisServer current - RESTful API endpoints for Smalltalk operations
- Auto-restart on image startup via
startUp:class method - Default port: 8086 (configurable via
SisServer teapotConfig at: #port put: <port>)
- Singleton pattern via
- Sis-Core: Core server implementation
- Sis-Tests: Main test suite with comprehensive API testing
- Sis-Tests-Dummy: Dummy test fixtures for testing export/import functionality
The server provides extensive Smalltalk introspection and manipulation capabilities:
- Code evaluation (
/eval/) - Settings management (
/apply-settings,/get-settings) - Dynamic server configuration - Package/class/method listing and source retrieval
- Method source retrieval supports
is_class_methodparameter for class-side methods
- Method source retrieval supports
- Search functionality (classes, traits, methods, references, implementors)
- Package export/import (Tonel format)
- Test execution (package and class level)
- Project installation (
/install-project) using Metacello - UI debugging (
/read-screen) - Screenshot capture and UI structure extraction for World morphs, Spec presenters, and Roassal visualizations
SisServer current start "Start the server"
SisServer current stop "Stop the server"
SisServer restart "Restart the server (stop, reset, start)"SisServer teapotConfig at: #port put: 8080 "Change port"
"Settings management"
SisServer current settings at: #stackSize put: 200 "Change stack size"
SisServer current settings "View current settings"(Smalltalk packages detect: [:pkg | pkg name = 'Sis-Tests']) testSuite runMetacello new
baseline: 'PharoSmalltalkInteropServer';
repository: 'github://Mercap/PharoSmalltalkInteropServer:release-candidate/src';
load..class.st: Smalltalk class definitions in Tonel format.trait.st: Smalltalk trait definitions in Tonel formatpackage.st: Package metadata files
- Uses Teapot web framework for HTTP handling
- JSON request/response format via NeoJSON
- Error handling wraps all operations in
returnResultDo:pattern - Comprehensive error reporting via
returnError:by:with stack traces and receiver context - Method source retrieval (
/get-method-source) with class-side support:is_class_methodparameter: Set to 'true' to retrieve class-side methods- Backward compatible: Still supports 'ClassName class' syntax
- String-to-boolean conversion: Accepts 'true'/'false' strings from query parameters
- Settings management via instance variable with default values:
- Default settings defined in
SisServer class >> defaultSettings - Settings accessible via
/apply-settings(POST) and/get-settings(GET) endpoints - Key naming flexibility: Accepts both camelCase and snake_case keys (e.g.,
stackSizeorstack_size), with automatic normalization to camelCase - Common settings:
stackSize(controls error stack trace depth, default: 100)
- Default settings defined in
- SystemNavigation for code introspection
- TonelWriter/TonelReader for package export/import
- ZnEasy HTTP client for testing
- UI debugging via
/read-screenendpoint:- Captures PNG screenshots to temp directory
- Extracts morph hierarchies with geometry, colors, and structure
- Supports Spec presenter introspection with recursive hierarchy extraction (up to 3 levels)
- Supports Roassal canvas analysis with shape/edge details
- Target types: 'world' (morphs), 'spec' (Spec presenters), 'roassal' (Roassal visualizations)
When errors occur, the server returns detailed error information:
{
"success": false,
"error": {
"description": "Error type (e.g., 'ZeroDivide')",
"stack_trace": "Complete call stack leading to the error",
"receiver": {
"class": "Class name of the object that received the failing message",
"self": "String representation of the receiver object",
"variables": {"varName": "varValue"}
}
}
}The test suite (SisTest) validates all API endpoints by:
- Starting HTTP requests against running server
- Validating JSON response structure (
successflag,result/errorfields) - Using fixture classes/traits for consistent test data
SisFixtureClassForTestincludes both instance and class methods for testing
- Testing both positive and error cases
- Comprehensive error response validation including stack traces and receiver information
- Error case testing with
testEvalWithError(validates ZeroDivide error handling) - Method source retrieval testing:
testGetMethodSource- Instance method retrievaltestGetMethodSourceClassMethodOldWay- Class method via 'ClassName class' syntaxtestGetMethodSourceClassMethodWithFlag- Class method viais_class_method=truetestGetMethodSourceClassMethodWithFalseFlag- Explicitis_class_method=false
- Teapot (HTTP server framework)
- NeoJSON (JSON handling)
- Zinc HTTP Components (HTTP client for tests)
- SystemNavigation (code introspection)
- Tonel (package serialization format)
- Metacello (project installation and management)