Skip to content

chore: split mcp/tools.py into focused submodules — 1448 → 240 lines (AC-482)#589

Merged
jayscambler merged 1 commit intomainfrom
chore/split-mcp-tools
Mar 31, 2026
Merged

chore: split mcp/tools.py into focused submodules — 1448 → 240 lines (AC-482)#589
jayscambler merged 1 commit intomainfrom
chore/split-mcp-tools

Conversation

@jayscambler
Copy link
Copy Markdown
Contributor

Summary

Split mcp/tools.py (1,448 lines, 62 functions) into 5 focused submodules plus a shared base, reducing it to 240 lines (83% reduction).

New structure

mcp/
├── _base.py              (67 lines)  — MtsToolContext + shared helpers
├── tools.py              (240 lines) — scenario tools + skill tools + re-exports
├── agent_task_tools.py   (454 lines) — create/evaluate/queue agent tasks
├── knowledge_tools.py    (334 lines) — playbook/trajectory/skill reads + exports
├── artifact_tools.py     (229 lines) — publish/fetch/validate artifacts
├── distill_tools.py      (167 lines) — distillation workflow management
├── monitor_tools.py      (85 lines)  — monitor conditions/alerts
├── server.py             (642 lines) — unchanged
└── sandbox.py            (206 lines) — unchanged

Backward compatibility

tools.py re-exports all extracted functions via # noqa: F401 imports, so all existing consumers (server/openclaw_api.py, cli.py, knowledge/, openclaw/) continue to work without changes.

Also fixed

  • Updated sdk.py to import from specific submodules instead of via tools module attribute access
  • Updated tests/test_sdk.py patches to match new import paths

Verification

  • ruff check src — all checks passed
  • mypy src — zero errors
  • pytest tests/ — all tests pass

Issue

Continues AC-482 (stages.py done in #586, mcp/tools.py done here, cli.py deferred)

…(AC-482)

Extracted 46 tool functions from mcp/tools.py into 5 focused modules:

- mcp/_base.py (67 lines) — MtsToolContext + shared helpers
- mcp/agent_task_tools.py (454 lines) — agent task CRUD + evaluation
- mcp/knowledge_tools.py (334 lines) — playbook/trajectory/skill reads
- mcp/artifact_tools.py (229 lines) — publish/fetch/validate artifacts
- mcp/distill_tools.py (167 lines) — distillation workflow
- mcp/monitor_tools.py (85 lines) — monitor conditions/alerts

tools.py retains scenario exploration + skill tools (240 lines)
with re-exports for full backward compatibility.

Also updated sdk.py to import from specific submodules and
fixed test patches accordingly.

9 files changed
@linear
Copy link
Copy Markdown

linear bot commented Mar 31, 2026

@jayscambler jayscambler merged commit 316aa24 into main Mar 31, 2026
4 checks passed
@jayscambler jayscambler deleted the chore/split-mcp-tools branch March 31, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant