Skip to content

Commit 55e4817

Browse files
committed
Reimplement mcp server using mcp instead of fastmcp. Provide action payload schema as tool schema and description from docstrings.
1 parent b032201 commit 55e4817

31 files changed

+512
-67
lines changed

docs/wm-er-protocol.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ The protocol is LSP-shaped with a small set of custom commands.
9696
- Note: `result_by_format` is a JSON string (not a JSON object) due to
9797
LSP serialization constraints in the runner.
9898

99+
- `actions/getPayloadSchemas`
100+
- Arguments: none
101+
- Result: `{ action_name: JSON Schema fragment | null }`
102+
- Returns a payload schema for every action currently known to the runner.
103+
Each schema has `properties` (field name → JSON Schema type object) and
104+
`required` (list of field names without defaults).
105+
`null` means the action class could not be imported.
106+
99107
- `actions/mergeResults`
100108
- Arguments: `[action_name, results]`
101109
- Result: `{ "merged": ... }` or `{ "error": "..." }`

docs/wm-protocol.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,38 @@ All fields optional. If `project` is omitted, returns actions from all projects.
310310

311311
---
312312

313+
#### `actions/getPayloadSchemas`
314+
315+
Return payload schemas for the specified actions in a project. Used by the MCP
316+
server to build accurate `inputSchema` entries for each tool.
317+
318+
- **Type:** request
319+
- **Clients:** MCP
320+
- **Status:** implemented
321+
322+
**Params:**
323+
324+
```json
325+
{ "project": "/abs/path/to/project", "action_names": ["lint", "format"] }
326+
```
327+
328+
**Result:**
329+
330+
```json
331+
{
332+
"schemas": {
333+
"lint": { "properties": { "file_paths": {"type": "array", "items": {"type": "string"}}, "target": {"type": "string", "enum": ["project", "files"]} }, "required": [] },
334+
"format": { "properties": { "save": {"type": "boolean"}, "target": {"type": "string"}, "file_paths": {"type": "array", "items": {"type": "string"}} }, "required": [] }
335+
}
336+
}
337+
```
338+
339+
Each schema value is `null` for actions whose class cannot be imported in any
340+
Extension Runner. Schemas are cached per project in the WM and invalidated
341+
whenever runner config is updated.
342+
343+
---
344+
313345
#### `actions/getTree`
314346

315347
Get the hierarchical action tree for IDE sidebar display.

finecode_extension_api/src/finecode_extension_api/actions/clean_finecode_logs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CleanFinecodeLogsAction(
4040
CleanFinecodeLogsRunResult,
4141
]
4242
):
43+
"""Remove FineCode log files."""
44+
4345
PAYLOAD_TYPE = CleanFinecodeLogsRunPayload
4446
RUN_CONTEXT_TYPE = CleanFinecodeLogsRunContext
4547
RESULT_TYPE = CleanFinecodeLogsRunResult

finecode_extension_api/src/finecode_extension_api/actions/create_env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class CreateEnvAction(
1919
CreateEnvRunPayload, CreateEnvRunContext, CreateEnvsRunResult
2020
]
2121
):
22+
"""Create a single environment(without installing dependencies, only environment)."""
23+
2224
PAYLOAD_TYPE = CreateEnvRunPayload
2325
RUN_CONTEXT_TYPE = CreateEnvRunContext
2426
RESULT_TYPE = CreateEnvsRunResult

finecode_extension_api/src/finecode_extension_api/actions/create_envs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ class EnvInfo:
1919

2020
@dataclasses.dataclass
2121
class CreateEnvsRunPayload(code_action.RunActionPayload):
22-
# Explicit env list. When empty, handlers should discover envs.
2322
envs: list[EnvInfo] = dataclasses.field(default_factory=list)
24-
# Remove old env and create a new one from scratch even if the current one
25-
# is valid.
23+
"""Explicit list of environments to create. Empty means handlers discover envs."""
2624
recreate: bool = False
25+
"""Remove and recreate existing environments from scratch even if they are already valid."""
2726

2827

2928
class CreateEnvsRunContext(code_action.RunActionContext[CreateEnvsRunPayload]):
@@ -74,6 +73,8 @@ class CreateEnvsAction(
7473
CreateEnvsRunPayload, CreateEnvsRunContext, CreateEnvsRunResult
7574
]
7675
):
76+
"""Create environments for the workspace(without installing dependencies, only environment)."""
77+
7778
PAYLOAD_TYPE = CreateEnvsRunPayload
7879
RUN_CONTEXT_TYPE = CreateEnvsRunContext
7980
RESULT_TYPE = CreateEnvsRunResult

finecode_extension_api/src/finecode_extension_api/actions/dump_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def to_text(self) -> str | textstyler.StyledText:
6363
class DumpConfigAction(
6464
code_action.Action[DumpConfigRunPayload, DumpConfigRunContext, DumpConfigRunResult]
6565
):
66+
"""Resolve and dump the merged project configuration."""
67+
6668
PAYLOAD_TYPE = DumpConfigRunPayload
6769
RUN_CONTEXT_TYPE = DumpConfigRunContext
6870
RESULT_TYPE = DumpConfigRunResult

finecode_extension_api/src/finecode_extension_api/actions/format.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class FormatTarget(enum.StrEnum):
1515
@dataclasses.dataclass
1616
class FormatRunPayload(code_action.RunActionPayload):
1717
save: bool = True
18+
"""Whether to write formatted content back to disk."""
1819
target: FormatTarget = FormatTarget.PROJECT
19-
# optional, expected only with `target == FormatTarget.FILES`
20+
"""Scope of formatting: 'project' (default) formats the whole project, 'files' formats only file_paths."""
2021
file_paths: list[Path] = dataclasses.field(default_factory=list)
22+
"""Files to format. Only used when target is 'files'."""
2123

2224

2325
class FormatRunContext(code_action.RunActionContext[FormatRunPayload]): ...
@@ -30,6 +32,8 @@ class FormatRunResult(format_files_action.FormatFilesRunResult): ...
3032
class FormatAction(
3133
code_action.Action[FormatRunPayload, FormatRunContext, FormatRunResult]
3234
):
35+
"""Format source code in a project or specific files."""
36+
3337
PAYLOAD_TYPE = FormatRunPayload
3438
RUN_CONTEXT_TYPE = FormatRunContext
3539
RESULT_TYPE = FormatRunResult

finecode_extension_api/src/finecode_extension_api/actions/format_files.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class FormatFilesAction(
108108
FormatFilesRunPayload, FormatFilesRunContext, FormatFilesRunResult
109109
]
110110
):
111+
"""Format specific files. Internal action dispatched by format."""
112+
111113
PAYLOAD_TYPE = FormatFilesRunPayload
112114
RUN_CONTEXT_TYPE = FormatFilesRunContext
113115
RESULT_TYPE = FormatFilesRunResult

finecode_extension_api/src/finecode_extension_api/actions/get_dist_artifact_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class GetDistArtifactVersionAction(
4040
GetDistArtifactVersionRunResult,
4141
]
4242
):
43+
"""Read the version from a distribution artifact."""
44+
4345
PAYLOAD_TYPE = GetDistArtifactVersionRunPayload
4446
RUN_CONTEXT_TYPE = GetDistArtifactVersionRunContext
4547
RESULT_TYPE = GetDistArtifactVersionRunResult

finecode_extension_api/src/finecode_extension_api/actions/get_src_artifact_registries.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class GetSrcArtifactRegistriesAction(
5252
GetSrcArtifactRegistriesRunResult,
5353
]
5454
):
55+
"""List the registries configured for an artifact."""
56+
5557
PAYLOAD_TYPE = GetSrcArtifactRegistriesRunPayload
5658
RUN_CONTEXT_TYPE = GetSrcArtifactRegistriesRunContext
5759
RESULT_TYPE = GetSrcArtifactRegistriesRunResult

0 commit comments

Comments
 (0)