HashiCorp Vault MCP Server
Enables language models to securely manage HashiCorp Vault secrets and ACL policies through the Model Context Protocol. It supports automated secret rotation, discovery, and HCL policy authoring using a suite of dedicated tools and resources.
README
HashiCorp Vault MCP Server
HashiCorp Vault MCP Server is a full-featured Model Context Protocol (MCP) integration that lets language models and other MCP-aware clients manage Vault secrets and policies through a safe, auditable interface. It bridges Vault's security model with the structured interaction model that MCP expects, so you can automate tasks such as credential rotation, policy authoring, and discovery without exposing raw Vault APIs.
Table of Contents
- HashiCorp Vault MCP Server
Introduction
The server wraps the HashiCorp Vault KV v2 API and common policy workflows inside MCP primitives. Once a client connects, it can call typed tools, browse resources, and request prompt completions that are all backed by the same Vault instance you already operate. Every interaction is explicit: clients must supply the paths, data, and policies they want to work with, and the server relays those requests directly to Vault using a token you control.
<img width="1222" height="909" alt="image" src="https://github.com/user-attachments/assets/4517458f-e882-4928-83ba-2ba3be2354a0" />
Why Use This Server
- Automate secret rotation and retrieval directly from MCP-compatible IDEs and agents.
- Generate or update Vault ACL policies without manually editing HCL snippets.
- Safely expose only the operations you approve by scoping the Vault token that powers the server.
- Avoid ad-hoc scripting: the server comes with well-defined tools and prompts designed around common Vault tasks.
How the Server Works
- You launch the server either locally or inside a container with a Vault token.
- An MCP client (Cursor, Claude Desktop, custom agents) connects over stdio.
- The client calls tools like
create_secretorcreate_policy; the server validates the payload, forwards it to Vault, and returns structured responses. - Resource requests such as
vault://secretslist data-driven content that the client can browse or feed into follow-up prompts. - Prompt handlers like
generate_policyhelp you synthesize Vault-ready HCL from natural-language intents.
The implementation is written in TypeScript, bundles to a single JavaScript file, and relies on the official @modelcontextprotocol/sdk for transport and schema validation.
Requirements
- HashiCorp Vault 1.9+ with the KV secrets engine (v2) enabled on the paths you plan to manage.
- A Vault token that starts with
hvs.and grants the capabilities you need (read, create, update, delete and/or sudo for policy work). - Docker 24+.
- Network access from the machine running the MCP server to your Vault cluster.
Getting Started
Cursor
Production (recommended) — use the official image. Paste this under ~/.cursor/mcp.json:
{
"mcpServers": {
"Vault": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"VAULT_ADDR=https://your-vault-server:8200",
"-e",
"VAULT_TOKEN=hvs.your-vault-token",
"ashgw/vault-mcp:latest"
]
}
}
}
Cursor starts the container on-demand, wires stdio to the MCP transport, and tears it down once the session ends. Pin a tag (e.g. ashgw/vault-mcp:1.x.y) if you want a fixed version.
Local Cursor
You can build & run locally & use it like this
{
"mcpServers": {
"Vault": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network=host",
"-e",
"VAULT_ADDR=http://127.0.0.1:8200",
"-e",
"VAULT_TOKEN=hvs.test-token-1234567890abcdef",
"vault-mcp:local"
]
}
}
}
Local Docker
git clone https://github.com/rccyx/vault-mcp.git
cd vault-mcp
docker build -t vault-mcp:local .
docker run -i --rm \
--network=host \
-e VAULT_ADDR=http://127.0.0.1:8200 \
-e VAULT_TOKEN=hvs.test-token-1234567890abcdef \
vault-mcp:local
Configuration
VAULT_ADDR(required): URL of the Vault cluster, for examplehttps://vault.internal:8200orhttp://127.0.0.1:8200.VAULT_TOKEN(required): Short-lived or renewable Vault token starting withhvs.. Scope it tightly using Vault policies.NODE_TLS_REJECT_UNAUTHORIZED(optional): Set to0only for testing with self-signed certificates. Prefer adding proper CA bundles instead.
Provide any additional Vault environment variables (such as VAULT_NAMESPACE) if your deployment requires them; the server forwards the process environment to the Vault client library.
For sane testing defaults locally use the
.env.copy.examplefile.
Tool Reference
The MCP server exposes tools that map directly to Vault operations. Payloads are validated before they are sent to Vault, and responses mirror Vault's JSON structure.
create_secret
- Purpose: Write or update a secret at a KV v2 path.
- Input:
path(string): KV v2 logical path, for exampleapps/myapp/config.data(object): Key/value pairs to store underdata.
- Response: Returns the Vault write response including version metadata.
await tool("create_secret", {
path: "apps/myapp/config",
data: {
apiKey: "secret-key-123",
environment: "production",
},
});
read_secret
- Purpose: Retrieve a specific secret version from KV v2.
- Input:
path(string): KV v2 logical path.version(optional number): Explicit version to fetch; defaults to latest.
- Response: Vault
dataobject along with metadata (created_time,version).
const secret = await tool("read_secret", { path: "apps/myapp/config" });
console.log(secret.data.apiKey);
delete_secret
- Purpose: Soft-delete the latest version of a KV v2 secret.
- Input:
path(string): KV v2 logical path.
- Response: Vault deletion metadata. Older versions remain unless destroyed separately.
await tool("delete_secret", { path: "apps/myapp/config" });
create_policy
- Purpose: Create or replace a Vault ACL policy.
- Input:
name(string): Policy name to upsert.policy(string): HCL policy definition.
- Response:
trueon success.
await tool("create_policy", {
name: "app-readonly",
policy: """
path "secret/data/apps/myapp/*" {
capabilities = ["read", "list"]
}
"""
});
Resource Reference
Resources expose browsable datasets that help MCP clients decide which tool call to make next.
vault://secrets
Lists the keys available at the root of the KV store. Nested directories end with / so clients can drill deeper.
{
"keys": ["apps/", "databases/", "certificates/"]
}
vault://policies
Enumerates policy names the token can read. Useful for auditing or feeding into prompts.
{
"policies": ["default", "app-readonly", "admin"]
}
Prompt Reference
Prompts assist with higher-level authoring tasks by turning structured input into Vault-friendly output.
generate_policy
- Input:
path(string): Target KV path or pattern, such assecret/data/apps/*.capabilities(string): Comma-separated capabilities (for exampleread,list,delete).
- Response: JSON object that maps paths to capability arrays so you can embed the result into an ACL policy or feed it back into
create_policy.
const draft = await prompt("generate_policy", {
path: "secret/data/apps/*",
capabilities: "read,list",
});
Troubleshooting
- Authentication failed: Confirm
VAULT_TOKENis valid and not revoked. Runvault token lookup hvs.your-tokento inspect TTL and policies. - Permission denied for a path: Adjust the Vault policy attached to your token or verify you are targeting the correct mount (for example
secret/data/...versuskv/data/...). - Self-signed certificate errors: Supply a CA bundle via
VAULT_CACERTor temporarily setNODE_TLS_REJECT_UNAUTHORIZED=0while testing. - Resources look empty: The token only sees paths it is permitted to
list. Double-check the policy allows thelistcapability on the relevant prefixes.
License
Distributed under the MIT License.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。