feat(mcp): separate direct order queries from wiki tools

Add an opt-in business group with schema, template, guarded SQL, and status tools. Reuse existing order statistics through read-only SQLite connections without OpenCode or wiki retrieval.

Add tools set for switching enabled groups with one restart. Gate file diagnostics with file-assets and document business-only operation while retaining the independent Kingdee sync task.

Validation: 217 unit tests passed; business tool tests rerun after read-only annotations. Live authenticated MCP schema/status/template/SQL calls passed, ask_wiki was unavailable, uploads returned 404, and unauthenticated requests returned 401.
This commit is contained in:
Codex
2026-10-31 06:47:43 +00:00
parent 1133e2bf50
commit 6c451c3eb6
10 changed files with 500 additions and 44 deletions
+26
View File
@@ -15,6 +15,32 @@ import manage_mcp_service
class McpServiceConfigTests(unittest.TestCase):
def test_set_business_only_preserves_connection_and_restarts_once_without_opencode(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
config_home = root / "config"
env_path = root / ".runtime" / "obsidian-wiki-mcp.env"
manage_mcp_service.write_token_env_file(
env_path, "existing-token", host="0.0.0.0", port=8765,
public_base_url="https://orders.example.test/mcp",
enabled_tools=("file-assets", "ingest", "query"),
)
with (
patch.dict(os.environ, {"XDG_CONFIG_HOME": str(config_home)}),
patch.object(manage_mcp_service, "restart_service_if_installed", return_value=True) as restart,
patch.object(manage_mcp_service, "resolve_opencode_path", side_effect=AssertionError("no OpenCode")),
patch("builtins.print"),
):
result = manage_mcp_service.main(["tools", "set", "business", "--project-root", str(root)])
self.assertEqual(result, 0)
restart.assert_called_once()
config = manage_mcp_service.saved_service_config(root)
self.assertEqual(config.enabled_tools, ("business",))
self.assertEqual(config.token, "existing-token")
self.assertEqual(config.public_base_url, "https://orders.example.test/mcp")
self.assertEqual(config.port, 8765)
self.assertIn("OBSIDIAN_MCP_ENABLE_INGEST=0", env_path.read_text())
def test_service_commands_delegate_to_unified_user_ops_entrypoint(self):
entrypoint = SCRIPTS_DIR / "mcp_service.sh"
legacy_wrappers = [