Add list_namespaces MCP tool - #116
Open
jm-merchan wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new MCP tool to list Vault child namespaces and wires it into tool initialization.
Changes:
- Register new
list_namespacestool in the tools initializer. - Implement
sys.ListNamespacestool + handler to call Vaultsys/namespaceslisting and return results as JSON.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pkg/tools/tools.go | Registers the new list_namespaces tool with the MCP server. |
| pkg/tools/sys/list_namespaces.go | Implements the Vault namespaces listing tool and handler logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+66
to
+69
| fullPath := "sys/namespaces" | ||
| if strings.TrimSpace(path) != "" { | ||
| fullPath = fmt.Sprintf("sys/namespaces/%s", strings.Trim(path, "/")) | ||
| } |
Comment on lines
+56
to
+59
| if err != nil { | ||
| logger.WithError(err).Error("Failed to get Vault client") | ||
| return mcp.NewToolResultError(fmt.Sprintf("Failed to get Vault client: %v", err)), nil | ||
| } |
Comment on lines
+72
to
+79
| if err != nil { | ||
| logger.WithError(err).WithFields(log.Fields{ | ||
| "namespace": namespace, | ||
| "path": path, | ||
| "full_path": fullPath, | ||
| }).Error("Failed to list namespaces") | ||
| return mcp.NewToolResultError(fmt.Sprintf("Failed to list namespaces: %v", err)), nil | ||
| } |
Comment on lines
+85
to
+88
| keys, ok := secret.Data["keys"].([]interface{}) | ||
| if !ok { | ||
| return mcp.NewToolResultText("[]"), nil | ||
| } |
Comment on lines
+47
to
+50
| args, ok := req.Params.Arguments.(map[string]interface{}) | ||
| if !ok { | ||
| return mcp.NewToolResultError("Missing or invalid arguments format"), nil | ||
| } |
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 new
list_namespacesMCP tool for Vault Enterprise namespace discovery.Changes
pkg/tools/sys/list_namespaces.gopkg/tools/tools.gonamespaceandpathinputsWhy
Namespace discovery is a common prerequisite for multi-tenant Vault workflows and currently requires leaving the MCP surface.
Validation
go test ./pkg/tools/...