@evref-bl/pharo-mcp 2.3.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,322 +0,0 @@
1
- # Safety And Ecosystem Integration
2
-
3
- MCP is safest when callers use the dedicated tools before falling back to raw
4
- evaluation. The tools are built around Pharo's normal development systems, so an
5
- agent works through image-aware operations instead of editing exported source
6
- text blindly.
7
-
8
- ## Tool Boundary
9
-
10
- Each tool owns its MCP metadata:
11
-
12
- - name and title
13
- - description
14
- - icon
15
- - input JSON schema
16
- - output JSON schema
17
-
18
- The execution path is:
19
-
20
- 1. The HTTP endpoint receives a JSON-RPC `tools/call`.
21
- 2. `MCPToolRequest` validates raw arguments against the tool input schema.
22
- 3. The concrete tool parses the request into a typed request or spec object.
23
- 4. The tool dispatches a command or query object.
24
- 5. The command uses Pharo APIs to query or mutate the image.
25
- 6. The tool returns a payload with `summary`, `warnings`, and either `data` or
26
- `error`, with a failure flagged by the protocol's own `isError`. By default
27
- this payload reaches the MCP `content` field; the server can also emit
28
- `structuredContent` for clients that need programmatic results.
29
-
30
- ### Notifications
31
-
32
- A notification is not a failed call. Pharo signals them for remarks rather than
33
- faults, and every `Warning` is one. The tool boundary resumes them with the
34
- value the image itself would have produced and the call proceeds, so a
35
- deprecated send, or an undeclared variable during a package load, does not fail
36
- it. A deprecated method called from a test does not abort the suite.
37
-
38
- Refactoring warnings are the exception. `RBRefactoringWarning` reports a change
39
- that breaks something, so it reaches the boundary unresumed and stops the call,
40
- aborting a removal or a rename that `force=true` did not authorize.
41
-
42
- ```mermaid
43
- sequenceDiagram
44
- participant Client
45
- participant HTTP as HTTP Endpoint
46
- participant Req as MCPToolRequest
47
- participant Tool as Concrete Tool
48
- participant Cmd as Command/Query
49
- participant Pharo as Pharo Image
50
-
51
- Client->>HTTP: JSON-RPC tools/call
52
- HTTP->>Req: validate raw arguments
53
- Req->>Req: check against tool input schema
54
- alt invalid arguments
55
- Req-->>HTTP: validation error
56
- HTTP-->>Client: error response
57
- else valid arguments
58
- Req->>Tool: validated arguments
59
- Tool->>Tool: parse into typed request/spec
60
- Tool->>Cmd: dispatch command or query
61
- Cmd->>Pharo: query or mutate image via Pharo APIs
62
- Pharo-->>Cmd: result / side effect
63
- Cmd-->>Tool: outcome
64
- Tool-->>HTTP: structured content (status, summary, warnings, data/error)
65
- HTTP-->>Client: JSON-RPC response
66
- end
67
- ```
68
-
69
- This keeps transport parsing, schema validation, image operations, and result
70
- formatting in separate places.
71
-
72
- ## Refactorings
73
-
74
- Class and method edits use Refactoring Browser and Refactoring Engine operations
75
- where Pharo owns the behavior.
76
-
77
- Examples include:
78
-
79
- - class rename with `ReRenameClassRefactoring`
80
- - class removal with `ReRemoveClassRefactoring`
81
- - method rename with `ReRenameMethodRefactoring`
82
- - argument add/remove with `RBAddParameterRefactoring` and
83
- `RBRemoveParameterRefactoring`
84
- - slot add, remove, rename, pull-up, and push-down with the corresponding
85
- instance-variable refactorings
86
- - method batch removal with `ReRemoveMethodsRefactoring`
87
-
88
- When a refactoring raises `RBRefactoringWarning`, the default behavior is to
89
- stop. The tool result includes:
90
-
91
- ```text
92
- impactMessages
93
- howToProceed
94
- forceSupported: true
95
- ```
96
-
97
- Review the impact and rerun the same request with `force=true` only when the
98
- warning is acceptable. When forced, the warning messages are returned in the
99
- normal `warnings` array.
100
-
101
- ## Critiques
102
-
103
- `method_compile` compiles method source in the image and returns selected Renraku
104
- critiques in the structured result. It includes error-severity critiques and a
105
- small set of non-error rules that are useful after automated edits, such as
106
- excessive arguments, missing super sends, return in ensure, temporary variable
107
- overrides, and unary accessing methods without returns.
108
-
109
- Critiques include:
110
-
111
- - Renraku rule class
112
- - title
113
- - description
114
- - source interval when available
115
-
116
- The method may compile successfully and still return critiques. Treat critiques
117
- as follow-up review evidence, not as transport failures.
118
-
119
- ## Rewriting Methods
120
-
121
- `method_rewrite` uses Smalltalk AST rewrite patterns, not regex. A rule has a
122
- `match` and a `replacement`, and a scope is required, so rewriting everything is
123
- something a caller asks for by naming the packages rather than by leaving an
124
- argument out.
125
-
126
- A metavariable starts with a backquote and stands for whatever is in its place.
127
- `` `@receiver `` matches one expression, however big: the same rule rewrites
128
- `anObject notNil` and `(anObject foo) notNil`. **The names must be the same on
129
- both sides** — a name that appears only in `replacement` is bound to nothing.
130
-
131
- The default mode is preview, which carries the old and new source of every
132
- change:
133
-
134
- ```json
135
- {
136
- "rules": [
137
- {
138
- "match": "`@receiver notNil",
139
- "replacement": "`@receiver isNotNil"
140
- }
141
- ],
142
- "scope": { "packages": ["MyPackage"] }
143
- }
144
- ```
145
-
146
- A metavariable stands for a block just as readily, which is how a rule drops
147
- one branch of a conditional:
148
-
149
- ```json
150
- {
151
- "rules": [
152
- {
153
- "match": "`@receiver ifTrue: [ `@body ] ifFalse: [ nil ]",
154
- "replacement": "`@receiver ifTrue: [ `@body ]"
155
- }
156
- ],
157
- "scope": { "packages": ["MyPackage"] }
158
- }
159
- ```
160
-
161
- Add `apply` to make the changes. One call is enough; preview first only when
162
- you want to read them before they land. `history_entry_revert` undoes a rewrite
163
- that turned out wrong.
164
-
165
- Any rewrite rule stands for its own patterns, so its name can be given instead
166
- of writing them out. That includes Pharo's own, not only MCP's:
167
-
168
- ```json
169
- {
170
- "ruleClasses": ["MCPCollectionThenDoRule"],
171
- "scope": { "packages": ["MyPackage"] },
172
- "apply": true
173
- }
174
- ```
175
-
176
- Rules that report a critique are not applied by the tools that compile. A
177
- compile reports what it would change; changing it is this tool's job, and the
178
- caller asks.
179
-
180
- ## Tests And Coverage
181
-
182
- `test_run` runs SUnit classes or individual methods and returns structured test
183
- results. Use `test_coverage_run` when the same test run should collect
184
- CoverageCollector method and node coverage for an explicit method scope.
185
- `test_run` deduplicates concrete test cases across a batch. Use
186
- `selectedTestCount` for selected unique tests, `runCount` for non-skipped
187
- executed tests, and `skippedCount` for skipped tests.
188
-
189
- Coverage output includes method counts, node counts, uncovered methods,
190
- partially covered methods, and optional covered method details. Use it after
191
- edits to ask whether the relevant methods were exercised.
192
-
193
- ## Repository Work
194
-
195
- MCP uses Iceberg for repository state. The repository tools can:
196
-
197
- - list registered repositories and their branch, head, package, modified, and
198
- remote metadata
199
- - load Metacello baselines
200
- - create image-side repository registrations or update their metadata,
201
- including registrations for linked Git worktree checkouts
202
- - inspect `workingCopyDiff`
203
- - verify expected repository identity before edits or exports
204
- - export image changes to Tonel files
205
- - commit, fetch, pull, push, create branches, and switch branches
206
-
207
- Use `repository_identity_verify` before edits or exports, and
208
- `repository_change_list` before exporting or committing. Use
209
- `repository_create`, `repository_attach`, and `repository_update` for repository
210
- registration workflows. Export writes image changes to disk and updates the
211
- Iceberg index; it does not stage or commit Git changes.
212
-
213
- ## Change History
214
-
215
- MCP uses Epicea change history. `history_file_list` lists `.ombu`
216
- files, and `history_entry_list` lists entries from the current history
217
- or a selected file. `history_entry_apply` and `history_entry_revert` preview
218
- selected entries, and perform the selected apply or revert only when
219
- `confirm=true`.
220
-
221
- Use this when recovering image-side changes or preparing a clean handoff from a
222
- live image back to Tonel/Git.
223
-
224
- ## Debugging
225
-
226
- Debugger tools are discoverable through the `debugging` group. They keep no
227
- state: `debug_watch` installs non-halting probes and removes them before it
228
- answers, and `debug_search` only reads the debuggers a person has open.
229
-
230
- A debugger somebody opened belongs to them. Read it, then act with the ordinary
231
- class and method tools; do not step, resume or terminate it.
232
-
233
- ## Evaluation Escape Hatch
234
-
235
- `image_evaluate` runs arbitrary Smalltalk in the running image without saving
236
- it. It is useful for short inspection or glue code when no dedicated tool
237
- exists.
238
-
239
- Prefer a dedicated tool when one exists, because the dedicated tools validate
240
- input, return structured result data, and often use safer Pharo APIs.
241
-
242
- Compiling source is one of those cases. Method source in the image separates
243
- lines with CR, and `method_compile` normalizes what it is given; a bare
244
- `compile:` from `image_evaluate` stores whatever it receives, so source written
245
- with LF compares unequal to every other method in the image. Use
246
- `method_compile` for a method, and `withInternalLineEndings` if you must compile
247
- source by hand.
248
-
249
- ## Observability And UI
250
-
251
- The servers an image holds are listed under `Library → MCP Servers` in the
252
- world menu, and on the `Servers` tab of an inspected `MCP` class. From there a
253
- server can be started, stopped, or opened in its dashboard, and a new one
254
- created on a port, where 0 asks for a free one. The tool catalog sits beside it
255
- under `Library → MCP Tool Catalog`, since it describes the image rather than
256
- any one server. The same list in a script:
257
-
258
- ```smalltalk
259
- MCP allServers
260
- ```
261
-
262
- It is taken from the heap rather than from a registry, so a server is never
263
- kept alive for being listable, and one that is still holding a port after its
264
- owner forgot it is shown rather than hidden.
265
-
266
- To reach the server on a port, whether or not this script is the one that
267
- started it, ask for the port rather than for a new server:
268
-
269
- ```smalltalk
270
- MCP startOnPort: 4000
271
- ```
272
-
273
- That answers the server already on 4000, starting it if it was stopped, and
274
- makes one only when the image has none there. Starting a second server on a
275
- taken port fails after a couple of seconds, and the error now says when the
276
- port is held by another MCP in the same image.
277
-
278
- An inspected `MCP` object has two Spec tabs. The dashboard runs the server:
279
-
280
- - server status, endpoint and port
281
- - debug mode
282
- - every tool the server could run, with `Enabled` for whether it has the tool
283
- at all and `Listed` for whether `tools/list` shows it; an unlisted tool is
284
- still found by `tool_search` and still runs
285
-
286
- The observability tab shows what the server recorded about itself:
287
-
288
- - per-tool timing metrics
289
- - traces for errors, outliers, and output overruns
290
- - recent logs
291
- - auto-refresh while the tab is displayed
292
-
293
- MCP starts with the built-in JSON observability backend enabled. Disable it for
294
- a specific server when its local metrics, traces, and logs are not wanted:
295
-
296
- ```smalltalk
297
- mcp observabilityEnabled: false
298
- ```
299
-
300
- By default, JSON observability exports under the image-local
301
- `pharo-local/mcp/observability` directory. Configure
302
- `mcp observabilityExportDirectory: aDirectory` to override that export root for
303
- instance metadata, `logs.jsonl`, `metrics.json`, and `traces.jsonl`.
304
-
305
- OpenTelemetry support is optional. Load the `Telemetry` group, then enable
306
- the OpenTelemetry backend for an MCP instance:
307
-
308
- ```smalltalk
309
- Metacello new
310
- baseline: 'MCP';
311
- repository: 'github://Evref-BL/MCP:main/src';
312
- load: 'Telemetry'.
313
-
314
- mcp useOpenTelemetryObservability
315
- ```
316
-
317
- ## Version Compatibility
318
-
319
- The core baseline loads PharoBackwardCompatibility, JRPC, and PCRE2.
320
- OpenTelemetry is loaded only by the optional `Telemetry` group. CI covers
321
- Pharo 12, 13, 14, and 15. Code should target the Pharo 14 API;
322
- PharoBackwardCompatibility backports supported APIs to older images.
@@ -1,75 +0,0 @@
1
- # Source Files Vs Live Pharo Image State
2
-
3
- Applies when an agent uses the Pharo MCP server to inspect, modify, or verify a
4
- Pharo project.
5
-
6
- ## Goal
7
-
8
- Keep source inspection, loaded image state, Iceberg state, and Git state
9
- separate. Each one can answer different questions, and none should be treated
10
- as a substitute for the others.
11
-
12
- ## Source-Only Checks
13
-
14
- Source-only checks can confirm:
15
-
16
- - files exist where expected;
17
- - packages, classes, and methods are exported in Tonel;
18
- - baseline files and package declarations look coherent;
19
- - static documentation and scripts are present;
20
- - Git diffs contain the expected source changes;
21
- - formatting and whitespace checks pass.
22
-
23
- Source-only checks cannot prove:
24
-
25
- - the project loads in the image;
26
- - classes and methods are currently loaded;
27
- - tools see the expected image state;
28
- - tests pass inside the image;
29
- - image-side edits were exported to source;
30
- - the running server or application behaves correctly.
31
-
32
- ## Live Image Checks
33
-
34
- Use live image checks when the answer depends on image state:
35
-
36
- - loading a baseline or package;
37
- - listing loaded repositories, packages, classes, or methods;
38
- - inspecting compiled methods or class definitions;
39
- - running SUnit tests;
40
- - starting or exercising a server/application in the image;
41
- - applying image-side edits;
42
- - exporting image-side changes to Tonel or Git.
43
-
44
- Prefer dedicated `pharo` MCP tools for these checks. Use `image_evaluate` only
45
- when no dedicated tool fits.
46
-
47
- ## Iceberg And Git
48
-
49
- Remember:
50
-
51
- - Tonel files are exported source.
52
- - The loaded image can differ from Tonel files.
53
- - Iceberg working-copy state can differ from both image state and Git state.
54
- - Git commits record disk files, not unsaved image changes.
55
-
56
- When these states disagree, report the mismatch and resolve it deliberately.
57
- Do not claim a change is complete just because one layer looks correct.
58
-
59
- ## Blocked Live Verification
60
-
61
- If the current context does not have a safe or approved live image:
62
-
63
- - run only source-safe checks;
64
- - say which live checks are still needed;
65
- - do not use image-side evaluation or mutation as a workaround;
66
- - do not claim live behavior is verified.
67
-
68
- ## Reporting
69
-
70
- When finishing work, report:
71
-
72
- - source checks run;
73
- - live image checks run;
74
- - live checks not run and why;
75
- - any image/source/Iceberg/Git state mismatch observed.
@@ -1,145 +0,0 @@
1
- # Troubleshooting
2
-
3
- Most failures fall into one of three groups: the image is not reachable, the
4
- requested tool input is invalid, or the live image state differs from what the
5
- caller expected.
6
-
7
- For standalone image crashes or stopped servers, the installed
8
- `pharo-mcp-recovery` skill gives agents a recovery workflow for preserving
9
- evidence, restarting or replacing the image, reloading projects, and recovering
10
- change history.
11
-
12
- ## The Client Cannot Connect
13
-
14
- Ask the image what servers it holds, which answers after a restart even when
15
- nothing in the workspace refers to one:
16
-
17
- ```smalltalk
18
- MCP allServers.
19
- ```
20
-
21
- `Library → MCP Servers` in the world menu shows the same list, with the state,
22
- port and endpoint of each, and starts or stops the one selected.
23
-
24
- Check a server directly:
25
-
26
- ```smalltalk
27
- mcp isRunning.
28
- mcp isListening.
29
- mcp localUrlString.
30
- ```
31
-
32
- Confirm that the client URL uses the same host and port:
33
-
34
- ```text
35
- http://127.0.0.1:4000
36
- ```
37
-
38
- If you changed the port in Pharo, update the MCP client configuration.
39
-
40
- MCP currently handles MCP calls over HTTP POST. Unsupported HTTP methods
41
- return method-not-allowed instead of hanging.
42
-
43
- ## `tools/list` Is Empty Or Stale
44
-
45
- Run:
46
-
47
- ```smalltalk
48
- mcp refreshToolsList.
49
- ```
50
-
51
- Then call `tools/list` again. If you loaded new MCP code into the image, restart
52
- the server:
53
-
54
- ```smalltalk
55
- mcp restart.
56
- ```
57
-
58
- ## A Tool Rejects Input
59
-
60
- Each tool validates arguments against its input schema. Call `tools/list` and
61
- inspect the tool's `inputSchema`.
62
-
63
- Common causes:
64
-
65
- - missing required fields for the selected tool
66
- - extra fields rejected by `additionalProperties: false`
67
- - passing arguments from a different tool
68
- - `history_entry_apply` or `history_entry_revert` without `confirm=true`
69
-
70
- ## A Refactoring Stops With A Warning
71
-
72
- This is expected for Pharo refactoring warnings. With `force=false`, the edit
73
- tool stops and returns impact details.
74
-
75
- Read:
76
-
77
- ```text
78
- impactMessages
79
- howToProceed
80
- forceSupported
81
- ```
82
-
83
- Rerun with `force=true` only when the impact is acceptable.
84
-
85
- ## A Method Compiles But Returns Critiques
86
-
87
- `method_compile` can return Renraku critiques after compilation. The method exists,
88
- but Pharo found review issues. Inspect the critique rule class, title,
89
- description, and source interval if present.
90
-
91
- Use a follow-up `method_compile`, `method_update`, `test_run`, or
92
- `method_get` call depending on the critique.
93
-
94
- ## Repository State Looks Wrong
95
-
96
- MCP reads repository state from Iceberg in the running image. The exported
97
- Tonel files, the image's loaded packages, and Iceberg's working-copy state can
98
- differ.
99
-
100
- Start with:
101
-
102
- ```text
103
- repository_search
104
- repository_identity_verify
105
- repository_change_list
106
- ```
107
-
108
- Use `repository_export` only when you mean to write image changes to files.
109
- Export updates the Iceberg index but does not stage or commit Git changes.
110
-
111
- ## Tests Do Not Prove The Edited Scope
112
-
113
- `test_run` tells you whether selected tests passed. Use `test_coverage_run` with
114
- an explicit coverage scope when you need to know whether the edited methods
115
- executed.
116
-
117
- Coverage scopes should be narrow: package, class, hierarchy, or method names.
118
-
119
- ## The Image Changed Unexpectedly
120
-
121
- Image-changing tools change the running image without saving it. If you are
122
- using an automation or agent, run it against a copied or disposable image.
123
-
124
- Use `history_file_list` and `history_entry_list` to inspect
125
- Epicea history. Apply or revert operations stay in `history_entry_apply` and
126
- `history_entry_revert`, where they can be previewed first and performed with
127
- `confirm=true`.
128
-
129
- ## A Debugger Picture Goes Out Of Date
130
-
131
- `debug_search` answers what is open at the moment it is called. A person can
132
- step, resume or close their debugger at any time, so ask again rather than
133
- acting on an older answer.
134
-
135
- Do not drive debugger windows with raw `image_evaluate` code, and do not step,
136
- resume or terminate a debugger a person opened.
137
-
138
- ## Source Checks Are Not Enough
139
-
140
- Exported source files can confirm package layout, class definitions, and docs.
141
- They cannot prove that the running image has loaded the latest code or that an
142
- MCP tool works over HTTP.
143
-
144
- Use [Source vs live image](source-vs-live-image.md) to decide which checks are
145
- valid for the current work boundary.