Skip to main content
Glama

CI codecov npm version License: MIT

MCP Secrets Vault

A secure Model Context Protocol (MCP) server that enables AI assistants to use secrets (API keys, tokens) without ever exposing them. Built with TypeScript, featuring policy-based access control, rate limiting, and comprehensive audit logging.

MCP Secrets Vault Demo

πŸ“Ί View Full Demo Guide

πŸ”’ Security First

Key Security Guarantee: AI assistants can use your secrets to perform actions but will NEVER see the actual secret values.

  • Secrets are stored only in environment variables

  • All outputs are sanitized before returning to the AI

  • Every action is logged for audit compliance

  • Deny-by-default policy enforcement

  • Rate limiting prevents abuse

Related MCP server: keywarden

πŸš€ Quick Start

Installation

Option 1: Global Installation

npm install -g mcp-secrets-vault
mcp-secrets-vault doctor  # Verify installation
npx mcp-secrets-vault doctor  # Test without installing

Option 3: Local Installation in Project

npm install mcp-secrets-vault

MCP Client Configuration

For use with Claude Desktop or other MCP clients:

{
  "mcpServers": {
    "secrets-vault": {
      "command": "npx",
      "args": ["mcp-secrets-vault"],
      "env": {
        "VAULT_CONFIG": "./vault.config.json"
      }
    }
  }
}

Basic Setup

  1. Set your environment variables:

export GITHUB_TOKEN="ghp_example123fake456token"
export OPENAI_API_KEY="sk-fake789example012key"
  1. Create a configuration file (vault.config.json):

{
  "secrets": [
    {
      "secretId": "github_api",
      "envVar": "GITHUB_TOKEN",
      "description": "GitHub API access"
    },
    {
      "secretId": "openai_key",
      "envVar": "OPENAI_API_KEY",
      "description": "OpenAI API access"
    }
  ],
  "policies": [
    {
      "secretId": "github_api",
      "allowedActions": ["http_get", "http_post"],
      "allowedDomains": ["api.github.com"],
      "rateLimit": {
        "requests": 100,
        "windowSeconds": 3600
      }
    },
    {
      "secretId": "openai_key",
      "allowedActions": ["http_post"],
      "allowedDomains": ["api.openai.com"],
      "rateLimit": {
        "requests": 50,
        "windowSeconds": 3600
      }
    }
  ]
}

πŸ“– Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   MCP Client (AI)                   β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚Discover β”‚ β”‚ Describe β”‚ β”‚   Use   β”‚ β”‚  Query   β”‚  β”‚
β”‚  β”‚ Secrets β”‚ β”‚  Policy  β”‚ β”‚ Secret  β”‚ β”‚  Audit   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚           β”‚            β”‚           β”‚
        β–Ό           β–Ό            β–Ό           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               MCP Secrets Vault Server              β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚            Policy Evaluation Engine          β”‚   β”‚
β”‚  β”‚         (Exact FQDN matching only)           β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚           Rate Limiter (Token Bucket)        β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        Secret Provider (ENV mapping)         β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚      Action Executor (HTTP GET/POST)         β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚         Audit Logger (JSONL format)          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β–²                                    β”‚
        β”‚                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Environment   β”‚                   β”‚   Audit Files   β”‚
β”‚   Variables   β”‚                   β”‚    (JSONL)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Components

  • Policy Engine: Validates every request against strict allowlists (no wildcards)

  • Rate Limiter: Token bucket algorithm with per-secret limits

  • Secret Provider: Maps secret IDs to environment variables (never exposes values)

  • Action Executor: Performs HTTP requests with injected secrets

  • Audit Logger: Comprehensive JSONL audit trail for compliance

πŸ›‘οΈ Security Model

Multi-Layer Protection

  1. Input Boundary: All inputs validated with Zod schemas

  2. Policy Layer: Explicit allowlists only (deny by default)

  3. Execution Layer: Secrets injected only at execution time

  4. Output Boundary: All responses sanitized before return

Security Guarantees

  • βœ… Secret values NEVER appear in MCP responses

  • βœ… Secret values NEVER appear in error messages

  • βœ… Secret values NEVER appear in logs

  • βœ… Secret values NEVER appear in audit records

  • βœ… Every action attempt is audited (success or failure)

  • βœ… Rate limiting prevents abuse

  • βœ… Exact domain matching only (no wildcards)

πŸ“‹ Policy Configuration

Policy Structure

{
  "secretId": "api_key_identifier",
  "allowedActions": ["http_get", "http_post"],
  "allowedDomains": ["api.example.com"],
  "rateLimit": {
    "requests": 100,
    "windowSeconds": 3600
  },
  "expiresAt": "2024-12-31T23:59:59Z"
}

Supported Actions

  • http_get: HTTP GET requests

  • http_post: HTTP POST requests

Important Notes

  • Domains must be exact FQDNs (no wildcards or patterns)

  • All policies are deny-by-default

  • Rate limits use token bucket algorithm

  • Policies are validated on startup

πŸ” Available MCP Tools

1. discover_secrets

Lists all available secrets (IDs only, never values).

Response Example:

{
  "secrets": [
    {
      "secretId": "github_api",
      "description": "GitHub API access",
      "hasPolicy": true
    }
  ]
}

2. describe_policy

Returns the policy for a specific secret.

Request:

{
  "secretId": "github_api"
}

Response:

{
  "secretId": "github_api",
  "allowedActions": ["http_get", "http_post"],
  "allowedDomains": ["api.github.com"],
  "rateLimit": {
    "requests": 100,
    "windowSeconds": 3600
  }
}

3. use_secret

Execute an action using a secret (without exposing it).

Request:

{
  "secretId": "github_api",
  "action": "http_get",
  "url": "https://api.github.com/user/repos",
  "options": {
    "headers": {
      "Accept": "application/vnd.github.v3+json"
    }
  }
}

Response (sanitized):

{
  "success": true,
  "statusCode": 200,
  "summary": "Retrieved 15 repositories",
  "headers": {
    "content-type": "application/json"
  }
}

4. query_audit

Query the audit log for usage history.

Request:

{
  "secretId": "github_api",
  "startTime": "2024-01-01T00:00:00Z",
  "limit": 10
}

πŸ“ Audit Logging

All actions are logged in JSONL format for compliance:

{"timestamp":"2024-01-15T10:30:00Z","secretId":"github_api","action":"http_get","domain":"api.github.com","outcome":"allowed","statusCode":200}
{"timestamp":"2024-01-15T10:31:00Z","secretId":"openai_key","action":"http_post","domain":"api.openai.com","outcome":"rate_limited","reason":"Exceeded 50 requests per hour"}

πŸ”§ Configuration

Environment Variables

  • VAULT_CONFIG: Path to configuration file (default: ./vault.config.json)

  • VAULT_LOG_LEVEL: Logging level (ERROR, WARN, INFO, DEBUG)

  • VAULT_AUDIT_DIR: Directory for audit logs (default: ./audit)

Configuration Schema

See config.schema.json for the complete JSON schema.

πŸ§ͺ Development

Prerequisites

  • Node.js 20+ (LTS)

  • npm or yarn

Setup

# Clone the repository
git clone https://github.com/RachidChabane/mcp-secrets-vault
cd mcp-secrets-vault

# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

# Run in development mode
npm run dev

Testing

# Run tests with coverage
npm run test:coverage

# Run specific test
npx vitest run src/services/rate-limiter.test.ts

# Type checking
npm run typecheck

CI/CD

This project uses GitHub Actions for continuous integration. The CI pipeline:

  • Triggers: Runs on push to develop, main, and feature branches (feat/**, fix/**, hotfix/**, release/**), and on pull requests targeting develop

  • Coverage Requirement: Enforces β‰₯80% test coverage threshold - builds will fail if coverage drops below this level

  • Build Artifacts: Coverage reports are uploaded and retained for 7 days

  • Branch Protection: The build-and-test check must pass before merging to develop or main

The CI workflow ensures code quality and test coverage standards are maintained across all contributions.

🀝 Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository

  2. Create a feature branch (feat/your-feature)

  3. Write tests (maintain β‰₯80% coverage)

  4. Use the provided text constants

  5. Commit with emoji prefixes (:sparkles: [task-XX] Add feature)

  6. Open a PR to develop branch

Code Standards

  • TypeScript strict mode

  • 80%+ test coverage

  • All strings in constants files

  • Comprehensive error handling

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ”­ Roadmap (post-MVP, non-binding)

  • Init wizard + templates: scaffold a minimal vault.config.json.

  • Dry-run mode: simulate requests and show effective headers (secrets masked).

  • CLI audit viewer: list/filter/export JSONL by date/id/FQDN with simple pagination.

  • Refined rate limits: per-FQDN and per-secret; deterministic retry/backoff.

  • Consent gate & response guards: first-use confirmation per domain; max body size & per-domain timeouts.

⚠️ Disclaimer

This tool is designed for development and controlled environments. Always follow your organization's security policies when handling sensitive credentials.

Available Tools

4 tools
describe_policyC

Get policy details for a secret

Inputs: secretId (required).

discover_secretsB

List all available secret identifiers and their metadata

Inputs: no named parameters.

query_auditC

Query audit log entries with filtering and pagination

Inputs: page, endTime, outcome, pageSize, +2 more.

use_secretC

Use a secret to perform an action

Inputs: action (required), secretId (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool targets a distinct part of the vault workflow: listing identifiers, reading policy, using a secret, and querying audit logs. There is minor potential confusion between discover_secrets metadata and describe_policy policy details, but the descriptions make the boundary workable.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern: discover_secrets, describe_policy, use_secret, query_audit. There are no mixed conventions or vague standalone verbs.

    Tool Count4/5

    Four tools is a lean but reasonable surface for a consumption-focused secrets vault, and each tool has a clear role. It is slightly thin if the server is intended for full vault administration, but the count itself is not excessive or trivial.

    Completeness3/5

    The surface covers discovery, policy lookup, usage, and audit, but lacks secret creation/update/deletion, rotation/revocation, and policy management. These are notable gaps for a vault lifecycle, though basic consumption workflows are possible.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to securely use API keys by storing them in an encrypted vault and injecting them on demand with user approval, without exposing the key values to the model.
      3
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to make authenticated API calls and run commands with secrets injected, while keeping credentials completely hidden from the model, with policy enforcement, grants, and audit logging.
      6
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to call external endpoints under per-endpoint policy enforcement, with credentials and personal data kept inside a hardware enclave and every allowed or denied attempt recorded to an immutable audit ledger.
      2
      ISC
    • F
      license
      A
      quality
      F
      maintenance
      Enables AI agents to securely store and retrieve secrets and make authenticated API calls on their behalf, keeping API keys out of conversation context and supporting local file or GCP Secret Manager backends.
      4
      -