MCP is an in-image server for the Model Context Protocol in Pharo Smalltalk.
Load it into a Pharo image, start its HTTP server, and an MCP client can inspect and change the live image through Pharo-aware tools. The server exposes packages, classes, methods, tests, repositories, change history, screenshots, and a bounded evaluate escape hatch.
The main design point is integration with the existing Pharo ecosystem. Edits use Pharo compilation, Refactoring Browser and Refactoring Engine operations, Renraku critiques, SUnit, CoverageCollector, Iceberg, Metacello, Epicea change history, Spec dashboards, and PharoCompatibility where those systems own the behavior. MCP is not a text patcher over Tonel files; it works with the running image and returns structured MCP results.
MCP supports Pharo 12, Pharo 13, and Pharo 14. Mainline development targets the Pharo 13 API surface and uses PharoCompatibility to keep the supported range loadable and tested.
Download and open a supported Pharo image, then load MCP:
Metacello new
baseline: 'MCP';
repository: 'github://Evref-BL/MCP:main/src';
load.To use MCP as a dependency, reference the baseline from your project:
spec
baseline: 'MCP'
with: [ spec repository: 'github://Evref-BL/MCP:main/src' ].Start the HTTP server from a Playground or Workspace:
mcp := MCP new.
mcp port: 4000.
mcp start.The server runs while the image runs. Stop it with:
mcp stop.Connect an MCP client to:
http://127.0.0.1:4000
A generic remote MCP client entry looks like this:
{
"mcp": {
"pharo": {
"type": "remote",
"url": "http://127.0.0.1:4000",
"enabled": true
}
}
}For Codex, copy user/codex/.codex into your agent workspace as .codex, and copy user/AGENTS.md as AGENTS.md. If you use a different port, update .codex/config.toml.
Start with read-only discovery:
tools/list
find-packages
find-classes
find-methods
inspect-class
inspect-method
find-repositories
Then use dedicated operations before falling back to evaluate:
edit-class
edit-method
rewrite-methods
run-tests
edit-repository
manage-change-history
capture-screenshot
evaluate can run arbitrary Smalltalk. Use it only for short inspection or glue code when no dedicated tool fits.
The server keeps raw MCP arguments at the transport boundary. Each tool owns its JSON schema, parses requests into typed request objects, dispatches command or query objects, and returns structured content with status, summary, warnings, and either data or error.
Image-changing tools save the image after a successful mutation. Read-only tools do not.
The safer edit paths use Pharo facilities:
edit-classandedit-methoduse Refactoring Browser and Refactoring Engine operations for renames, slot changes, argument changes, moves, and removals where Pharo provides them.force=falsestops onRBRefactoringWarningand returnsimpactMessages,howToProceed, andforceSupported=true. Rerun withforce=trueonly after reviewing the impact.edit-methodreturns selected Renraku critiques after method compilation, including error-severity critiques and selected non-error rules.rewrite-methodspreviews AST rewrite changes first and returns achangeSetHash; applying the rewrite requiresexpectedChangeSetHash.run-testsuses SUnit and can collect CoverageCollector method and node coverage for an explicit method scope.edit-repositoryworks through Iceberg. UseverifyIdentityto assert repository identity before edits or exports, anddiffto inspect image-side repository changes before exporting, committing, pulling, or pushing.manage-change-historypreviews Epicea apply/revert operations and performs them only withconfirm=true.
This does not remove the normal responsibility of working in a safe image. Use disposable or copied images for automation and risky edits.
Inspect an MCP instance in a graphical image and open the dashboard tab. The Spec dashboard shows server status, port and debug-mode controls, registered tools, optional observability, metrics, traces, and recent logs. The tool catalog uses the same tool metadata exposed to MCP clients.
- Getting started covers loading, starting, and connecting an MCP client.
- Safety and ecosystem integration explains the refactoring, critique, test, repository, change-history, and dashboard boundaries.
- Tool reference lists the MCP tool groups and their intended use.
- Troubleshooting maps common startup, connection, and image-state problems to checks.
- Source vs live image checks explains what can be verified from exported source and what needs a live image.
CI loads the project with smalltalkCI and runs MCP-Tests and MCP-Spec-Tests on Pharo 12, 13, and 14.
Static checks from source are useful for documentation and package layout, but tool execution must be verified in a live image. See Source vs live image checks.