Skip to main content
Glama
Agent Keyring

Agent Keyring

Agent Keyring

An MCP server that holds secrets and makes authenticated API calls on behalf of AI agents — so API keys never enter conversation context.

Agent → Keyring MCP → retrieve secret → make API call → return data only

The agent says what to do ("query GA4 for sessions"). The keyring handles how to authenticate. Keys stay on the keyring, never in the agent's mouth.

Quickstart

# 1. Clone
git clone https://github.com/MithrynMarious/agent-keyring.git
cd agent-keyring

# 2. Create a virtual environment and install
python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install .

# 3. Copy the skeleton and fill in your keys
cp .secrets.skeleton.json .secrets.json
# Edit .secrets.json — replace placeholders with real values

# 4. Add to your MCP config (.mcp.json or Claude Desktop settings)

Add to your MCP config file:

Claude Code — .mcp.json in your project root:

{
  "mcpServers": {
    "keyring": {
      "command": "python",
      "args": ["server.py"],
      "cwd": "/path/to/agent-keyring"
    }
  }
}

Claude Desktop — config file location varies by OS:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

Same JSON format — add the keyring entry to your existing mcpServers block.

# 5. Verify
python -c "from secret_store import LocalFileStore; s = LocalFileStore('.secrets.json'); print(f'{len(s.list_names())} secrets loaded')"

Related MCP server: AI Service Gateway MCP

What's Working

Component

Status

Notes

Local file store

Active

.secrets.json backend, PASTE_FROM references

GCP Secret Manager store

Active

Multi-machine, 3 auth paths (SA key, ADC, GCE metadata)

GA4 adapter

Active

OAuth + service account JWT, report formatting

AgentMail adapter

Active

Bearer token auth, inbox/thread operations

Stripe adapter

Active

Charges, customers, subscriptions (read-only)

Supabase adapter

Active

Table queries via PostgREST, auth admin

Anthropic adapter

Active

Messages API, model listing

GitHub adapter

Active

Repos, issues, PRs via REST API

Discord adapter

Active

Channel messages, webhooks

Identity verification

Active

DID primary, AgentMail fallback

Checkout ledger

Active

Append-only JSONL, agent affinity analysis

Key health monitor

Active

Connectivity checks, rotation tracking, HTML dashboard

Service taxonomy

Active

6 archetypes, 60+ ecosystem entries

Permissions

Active

Per-agent, per-secret access control

MCP Tools

Tool

What It Does

keyring_list_available

List secrets the agent can access (names only, never values)

keyring_authenticated_request

Make an API call using a managed secret

keyring_checkout_history

Query who accessed what, when, and why

keyring_agent_affinity

Analyze agent-service usage patterns

Security Model (DC-1)

Secret values never appear in:

  • MCP tool results

  • Conversation context

  • Log output

  • EAM entries or session records

The keyring makes the authenticated API call and returns only the response data. The checkout ledger logs every access (who, what, when, why) without recording the secret value.

Docs

  • SETUP.md — Full setup guide with GCP migration, troubleshooting, and embedded lessons from prior setups

  • FRICTION_JOURNAL.md — GCP console gotchas (training-data-vs-reality deltas)

  • AGENTS.md — Engineering posture and conventions

Populating Secrets

Scan a machine for scattered credentials, collect them, and populate the keyring:

python consolidate.py bootstrap ~/projects ~/.config ~/keys
# Scans → migrates → ingests → validates. Values stay on disk, never in stdout.

Add --dry-run to preview without changing anything. DC-1 safe: the bootstrap prints filenames and counts, never secret values.

Manual paths

# Interactive (value from stdin, never CLI args)
python add_secret.py my-api-key

# From files
mkdir -p .secrets
# Place key files in .secrets/
python consolidate.py ingest

# Bulk discovery
python consolidate.py scan ~/projects    # find scattered creds
python consolidate.py migrate ~/projects --target .secrets/

GCP Backend (Multi-Machine)

For shared secrets across machines, use GCP Secret Manager as the backend:

{
  "mcpServers": {
    "keyring": {
      "command": "python",
      "args": ["server.py"],
      "env": { "KEYRING_GCP_PROJECT": "your-project-id" }
    }
  }
}

See SETUP.md Option B for the full GCP walkthrough.

Registering Agents

New agents are denied access by default (DC-1). To grant an agent access to secrets, add an entry to permissions.json:

{
  "agent-name@agentmail.to": ["secret-name-1", "secret-name-2"],
  "admin-agent@agentmail.to": ["*"],
  "_default": []
}
  • Each key is an agent identifier (AgentMail address or DID)

  • Values list the secret names the agent can check out

  • "*" grants access to all secrets

  • "_default": [] means unregistered agents get nothing — this is the DC-1 structural default

When an unregistered agent calls keyring_list_available, it sees an empty list. The checkout ledger still records the attempt.

Environment Variables

See .env.example for the complete list. Key variables:

Variable

Required

Default

Purpose

KEYRING_GCP_PROJECT

For GCP backend

—

Selects GCP Secret Manager over local file

KEYRING_SECRET_STORE

No

.secrets.json

Local store file path

KEYRING_SECRETS_ROOT

No

3 dirs up

Root for PASTE_FROM: path resolution

GOOGLE_APPLICATION_CREDENTIALS

For GCP SA auth

—

GCP service account key file

Logging

The server uses Python's logging module. Set the log level via environment:

# See all keyring activity
LOGLEVEL=DEBUG python server.py

# Quiet mode (errors only)
LOGLEVEL=ERROR python server.py

Default level is WARNING. The keyring.store and keyring.ledger loggers are the most useful for debugging auth and access issues.

Troubleshooting

Symptom

Cause

Fix

0 secrets loaded

.secrets.json missing or empty

Copy .secrets.skeleton.json to .secrets.json and fill in values

PASTE_FROM file not found

KEYRING_SECRETS_ROOT not set or wrong

Set it to the parent directory of your .secrets/ folder

No adapter registered for service

Service name doesn't match a registered adapter

Check keyring_list_available output for exact service names

Agent sees empty list

Agent not in permissions.json

Add the agent's identifier to permissions.json with allowed secrets

GCP 403 Permission denied

Service account lacks Secret Manager access

Grant roles/secretmanager.secretAccessor to the SA in GCP console

GCP 404 Secret not found

Wrong prefix or secret name

Check KEYRING_GCP_PREFIX — secret is stored as {prefix}{name} in GCP

Stale secret value from GCP

Cache TTL hasn't expired

Set KEYRING_GCP_CACHE_TTL=0 or restart the server

401 from adapter API call

Secret value is expired or invalid

Rotate the key in .secrets.json or GCP, then restart

For GCP-specific setup issues, see SETUP.md and FRICTION_JOURNAL.md.

Docker

# Local file store
docker compose up keyring

# GCP backend
KEYRING_GCP_PROJECT=your-project docker compose --profile gcp up keyring-gcp

Mount your .secrets.json and permissions.json as volumes. See docker-compose.yml for the full configuration.

CI

Tests run on push and PR via GitHub Actions across Python 3.12–3.13 on Linux, Windows, and macOS. See .github/workflows/test.yml.

License

Proprietary — CoreForged LLC. See LICENSE for terms.

Available Tools

4 tools
keyring_agent_affinityA

Analyze agent-service affinity patterns from the checkout ledger.

Returns which agents use which services most — the raw data for workstation specialization analysis and context overload detection.

Args: days: How far back to analyze (default 30).

Inputs: days.

keyring_authenticated_requestA

Make an authenticated API call using a managed secret. The key never appears in the response.

The keyring retrieves the secret, makes the API call, and returns only the response data. Every call is logged to the checkout ledger.

Args: service: Service identifier (e.g. 'agentmail', 'stripe', 'ga4', 'firebase'). For unregistered services, pass any name — the generic adapter handles the request if base_url is in params. secret_name: Name of the secret to use (from keyring_list_available). method: HTTP method (GET, POST, PUT, DELETE). endpoint: API endpoint path (appended to service base URL). params: Query parameters for the request. For unregistered services, include: base_url (required), auth_type ('bearer'|'header'|'basic'|'query', default 'bearer'), auth_header (header name when auth_type='header'). body: JSON body for POST/PUT requests. scope: Optional scope for multi-value keys (e.g. 'fleet', 'mcp'). When set, tries secret_name:scope first, falls back to secret_name. purpose: Why this request is being made (logged to ledger). did: Agent's DID for identity verification. agentmail_token: AgentMail API key for identity fallback. agentmail_inbox: Agent's AgentMail address for identity fallback.

Inputs: service (required), secret_name (required), did, body, +7 more.

keyring_checkout_historyB

Query the checkout ledger — who accessed what, when, and why.

Args: agent_id: Filter by agent (DID or AM address). service: Filter by service name. secret_name: Filter by secret name. days: How far back to look (default 30).

Inputs: days, service, agent_id, secret_name.

keyring_list_availableA

List secrets the calling agent can access. Returns names and descriptions only — never values.

Args: did: Agent's DID (did:key:...) for identity verification. agentmail_inbox: Agent's AgentMail address (e.g. sofer@agentmail.to) as fallback identity.

Inputs: did, agentmail_inbox.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: listing available secrets, making an authenticated request, querying the audit ledger, and analyzing ledger patterns. The closest pair, checkout_history and agent_affinity, are separated by raw logging versus aggregate analysis.

    Naming Consistency3/5

    The shared keyring_ prefix provides some consistency, but the suffixes are grammatically mixed: list_available is verb-like, while authenticated_request, checkout_history, and agent_affinity are noun phrases. A consistent verb_noun pattern would make the tool names more predictable.

    Tool Count5/5

    Four tools is well-scoped for an agent-facing keyring: discovery, usage, audit, and analytics. Each tool serves a distinct purpose without redundancy or unnecessary bloat.

    Completeness5/5

    The surface covers the full agent-facing workflow: see what secrets are available, use them without exposing values, review the audit trail, and analyze usage patterns. Secret lifecycle management tools are absent but appear intentionally reserved for administrators rather than agents.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables secure credential storage for AI agents by encrypting secrets and providing agent-invisible references, ensuring sensitive data never leaks to the model.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to securely access authenticated services (HTTP, SSH, SMTP) without exposing secrets, by acting as a server-side proxy that injects authentication.
      MIT
    • 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
      C
      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