Add sproc command for stored procedures#124
Open
mkrueger wants to merge 8 commits into
Open
Conversation
The editor is now always resolved from $VISUAL, then $EDITOR, then a platform default, matching the �dit command. Drops the --editor option and its localized help/docs for heme edit and sproc edit.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new sproc command to the Cosmos DB Shell for managing stored procedures (list/show/create/exec/edit/delete), including an external-editor workflow for authoring and editing bodies, updated help/localization, MCP restrictions documentation, and test coverage for MCP tooling metadata.
Changes:
- Introduces
sproccommand implementation plus docs/localization entries and changelog note. - Removes the redundant
--editoroption fromtheme(and updates docs/localization accordingly). - Adds/extends tests to validate MCP restriction annotations and
sprochelper behaviors.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Mentions the new sproc command in the feature list. |
| docs/mcp.md | Documents that sproc operations are restricted from MCP. |
| docs/commands.md | Updates theme usage and adds full sproc command documentation. |
| CosmosDBShell/lang/en.ftl | Adds sproc localized strings and removes the theme editor option string. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThemeCommand.cs | Removes --editor option handling and always resolves editor from environment defaults. |
| CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/SprocCommand.cs | Implements the new stored procedure command and editor workflow. |
| CosmosDBShell.Tests/ToolOperationsTests.cs | Adds a test asserting sproc is MCP-restricted and annotated as destructive/open-world. |
| CosmosDBShell.Tests/CommandTests/SprocCommandTests.cs | Adds unit tests for sproc helper methods (normalize/param parsing/PK parsing/template seed). |
| CHANGELOG.md | Adds an Unreleased entry describing the new sproc command. |
…anches Adds 'sproc exists <name>' which returns a ShellBool so it can be used directly in if/while conditions. Also fixes CommandStatement.RunAsync so it resets IsPrinted at the start of each statement; previously a prior command that set IsPrinted (such as a condition command in an if) leaked the flag and suppressed the branch command's output in PrintState.
…ical PK support) + test
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThemeCommand.cs:660
ThemeCommandno longer supports--editor, but when no editor is found it still uses the theme-specific message key whose text says "or pass --editor=". This produces an incorrect user-facing error now that the option is removed.
var editor = ExternalEditor.Resolve(null);
if (editor is null)
{
var message = MessageService.GetString("command-theme-edit-no-editor");
AnsiConsole.MarkupLine(Theme.FormatError(message));
return new ErrorCommandState(new CommandException("theme", message));
- Reject object-shaped/malformed --partition-key instead of silent string fallback (new command-sproc-error-invalid_pk) - List exists/edit subcommands in the MCP annotation description - Drop misleading 'MCP server' mention from the create comment - Add exists to sproc help description strings - Fix obsolete '--editor' hint in command-theme-edit-no-editor - Add exists to the sproc feature list in README - Document sproc list JSON metadata and that sproc is MCP-restricted in docs - Add unit test for object-shaped partition key rejection
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
Adds a
sproccommand for working with Azure Cosmos DB stored procedures from the shell, with an interactive editor workflow and clean, human-friendly output.Changes
sproccommand with subcommands:list,show,create,exec,edit,delete(MCP-restricted).sproc listrenders a human-readable table (Id / Last Modified / Size) for interactive sessions while still returning structured JSON for MCP consumers.sproc createopens an external editor, then shows a preview and a confirmation prompt before creating the stored procedure.sproc editedits an existing stored procedure body and fails with a not-found error if it does not exist (usecreateto add a new one).IsPrintedso the JSON echo is hidden in the interactive shell and only surfaced over MCP.--editoroption from the theme andsproccommands.Validation
dotnet build CosmosDBShell.Tests/CosmosDBShell.Tests.csproj— succeeds.