feat: add opt-in execute_command tool#21
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in, destructive execute_command MCP tool that can execute real device commands through the Enapter HTTP SDK, with layered safety controls (deployment kill switch + manifest-based confirmation gate + fast-fail on unknown command names).
Changes:
- Introduces
execute_commandtool registration behindServerConfig.command_execution_enabled(CLI/env kill switch), with destructive tool annotations. - Adds domain/MCP models and HTTP mapping for a vendor-provided
confirmationblock on command declarations, and enforceshuman_confirmed_this_actioninApplicationServer.execute_command. - Expands unit + integration tests and commits schema snapshots for the new tool and extended blueprint schema.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/http/test_enapter_data_mapper.py | Adds unit coverage for mapping confirmation into command declarations. |
| tests/unit/http/test_enapter_api.py | Adds unit coverage for EnapterAPI.execute_command SDK call-through and domain mapping. |
| tests/unit/core/test_application_server.py | Adds unit coverage for command-name existence and confirmation gate behavior. |
| tests/integration/test_mcp.py | Adds enabled/disabled integration coverage and schema snapshot assertions for tool registration. |
| tests/integration/schemas/read_blueprint.json | Updates blueprint schema snapshot to include confirmation on command declarations. |
| tests/integration/schemas/execute_command.json | Adds schema snapshot for the new execute_command tool. |
| src/enapter_mcp_server/mcp/server.py | Registers execute_command conditionally and implements the MCP tool handler. |
| src/enapter_mcp_server/mcp/server_config.py | Adds command_execution_enabled configuration flag (default off). |
| src/enapter_mcp_server/mcp/models/command_declaration.py | Exposes optional confirmation on MCP command declarations + mapping from domain. |
| src/enapter_mcp_server/mcp/models/command_confirmation.py | Adds MCP model for vendor confirmation block. |
| src/enapter_mcp_server/mcp/models/init.py | Exports CommandConfirmation from MCP models package. |
| src/enapter_mcp_server/http/enapter_data_mapper.py | Maps manifest confirmation into new domain type. |
| src/enapter_mcp_server/http/enapter_api.py | Adds execute_command implementation using client.commands.execute. |
| src/enapter_mcp_server/domain/command_declaration.py | Adds optional confirmation field to domain command declaration. |
| src/enapter_mcp_server/domain/command_confirmation.py | Adds domain type for vendor confirmation metadata. |
| src/enapter_mcp_server/domain/init.py | Exports CommandConfirmation from domain package. |
| src/enapter_mcp_server/core/errors.py | Adds ConfirmationRequired and CommandNotFound errors. |
| src/enapter_mcp_server/core/enapter_api.py | Extends core API protocol with execute_command. |
| src/enapter_mcp_server/core/application_server.py | Adds execute_command orchestration (manifest lookup + confirmation gate + SDK call). |
| src/enapter_mcp_server/core/init.py | Re-exports new core errors. |
| src/enapter_mcp_server/cli/serve_command.py | Wires CLI/env kill switch into server config. |
| specs/SPEC-007-command-execution.md | Adds design spec and acceptance criteria for command execution. |
| README.md | Documents the new tool and adds a human-confirmation usage example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eedfd16 to
25b9cd0
Compare
25b9cd0 to
a34943c
Compare
a34943c to
a98bf9c
Compare
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.
No description provided.