Provides tools for interacting with HashiCorp Vault, enabling secret management operations including reading, writing, listing, and deleting secrets at specified paths.
Provides tools for interacting with HashiCorp Vault, enabling secret management operations including reading, writing, listing, and deleting secrets at specified paths.
HashiCorp Vault MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with HashiCorp Vault via Streamable HTTP API.
Features
This MCP server provides the following tools for Vault KV operations:
vault_kv_read: Read secrets from Vault at a specified path with optional version and mount point
vault_kv_create: Create/write secrets to Vault at a specified path
vault_kv_list: List secrets at a specified path in a mount point
vault_kv_delete: Delete the latest version of secrets from Vault at a specified path
Security Features
Optional Bearer Token Authentication: Protect your MCP endpoints with token-based authentication
TLS/HTTPS Support: Enable encrypted connections with custom certificates
CORS Configuration: Control cross-origin access to your server
Installation
Prerequisites
This server uses the hashi-vault-js library to communicate with HashiCorp Vault. Make sure you have:
Node.js 18 or later
A running HashiCorp Vault server
A valid Vault authentication token
Configuration
The server supports the following environment variables:
Vault Configuration (Required)
VAULT_ADDR: The address of your Vault server (default:http://127.0.0.1:8200)VAULT_TOKEN: Your Vault authentication tokenVAULT_URL: Full Vault API URL (default:${VAULT_ADDR}/v1)VAULT_TIMEOUT: Request timeout in milliseconds (default:5000)VAULT_CACERT: Path to CA certificate for Vault TLS verification (optional)
MCP Server Configuration
MCP_PORT: The port for the MCP server API (default:3000)
Security Configuration (Optional)
MCP_AUTH_TOKEN: Bearer token for API authentication (if not set, authentication is disabled)MCP_TLS_ENABLED: Set to"true"to enable HTTPS (default:false)MCP_TLS_KEY: Path to TLS private key (default:./certs/mcp-server.key)MCP_TLS_CERT: Path to TLS certificate (default:./certs/mcp-server.crt)MCP_TLS_CA: Path to CA certificate (default:./certs/ca.crt)
See .env.example for a complete configuration template.
Usage
Running the Server
Basic (HTTP, no authentication):
With Authentication:
With HTTPS:
The server will expose the following endpoints:
/health- Health check endpoint (unprotected)/mcp- MCP endpoint for client connections (protected ifMCP_AUTH_TOKENis set)
Authentication
When MCP_AUTH_TOKEN is set, all requests to /mcp must include:
For detailed authentication setup, see AUTHENTICATION.md.
Using with Gemini CLI
Add this configuration to your Gemini config file:
MacOS: ~/.config/gemini-cli/config.json
Without Authentication:
With Authentication:
With HTTPS:
For more details, see GEMINI_CLI_SETUP.md.
Note: Make sure the server is running before connecting with Gemini CLI.
Using with Claude Desktop
Add this configuration to Claude Desktop:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
For more details, see COPILOT_SETUP.md.
Using with Other MCP Clients
Connect to the endpoint at http://localhost:3000/mcp (or https:// if TLS is enabled) using any MCP-compatible client. The server supports both GET and POST requests with StreamableHTTPServerTransport.
Tool Examples
Reading a Secret
Creating/Writing a Secret
Listing Secrets
Deleting a Secret
Testing with cURL
For more examples, see TESTING.md.
Development
Build
Watch Mode
Vault Setup
For testing, you can run Vault in dev mode:
This will start Vault at http://127.0.0.1:8200 with a root token displayed in the output.
Security Notes
Vault Security
Never commit your
VAULT_TOKENto version controlUse appropriate Vault policies to restrict access
Consider using AppRole or other authentication methods for production
Ensure your Vault server uses TLS in production environments
Use
VAULT_CACERTto verify Vault's TLS certificate
MCP Server Security
Enable Authentication: Set
MCP_AUTH_TOKENto protect your MCP endpointsUse HTTPS: Enable
MCP_TLS_ENABLEDfor encrypted connections in productionGenerate Strong Tokens: Use
openssl rand -hex 32for authentication tokensRotate Tokens: Change authentication tokens regularly
Network Access: Use firewalls or reverse proxies to restrict access
Environment Security: Never commit
.envfiles with real tokensCertificate Management: Keep TLS certificates and keys secure (
chmod 600)
For detailed security guidance, see AUTHENTICATION.md.
Quick Start
Clone and install:
git clone <repository-url> cd hashi-vault-mcp npm installConfigure environment:
cp .env.example .env # Edit .env with your Vault detailsBuild and run:
npm run build npm startTest the server:
curl http://localhost:3000/health
Additional Documentation
Authentication Setup - Detailed guide for bearer token authentication and TLS
Gemini CLI Setup - Configure Gemini CLI to use this server
Claude Desktop Setup - Configure Claude Desktop integration
Testing Guide - Test scripts and troubleshooting
Troubleshooting
Connection Issues
Verify Vault is running:
vault statusCheck
VAULT_ADDRmatches your Vault server addressEnsure
VAULT_TOKENhas appropriate permissionsFor HTTPS Vault, set
VAULT_CACERTto your CA certificate path
Authentication Errors
Verify
MCP_AUTH_TOKENmatches between server and clientCheck Authorization header format:
Bearer <token>Ensure token is set in client configuration
TLS/HTTPS Issues
Verify certificate files exist at configured paths
Check certificate file permissions
For self-signed certificates, clients may need to trust the CA or use
-kflag
License
MIT