No description
Find a file
oss-core-libraries-dashboard[bot] 525571081f
[COMPLIANCE] Update Copyright and License Headers (Batch 1 of 1) (#32)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2026-02-20 15:30:53 +05:30
.github Remove files that make it look like this repo is meant to be run (#12) 2021-12-13 14:35:37 -08:00
examples [COMPLIANCE] Update Copyright and License Headers (Batch 1 of 1) (#32) 2026-02-20 15:30:53 +05:30
.gitignore feat: Add Spring AI MCP Server example with HashiCorp Vault integration 2026-01-15 16:38:45 +09:00
CODEOWNERS Kubernetes auth example (Go) (#6) 2021-10-01 10:04:58 -07:00
LICENSE [COMPLIANCE] Update Copyright and License Headers (Batch 1 of 1) (#32) 2026-02-20 15:30:53 +05:30
README.md feat: Add Spring AI MCP Server example with HashiCorp Vault integration 2026-01-15 16:38:45 +09:00

Vault Examples

A collection of copy-pastable code example snippets demonstrating the various ways to use the Vault client libraries for various languages to authenticate and retrieve secrets.

Currently Supported Languages

How To Use

Find the relevant directory for the concept you're interested in learning about, then find the file for your language of choice. You can use the example code as a reference or paste it into your application and tweak as needed. Each concept's directory also contains a readme explaining some of the specific terminology and operational setup.

This repo is not intended to be "run" as a standalone application.

For an out-of-the-box runnable sample app, please see our Hello-Vault repos.

Hello-Vault:

Client Applications

For complete, runnable client application examples that demonstrate real-world Vault integration patterns, see the Client Applications directory.

These examples include:

  • Complete applications in multiple languages (C, C++, Java, Python, Spring Boot, Tomcat)
  • Script examples using Vault Proxy
  • Real-world patterns for authentication, token renewal, and secret management
  • Multiple secret engine support (KV v2, Database Dynamic/Static, SSH, AWS)

Each example includes:

  • Full source code
  • Build and run instructions
  • Configuration examples
  • Detailed documentation

See the Client Applications README for more details.

MCP Examples

Spring AI MCP Server with HashiCorp Vault

For examples demonstrating how to secure a Spring AI Model Context Protocol (MCP) server using HashiCorp Vault for API key management, see the Spring AI MCP Server with Vault directory.

This example demonstrates:

  • API key management using HashiCorp Vault for centralized secret storage
  • AppRole authentication for machine-to-machine authentication
  • Spring Cloud Vault integration for seamless Vault access
  • API key validation via custom interceptor
  • KV v2 secrets engine for API key storage
  • Complete Docker Compose setup with Vault, Spring Boot, and MCP Inspector

See the Spring AI MCP Server with Vault README for more details.

Identity-Aware Remote MCP Examples (Agent Protection)

For examples demonstrating Vault integration with Model Context Protocol (MCP) servers for identity-aware credential management, see the MCP Examples directory.

The identity-aware remote example demonstrates:

  • User-specific credential separation using Vault Policy Templating
  • JWT-based authentication with Keycloak integration
  • Remote MCP servers retrieving user-specific credentials from Vault
  • Multiple secret engine support (KV v2, Database Dynamic Secrets)
  • Authentication flow tracing and credential debugging

See the MCP Remote Vault Demo README and Quick Start Guide for more details.

How To Contribute

If you would like to submit a code example to this repo, please create a file containing one function (or a grouping of several related functions) in the appropriate directory.