feat(mcp): expose STRATEGY.md / STATE.json via 5 new MCP tools#74
Merged
feat(mcp): expose STRATEGY.md / STATE.json via 5 new MCP tools#74
Conversation
Add `mureo_strategy_get`, `mureo_strategy_set`, `mureo_state_get`,
`mureo_state_action_log_append`, and `mureo_state_upsert_campaign`
so MCP hosts that lack a Read tool (Claude Desktop chat, claude.ai
web, remote MCP) can inspect and update mureo's context layer
without filesystem access.
Why: the existing google_ads_* / meta_ads_* tools already work over
MCP, but STRATEGY.md / STATE.json access still requires Claude Code
or a paste-into-chat workaround. With Meta's MCP shipping and
Google's likely to follow, mureo needs its own MCP surface for the
orchestration layer (strategy, state, action_log, rollback) — that's
where mureo's value lives once vendor MCPs handle raw API access.
Security:
- `_resolve_path` refuses paths outside cwd, mirroring the rollback
surface's `_resolve_state_file` (Path.resolve() follows symlinks,
so an in-cwd symlink to /etc/passwd resolves to its target and is
rejected).
- All writes go through pre-existing atomic helpers in
context.state and context.strategy (temp file + os.replace).
- mureo_strategy_set round-trips the input through parse_strategy()
to refuse malformed markdown rather than corrupting the file.
Tool names match the MCP spec regex `^[a-zA-Z0-9_-]{1,64}$` and are
covered by the existing test_mcp_tool_name_spec regression guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add 5 MCP tools that expose mureo's context layer (STRATEGY.md and STATE.json) so MCP hosts without filesystem access can read and update strategic context:
mureo_strategy_getmureo_strategy_setparse_strategy)mureo_state_getmureo_state_action_log_appendmureo_state_upsert_campaignWhy now
Readtool — without these MCP tools, users have to paste STRATEGY.md / STATE.json into chat manually.Security
_resolve_pathrefuses any path that resolves outside cwd, mirroringmureo/mcp/_handlers_rollback.py:_resolve_state_file.Path.resolve()follows symlinks, so a STRATEGY.md inside cwd that symlinks to/etc/passwdresolves to the target and is rejected.mureo.context.state/mureo.context.strategy(temp file +os.replace). A failed write leaves the original file intact (covered bytest_strategy_set_is_atomic).mureo_strategy_setround-trips input throughparse_strategy()so a malformed payload raises before the file is overwritten.Test plan
tests/test_mcp_tools_mureo_context.py— 13 unit tests covering all 5 tools, including atomic-write failure, missing-file defaults, required-field validation, upsert-create + upsert-update, and the path-traversal refusal.tests/test_mcp_tool_name_spec.py— regression guard updated to includetools_mureo_context; all 5 names match^[a-zA-Z0-9_-]{1,64}$.tests/test_mcp_server.py::TestListTools::test_list_tools_returns_all_tools— total tool count updated 173 → 178.ruff check,black --check,mypy --strictall pass on new files.relative_toidiom) and MEDIUM (drop redundant default inhandle_state_get, add upsert-update test).Out of scope
Pre-existing test failures in
tests/test_mcp_tools_meta_ads_*and 4 tests intest_mcp_server.py(BYOD demo data leaking into expected "no credentials" assertions) are unrelated to this change and exist on the branch base.