Skip to content

Commit 18a20fd

Browse files
committed
Add Stripe MCP support for environments like staging and production and enforce restricted keys
1 parent 773e321 commit 18a20fd

3 files changed

Lines changed: 31 additions & 18 deletions

File tree

.claude/scripts/stripe-mcp-dev.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

.claude/scripts/stripe-mcp.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Reads a Stripe API key from dotnet user-secrets and execs @stripe/mcp.
5+
# Only accepts restricted keys (rk_*) so write-capable full secret keys (sk_*)
6+
# can never reach the MCP, regardless of environment. Configure the restricted
7+
# key with read-only scopes in the Stripe dashboard.
8+
# Usage: stripe-mcp.sh <secret-name>
9+
# Example: stripe-mcp.sh Parameters:stripe-api-key
10+
SECRET_NAME="${1:?Secret name required, e.g. Parameters:stripe-api-key}"
11+
12+
STRIPE_SECRET_KEY=$(dotnet user-secrets list --project application/AppHost/AppHost.csproj | sed -n "s/^${SECRET_NAME} = //p")
13+
14+
if [ -z "$STRIPE_SECRET_KEY" ]; then
15+
echo "Stripe MCP: secret '${SECRET_NAME}' not found in dotnet user-secrets." >&2
16+
exit 1
17+
fi
18+
19+
if [[ "$STRIPE_SECRET_KEY" != rk_* ]]; then
20+
echo "Stripe MCP: secret '${SECRET_NAME}' must be a restricted key (rk_test_* or rk_live_*); full secret keys (sk_*) are not allowed." >&2
21+
exit 1
22+
fi
23+
24+
export STRIPE_SECRET_KEY
25+
exec npx -y @stripe/mcp

.mcp.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
}
4040
},
4141
"stripe-development": {
42-
"command": ".claude/scripts/stripe-mcp-dev.sh"
42+
"command": ".claude/scripts/stripe-mcp.sh",
43+
"args": ["Parameters:stripe-api-key"]
44+
},
45+
"stripe-staging": {
46+
"command": ".claude/scripts/stripe-mcp.sh",
47+
"args": ["Parameters:stripe-api-key-staging"]
4348
}
4449
}
4550
}

0 commit comments

Comments
 (0)