Skip to content

Add optional namespace override to KV tools#115

Open
jm-merchan wants to merge 1 commit into
hashicorp:mainfrom
jm-merchan:feat/mcp-kv-namespace-override
Open

Add optional namespace override to KV tools#115
jm-merchan wants to merge 1 commit into
hashicorp:mainfrom
jm-merchan:feat/mcp-kv-namespace-override

Conversation

@jm-merchan

Copy link
Copy Markdown

Summary

Adds an optional parameter to the existing KV tools so callers can target a different Vault namespace per request without changing the MCP session namespace.

Changes

  • add to
  • add to
  • add to
  • add to
  • factor namespace application into a small helper

Why

This supports multi-namespace workflows from a single MCP session and avoids having to reconfigure the server between calls.

Validation

  • ok github.com/hashicorp/vault-mcp-server/pkg/tools/kv (cached)

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

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 per-call Vault namespace override support to KV tools so callers can target a specific Vault namespace without changing the MCP session default.

Changes:

  • Added a new optional namespace string parameter to read/write/list/delete KV tools.
  • Applied the namespace override to the Vault client before performing KV operations.
  • Introduced a small helper to apply the namespace only when provided.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/tools/kv/write_secret.go Adds namespace tool argument and applies optional namespace to Vault client.
pkg/tools/kv/read_secret.go Adds namespace tool argument and applies optional namespace to Vault client.
pkg/tools/kv/list_secrets.go Adds namespace tool argument and applies optional namespace to Vault client.
pkg/tools/kv/delete_secret.go Adds namespace tool argument and applies optional namespace to Vault client.
pkg/tools/kv/namespace.go New helper to apply an optional Vault namespace to the client.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/tools/kv/namespace.go
Comment on lines +12 to +18
func withOptionalNamespace(vault *api.Client, namespace string) *api.Client {
ns := strings.TrimSpace(namespace)
if ns == "" {
return vault
}
return vault.WithNamespace(ns)
} No newline at end of file
Comment on lines +33 to +36
mcp.WithString("namespace",
mcp.DefaultString(""),
mcp.Description("Optional Vault namespace override for this call (for example: 'admin/team-03'). If not set, uses the MCP session namespace."),
),
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