Skip to content

Add list_namespaces MCP tool - #116

Open
jm-merchan wants to merge 1 commit into
hashicorp:mainfrom
jm-merchan:feat/mcp-list-namespaces
Open

Add list_namespaces MCP tool#116
jm-merchan wants to merge 1 commit into
hashicorp:mainfrom
jm-merchan:feat/mcp-list-namespaces

Conversation

@jm-merchan

Copy link
Copy Markdown

Summary

Adds a new list_namespaces MCP tool for Vault Enterprise namespace discovery.

Changes

  • add pkg/tools/sys/list_namespaces.go
  • register the tool in pkg/tools/tools.go
  • support optional namespace and path inputs

Why

Namespace discovery is a common prerequisite for multi-tenant Vault workflows and currently requires leaving the MCP surface.

Validation

  • go test ./pkg/tools/...

@jm-merchan
jm-merchan requested a review from a team as a code owner June 12, 2026 09:55
Copilot AI review requested due to automatic review settings June 12, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_namespaces tool in the tools initializer.
  • Implement sys.ListNamespaces tool + handler to call Vault sys/namespaces listing 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants