Integrations

MCP Server Integration

@secr/mcp is a Model Context Protocol server that gives AI coding agents direct access to your secrets. Instead of manually running secr pull or maintaining .env files, agents can read, write, and manage secrets through MCP tool calls.

Quick Start

1. Create an agent token

Terminal
secr agents create --name "claude-code" --scope "read:secrets,write:secrets"
# → secr_agent_abc123...

2. Add the MCP server

Claude Code

Terminal
claude mcp add secr -e SECR_TOKEN=secr_agent_xxx -- npx @secr/mcp

Cursor

~/.cursor/mcp.json
{
  "mcpServers": {
    "secr": {
      "command": "npx",
      "args": ["@secr/mcp"],
      "env": { "SECR_TOKEN": "secr_agent_xxx" }
    }
  }
}

VS Code / Copilot

.vscode/mcp.json
{
  "servers": {
    "secr": {
      "command": "npx",
      "args": ["@secr/mcp"],
      "env": { "SECR_TOKEN": "secr_agent_xxx" }
    }
  }
}

3. Start using it

Ask your agent “what secrets do we have?” or “set the Stripe key to sk_live_...”. The agent calls secr tools automatically.

Tools Reference

The server exposes 5 tools. All tools accept optional org, project, and environment parameters that override configured defaults.

get_secret

Get a single secret value by key.

ParameterTypeRequiredDescription
keystringYesThe secret key name to retrieve
orgstringNoOrganization slug
projectstringNoProject slug
environmentstringNoEnvironment slug

Returns the secret in KEY=value format. Returns an error if the key is not found.

list_secrets

List secret key names without values.

ParameterTypeRequiredDescription
searchstringNoFilter keys by search term
orgstringNoOrganization slug
projectstringNoProject slug
environmentstringNoEnvironment slug

Returns key names, one per line. Includes descriptions when available.

set_secret

Create or update a secret.

ParameterTypeRequiredDescription
keystringYesThe secret key name
valuestringYesThe secret value
orgstringNoOrganization slug
projectstringNoProject slug
environmentstringNoEnvironment slug

Returns the key name and new version number.

delete_secret

Delete a secret.

ParameterTypeRequiredDescription
keystringYesThe secret key name to delete
orgstringNoOrganization slug
projectstringNoProject slug
environmentstringNoEnvironment slug

list_environments

List all environments for a project.

ParameterTypeRequiredDescription
orgstringNoOrganization slug
projectstringNoProject slug

Returns environment slugs and names.

Configuration

Environment Variables

ParameterTypeRequiredDescription
SECR_TOKENstringYesAgent token (secr_agent_...). Required.
SECR_ORGstring.secr.jsonOrganization slug.
SECR_PROJECTstring.secr.jsonProject slug.
SECR_ENVIRONMENTstring.secr.jsonDefault environment slug.
SECR_API_URLstringhttps://api.secr.devAPI base URL (for self-hosted).

Parameter Resolution

All tools resolve org, project, and environment in this order:

  1. Explicit tool argument — passed by the agent in the tool call
  2. Environment variableSECR_ORG, SECR_PROJECT, SECR_ENVIRONMENT
  3. .secr.json — project config file from secr init

If your project has a .secr.json, tools can be called with just the required params (e.g. key) and everything else resolves automatically.

Security

Agent Tokens

Use scoped agent tokens instead of personal CLI tokens. Agent tokens have explicit permissions that limit what the MCP server can do.

Terminal
# Read-only (recommended to start)
secr agents create --name "cursor-readonly" --scope "read:secrets"

# Read-write for full workflow
secr agents create --name "claude-code" --scope "read:secrets,write:secrets"

Token Storage

  • Claude Code — stored in Claude's MCP config, not in project files
  • Cursor — store in ~/.cursor/mcp.json (user-level, not committed)
  • VS Code — use .vscode/mcp.json and add it to .gitignore, or use user-level settings

Never commit agent tokens to source control.

Audit Trail

All operations through the MCP server are logged in secr's audit log, tagged with the agent identity. View them with:

secr log

Troubleshooting

ErrorCauseFix
SECR_TOKEN environment variable is requiredToken not set in MCP server env config.Pass SECR_TOKEN in the env config for the MCP server.
Missing orgNo org configured and not passed in tool call.Set SECR_ORG env var or run secr init in the project.
Missing projectNo project configured and not passed in tool call.Set SECR_PROJECT env var or run secr init.
API error: ForbiddenAgent token lacks the required scope.Create a new token with the needed scope (e.g. write:secrets).
Secret "X" not foundThe key doesn't exist in the target environment.Check spelling or use list_secrets to see available keys.

AI agents + secr = fast and secure

claude mcp add secr -- npx @secr/mcp